This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Add C wrapper for ioctl(2) for sockets binding


This change introduces a C wrapper for use at places where the GNAT sockets
binding invokes the ioctl(2) system call. This is required because ioctl(2)
is a variadic C function, and on some platforms (most notably x86_64) such
functions cannot be directly called from Ada code.

The following program must compile cleanly and display "PASS":

with GNAT.Sockets; use GNAT.Sockets;
with Ada.Text_IO;
with Interfaces.C;

procedure Simple_NB_Sock is
   NON_BLOCKING_REQUEST : GNAT.Sockets.Request_Type :=
                            (Name    => GNAT.Sockets.Non_Blocking_IO,
                             Enabled => True);
   Server   : Socket_Type;
begin
   Create_Socket(Server);
   GNAT.Sockets.Control_Socket(
            Socket  => Server,
            Request => NON_BLOCKING_REQUEST);
   Ada.Text_IO.Put_Line("PASS");
end Simple_NB_Sock;

Tested on x86_64-pc-linux-gnu, committed on trunk

2009-06-19  Thomas Quinot  <quinot@adacore.com>

	* socket.c, g-socthi-vms.adb, g-socthi-vms.ads, g-socthi-vxworks.adb,
	g-socthi-vxworks.ads, g-socthi-mingw.adb, g-socthi-mingw.ads,
	g-socthi.adb, g-socthi.ads, g-socket.adb, g-sothco.ads
	(GNAT.Sockets.Thin.C_Ioctl): Rename to Socket_Ioctl.
	(GNAT.Sockets.Thin.Socket_Ioctl): Use new function
	Thin_Common.Socket_Ioctl.
	(GNAT.Sockets.Thin_Common.Socket_Ioctl): Binding to new C wrapper
	__gnat_socket_ioctl.
	(__gnat_socket_ioctl): Wrapper for ioctl(2) called with a single int*
	argument after the file descriptor and request code.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]