diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-04-06 09:15:09 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-04-06 09:15:09 +0000 |
commit | 232e4d04f0263022b1379a7886e28e7f082f7eb8 (patch) | |
tree | d2a9f2de1b4f8ce5a655a929362077213fa220da /gcc/ada/g-socthi-mingw.ads | |
parent | 32c07c22100b9a6f342e6a5825ac36b1b72d036b (diff) | |
download | gcc-232e4d04f0263022b1379a7886e28e7f082f7eb8.tar.gz |
2007-04-06 Thomas Quinot <quinot@adacore.com>
Pat Rogers <rogers@adacore.com>
Pascal Obry <obry@adacore.com>
* g-stsifd-sockets.adb: New file.
* g-socthi.ads, g-socket.adb, g-socthi-vxworks.adb,
g-socthi-vxworks.ads, g-socthi-mingw.ads, g-socthi-vms.ads,
g-socthi-vms.adb: Move signalling
fd management to a nested package, so that they can conveniently be
moved to a subunit that is shared across Windows, VMS, and VxWorks
(Ada implementation) or completed with imported bodies from socket.c
(UNIX case).
(Read_Signalling_Fd, Write_Signalling_Fd, Create_Signalling_Fds): New
subprograms.
(Check_Selector): Use Read_Signalling_Fd to read and discard data from
the signalling file descriptor.
(Abort_Selector): Use Write_Signalling_Fd to write dummy data to the
signalling file descriptor.
(Create_Selector): Use new C-imported subprogram Create_Signalling_Fds
instead of creating a pair of sockets for signalling here.
* g-socthi.adb: Ditto.
Set the runtime process to ignore SIGPIPEs on platforms that support
neither SO_NOSIGPIPE nor MSG_NOSIGNAL functionality.
* g-socthi-mingw.adb: Ditto.
(WS_Version): Use Windows 2.2.
Use Winsock 2.2 (instead of 1.1) for the GNAT.Socket API.
* g-soliop-mingw.ads: Link with ws2_32 for Windows 2.x support.
Use Winsock 2.2 (instead of 1.1) for the GNAT.Socket API.
* Makefile.in: New libgnat pair g-stsifd.adb<g-stsifd-sockets.adb.
added GNAT byte swapping facility
Update FreeBSD THREADSLIB from -lc_r to -lpthread, for FreeBSD 6.
* g-bytswa.adb, g-bytswa-x86.adb, g-bytswa.ads: New files.
* socket.c (__gnat_read_signalling_fd, __gnat_write_controlling_fd):
New subprograms.
(__gnat_create_signalling_fds): New subprogram.
Set the runtime process to ignore SIGPIPEs on platforms that support
neither SO_NOSIGPIPE nor MSG_NOSIGNAL functionality.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@123542 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/g-socthi-mingw.ads')
-rw-r--r-- | gcc/ada/g-socthi-mingw.ads | 108 |
1 files changed, 69 insertions, 39 deletions
diff --git a/gcc/ada/g-socthi-mingw.ads b/gcc/ada/g-socthi-mingw.ads index 11509c095ea..9db2866f5cf 100644 --- a/gcc/ada/g-socthi-mingw.ads +++ b/gcc/ada/g-socthi-mingw.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 2001-2005, AdaCore -- +-- Copyright (C) 2001-2006, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -60,10 +60,9 @@ package GNAT.Sockets.Thin is procedure Set_Socket_Errno (Errno : Integer); -- Set last socket error number - function Socket_Error_Message - (Errno : Integer) return C.Strings.chars_ptr; - -- Returns the error message string for the error number Errno. If - -- Errno is not known it returns "Unknown system error". + function Socket_Error_Message (Errno : Integer) return C.Strings.chars_ptr; + -- Returns the error message string for the error number Errno. If Errno is + -- not known it returns "Unknown system error". function Host_Errno return Integer; pragma Import (C, Host_Errno, "__gnat_get_h_errno"); @@ -73,14 +72,14 @@ package GNAT.Sockets.Thin is No_Fd_Set : constant Fd_Set_Access := System.Null_Address; type time_t is - range -(2 ** (8 * Constants.SIZEOF_tv_sec - 1)) - .. 2 ** (8 * Constants.SIZEOF_tv_sec - 1) - 1; + range -2 ** (8 * Constants.SIZEOF_tv_sec - 1) + .. 2 ** (8 * Constants.SIZEOF_tv_sec - 1) - 1; for time_t'Size use 8 * Constants.SIZEOF_tv_sec; pragma Convention (C, time_t); type suseconds_t is - range -(2 ** (8 * Constants.SIZEOF_tv_usec - 1)) - .. 2 ** (8 * Constants.SIZEOF_tv_usec - 1) - 1; + range -2 ** (8 * Constants.SIZEOF_tv_usec - 1) + .. 2 ** (8 * Constants.SIZEOF_tv_usec - 1) - 1; for suseconds_t'Size use 8 * Constants.SIZEOF_tv_usec; pragma Convention (C, suseconds_t); @@ -104,7 +103,7 @@ package GNAT.Sockets.Thin is package Chars_Ptr_Pointers is new C.Pointers (C.size_t, C.Strings.chars_ptr, Chars_Ptr_Array, - C.Strings.Null_Ptr); + C.Strings.Null_Ptr); -- Arrays of C (char *) type In_Addr is record @@ -123,6 +122,7 @@ package GNAT.Sockets.Thin is type In_Addr_Access_Array is array (C.size_t range <>) of aliased In_Addr_Access; pragma Convention (C, In_Addr_Access_Array); + package In_Addr_Access_Pointers is new C.Pointers (C.size_t, In_Addr_Access, In_Addr_Access_Array, null); -- Array of internet addresses @@ -203,14 +203,24 @@ package GNAT.Sockets.Thin is pragma Convention (C, Servent_Access); -- Access to service entry - type Two_Int is array (0 .. 1) of C.int; - pragma Convention (C, Two_Int); - -- Used with pipe() + type Two_Ints is array (0 .. 1) of C.int; + pragma Convention (C, Two_Ints); + -- Container for two int values + + subtype Fd_Pair is Two_Ints; + -- Two_Ints as used for Create_Signalling_Fds: a pair of connected file + -- descriptors, one of which (the "read end" of the connection) being used + -- for reading, the other one (the "write end") being used for writing. + + Read_End : constant := 0; + Write_End : constant := 1; + -- Indices into an Fd_Pair value providing access to each of the connected + -- file descriptors. function C_Accept (S : C.int; Addr : System.Address; - Addrlen : access C.int) return C.int; + Addrlen : not null access C.int) return C.int; function C_Bind (S : C.int; @@ -226,9 +236,9 @@ package GNAT.Sockets.Thin is Namelen : C.int) return C.int; function C_Gethostbyaddr - (Addr : System.Address; - Length : C.int; - Typ : C.int) return Hostent_Access; + (Addr : System.Address; + Len : C.int; + Typ : C.int) return Hostent_Access; function C_Gethostbyname (Name : C.char_array) return Hostent_Access; @@ -240,7 +250,7 @@ package GNAT.Sockets.Thin is function C_Getpeername (S : C.int; Name : System.Address; - Namelen : access C.int) return C.int; + Namelen : not null access C.int) return C.int; function C_Getservbyname (Name : C.char_array; @@ -253,14 +263,14 @@ package GNAT.Sockets.Thin is function C_Getsockname (S : C.int; Name : System.Address; - Namelen : access C.int) return C.int; + Namelen : not null access C.int) return C.int; function C_Getsockopt (S : C.int; Level : C.int; Optname : C.int; Optval : System.Address; - Optlen : access C.int) return C.int; + Optlen : not null access C.int) return C.int; function C_Inet_Addr (Cp : C.Strings.chars_ptr) return C.int; @@ -275,23 +285,23 @@ package GNAT.Sockets.Thin is Backlog : C.int) return C.int; function C_Readv - (Socket : C.int; + (Fd : C.int; Iov : System.Address; Iovcnt : C.int) return C.int; function C_Recv (S : C.int; - Buf : System.Address; + Msg : System.Address; Len : C.int; Flags : C.int) return C.int; function C_Recvfrom (S : C.int; - Buf : System.Address; + Msg : System.Address; Len : C.int; Flags : C.int; From : Sockaddr_In_Access; - Fromlen : access C.int) return C.int; + Fromlen : not null access C.int) return C.int; function C_Select (Nfds : C.int; @@ -302,7 +312,7 @@ package GNAT.Sockets.Thin is function C_Send (S : C.int; - Buf : System.Address; + Msg : System.Address; Len : C.int; Flags : C.int) return C.int; @@ -322,8 +332,8 @@ package GNAT.Sockets.Thin is Optlen : C.int) return C.int; function C_Shutdown - (S : C.int; - How : C.int) return C.int; + (S : C.int; + How : C.int) return C.int; function C_Socket (Domain : C.int; @@ -337,7 +347,7 @@ package GNAT.Sockets.Thin is (Command : System.Address) return C.int; function C_Writev - (Socket : C.int; + (Fd : C.int; Iov : System.Address; Iovcnt : C.int) return C.int; @@ -345,6 +355,25 @@ package GNAT.Sockets.Thin is (WS_Version : Interfaces.C.int; WSADataAddress : System.Address) return Interfaces.C.int; + package Signalling_Fds is + + function Create (Fds : not null access Fd_Pair) return C.int; + pragma Convention (C, Create); + -- Create a pair of connected descriptors suitable for use with C_Select + -- (used for signalling in Selector objects). + + function Read (Rsig : C.int) return C.int; + pragma Convention (C, Read); + -- Read one byte of data from rsig, the read end of a pair of signalling + -- fds created by Create_Signalling_Fds. + + function Write (Wsig : C.int) return C.int; + pragma Convention (C, Write); + -- Write one byte of data to wsig, the write end of a pair of signalling + -- fds created by Create_Signalling_Fds. + + end Signalling_Fds; + procedure Free_Socket_Set (Set : Fd_Set_Access); -- Free system-dependent socket set @@ -371,19 +400,19 @@ package GNAT.Sockets.Thin is -- value if it is, zero if it is not. procedure Last_Socket_In_Set - (Set : Fd_Set_Access; - Last : Int_Access); - -- Find the largest socket in the socket set. This is needed for - -- select(). When Last_Socket_In_Set is called, parameter Last is - -- a maximum value of the largest socket. This hint is used to - -- avoid scanning very large socket sets. After the call, Last is - -- set back to the real largest socket in the socket set. + (Set : Fd_Set_Access; + Last : Int_Access); + -- Find the largest socket in the socket set. This is needed for select(). + -- When Last_Socket_In_Set is called, parameter Last is a maximum value of + -- the largest socket. This hint is used to avoid scanning very large + -- socket sets. After the call, Last is set back to the real largest socket + -- in the socket set. function New_Socket_Set (Set : Fd_Set_Access) return Fd_Set_Access; - -- Allocate a new socket set which is a system-dependent structure - -- and initialize by copying Set if it is non-null, by making it - -- empty otherwise. + -- Allocate a new socket set which is a system-dependent structure and + -- initialize by copying Set if it is non-null, by making it empty + -- otherwise. procedure Remove_Socket_From_Set (Set : Fd_Set_Access; @@ -393,7 +422,7 @@ package GNAT.Sockets.Thin is procedure WSACleanup; procedure Finalize; - procedure Initialize (Process_Blocking_IO : Boolean := False); + procedure Initialize (Process_Blocking_IO : Boolean); private pragma Import (Stdcall, C_Accept, "accept"); @@ -430,4 +459,5 @@ private pragma Import (C, New_Socket_Set, "__gnat_new_socket_set"); pragma Import (C, Insert_Socket_In_Set, "__gnat_insert_socket_in_set"); pragma Import (C, Remove_Socket_From_Set, "__gnat_remove_socket_from_set"); + end GNAT.Sockets.Thin; |