diff options
author | Thomas Quinot <quinot@adacore.com> | 2007-06-06 12:31:06 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2007-06-06 12:31:06 +0200 |
commit | 9aeef76b6f20d5f895821f10e3cef2518b4b9ebc (patch) | |
tree | fc7e9dbcdb9f0960c2ce0a3170d937a7c1f6f6a4 /gcc/ada/g-socthi.ads | |
parent | 96338f1975a1543a0547df82b9d0f2c5d206fb1b (diff) | |
download | gcc-9aeef76b6f20d5f895821f10e3cef2518b4b9ebc.zip gcc-9aeef76b6f20d5f895821f10e3cef2518b4b9ebc.tar.gz gcc-9aeef76b6f20d5f895821f10e3cef2518b4b9ebc.tar.bz2 |
g-soccon.ads: Add new constant Thread_Blocking_IO...
2007-04-20 Thomas Quinot <quinot@adacore.com>
* g-soccon.ads: Add new constant Thread_Blocking_IO, always True by
default, set False on a per-runtime basis.
(Need_Netdb_Buffer): New constant.
* g-socket.ads, g-socket.adb: Import new package
GNAT.Sockets.Thin.Task_Safe_NetDB.
(Raise_Host_Error): Use Host_Error_Message from platform-specific thin
binding to obtain proper message.
(Close_Selector): Use GNAT.Sockets.Thin.Signalling_Fds.Close.
Replace various occurrences of Arry (Arry'First)'Address with the
equivalent Arry'Address (GNAT always follows implementation advice from
13.3(14)).
(Get_Host_By_Address, Get_Host_By_Name,
Get_Service_By_Name, Get_Service_By_Port): Do not use GNAT.Task_Lock;
instead, rely on platform-specific task safe netdb operations provided
by g-socthi.
* g-socthi.ads, g-socthi.adb (Initialize): Remove obsolete formal
parameter Process_Blocking_IO.
(Host_Error_Messages): Add stub body.
(GNAT.Sockets.Thin.Signalling_Fds): New procedure Close.
(Safe_Gethostbyname, Safe_Gethostbyaddr, Safe_Getservbyname,
Safe_Getservbyport): Move functions into new child package
Task_Safe_NetDB.
(Nonreentrant_Gethostbyname, Nonreentrant_Gethostbyaddr,
Nonreentrant_Getservbyname, Nonreentrant_Getservbyport): New routines.
(In_Addr): Add alignment clause.
From-SVN: r125424
Diffstat (limited to 'gcc/ada/g-socthi.ads')
-rw-r--r-- | gcc/ada/g-socthi.ads | 97 |
1 files changed, 67 insertions, 30 deletions
diff --git a/gcc/ada/g-socthi.ads b/gcc/ada/g-socthi.ads index ce3f758..59e9004 100644 --- a/gcc/ada/g-socthi.ads +++ b/gcc/ada/g-socthi.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 2001-2006, AdaCore -- +-- Copyright (C) 2001-2007, 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- -- @@ -40,8 +40,8 @@ with Interfaces.C.Pointers; with Interfaces.C.Strings; -with GNAT.Sockets.Constants; with GNAT.OS_Lib; +with GNAT.Sockets.Constants; with System; @@ -64,12 +64,21 @@ package GNAT.Sockets.Thin is 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". + -- not known, returns "Unknown system error". function Host_Errno return Integer; pragma Import (C, Host_Errno, "__gnat_get_h_errno"); -- Returns last host error number + package Host_Error_Messages is + + function Host_Error_Message + (H_Errno : Integer) return C.Strings.chars_ptr; + -- Returns the error message string for the host error number H_Errno. + -- If H_Errno is not known, returns "Unknown system error". + + end Host_Error_Messages; + subtype Fd_Set_Access is System.Address; No_Fd_Set : constant Fd_Set_Access := System.Null_Address; @@ -111,8 +120,11 @@ package GNAT.Sockets.Thin is type In_Addr is record S_B1, S_B2, S_B3, S_B4 : C.unsigned_char; end record; + for In_Addr'Alignment use C.int'Alignment; pragma Convention (C, In_Addr); - -- Internet address + -- IPv4 address, represented as a network-order C.int. Note that the + -- underlying operating system may assume that values of this type have + -- C.int alignment, so we need to provide a suitable alignment clause here. type In_Addr_Access is access all In_Addr; pragma Convention (C, In_Addr_Access); @@ -219,6 +231,10 @@ package GNAT.Sockets.Thin is -- Indices into an Fd_Pair value providing access to each of the connected -- file descriptors. + -------------------------------- + -- Standard library functions -- + -------------------------------- + function C_Accept (S : C.int; Addr : System.Address; @@ -237,14 +253,6 @@ package GNAT.Sockets.Thin is Name : System.Address; Namelen : C.int) return C.int; - function C_Gethostbyaddr - (Addr : System.Address; - Len : C.int; - Typ : C.int) return Hostent_Access; - - function C_Gethostbyname - (Name : C.char_array) return Hostent_Access; - function C_Gethostname (Name : System.Address; Namelen : C.int) return C.int; @@ -254,14 +262,6 @@ package GNAT.Sockets.Thin is Name : System.Address; Namelen : not null access C.int) return C.int; - function C_Getservbyname - (Name : C.char_array; - Proto : C.char_array) return Servent_Access; - - function C_Getservbyport - (Port : C.int; - Proto : C.char_array) return Servent_Access; - function C_Getsockname (S : C.int; Name : System.Address; @@ -353,6 +353,10 @@ package GNAT.Sockets.Thin is Iov : System.Address; Iovcnt : C.int) return C.int; + ------------------------------------------------------- + -- Signalling file descriptors for selector abortion -- + ------------------------------------------------------- + package Signalling_Fds is function Create (Fds : not null access Fd_Pair) return C.int; @@ -370,8 +374,16 @@ package GNAT.Sockets.Thin is -- Write one byte of data to wsig, the write end of a pair of signalling -- fds created by Create_Signalling_Fds. + procedure Close (Sig : C.int); + pragma Convention (C, Close); + -- Close one end of a pair of signalling fds (ignoring any error) + end Signalling_Fds; + ---------------------------- + -- Socket sets management -- + ---------------------------- + procedure Free_Socket_Set (Set : Fd_Set_Access); -- Free system-dependent socket set @@ -380,11 +392,11 @@ package GNAT.Sockets.Thin is (Set : Fd_Set_Access; Socket : Int_Access; Last : Int_Access); - -- Get last socket in Socket and remove it from the socket - -- set. The parameter Last is a maximum value of the largest - -- socket. This hint is used to avoid scanning very large socket - -- sets. After a call to Get_Socket_From_Set, Last is set back to - -- the real largest socket in the socket set. + -- Get last socket in Socket and remove it from the socket set. The + -- parameter Last is a maximum value of the largest socket. This hint is + -- used to avoid scanning very large socket sets. After a call to + -- Get_Socket_From_Set, Last is set back to the real largest socket in the + -- socket set. procedure Insert_Socket_In_Set (Set : Fd_Set_Access; @@ -417,18 +429,38 @@ package GNAT.Sockets.Thin is Socket : C.int); -- Remove socket from the socket set + ------------------------------------------- + -- Nonreentrant network databases access -- + ------------------------------------------- + + -- The following are used only on systems that have nonreentrant + -- getXXXbyYYY functions, and do NOT have corresponding getXXXbyYYY_ + -- functions. Currently, LynxOS is the only such system. + + function Nonreentrant_Gethostbyname + (Name : C.char_array) return Hostent_Access; + + function Nonreentrant_Gethostbyaddr + (Addr : System.Address; + Addr_Len : C.int; + Addr_Type : C.int) return Hostent_Access; + + function Nonreentrant_Getservbyname + (Name : C.char_array; + Proto : C.char_array) return Servent_Access; + + function Nonreentrant_Getservbyport + (Port : C.int; + Proto : C.char_array) return Servent_Access; + + procedure Initialize; procedure Finalize; - procedure Initialize (Process_Blocking_IO : Boolean); private pragma Import (C, C_Bind, "bind"); pragma Import (C, C_Close, "close"); - pragma Import (C, C_Gethostbyaddr, "gethostbyaddr"); - pragma Import (C, C_Gethostbyname, "gethostbyname"); pragma Import (C, C_Gethostname, "gethostname"); pragma Import (C, C_Getpeername, "getpeername"); - pragma Import (C, C_Getservbyname, "getservbyname"); - pragma Import (C, C_Getservbyport, "getservbyport"); pragma Import (C, C_Getsockname, "getsockname"); pragma Import (C, C_Getsockopt, "getsockopt"); pragma Import (C, C_Inet_Addr, "inet_addr"); @@ -449,4 +481,9 @@ private pragma Import (C, Insert_Socket_In_Set, "__gnat_insert_socket_in_set"); pragma Import (C, Remove_Socket_From_Set, "__gnat_remove_socket_from_set"); + pragma Import (C, Nonreentrant_Gethostbyname, "gethostbyname"); + pragma Import (C, Nonreentrant_Gethostbyaddr, "gethostbyaddr"); + pragma Import (C, Nonreentrant_Getservbyname, "getservbyname"); + pragma Import (C, Nonreentrant_Getservbyport, "getservbyport"); + end GNAT.Sockets.Thin; |