Commit 3e1fd98f by Thomas Quinot Committed by Arnaud Charlet

g-soccon.ads: Minor reformatting.

2005-11-14  Thomas Quinot  <quinot@adacore.com>

	* g-soccon.ads: Minor reformatting. Update comments.

	* gsocket.h: Include <sys/times.h> in the VxWorks case, in order to
	gain visibility on the declaration of struct timeval.

	* g-soccon-freebsd.ads,
	g-soccon-darwin.ads,
	g-soccon-tru64.ads,
	g-soccon-aix.ads,
	g-soccon-irix.ads,
	g-soccon-hpux.ads,
	g-soccon-solaris.ads,
	g-soccon-vms.ads,
	g-soccon-mingw.ads,
	g-soccon-vxworks.ads (SIZEOF_tv_sec, SIZEOF_tv_usec): New constants.

	* g-soccon-hpux-ia64.ads, g-soccon-linux-ppc.ads,
	g-soccon-solaris-64.ads, g-soccon-linux-64.ads,
	g-soccon-linux-x86.ads: New files.

	* g-socthi-mingw.adb: 
	(Socket_Error_Message): Remove redundant use of GNAT.Sockets.Constants

	* g-socthi-vxworks.ads, g-socthi-vms.ads, g-socthi-mingw.ads
	(time_t, suseconds_t): New types constructed to match the tv_sec
	and tv_usec fields of C struct timeval.
	(Timeval): Construct structure in terms of the new types.
	(Host_Errno): New function (imported from socket.c), returns last hosts
	database error.

	* g-socthi-vxworks.adb:  Add error handling circuitry.

	* g-socket.ads, g-socket.adb (To_Timeval): Reflect change of type for
	components of struct timeval.
	(Get_Host_By_Name, Get_Host_By_Address): Fix error reporting circuitry.
	(Check_Selector): In error conditions, clear internal socket sets to
	avoid a memory leak.
	(Get_Socket_Option, Set_Socket_Option): Support for Multicast_If,
	Send_Timeout, Receive_Timeout.

	* g-socthi.ads (time_t, suseconds_t): New types constructed to match
	the tv_sec and tv_usec fields of C struct timeval.
	(Timeval): Construct structure in terms of the new types.
	(Host_Errno): New function (imported from socket.c), returns last hosts
	database error.

	* socket.c (__gnat_get_h_errno): New function to retrieve h_errno, the
	hosts database last error code.

	* gen-soccon.c: Complete value expansion should not be performed on
	TARGET, as it has the form of a math expression, and some components
	may be platform-defined macros.
	For VxWorks, generate the OK and ERROR values.
	New constants giving the sizes of the components of C struct timeval.

From-SVN: r106949
parent b4f32d07
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2000-2005 Free Software Foundation, Inc. -- -- Copyright (C) 2000-2005, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
-- by the GNAT.Sockets package (g-socket.ads). This package should not be -- by the GNAT.Sockets package (g-socket.ads). This package should not be
-- directly with'ed by an applications program. -- directly with'ed by an applications program.
-- This is the version for powerpc-ibm-aix5.1.0.0 -- This is the version for powerpc-ibm-aix5.3.0.0
-- This file is generated automatically, do not modify it by hand! Instead, -- This file is generated automatically, do not modify it by hand! Instead,
-- make changes to gen-soccon.c and re-run it on each target. -- make changes to gen-soccon.c and re-run it on each target.
...@@ -169,4 +169,13 @@ package GNAT.Sockets.Constants is ...@@ -169,4 +169,13 @@ package GNAT.Sockets.Constants is
IOV_MAX : constant := 16; -- Maximum writev iovcnt IOV_MAX : constant := 16; -- Maximum writev iovcnt
----------------------
-- Type definitions --
----------------------
-- Sizes (in bytes) of the components of struct timeval
SIZEOF_tv_sec : constant := 4; -- tv_sec
SIZEOF_tv_usec : constant := 4; -- tv_usec
end GNAT.Sockets.Constants; end GNAT.Sockets.Constants;
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2000-2005 Free Software Foundation, Inc. -- -- Copyright (C) 2000-2005, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -169,4 +169,13 @@ package GNAT.Sockets.Constants is ...@@ -169,4 +169,13 @@ package GNAT.Sockets.Constants is
IOV_MAX : constant := 2147483647; -- Maximum writev iovcnt IOV_MAX : constant := 2147483647; -- Maximum writev iovcnt
----------------------
-- Type definitions --
----------------------
-- Sizes (in bytes) of the components of struct timeval
SIZEOF_tv_sec : constant := 4; -- tv_sec
SIZEOF_tv_usec : constant := 4; -- tv_usec
end GNAT.Sockets.Constants; end GNAT.Sockets.Constants;
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2000-2005 Free Software Foundation, Inc. -- -- Copyright (C) 2000-2005, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -169,4 +169,13 @@ package GNAT.Sockets.Constants is ...@@ -169,4 +169,13 @@ package GNAT.Sockets.Constants is
IOV_MAX : constant := 1024; -- Maximum writev iovcnt IOV_MAX : constant := 1024; -- Maximum writev iovcnt
----------------------
-- Type definitions --
----------------------
-- Sizes (in bytes) of the components of struct timeval
SIZEOF_tv_sec : constant := 4; -- tv_sec
SIZEOF_tv_usec : constant := 4; -- tv_usec
end GNAT.Sockets.Constants; end GNAT.Sockets.Constants;
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . S O C K E T S . C O N S T A N T S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2000-2005, Free Software Foundation, Inc. --
-- --
-- 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- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package provides target dependent definitions of constant for use
-- by the GNAT.Sockets package (g-socket.ads). This package should not be
-- directly with'ed by an applications program.
-- This is the version for ia64-hp-hpux11.23
-- This file is generated automatically, do not modify it by hand! Instead,
-- make changes to gen-soccon.c and re-run it on each target.
package GNAT.Sockets.Constants is
--------------
-- Families --
--------------
AF_INET : constant := 2; -- IPv4 address family
AF_INET6 : constant := 22; -- IPv6 address family
-----------
-- Modes --
-----------
SOCK_STREAM : constant := 1; -- Stream socket
SOCK_DGRAM : constant := 2; -- Datagram socket
-------------------
-- Socket errors --
-------------------
EACCES : constant := 13; -- Permission denied
EADDRINUSE : constant := 226; -- Address already in use
EADDRNOTAVAIL : constant := 227; -- Cannot assign address
EAFNOSUPPORT : constant := 225; -- Addr family not supported
EALREADY : constant := 244; -- Operation in progress
EBADF : constant := 9; -- Bad file descriptor
ECONNABORTED : constant := 231; -- Connection aborted
ECONNREFUSED : constant := 239; -- Connection refused
ECONNRESET : constant := 232; -- Connection reset by peer
EDESTADDRREQ : constant := 217; -- Destination addr required
EFAULT : constant := 14; -- Bad address
EHOSTDOWN : constant := 241; -- Host is down
EHOSTUNREACH : constant := 242; -- No route to host
EINPROGRESS : constant := 245; -- Operation now in progress
EINTR : constant := 4; -- Interrupted system call
EINVAL : constant := 22; -- Invalid argument
EIO : constant := 5; -- Input output error
EISCONN : constant := 234; -- Socket already connected
ELOOP : constant := 249; -- Too many symbolic lynks
EMFILE : constant := 24; -- Too many open files
EMSGSIZE : constant := 218; -- Message too long
ENAMETOOLONG : constant := 248; -- Name too long
ENETDOWN : constant := 228; -- Network is down
ENETRESET : constant := 230; -- Disconn. on network reset
ENETUNREACH : constant := 229; -- Network is unreachable
ENOBUFS : constant := 233; -- No buffer space available
ENOPROTOOPT : constant := 220; -- Protocol not available
ENOTCONN : constant := 235; -- Socket not connected
ENOTSOCK : constant := 216; -- Operation on non socket
EOPNOTSUPP : constant := 223; -- Operation not supported
EPFNOSUPPORT : constant := 224; -- Unknown protocol family
EPROTONOSUPPORT : constant := 221; -- Unknown protocol
EPROTOTYPE : constant := 219; -- Unknown protocol type
ESHUTDOWN : constant := 236; -- Cannot send once shutdown
ESOCKTNOSUPPORT : constant := 222; -- Socket type not supported
ETIMEDOUT : constant := 238; -- Connection timed out
ETOOMANYREFS : constant := 237; -- Too many references
EWOULDBLOCK : constant := 246; -- Operation would block
-----------------
-- Host errors --
-----------------
HOST_NOT_FOUND : constant := 1; -- Unknown host
TRY_AGAIN : constant := 2; -- Host name lookup failure
NO_DATA : constant := 4; -- No data record for name
NO_RECOVERY : constant := 3; -- Non recoverable errors
-------------------
-- Control flags --
-------------------
FIONBIO : constant := -2147195266; -- Set/clear non-blocking io
FIONREAD : constant := 1074030207; -- How many bytes to read
--------------------
-- Shutdown modes --
--------------------
SHUT_RD : constant := 0; -- No more recv
SHUT_WR : constant := 1; -- No more send
SHUT_RDWR : constant := 2; -- No more recv/send
---------------------
-- Protocol levels --
---------------------
SOL_SOCKET : constant := 65535; -- Options for socket level
IPPROTO_IP : constant := 0; -- Dummy protocol for IP
IPPROTO_UDP : constant := 17; -- UDP
IPPROTO_TCP : constant := 6; -- TCP
-------------------
-- Request flags --
-------------------
MSG_OOB : constant := 1; -- Process out-of-band data
MSG_PEEK : constant := 2; -- Peek at incoming data
MSG_EOR : constant := 8; -- Send end of record
MSG_WAITALL : constant := 64; -- Wait for full reception
MSG_NOSIGNAL : constant := -1; -- No SIGPIPE on send
MSG_Forced_Flags : constant := 0;
-- Flags set on all send(2) calls
--------------------
-- Socket options --
--------------------
TCP_NODELAY : constant := 1; -- Do not coalesce packets
SO_REUSEADDR : constant := 4; -- Bind reuse local address
SO_KEEPALIVE : constant := 8; -- Enable keep-alive msgs
SO_LINGER : constant := 128; -- Defer close to flush data
SO_BROADCAST : constant := 32; -- Can send broadcast msgs
SO_SNDBUF : constant := 4097; -- Set/get send buffer size
SO_RCVBUF : constant := 4098; -- Set/get recv buffer size
SO_SNDTIMEO : constant := 4101; -- Emission timeout
SO_RCVTIMEO : constant := 4102; -- Reception timeout
SO_ERROR : constant := 4103; -- Get/clear error status
IP_MULTICAST_IF : constant := 2; -- Set/get mcast interface
IP_MULTICAST_TTL : constant := 3; -- Set/get multicast TTL
IP_MULTICAST_LOOP : constant := 4; -- Set/get mcast loopback
IP_ADD_MEMBERSHIP : constant := 5; -- Join a multicast group
IP_DROP_MEMBERSHIP : constant := 6; -- Leave a multicast group
-------------------
-- System limits --
-------------------
IOV_MAX : constant := 16; -- Maximum writev iovcnt
----------------------
-- Type definitions --
----------------------
-- Sizes (in bytes) of the components of struct timeval
SIZEOF_tv_sec : constant := 8; -- tv_sec
SIZEOF_tv_usec : constant := 8; -- tv_usec
end GNAT.Sockets.Constants;
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2000-2005 Free Software Foundation, Inc. -- -- Copyright (C) 2000-2005, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -169,4 +169,13 @@ package GNAT.Sockets.Constants is ...@@ -169,4 +169,13 @@ package GNAT.Sockets.Constants is
IOV_MAX : constant := 16; -- Maximum writev iovcnt IOV_MAX : constant := 16; -- Maximum writev iovcnt
----------------------
-- Type definitions --
----------------------
-- Sizes (in bytes) of the components of struct timeval
SIZEOF_tv_sec : constant := 4; -- tv_sec
SIZEOF_tv_usec : constant := 4; -- tv_usec
end GNAT.Sockets.Constants; end GNAT.Sockets.Constants;
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2000-2005 Free Software Foundation, Inc. -- -- Copyright (C) 2000-2005, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -169,4 +169,13 @@ package GNAT.Sockets.Constants is ...@@ -169,4 +169,13 @@ package GNAT.Sockets.Constants is
IOV_MAX : constant := 2147483647; -- Maximum writev iovcnt IOV_MAX : constant := 2147483647; -- Maximum writev iovcnt
----------------------
-- Type definitions --
----------------------
-- Sizes (in bytes) of the components of struct timeval
SIZEOF_tv_sec : constant := 4; -- tv_sec
SIZEOF_tv_usec : constant := 4; -- tv_usec
end GNAT.Sockets.Constants; end GNAT.Sockets.Constants;
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . S O C K E T S . C O N S T A N T S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2000-2005, Free Software Foundation, Inc. --
-- --
-- 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- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package provides target dependent definitions of constant for use
-- by the GNAT.Sockets package (g-socket.ads). This package should not be
-- directly with'ed by an applications program.
-- This is the version for ia64-hp-linux-gnu
-- This file is generated automatically, do not modify it by hand! Instead,
-- make changes to gen-soccon.c and re-run it on each target.
package GNAT.Sockets.Constants is
--------------
-- Families --
--------------
AF_INET : constant := 2; -- IPv4 address family
AF_INET6 : constant := 10; -- IPv6 address family
-----------
-- Modes --
-----------
SOCK_STREAM : constant := 1; -- Stream socket
SOCK_DGRAM : constant := 2; -- Datagram socket
-------------------
-- Socket errors --
-------------------
EACCES : constant := 13; -- Permission denied
EADDRINUSE : constant := 98; -- Address already in use
EADDRNOTAVAIL : constant := 99; -- Cannot assign address
EAFNOSUPPORT : constant := 97; -- Addr family not supported
EALREADY : constant := 114; -- Operation in progress
EBADF : constant := 9; -- Bad file descriptor
ECONNABORTED : constant := 103; -- Connection aborted
ECONNREFUSED : constant := 111; -- Connection refused
ECONNRESET : constant := 104; -- Connection reset by peer
EDESTADDRREQ : constant := 89; -- Destination addr required
EFAULT : constant := 14; -- Bad address
EHOSTDOWN : constant := 112; -- Host is down
EHOSTUNREACH : constant := 113; -- No route to host
EINPROGRESS : constant := 115; -- Operation now in progress
EINTR : constant := 4; -- Interrupted system call
EINVAL : constant := 22; -- Invalid argument
EIO : constant := 5; -- Input output error
EISCONN : constant := 106; -- Socket already connected
ELOOP : constant := 40; -- Too many symbolic lynks
EMFILE : constant := 24; -- Too many open files
EMSGSIZE : constant := 90; -- Message too long
ENAMETOOLONG : constant := 36; -- Name too long
ENETDOWN : constant := 100; -- Network is down
ENETRESET : constant := 102; -- Disconn. on network reset
ENETUNREACH : constant := 101; -- Network is unreachable
ENOBUFS : constant := 105; -- No buffer space available
ENOPROTOOPT : constant := 92; -- Protocol not available
ENOTCONN : constant := 107; -- Socket not connected
ENOTSOCK : constant := 88; -- Operation on non socket
EOPNOTSUPP : constant := 95; -- Operation not supported
EPFNOSUPPORT : constant := 96; -- Unknown protocol family
EPROTONOSUPPORT : constant := 93; -- Unknown protocol
EPROTOTYPE : constant := 91; -- Unknown protocol type
ESHUTDOWN : constant := 108; -- Cannot send once shutdown
ESOCKTNOSUPPORT : constant := 94; -- Socket type not supported
ETIMEDOUT : constant := 110; -- Connection timed out
ETOOMANYREFS : constant := 109; -- Too many references
EWOULDBLOCK : constant := 11; -- Operation would block
-----------------
-- Host errors --
-----------------
HOST_NOT_FOUND : constant := 1; -- Unknown host
TRY_AGAIN : constant := 2; -- Host name lookup failure
NO_DATA : constant := 4; -- No data record for name
NO_RECOVERY : constant := 3; -- Non recoverable errors
-------------------
-- Control flags --
-------------------
FIONBIO : constant := 21537; -- Set/clear non-blocking io
FIONREAD : constant := 21531; -- How many bytes to read
--------------------
-- Shutdown modes --
--------------------
SHUT_RD : constant := 0; -- No more recv
SHUT_WR : constant := 1; -- No more send
SHUT_RDWR : constant := 2; -- No more recv/send
---------------------
-- Protocol levels --
---------------------
SOL_SOCKET : constant := 1; -- Options for socket level
IPPROTO_IP : constant := 0; -- Dummy protocol for IP
IPPROTO_UDP : constant := 17; -- UDP
IPPROTO_TCP : constant := 6; -- TCP
-------------------
-- Request flags --
-------------------
MSG_OOB : constant := 1; -- Process out-of-band data
MSG_PEEK : constant := 2; -- Peek at incoming data
MSG_EOR : constant := 128; -- Send end of record
MSG_WAITALL : constant := 256; -- Wait for full reception
MSG_NOSIGNAL : constant := 16384; -- No SIGPIPE on send
MSG_Forced_Flags : constant := MSG_NOSIGNAL;
-- Flags set on all send(2) calls
--------------------
-- Socket options --
--------------------
TCP_NODELAY : constant := 1; -- Do not coalesce packets
SO_REUSEADDR : constant := 2; -- Bind reuse local address
SO_KEEPALIVE : constant := 9; -- Enable keep-alive msgs
SO_LINGER : constant := 13; -- Defer close to flush data
SO_BROADCAST : constant := 6; -- Can send broadcast msgs
SO_SNDBUF : constant := 7; -- Set/get send buffer size
SO_RCVBUF : constant := 8; -- Set/get recv buffer size
SO_SNDTIMEO : constant := 21; -- Emission timeout
SO_RCVTIMEO : constant := 20; -- Reception timeout
SO_ERROR : constant := 4; -- Get/clear error status
IP_MULTICAST_IF : constant := 32; -- Set/get mcast interface
IP_MULTICAST_TTL : constant := 33; -- Set/get multicast TTL
IP_MULTICAST_LOOP : constant := 34; -- Set/get mcast loopback
IP_ADD_MEMBERSHIP : constant := 35; -- Join a multicast group
IP_DROP_MEMBERSHIP : constant := 36; -- Leave a multicast group
-------------------
-- System limits --
-------------------
IOV_MAX : constant := 2147483647; -- Maximum writev iovcnt
----------------------
-- Type definitions --
----------------------
-- Sizes (in bytes) of the components of struct timeval
SIZEOF_tv_sec : constant := 8; -- tv_sec
SIZEOF_tv_usec : constant := 8; -- tv_usec
end GNAT.Sockets.Constants;
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . S O C K E T S . C O N S T A N T S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2000-2005, Free Software Foundation, Inc. --
-- --
-- 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- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package provides target dependent definitions of constant for use
-- by the GNAT.Sockets package (g-socket.ads). This package should not be
-- directly with'ed by an applications program.
-- This is the version for powerpc-linux
-- This file is generated automatically, do not modify it by hand! Instead,
-- make changes to gen-soccon.c and re-run it on each target.
package GNAT.Sockets.Constants is
--------------
-- Families --
--------------
AF_INET : constant := 2; -- IPv4 address family
AF_INET6 : constant := 10; -- IPv6 address family
-----------
-- Modes --
-----------
SOCK_STREAM : constant := 1; -- Stream socket
SOCK_DGRAM : constant := 2; -- Datagram socket
-------------------
-- Socket errors --
-------------------
EACCES : constant := 13; -- Permission denied
EADDRINUSE : constant := 98; -- Address already in use
EADDRNOTAVAIL : constant := 99; -- Cannot assign address
EAFNOSUPPORT : constant := 97; -- Addr family not supported
EALREADY : constant := 114; -- Operation in progress
EBADF : constant := 9; -- Bad file descriptor
ECONNABORTED : constant := 103; -- Connection aborted
ECONNREFUSED : constant := 111; -- Connection refused
ECONNRESET : constant := 104; -- Connection reset by peer
EDESTADDRREQ : constant := 89; -- Destination addr required
EFAULT : constant := 14; -- Bad address
EHOSTDOWN : constant := 112; -- Host is down
EHOSTUNREACH : constant := 113; -- No route to host
EINPROGRESS : constant := 115; -- Operation now in progress
EINTR : constant := 4; -- Interrupted system call
EINVAL : constant := 22; -- Invalid argument
EIO : constant := 5; -- Input output error
EISCONN : constant := 106; -- Socket already connected
ELOOP : constant := 40; -- Too many symbolic lynks
EMFILE : constant := 24; -- Too many open files
EMSGSIZE : constant := 90; -- Message too long
ENAMETOOLONG : constant := 36; -- Name too long
ENETDOWN : constant := 100; -- Network is down
ENETRESET : constant := 102; -- Disconn. on network reset
ENETUNREACH : constant := 101; -- Network is unreachable
ENOBUFS : constant := 105; -- No buffer space available
ENOPROTOOPT : constant := 92; -- Protocol not available
ENOTCONN : constant := 107; -- Socket not connected
ENOTSOCK : constant := 88; -- Operation on non socket
EOPNOTSUPP : constant := 95; -- Operation not supported
EPFNOSUPPORT : constant := 96; -- Unknown protocol family
EPROTONOSUPPORT : constant := 93; -- Unknown protocol
EPROTOTYPE : constant := 91; -- Unknown protocol type
ESHUTDOWN : constant := 108; -- Cannot send once shutdown
ESOCKTNOSUPPORT : constant := 94; -- Socket type not supported
ETIMEDOUT : constant := 110; -- Connection timed out
ETOOMANYREFS : constant := 109; -- Too many references
EWOULDBLOCK : constant := 11; -- Operation would block
-----------------
-- Host errors --
-----------------
HOST_NOT_FOUND : constant := 1; -- Unknown host
TRY_AGAIN : constant := 2; -- Host name lookup failure
NO_DATA : constant := 4; -- No data record for name
NO_RECOVERY : constant := 3; -- Non recoverable errors
-------------------
-- Control flags --
-------------------
FIONBIO : constant := -2147195266; -- Set/clear non-blocking io
FIONREAD : constant := 1074030207; -- How many bytes to read
--------------------
-- Shutdown modes --
--------------------
SHUT_RD : constant := 0; -- No more recv
SHUT_WR : constant := 1; -- No more send
SHUT_RDWR : constant := 2; -- No more recv/send
---------------------
-- Protocol levels --
---------------------
SOL_SOCKET : constant := 1; -- Options for socket level
IPPROTO_IP : constant := 0; -- Dummy protocol for IP
IPPROTO_UDP : constant := 17; -- UDP
IPPROTO_TCP : constant := 6; -- TCP
-------------------
-- Request flags --
-------------------
MSG_OOB : constant := 1; -- Process out-of-band data
MSG_PEEK : constant := 2; -- Peek at incoming data
MSG_EOR : constant := 128; -- Send end of record
MSG_WAITALL : constant := 256; -- Wait for full reception
MSG_NOSIGNAL : constant := 16384; -- No SIGPIPE on send
MSG_Forced_Flags : constant := MSG_NOSIGNAL;
-- Flags set on all send(2) calls
--------------------
-- Socket options --
--------------------
TCP_NODELAY : constant := 1; -- Do not coalesce packets
SO_REUSEADDR : constant := 2; -- Bind reuse local address
SO_KEEPALIVE : constant := 9; -- Enable keep-alive msgs
SO_LINGER : constant := 13; -- Defer close to flush data
SO_BROADCAST : constant := 6; -- Can send broadcast msgs
SO_SNDBUF : constant := 7; -- Set/get send buffer size
SO_RCVBUF : constant := 8; -- Set/get recv buffer size
SO_SNDTIMEO : constant := 19; -- Emission timeout
SO_RCVTIMEO : constant := 18; -- Reception timeout
SO_ERROR : constant := 4; -- Get/clear error status
IP_MULTICAST_IF : constant := 32; -- Set/get mcast interface
IP_MULTICAST_TTL : constant := 33; -- Set/get multicast TTL
IP_MULTICAST_LOOP : constant := 34; -- Set/get mcast loopback
IP_ADD_MEMBERSHIP : constant := 35; -- Join a multicast group
IP_DROP_MEMBERSHIP : constant := 36; -- Leave a multicast group
-------------------
-- System limits --
-------------------
IOV_MAX : constant := 2147483647; -- Maximum writev iovcnt
----------------------
-- Type definitions --
----------------------
-- Sizes (in bytes) of the components of struct timeval
SIZEOF_tv_sec : constant := 4; -- tv_sec
SIZEOF_tv_usec : constant := 4; -- tv_usec
end GNAT.Sockets.Constants;
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . S O C K E T S . C O N S T A N T S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2000-2005, Free Software Foundation, Inc. --
-- --
-- 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- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package provides target dependent definitions of constant for use
-- by the GNAT.Sockets package (g-socket.ads). This package should not be
-- directly with'ed by an applications program.
-- This is the version for i686-pc-linux-gnu
-- This file is generated automatically, do not modify it by hand! Instead,
-- make changes to gen-soccon.c and re-run it on each target.
package GNAT.Sockets.Constants is
--------------
-- Families --
--------------
AF_INET : constant := 2; -- IPv4 address family
AF_INET6 : constant := 10; -- IPv6 address family
-----------
-- Modes --
-----------
SOCK_STREAM : constant := 1; -- Stream socket
SOCK_DGRAM : constant := 2; -- Datagram socket
-------------------
-- Socket errors --
-------------------
EACCES : constant := 13; -- Permission denied
EADDRINUSE : constant := 98; -- Address already in use
EADDRNOTAVAIL : constant := 99; -- Cannot assign address
EAFNOSUPPORT : constant := 97; -- Addr family not supported
EALREADY : constant := 114; -- Operation in progress
EBADF : constant := 9; -- Bad file descriptor
ECONNABORTED : constant := 103; -- Connection aborted
ECONNREFUSED : constant := 111; -- Connection refused
ECONNRESET : constant := 104; -- Connection reset by peer
EDESTADDRREQ : constant := 89; -- Destination addr required
EFAULT : constant := 14; -- Bad address
EHOSTDOWN : constant := 112; -- Host is down
EHOSTUNREACH : constant := 113; -- No route to host
EINPROGRESS : constant := 115; -- Operation now in progress
EINTR : constant := 4; -- Interrupted system call
EINVAL : constant := 22; -- Invalid argument
EIO : constant := 5; -- Input output error
EISCONN : constant := 106; -- Socket already connected
ELOOP : constant := 40; -- Too many symbolic lynks
EMFILE : constant := 24; -- Too many open files
EMSGSIZE : constant := 90; -- Message too long
ENAMETOOLONG : constant := 36; -- Name too long
ENETDOWN : constant := 100; -- Network is down
ENETRESET : constant := 102; -- Disconn. on network reset
ENETUNREACH : constant := 101; -- Network is unreachable
ENOBUFS : constant := 105; -- No buffer space available
ENOPROTOOPT : constant := 92; -- Protocol not available
ENOTCONN : constant := 107; -- Socket not connected
ENOTSOCK : constant := 88; -- Operation on non socket
EOPNOTSUPP : constant := 95; -- Operation not supported
EPFNOSUPPORT : constant := 96; -- Unknown protocol family
EPROTONOSUPPORT : constant := 93; -- Unknown protocol
EPROTOTYPE : constant := 91; -- Unknown protocol type
ESHUTDOWN : constant := 108; -- Cannot send once shutdown
ESOCKTNOSUPPORT : constant := 94; -- Socket type not supported
ETIMEDOUT : constant := 110; -- Connection timed out
ETOOMANYREFS : constant := 109; -- Too many references
EWOULDBLOCK : constant := 11; -- Operation would block
-----------------
-- Host errors --
-----------------
HOST_NOT_FOUND : constant := 1; -- Unknown host
TRY_AGAIN : constant := 2; -- Host name lookup failure
NO_DATA : constant := 4; -- No data record for name
NO_RECOVERY : constant := 3; -- Non recoverable errors
-------------------
-- Control flags --
-------------------
FIONBIO : constant := 21537; -- Set/clear non-blocking io
FIONREAD : constant := 21531; -- How many bytes to read
--------------------
-- Shutdown modes --
--------------------
SHUT_RD : constant := 0; -- No more recv
SHUT_WR : constant := 1; -- No more send
SHUT_RDWR : constant := 2; -- No more recv/send
---------------------
-- Protocol levels --
---------------------
SOL_SOCKET : constant := 1; -- Options for socket level
IPPROTO_IP : constant := 0; -- Dummy protocol for IP
IPPROTO_UDP : constant := 17; -- UDP
IPPROTO_TCP : constant := 6; -- TCP
-------------------
-- Request flags --
-------------------
MSG_OOB : constant := 1; -- Process out-of-band data
MSG_PEEK : constant := 2; -- Peek at incoming data
MSG_EOR : constant := 128; -- Send end of record
MSG_WAITALL : constant := 256; -- Wait for full reception
MSG_NOSIGNAL : constant := 16384; -- No SIGPIPE on send
MSG_Forced_Flags : constant := MSG_NOSIGNAL;
-- Flags set on all send(2) calls
--------------------
-- Socket options --
--------------------
TCP_NODELAY : constant := 1; -- Do not coalesce packets
SO_REUSEADDR : constant := 2; -- Bind reuse local address
SO_KEEPALIVE : constant := 9; -- Enable keep-alive msgs
SO_LINGER : constant := 13; -- Defer close to flush data
SO_BROADCAST : constant := 6; -- Can send broadcast msgs
SO_SNDBUF : constant := 7; -- Set/get send buffer size
SO_RCVBUF : constant := 8; -- Set/get recv buffer size
SO_SNDTIMEO : constant := 21; -- Emission timeout
SO_RCVTIMEO : constant := 20; -- Reception timeout
SO_ERROR : constant := 4; -- Get/clear error status
IP_MULTICAST_IF : constant := 32; -- Set/get mcast interface
IP_MULTICAST_TTL : constant := 33; -- Set/get multicast TTL
IP_MULTICAST_LOOP : constant := 34; -- Set/get mcast loopback
IP_ADD_MEMBERSHIP : constant := 35; -- Join a multicast group
IP_DROP_MEMBERSHIP : constant := 36; -- Leave a multicast group
-------------------
-- System limits --
-------------------
IOV_MAX : constant := 2147483647; -- Maximum writev iovcnt
----------------------
-- Type definitions --
----------------------
-- Sizes (in bytes) of the components of struct timeval
SIZEOF_tv_sec : constant := 4; -- tv_sec
SIZEOF_tv_usec : constant := 4; -- tv_usec
end GNAT.Sockets.Constants;
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2000-2005 Free Software Foundation, Inc. -- -- Copyright (C) 2000-2005, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -169,4 +169,13 @@ package GNAT.Sockets.Constants is ...@@ -169,4 +169,13 @@ package GNAT.Sockets.Constants is
IOV_MAX : constant := 2147483647; -- Maximum writev iovcnt IOV_MAX : constant := 2147483647; -- Maximum writev iovcnt
----------------------
-- Type definitions --
----------------------
-- Sizes (in bytes) of the components of struct timeval
SIZEOF_tv_sec : constant := 4; -- tv_sec
SIZEOF_tv_usec : constant := 4; -- tv_usec
end GNAT.Sockets.Constants; end GNAT.Sockets.Constants;
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . S O C K E T S . C O N S T A N T S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2000-2005, Free Software Foundation, Inc. --
-- --
-- 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- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package provides target dependent definitions of constant for use
-- by the GNAT.Sockets package (g-socket.ads). This package should not be
-- directly with'ed by an applications program.
-- This is the version for sparc-sun-solaris2.8/64
-- This file is generated automatically, do not modify it by hand! Instead,
-- make changes to gen-soccon.c and re-run it on each target.
package GNAT.Sockets.Constants is
--------------
-- Families --
--------------
AF_INET : constant := 2; -- IPv4 address family
AF_INET6 : constant := 26; -- IPv6 address family
-----------
-- Modes --
-----------
SOCK_STREAM : constant := 2; -- Stream socket
SOCK_DGRAM : constant := 1; -- Datagram socket
-------------------
-- Socket errors --
-------------------
EACCES : constant := 13; -- Permission denied
EADDRINUSE : constant := 125; -- Address already in use
EADDRNOTAVAIL : constant := 126; -- Cannot assign address
EAFNOSUPPORT : constant := 124; -- Addr family not supported
EALREADY : constant := 149; -- Operation in progress
EBADF : constant := 9; -- Bad file descriptor
ECONNABORTED : constant := 130; -- Connection aborted
ECONNREFUSED : constant := 146; -- Connection refused
ECONNRESET : constant := 131; -- Connection reset by peer
EDESTADDRREQ : constant := 96; -- Destination addr required
EFAULT : constant := 14; -- Bad address
EHOSTDOWN : constant := 147; -- Host is down
EHOSTUNREACH : constant := 148; -- No route to host
EINPROGRESS : constant := 150; -- Operation now in progress
EINTR : constant := 4; -- Interrupted system call
EINVAL : constant := 22; -- Invalid argument
EIO : constant := 5; -- Input output error
EISCONN : constant := 133; -- Socket already connected
ELOOP : constant := 90; -- Too many symbolic lynks
EMFILE : constant := 24; -- Too many open files
EMSGSIZE : constant := 97; -- Message too long
ENAMETOOLONG : constant := 78; -- Name too long
ENETDOWN : constant := 127; -- Network is down
ENETRESET : constant := 129; -- Disconn. on network reset
ENETUNREACH : constant := 128; -- Network is unreachable
ENOBUFS : constant := 132; -- No buffer space available
ENOPROTOOPT : constant := 99; -- Protocol not available
ENOTCONN : constant := 134; -- Socket not connected
ENOTSOCK : constant := 95; -- Operation on non socket
EOPNOTSUPP : constant := 122; -- Operation not supported
EPFNOSUPPORT : constant := 123; -- Unknown protocol family
EPROTONOSUPPORT : constant := 120; -- Unknown protocol
EPROTOTYPE : constant := 98; -- Unknown protocol type
ESHUTDOWN : constant := 143; -- Cannot send once shutdown
ESOCKTNOSUPPORT : constant := 121; -- Socket type not supported
ETIMEDOUT : constant := 145; -- Connection timed out
ETOOMANYREFS : constant := 144; -- Too many references
EWOULDBLOCK : constant := 11; -- Operation would block
-----------------
-- Host errors --
-----------------
HOST_NOT_FOUND : constant := 1; -- Unknown host
TRY_AGAIN : constant := 2; -- Host name lookup failure
NO_DATA : constant := 4; -- No data record for name
NO_RECOVERY : constant := 3; -- Non recoverable errors
-------------------
-- Control flags --
-------------------
FIONBIO : constant := -2147195266; -- Set/clear non-blocking io
FIONREAD : constant := 1074030207; -- How many bytes to read
--------------------
-- Shutdown modes --
--------------------
SHUT_RD : constant := 0; -- No more recv
SHUT_WR : constant := 1; -- No more send
SHUT_RDWR : constant := 2; -- No more recv/send
---------------------
-- Protocol levels --
---------------------
SOL_SOCKET : constant := 65535; -- Options for socket level
IPPROTO_IP : constant := 0; -- Dummy protocol for IP
IPPROTO_UDP : constant := 17; -- UDP
IPPROTO_TCP : constant := 6; -- TCP
-------------------
-- Request flags --
-------------------
MSG_OOB : constant := 1; -- Process out-of-band data
MSG_PEEK : constant := 2; -- Peek at incoming data
MSG_EOR : constant := 8; -- Send end of record
MSG_WAITALL : constant := 64; -- Wait for full reception
MSG_NOSIGNAL : constant := -1; -- No SIGPIPE on send
MSG_Forced_Flags : constant := 0;
-- Flags set on all send(2) calls
--------------------
-- Socket options --
--------------------
TCP_NODELAY : constant := 1; -- Do not coalesce packets
SO_REUSEADDR : constant := 4; -- Bind reuse local address
SO_KEEPALIVE : constant := 8; -- Enable keep-alive msgs
SO_LINGER : constant := 128; -- Defer close to flush data
SO_BROADCAST : constant := 32; -- Can send broadcast msgs
SO_SNDBUF : constant := 4097; -- Set/get send buffer size
SO_RCVBUF : constant := 4098; -- Set/get recv buffer size
SO_SNDTIMEO : constant := 4101; -- Emission timeout
SO_RCVTIMEO : constant := 4102; -- Reception timeout
SO_ERROR : constant := 4103; -- Get/clear error status
IP_MULTICAST_IF : constant := 16; -- Set/get mcast interface
IP_MULTICAST_TTL : constant := 17; -- Set/get multicast TTL
IP_MULTICAST_LOOP : constant := 18; -- Set/get mcast loopback
IP_ADD_MEMBERSHIP : constant := 19; -- Join a multicast group
IP_DROP_MEMBERSHIP : constant := 20; -- Leave a multicast group
-------------------
-- System limits --
-------------------
IOV_MAX : constant := 16; -- Maximum writev iovcnt
----------------------
-- Type definitions --
----------------------
-- Sizes (in bytes) of the components of struct timeval
SIZEOF_tv_sec : constant := 8; -- tv_sec
SIZEOF_tv_usec : constant := 8; -- tv_usec
end GNAT.Sockets.Constants;
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2000-2005 Free Software Foundation, Inc. -- -- Copyright (C) 2000-2005, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -169,4 +169,13 @@ package GNAT.Sockets.Constants is ...@@ -169,4 +169,13 @@ package GNAT.Sockets.Constants is
IOV_MAX : constant := 16; -- Maximum writev iovcnt IOV_MAX : constant := 16; -- Maximum writev iovcnt
----------------------
-- Type definitions --
----------------------
-- Sizes (in bytes) of the components of struct timeval
SIZEOF_tv_sec : constant := 4; -- tv_sec
SIZEOF_tv_usec : constant := 4; -- tv_usec
end GNAT.Sockets.Constants; end GNAT.Sockets.Constants;
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2000-2005 Free Software Foundation, Inc. -- -- Copyright (C) 2000-2005, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -169,4 +169,13 @@ package GNAT.Sockets.Constants is ...@@ -169,4 +169,13 @@ package GNAT.Sockets.Constants is
IOV_MAX : constant := 1024; -- Maximum writev iovcnt IOV_MAX : constant := 1024; -- Maximum writev iovcnt
----------------------
-- Type definitions --
----------------------
-- Sizes (in bytes) of the components of struct timeval
SIZEOF_tv_sec : constant := 4; -- tv_sec
SIZEOF_tv_usec : constant := 4; -- tv_usec
end GNAT.Sockets.Constants; end GNAT.Sockets.Constants;
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2000-2005 Free Software Foundation, Inc. -- -- Copyright (C) 2000-2005, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -169,4 +169,13 @@ package GNAT.Sockets.Constants is ...@@ -169,4 +169,13 @@ package GNAT.Sockets.Constants is
IOV_MAX : constant := 1024; -- Maximum writev iovcnt IOV_MAX : constant := 1024; -- Maximum writev iovcnt
----------------------
-- Type definitions --
----------------------
-- Sizes (in bytes) of the components of struct timeval
SIZEOF_tv_sec : constant := 4; -- tv_sec
SIZEOF_tv_usec : constant := 4; -- tv_usec
end GNAT.Sockets.Constants; end GNAT.Sockets.Constants;
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2000-2005 Free Software Foundation, Inc. -- -- Copyright (C) 2000-2005, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -169,4 +169,23 @@ package GNAT.Sockets.Constants is ...@@ -169,4 +169,23 @@ package GNAT.Sockets.Constants is
IOV_MAX : constant := 2147483647; -- Maximum writev iovcnt IOV_MAX : constant := 2147483647; -- Maximum writev iovcnt
----------------------
-- Type definitions --
----------------------
-- Sizes (in bytes) of the components of struct timeval
SIZEOF_tv_sec : constant := 4; -- tv_sec
SIZEOF_tv_usec : constant := 4; -- tv_usec
--------------------------------
-- VxWorks-specific constants --
--------------------------------
-- These constants may be used only within the VxWorks version of
-- GNAT.Sockets.Thin.
OK : constant := 0; -- VxWorks generic success
ERROR : constant := -1; -- VxWorks generic error
end GNAT.Sockets.Constants; end GNAT.Sockets.Constants;
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2000-2005 Free Software Foundation, Inc. -- -- Copyright (C) 2000-2005, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -36,6 +36,9 @@ ...@@ -36,6 +36,9 @@
-- directly with'ed by an applications program. -- directly with'ed by an applications program.
-- This is the version for i686-pc-linux-gnu -- This is the version for i686-pc-linux-gnu
-- WARNING! This file is a default version that must be replaced for
-- each platform.
-- This file is generated automatically, do not modify it by hand! Instead, -- This file is generated automatically, do not modify it by hand! Instead,
-- make changes to gen-soccon.c and re-run it on each target. -- make changes to gen-soccon.c and re-run it on each target.
...@@ -169,4 +172,13 @@ package GNAT.Sockets.Constants is ...@@ -169,4 +172,13 @@ package GNAT.Sockets.Constants is
IOV_MAX : constant := 2147483647; -- Maximum writev iovcnt IOV_MAX : constant := 2147483647; -- Maximum writev iovcnt
----------------------
-- Type definitions --
----------------------
-- Sizes (in bytes) of the components of struct timeval
SIZEOF_tv_sec : constant := 4; -- tv_sec
SIZEOF_tv_usec : constant := 4; -- tv_usec
end GNAT.Sockets.Constants; end GNAT.Sockets.Constants;
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2001-2005 Ada Core Technologies, Inc. -- -- Copyright (C) 2001-2005, AdaCore --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -92,8 +92,11 @@ package body GNAT.Sockets is ...@@ -92,8 +92,11 @@ package body GNAT.Sockets is
No_Delay => Constants.TCP_NODELAY, No_Delay => Constants.TCP_NODELAY,
Add_Membership => Constants.IP_ADD_MEMBERSHIP, Add_Membership => Constants.IP_ADD_MEMBERSHIP,
Drop_Membership => Constants.IP_DROP_MEMBERSHIP, Drop_Membership => Constants.IP_DROP_MEMBERSHIP,
Multicast_If => Constants.IP_MULTICAST_IF,
Multicast_TTL => Constants.IP_MULTICAST_TTL, Multicast_TTL => Constants.IP_MULTICAST_TTL,
Multicast_Loop => Constants.IP_MULTICAST_LOOP); Multicast_Loop => Constants.IP_MULTICAST_LOOP,
Send_Timeout => Constants.SO_SNDTIMEO,
Receive_Timeout => Constants.SO_RCVTIMEO);
Flags : constant array (0 .. 3) of C.int := Flags : constant array (0 .. 3) of C.int :=
(0 => Constants.MSG_OOB, -- Process_Out_Of_Band_Data (0 => Constants.MSG_OOB, -- Process_Out_Of_Band_Data
...@@ -110,6 +113,9 @@ package body GNAT.Sockets is ...@@ -110,6 +113,9 @@ package body GNAT.Sockets is
function To_In_Addr is new Ada.Unchecked_Conversion (C.int, In_Addr); function To_In_Addr is new Ada.Unchecked_Conversion (C.int, In_Addr);
function To_Int is new Ada.Unchecked_Conversion (In_Addr, C.int); function To_Int is new Ada.Unchecked_Conversion (In_Addr, C.int);
function Err_Code_Image (E : Integer) return String;
-- Return the value of E surrounded with brackets
----------------------- -----------------------
-- Local subprograms -- -- Local subprograms --
----------------------- -----------------------
...@@ -160,15 +166,20 @@ package body GNAT.Sockets is ...@@ -160,15 +166,20 @@ package body GNAT.Sockets is
function To_Service_Entry (E : Servent) return Service_Entry_Type; function To_Service_Entry (E : Servent) return Service_Entry_Type;
-- Conversion function -- Conversion function
function To_Timeval (Val : Selector_Duration) return Timeval; function To_Timeval (Val : Timeval_Duration) return Timeval;
-- Separate Val in seconds and microseconds -- Separate Val in seconds and microseconds
function To_Duration (Val : Timeval) return Timeval_Duration;
-- Reconstruct a Duration value from a Timeval record (seconds and
-- microseconds).
procedure Raise_Socket_Error (Error : Integer); procedure Raise_Socket_Error (Error : Integer);
-- Raise Socket_Error with an exception message describing the error code -- Raise Socket_Error with an exception message describing the error code
-- from errno.
procedure Raise_Host_Error (Error : Integer); procedure Raise_Host_Error (H_Error : Integer);
-- Raise Host_Error exception with message describing error code (note -- Raise Host_Error exception with message describing error code (note
-- hstrerror seems to be obsolete). -- hstrerror seems to be obsolete) from h_errno.
procedure Narrow (Item : in out Socket_Set_Type); procedure Narrow (Item : in out Socket_Set_Type);
-- Update Last as it may be greater than the real last socket -- Update Last as it may be greater than the real last socket
...@@ -384,6 +395,7 @@ package body GNAT.Sockets is ...@@ -384,6 +395,7 @@ package body GNAT.Sockets is
is is
Res : C.int; Res : C.int;
Last : C.int; Last : C.int;
RSig : Socket_Type renames Selector.R_Sig_Socket;
RSet : Socket_Set_Type; RSet : Socket_Set_Type;
WSet : Socket_Set_Type; WSet : Socket_Set_Type;
ESet : Socket_Set_Type; ESet : Socket_Set_Type;
...@@ -391,6 +403,7 @@ package body GNAT.Sockets is ...@@ -391,6 +403,7 @@ package body GNAT.Sockets is
TPtr : Timeval_Access; TPtr : Timeval_Access;
begin begin
begin
Status := Completed; Status := Completed;
-- No timeout or Forever is indicated by a null timeval pointer -- No timeout or Forever is indicated by a null timeval pointer
...@@ -406,7 +419,7 @@ package body GNAT.Sockets is ...@@ -406,7 +419,7 @@ package body GNAT.Sockets is
RSet := (Set => New_Socket_Set (R_Socket_Set.Set), RSet := (Set => New_Socket_Set (R_Socket_Set.Set),
Last => R_Socket_Set.Last); Last => R_Socket_Set.Last);
Set (RSet, Selector.R_Sig_Socket); Set (RSet, RSig);
-- Copy W_Socket_Set in WSet -- Copy W_Socket_Set in WSet
...@@ -437,14 +450,14 @@ package body GNAT.Sockets is ...@@ -437,14 +450,14 @@ package body GNAT.Sockets is
-- If Select was resumed because of read signalling socket, read this -- If Select was resumed because of read signalling socket, read this
-- data and remove socket from set. -- data and remove socket from set.
if Is_Set (RSet, Selector.R_Sig_Socket) then if Is_Set (RSet, RSig) then
Clear (RSet, Selector.R_Sig_Socket); Clear (RSet, RSig);
declare declare
Buf : Character; Buf : Character;
begin begin
Res := C_Recv (C.int (Selector.R_Sig_Socket), Buf'Address, 1, 0); Res := C_Recv (C.int (RSig), Buf'Address, 1, 0);
if Res = Failure then if Res = Failure then
Raise_Socket_Error (Socket_Errno); Raise_Socket_Error (Socket_Errno);
...@@ -487,6 +500,19 @@ package body GNAT.Sockets is ...@@ -487,6 +500,19 @@ package body GNAT.Sockets is
Empty (E_Socket_Set); Empty (E_Socket_Set);
E_Socket_Set := ESet; E_Socket_Set := ESet;
exception
when Socket_Error =>
-- The local socket sets must be emptied before propagating
-- Socket_Error so the associated storage is freed.
Empty (RSet);
Empty (WSet);
Empty (ESet);
raise;
end;
end Check_Selector; end Check_Selector;
----------- -----------
...@@ -510,11 +536,16 @@ package body GNAT.Sockets is ...@@ -510,11 +536,16 @@ package body GNAT.Sockets is
-- Close_Selector -- -- Close_Selector --
-------------------- --------------------
-- Comments needed below ???
-- Why are exceptions ignored ???
procedure Close_Selector (Selector : in out Selector_Type) is procedure Close_Selector (Selector : in out Selector_Type) is
begin begin
-- Close the signalling sockets used internally for the implementation
-- of Abort_Selector. Exceptions are ignored because these sockets
-- are implementation artefacts of no interest to the user, and
-- there is little that can be done if either Close_Socket call fails
-- (which theoretically should not happen anyway). We also want to try
-- to perform the second Close_Socket even if the first one failed.
begin begin
Close_Socket (Selector.R_Sig_Socket); Close_Socket (Selector.R_Sig_Socket);
exception exception
...@@ -772,6 +803,17 @@ package body GNAT.Sockets is ...@@ -772,6 +803,17 @@ package body GNAT.Sockets is
Item.Last := No_Socket; Item.Last := No_Socket;
end Empty; end Empty;
--------------------
-- Err_Code_Image --
--------------------
function Err_Code_Image (E : Integer) return String is
Msg : String := E'Img & "] ";
begin
Msg (Msg'First) := '[';
return Msg;
end Err_Code_Image;
-------------- --------------
-- Finalize -- -- Finalize --
-------------- --------------
...@@ -845,7 +887,7 @@ package body GNAT.Sockets is ...@@ -845,7 +887,7 @@ package body GNAT.Sockets is
Res := C_Gethostbyaddr (HA'Address, HA'Size / 8, Constants.AF_INET); Res := C_Gethostbyaddr (HA'Address, HA'Size / 8, Constants.AF_INET);
if Res = null then if Res = null then
Err := Socket_Errno; Err := Host_Errno;
Task_Lock.Unlock; Task_Lock.Unlock;
Raise_Host_Error (Err); Raise_Host_Error (Err);
end if; end if;
...@@ -884,7 +926,7 @@ package body GNAT.Sockets is ...@@ -884,7 +926,7 @@ package body GNAT.Sockets is
Res := C_Gethostbyname (HN); Res := C_Gethostbyname (HN);
if Res = null then if Res = null then
Err := Socket_Errno; Err := Host_Errno;
Task_Lock.Unlock; Task_Lock.Unlock;
Raise_Host_Error (Err); Raise_Host_Error (Err);
end if; end if;
...@@ -1027,6 +1069,7 @@ package body GNAT.Sockets is ...@@ -1027,6 +1069,7 @@ package body GNAT.Sockets is
V8 : aliased Two_Int; V8 : aliased Two_Int;
V4 : aliased C.int; V4 : aliased C.int;
V1 : aliased C.unsigned_char; V1 : aliased C.unsigned_char;
VT : aliased Timeval;
Len : aliased C.int; Len : aliased C.int;
Add : System.Address; Add : System.Address;
Res : C.int; Res : C.int;
...@@ -1045,10 +1088,16 @@ package body GNAT.Sockets is ...@@ -1045,10 +1088,16 @@ package body GNAT.Sockets is
No_Delay | No_Delay |
Send_Buffer | Send_Buffer |
Receive_Buffer | Receive_Buffer |
Multicast_If |
Error => Error =>
Len := V4'Size / 8; Len := V4'Size / 8;
Add := V4'Address; Add := V4'Address;
when Send_Timeout |
Receive_Timeout =>
Len := VT'Size / 8;
Add := VT'Address;
when Linger | when Linger |
Add_Membership | Add_Membership |
Drop_Membership => Drop_Membership =>
...@@ -1091,12 +1140,19 @@ package body GNAT.Sockets is ...@@ -1091,12 +1140,19 @@ package body GNAT.Sockets is
To_Inet_Addr (To_In_Addr (V8 (V8'First)), Opt.Multicast_Address); To_Inet_Addr (To_In_Addr (V8 (V8'First)), Opt.Multicast_Address);
To_Inet_Addr (To_In_Addr (V8 (V8'Last)), Opt.Local_Interface); To_Inet_Addr (To_In_Addr (V8 (V8'Last)), Opt.Local_Interface);
when Multicast_If =>
To_Inet_Addr (To_In_Addr (V4), Opt.Outgoing_If);
when Multicast_TTL => when Multicast_TTL =>
Opt.Time_To_Live := Integer (V1); Opt.Time_To_Live := Integer (V1);
when Multicast_Loop => when Multicast_Loop =>
Opt.Enabled := (V1 /= 0); Opt.Enabled := (V1 /= 0);
when Send_Timeout |
Receive_Timeout =>
Opt.Timeout := To_Duration (VT);
end case; end case;
return Opt; return Opt;
...@@ -1379,12 +1435,11 @@ package body GNAT.Sockets is ...@@ -1379,12 +1435,11 @@ package body GNAT.Sockets is
-- Raise_Host_Error -- -- Raise_Host_Error --
---------------------- ----------------------
procedure Raise_Host_Error (Error : Integer) is procedure Raise_Host_Error (H_Error : Integer) is
function Host_Error_Message return String; function Host_Error_Message return String;
-- We do not use a C function like strerror because hstrerror -- We do not use a C function like strerror because hstrerror that would
-- that would correspond seems to be obsolete. Return -- correspond is obsolete. Return appropriate string for error value.
-- appropriate string for error value.
------------------------ ------------------------
-- Host_Error_Message -- -- Host_Error_Message --
...@@ -1392,7 +1447,7 @@ package body GNAT.Sockets is ...@@ -1392,7 +1447,7 @@ package body GNAT.Sockets is
function Host_Error_Message return String is function Host_Error_Message return String is
begin begin
case Error is case H_Error is
when Constants.HOST_NOT_FOUND => return "Host not found"; when Constants.HOST_NOT_FOUND => return "Host not found";
when Constants.TRY_AGAIN => return "Try again"; when Constants.TRY_AGAIN => return "Try again";
when Constants.NO_RECOVERY => return "No recovery"; when Constants.NO_RECOVERY => return "No recovery";
...@@ -1404,7 +1459,9 @@ package body GNAT.Sockets is ...@@ -1404,7 +1459,9 @@ package body GNAT.Sockets is
-- Start of processing for Raise_Host_Error -- Start of processing for Raise_Host_Error
begin begin
Ada.Exceptions.Raise_Exception (Host_Error'Identity, Host_Error_Message); Ada.Exceptions.Raise_Exception (Host_Error'Identity,
Err_Code_Image (H_Error)
& Host_Error_Message);
end Raise_Host_Error; end Raise_Host_Error;
------------------------ ------------------------
...@@ -1413,26 +1470,10 @@ package body GNAT.Sockets is ...@@ -1413,26 +1470,10 @@ package body GNAT.Sockets is
procedure Raise_Socket_Error (Error : Integer) is procedure Raise_Socket_Error (Error : Integer) is
use type C.Strings.chars_ptr; use type C.Strings.chars_ptr;
function Image (E : Integer) return String;
-----------
-- Image --
-----------
function Image (E : Integer) return String is
Msg : String := E'Img & "] ";
begin
Msg (Msg'First) := '[';
return Msg;
end Image;
-- Start of processing for Raise_Socket_Error
begin begin
Ada.Exceptions.Raise_Exception Ada.Exceptions.Raise_Exception (Socket_Error'Identity,
(Socket_Error'Identity, Err_Code_Image (Error)
Image (Error) & C.Strings.Value (Socket_Error_Message (Error))); & C.Strings.Value (Socket_Error_Message (Error)));
end Raise_Socket_Error; end Raise_Socket_Error;
---------- ----------
...@@ -1639,11 +1680,12 @@ package body GNAT.Sockets is ...@@ -1639,11 +1680,12 @@ package body GNAT.Sockets is
is is
Id : constant Exception_Id := Exception_Identity (Occurrence); Id : constant Exception_Id := Exception_Identity (Occurrence);
Msg : constant String := Exception_Message (Occurrence); Msg : constant String := Exception_Message (Occurrence);
First : Natural := Msg'First; First : Natural;
Last : Natural; Last : Natural;
Val : Integer; Val : Integer;
begin begin
First := Msg'First;
while First <= Msg'Last while First <= Msg'Last
and then Msg (First) not in '0' .. '9' and then Msg (First) not in '0' .. '9'
loop loop
...@@ -1655,7 +1697,6 @@ package body GNAT.Sockets is ...@@ -1655,7 +1697,6 @@ package body GNAT.Sockets is
end if; end if;
Last := First; Last := First;
while Last < Msg'Last while Last < Msg'Last
and then Msg (Last + 1) in '0' .. '9' and then Msg (Last + 1) in '0' .. '9'
loop loop
...@@ -1854,7 +1895,8 @@ package body GNAT.Sockets is ...@@ -1854,7 +1895,8 @@ package body GNAT.Sockets is
V8 : aliased Two_Int; V8 : aliased Two_Int;
V4 : aliased C.int; V4 : aliased C.int;
V1 : aliased C.unsigned_char; V1 : aliased C.unsigned_char;
Len : aliased C.int; VT : aliased Timeval;
Len : C.int;
Add : System.Address := Null_Address; Add : System.Address := Null_Address;
Res : C.int; Res : C.int;
...@@ -1892,6 +1934,11 @@ package body GNAT.Sockets is ...@@ -1892,6 +1934,11 @@ package body GNAT.Sockets is
Len := V8'Size / 8; Len := V8'Size / 8;
Add := V8'Address; Add := V8'Address;
when Multicast_If =>
V4 := To_Int (To_In_Addr (Option.Outgoing_If));
Len := V4'Size / 8;
Add := V4'Address;
when Multicast_TTL => when Multicast_TTL =>
V1 := C.unsigned_char (Option.Time_To_Live); V1 := C.unsigned_char (Option.Time_To_Live);
Len := V1'Size / 8; Len := V1'Size / 8;
...@@ -1902,6 +1949,12 @@ package body GNAT.Sockets is ...@@ -1902,6 +1949,12 @@ package body GNAT.Sockets is
Len := V1'Size / 8; Len := V1'Size / 8;
Add := V1'Address; Add := V1'Address;
when Send_Timeout |
Receive_Timeout =>
VT := To_Timeval (Option.Timeout);
Len := VT'Size / 8;
Add := VT'Address;
end case; end case;
Res := C_Setsockopt Res := C_Setsockopt
...@@ -1999,6 +2052,15 @@ package body GNAT.Sockets is ...@@ -1999,6 +2052,15 @@ package body GNAT.Sockets is
return Integer (Socket); return Integer (Socket);
end To_C; end To_C;
-----------------
-- To_Duration --
-----------------
function To_Duration (Val : Timeval) return Timeval_Duration is
begin
return Natural (Val.Tv_Sec) * 1.0 + Natural (Val.Tv_Usec) * 1.0E-6;
end To_Duration;
------------------- -------------------
-- To_Host_Entry -- -- To_Host_Entry --
------------------- -------------------
...@@ -2100,6 +2162,7 @@ package body GNAT.Sockets is ...@@ -2100,6 +2162,7 @@ package body GNAT.Sockets is
if Flags (J) = -1 then if Flags (J) = -1 then
Raise_Socket_Error (Constants.EOPNOTSUPP); Raise_Socket_Error (Constants.EOPNOTSUPP);
end if; end if;
Result := Result + Flags (J); Result := Result + Flags (J);
end if; end if;
...@@ -2176,25 +2239,25 @@ package body GNAT.Sockets is ...@@ -2176,25 +2239,25 @@ package body GNAT.Sockets is
-- To_Timeval -- -- To_Timeval --
---------------- ----------------
function To_Timeval (Val : Selector_Duration) return Timeval is function To_Timeval (Val : Timeval_Duration) return Timeval is
S : Timeval_Unit; S : time_t;
MS : Timeval_Unit; uS : suseconds_t;
begin begin
-- If zero, set result as zero (otherwise it gets rounded down to -1) -- If zero, set result as zero (otherwise it gets rounded down to -1)
if Val = 0.0 then if Val = 0.0 then
S := 0; S := 0;
MS := 0; uS := 0;
-- Normal case where we do round down -- Normal case where we do round down
else else
S := Timeval_Unit (Val - 0.5); S := time_t (Val - 0.5);
MS := Timeval_Unit (1_000_000 * (Val - Selector_Duration (S))); uS := suseconds_t (1_000_000 * (Val - Selector_Duration (S)));
end if; end if;
return (S, MS); return (S, uS);
end To_Timeval; end To_Timeval;
----------- -----------
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2001-2005 Ada Core Technologies, Inc. -- -- Copyright (C) 2001-2005, AdaCore --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -489,7 +489,7 @@ package GNAT.Sockets is ...@@ -489,7 +489,7 @@ package GNAT.Sockets is
Host_Error : exception; Host_Error : exception;
-- Exception raised by the two following procedures. Once raised, its -- Exception raised by the two following procedures. Once raised, its
-- message contains a string describing the error code. This exception is -- message contains a string describing the error code. This exception is
-- raised when an host entry can not be retrieved. -- raised when an host entry cannot be retrieved.
function Get_Host_By_Address function Get_Host_By_Address
(Address : Inet_Addr_Type; (Address : Inet_Addr_Type;
...@@ -595,6 +595,16 @@ package GNAT.Sockets is ...@@ -595,6 +595,16 @@ package GNAT.Sockets is
Unknown_Server_Error, Unknown_Server_Error,
Cannot_Resolve_Error); Cannot_Resolve_Error);
-- Timeval_Duration is a subtype of Standard.Duration because the full
-- range of Standard.Duration cannot be represented in the equivalent C
-- structure. Moreover, negative values are not allowed to avoid system
-- incompatibilities.
Immediate : constant := 0.0;
Forever : constant := Duration (Integer'Last) * 1.0;
subtype Timeval_Duration is Duration range Immediate .. Forever;
-- Get_Socket_Options and Set_Socket_Options manipulate options associated -- Get_Socket_Options and Set_Socket_Options manipulate options associated
-- with a socket. Options may exist at multiple protocol levels in the -- with a socket. Options may exist at multiple protocol levels in the
-- communication stack. Socket_Level is the uppermost socket level. -- communication stack. Socket_Level is the uppermost socket level.
...@@ -612,7 +622,7 @@ package GNAT.Sockets is ...@@ -612,7 +622,7 @@ package GNAT.Sockets is
type Option_Name is ( type Option_Name is (
Keep_Alive, -- Enable sending of keep-alive messages Keep_Alive, -- Enable sending of keep-alive messages
Reuse_Address, -- Allow bind to reuse local address Reuse_Address, -- Allow bind to reuse local address
Broadcast, -- Enable datagram sockets to recv/send broadcast packets Broadcast, -- Enable datagram sockets to recv/send broadcasts
Send_Buffer, -- Set/get the maximum socket send buffer in bytes Send_Buffer, -- Set/get the maximum socket send buffer in bytes
Receive_Buffer, -- Set/get the maximum socket recv buffer in bytes Receive_Buffer, -- Set/get the maximum socket recv buffer in bytes
Linger, -- Shutdown wait for msg to be sent or timeout occur Linger, -- Shutdown wait for msg to be sent or timeout occur
...@@ -620,8 +630,11 @@ package GNAT.Sockets is ...@@ -620,8 +630,11 @@ package GNAT.Sockets is
No_Delay, -- Do not delay send to coalesce packets (TCP_NODELAY) No_Delay, -- Do not delay send to coalesce packets (TCP_NODELAY)
Add_Membership, -- Join a multicast group Add_Membership, -- Join a multicast group
Drop_Membership, -- Leave a multicast group Drop_Membership, -- Leave a multicast group
Multicast_If, -- Set default outgoing interface for multicast packets
Multicast_TTL, -- Indicate the time-to-live of sent multicast packets Multicast_TTL, -- Indicate the time-to-live of sent multicast packets
Multicast_Loop); -- Sent multicast packets are looped to the local socket Multicast_Loop, -- Sent multicast packets are looped to local socket
Send_Timeout, -- Set timeout value for output
Receive_Timeout); -- Set timeout value for input
type Option_Type (Name : Option_Name := Keep_Alive) is record type Option_Type (Name : Option_Name := Keep_Alive) is record
case Name is case Name is
...@@ -652,9 +665,16 @@ package GNAT.Sockets is ...@@ -652,9 +665,16 @@ package GNAT.Sockets is
Multicast_Address : Inet_Addr_Type; Multicast_Address : Inet_Addr_Type;
Local_Interface : Inet_Addr_Type; Local_Interface : Inet_Addr_Type;
when Multicast_If =>
Outgoing_If : Inet_Addr_Type;
when Multicast_TTL => when Multicast_TTL =>
Time_To_Live : Natural; Time_To_Live : Natural;
when Send_Timeout |
Receive_Timeout =>
Timeout : Timeval_Duration;
end case; end case;
end record; end record;
...@@ -935,15 +955,7 @@ package GNAT.Sockets is ...@@ -935,15 +955,7 @@ package GNAT.Sockets is
type Selector_Type is limited private; type Selector_Type is limited private;
type Selector_Access is access all Selector_Type; type Selector_Access is access all Selector_Type;
-- Selector_Duration is a subtype of Standard.Duration because the full subtype Selector_Duration is Timeval_Duration;
-- range of Standard.Duration cannot be represented in the equivalent C
-- structure. Moreover, negative values are not allowed to avoid system
-- incompatibilities.
Immediate : constant := 0.0;
Forever : constant := Duration (Integer'Last) * 1.0;
subtype Selector_Duration is Duration range Immediate .. Forever;
procedure Create_Selector (Selector : out Selector_Type); procedure Create_Selector (Selector : out Selector_Type);
-- Create a new selector -- Create a new selector
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2001-2005 AdaCore -- -- Copyright (C) 2001-2005, AdaCore --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -59,8 +59,7 @@ package body GNAT.Sockets.Thin is ...@@ -59,8 +59,7 @@ package body GNAT.Sockets.Thin is
function Standard_Connect function Standard_Connect
(S : C.int; (S : C.int;
Name : System.Address; Name : System.Address;
Namelen : C.int) Namelen : C.int) return C.int;
return C.int;
pragma Import (Stdcall, Standard_Connect, "connect"); pragma Import (Stdcall, Standard_Connect, "connect");
function Standard_Select function Standard_Select
...@@ -68,8 +67,7 @@ package body GNAT.Sockets.Thin is ...@@ -68,8 +67,7 @@ package body GNAT.Sockets.Thin is
Readfds : Fd_Set_Access; Readfds : Fd_Set_Access;
Writefds : Fd_Set_Access; Writefds : Fd_Set_Access;
Exceptfds : Fd_Set_Access; Exceptfds : Fd_Set_Access;
Timeout : Timeval_Access) Timeout : Timeval_Access) return C.int;
return C.int;
pragma Import (Stdcall, Standard_Select, "select"); pragma Import (Stdcall, Standard_Select, "select");
type Error_Type is type Error_Type is
...@@ -239,8 +237,7 @@ package body GNAT.Sockets.Thin is ...@@ -239,8 +237,7 @@ package body GNAT.Sockets.Thin is
function C_Connect function C_Connect
(S : C.int; (S : C.int;
Name : System.Address; Name : System.Address;
Namelen : C.int) Namelen : C.int) return C.int
return C.int
is is
Res : C.int; Res : C.int;
...@@ -263,8 +260,7 @@ package body GNAT.Sockets.Thin is ...@@ -263,8 +260,7 @@ package body GNAT.Sockets.Thin is
function C_Readv function C_Readv
(Socket : C.int; (Socket : C.int;
Iov : System.Address; Iov : System.Address;
Iovcnt : C.int) Iovcnt : C.int) return C.int
return C.int
is is
Res : C.int; Res : C.int;
Count : C.int := 0; Count : C.int := 0;
...@@ -299,8 +295,7 @@ package body GNAT.Sockets.Thin is ...@@ -299,8 +295,7 @@ package body GNAT.Sockets.Thin is
Readfds : Fd_Set_Access; Readfds : Fd_Set_Access;
Writefds : Fd_Set_Access; Writefds : Fd_Set_Access;
Exceptfds : Fd_Set_Access; Exceptfds : Fd_Set_Access;
Timeout : Timeval_Access) Timeout : Timeval_Access) return C.int
return C.int
is is
pragma Warnings (Off, Exceptfds); pragma Warnings (Off, Exceptfds);
...@@ -441,8 +436,7 @@ package body GNAT.Sockets.Thin is ...@@ -441,8 +436,7 @@ package body GNAT.Sockets.Thin is
function C_Writev function C_Writev
(Socket : C.int; (Socket : C.int;
Iov : System.Address; Iov : System.Address;
Iovcnt : C.int) Iovcnt : C.int) return C.int
return C.int
is is
Res : C.int; Res : C.int;
Count : C.int := 0; Count : C.int := 0;
...@@ -553,11 +547,8 @@ package body GNAT.Sockets.Thin is ...@@ -553,11 +547,8 @@ package body GNAT.Sockets.Thin is
-------------------------- --------------------------
function Socket_Error_Message function Socket_Error_Message
(Errno : Integer) (Errno : Integer) return C.Strings.chars_ptr
return C.Strings.chars_ptr
is is
use GNAT.Sockets.Constants;
begin begin
case Errno is case Errno is
when EINTR => return Error_Messages (N_EINTR); when EINTR => return Error_Messages (N_EINTR);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2001-2005 AdaCore -- -- Copyright (C) 2001-2005, AdaCore --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -61,20 +61,32 @@ package GNAT.Sockets.Thin is ...@@ -61,20 +61,32 @@ package GNAT.Sockets.Thin is
-- Set last socket error number -- Set last socket error number
function Socket_Error_Message function Socket_Error_Message
(Errno : Integer) (Errno : Integer) return C.Strings.chars_ptr;
return C.Strings.chars_ptr;
-- Returns the error message string for the error number Errno. If -- Returns the error message string for the error number Errno. If
-- Errno is not known it returns "Unknown system error". -- Errno is not known it returns "Unknown system error".
function Host_Errno return Integer;
pragma Import (C, Host_Errno, "__gnat_get_h_errno");
-- Returns last host error number
subtype Fd_Set_Access is System.Address; subtype Fd_Set_Access is System.Address;
No_Fd_Set : constant Fd_Set_Access := System.Null_Address; No_Fd_Set : constant Fd_Set_Access := System.Null_Address;
type Timeval_Unit is new C.long; type time_t is
pragma Convention (C, Timeval_Unit); 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;
for suseconds_t'Size use 8 * Constants.SIZEOF_tv_usec;
pragma Convention (C, suseconds_t);
type Timeval is record type Timeval is record
Tv_Sec : Timeval_Unit; Tv_Sec : time_t;
Tv_Usec : Timeval_Unit; Tv_Usec : suseconds_t;
end record; end record;
pragma Convention (C, Timeval); pragma Convention (C, Timeval);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2002-2005 Ada Core Technologies, Inc. -- -- Copyright (C) 2002-2005, AdaCore --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -64,15 +64,28 @@ package GNAT.Sockets.Thin is ...@@ -64,15 +64,28 @@ package GNAT.Sockets.Thin is
-- Returns the error message string for the error number Errno. If -- Returns the error message string for the error number Errno. If
-- Errno is not known it returns "Unknown system error". -- Errno is not known it returns "Unknown system error".
function Host_Errno return Integer;
pragma Import (C, Host_Errno, "__gnat_get_h_errno");
-- Returns last host error number
subtype Fd_Set_Access is System.Address; subtype Fd_Set_Access is System.Address;
No_Fd_Set : constant Fd_Set_Access := System.Null_Address; No_Fd_Set : constant Fd_Set_Access := System.Null_Address;
type Timeval_Unit is new C.int; type time_t is
pragma Convention (C, Timeval_Unit); 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;
for suseconds_t'Size use 8 * Constants.SIZEOF_tv_usec;
pragma Convention (C, suseconds_t);
type Timeval is record type Timeval is record
Tv_Sec : Timeval_Unit; Tv_Sec : time_t;
Tv_Usec : Timeval_Unit; Tv_Usec : suseconds_t;
end record; end record;
pragma Convention (C, Timeval); pragma Convention (C, Timeval);
...@@ -197,94 +210,78 @@ package GNAT.Sockets.Thin is ...@@ -197,94 +210,78 @@ package GNAT.Sockets.Thin is
function C_Accept function C_Accept
(S : C.int; (S : C.int;
Addr : System.Address; Addr : System.Address;
Addrlen : access C.int) Addrlen : access C.int) return C.int;
return C.int;
function C_Bind function C_Bind
(S : C.int; (S : C.int;
Name : System.Address; Name : System.Address;
Namelen : C.int) Namelen : C.int) return C.int;
return C.int;
function C_Close function C_Close
(Fd : C.int) (Fd : C.int) return C.int;
return C.int;
function C_Connect function C_Connect
(S : C.int; (S : C.int;
Name : System.Address; Name : System.Address;
Namelen : C.int) Namelen : C.int) return C.int;
return C.int;
function C_Gethostbyaddr function C_Gethostbyaddr
(Addr : System.Address; (Addr : System.Address;
Len : C.int; Len : C.int;
Typ : C.int) Typ : C.int) return Hostent_Access;
return Hostent_Access;
function C_Gethostbyname function C_Gethostbyname
(Name : C.char_array) (Name : C.char_array) return Hostent_Access;
return Hostent_Access;
function C_Gethostname function C_Gethostname
(Name : System.Address; (Name : System.Address;
Namelen : C.int) Namelen : C.int) return C.int;
return C.int;
function C_Getpeername function C_Getpeername
(S : C.int; (S : C.int;
Name : System.Address; Name : System.Address;
Namelen : access C.int) Namelen : access C.int) return C.int;
return C.int;
function C_Getservbyname function C_Getservbyname
(Name : C.char_array; (Name : C.char_array;
Proto : C.char_array) Proto : C.char_array) return Servent_Access;
return Servent_Access;
function C_Getservbyport function C_Getservbyport
(Port : C.int; (Port : C.int;
Proto : C.char_array) Proto : C.char_array) return Servent_Access;
return Servent_Access;
function C_Getsockname function C_Getsockname
(S : C.int; (S : C.int;
Name : System.Address; Name : System.Address;
Namelen : access C.int) Namelen : access C.int) return C.int;
return C.int;
function C_Getsockopt function C_Getsockopt
(S : C.int; (S : C.int;
Level : C.int; Level : C.int;
Optname : C.int; Optname : C.int;
Optval : System.Address; Optval : System.Address;
Optlen : access C.int) Optlen : access C.int) return C.int;
return C.int;
function C_Inet_Addr function C_Inet_Addr
(Cp : C.Strings.chars_ptr) (Cp : C.Strings.chars_ptr) return C.int;
return C.int;
function C_Ioctl function C_Ioctl
(S : C.int; (S : C.int;
Req : C.int; Req : C.int;
Arg : Int_Access) Arg : Int_Access) return C.int;
return C.int;
function C_Listen (S, Backlog : C.int) return C.int; function C_Listen (S, Backlog : C.int) return C.int;
function C_Readv function C_Readv
(Fd : C.int; (Fd : C.int;
Iov : System.Address; Iov : System.Address;
Iovcnt : C.int) Iovcnt : C.int) return C.int;
return C.int;
function C_Recv function C_Recv
(S : C.int; (S : C.int;
Msg : System.Address; Msg : System.Address;
Len : C.int; Len : C.int;
Flags : C.int) Flags : C.int) return C.int;
return C.int;
function C_Recvfrom function C_Recvfrom
(S : C.int; (S : C.int;
...@@ -292,23 +289,20 @@ package GNAT.Sockets.Thin is ...@@ -292,23 +289,20 @@ package GNAT.Sockets.Thin is
Len : C.int; Len : C.int;
Flags : C.int; Flags : C.int;
From : Sockaddr_In_Access; From : Sockaddr_In_Access;
Fromlen : access C.int) Fromlen : access C.int) return C.int;
return C.int;
function C_Select function C_Select
(Nfds : C.int; (Nfds : C.int;
Readfds : Fd_Set_Access; Readfds : Fd_Set_Access;
Writefds : Fd_Set_Access; Writefds : Fd_Set_Access;
Exceptfds : Fd_Set_Access; Exceptfds : Fd_Set_Access;
Timeout : Timeval_Access) Timeout : Timeval_Access) return C.int;
return C.int;
function C_Send function C_Send
(S : C.int; (S : C.int;
Msg : System.Address; Msg : System.Address;
Len : C.int; Len : C.int;
Flags : C.int) Flags : C.int) return C.int;
return C.int;
function C_Sendto function C_Sendto
(S : C.int; (S : C.int;
...@@ -316,41 +310,34 @@ package GNAT.Sockets.Thin is ...@@ -316,41 +310,34 @@ package GNAT.Sockets.Thin is
Len : C.int; Len : C.int;
Flags : C.int; Flags : C.int;
To : Sockaddr_In_Access; To : Sockaddr_In_Access;
Tolen : C.int) Tolen : C.int) return C.int;
return C.int;
function C_Setsockopt function C_Setsockopt
(S : C.int; (S : C.int;
Level : C.int; Level : C.int;
Optname : C.int; Optname : C.int;
Optval : System.Address; Optval : System.Address;
Optlen : C.int) Optlen : C.int) return C.int;
return C.int;
function C_Shutdown function C_Shutdown
(S : C.int; (S : C.int;
How : C.int) How : C.int) return C.int;
return C.int;
function C_Socket function C_Socket
(Domain : C.int; (Domain : C.int;
Typ : C.int; Typ : C.int;
Protocol : C.int) Protocol : C.int) return C.int;
return C.int;
function C_Strerror function C_Strerror
(Errnum : C.int) (Errnum : C.int) return C.Strings.chars_ptr;
return C.Strings.chars_ptr;
function C_System function C_System
(Command : System.Address) (Command : System.Address) return C.int;
return C.int;
function C_Writev function C_Writev
(Fd : C.int; (Fd : C.int;
Iov : System.Address; Iov : System.Address;
Iovcnt : C.int) Iovcnt : C.int) return C.int;
return C.int;
procedure Free_Socket_Set procedure Free_Socket_Set
(Set : Fd_Set_Access); (Set : Fd_Set_Access);
...@@ -387,8 +374,7 @@ package GNAT.Sockets.Thin is ...@@ -387,8 +374,7 @@ package GNAT.Sockets.Thin is
-- set back to the real largest socket in the socket set. -- set back to the real largest socket in the socket set.
function New_Socket_Set function New_Socket_Set
(Set : Fd_Set_Access) (Set : Fd_Set_Access) return Fd_Set_Access;
return Fd_Set_Access;
-- Allocate a new socket set which is a system-dependent structure -- Allocate a new socket set which is a system-dependent structure
-- and initialize by copying Set if it is non-null, by making it -- and initialize by copying Set if it is non-null, by making it
-- empty otherwise. -- empty otherwise.
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2002-2004 Ada Core Technologies, Inc. -- -- Copyright (C) 2002-2005, AdaCore --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -267,14 +267,19 @@ package body GNAT.Sockets.Thin is ...@@ -267,14 +267,19 @@ package body GNAT.Sockets.Thin is
function To_Pointer is function To_Pointer is
new Unchecked_Conversion (System.Address, int_Access); new Unchecked_Conversion (System.Address, int_Access);
procedure VxWorks_Gethostbyaddr function VxWorks_hostGetByAddr
(Addr : C.int; Buf : out C.char_array); (Addr : C.int; Buf : System.Address) return C.int;
pragma Import (C, VxWorks_Gethostbyaddr, "hostGetByAddr"); pragma Import (C, VxWorks_hostGetByAddr, "hostGetByAddr");
Host_Name : C.char_array (1 .. Max_Name_Length); Host_Name : aliased C.char_array (1 .. Max_Name_Length);
begin begin
VxWorks_Gethostbyaddr (To_Pointer (Addr).all, Host_Name); if VxWorks_hostGetByAddr (To_Pointer (Addr).all,
Host_Name (Host_Name'First)'Address)
/= Constants.OK
then
return null;
end if;
In_Addr_Access_Ptr.all.all := To_In_Addr (To_Pointer (Addr).all); In_Addr_Access_Ptr.all.all := To_In_Addr (To_Pointer (Addr).all);
Local_Hostent.all.H_Name := C.Strings.New_Char_Array (Host_Name); Local_Hostent.all.H_Name := C.Strings.New_Char_Array (Host_Name);
...@@ -289,14 +294,17 @@ package body GNAT.Sockets.Thin is ...@@ -289,14 +294,17 @@ package body GNAT.Sockets.Thin is
function C_Gethostbyname function C_Gethostbyname
(Name : C.char_array) return Hostent_Access (Name : C.char_array) return Hostent_Access
is is
function VxWorks_Gethostbyname function VxWorks_hostGetByName
(Name : C.char_array) return C.int; (Name : C.char_array) return C.int;
pragma Import (C, VxWorks_Gethostbyname, "hostGetByName"); pragma Import (C, VxWorks_hostGetByName, "hostGetByName");
Addr : C.int; Addr : C.int;
begin begin
Addr := VxWorks_Gethostbyname (Name); Addr := VxWorks_hostGetByName (Name);
if Addr /= Constants.OK then
return null;
end if;
In_Addr_Access_Ptr.all.all := To_In_Addr (Addr); In_Addr_Access_Ptr.all.all := To_In_Addr (Addr);
Local_Hostent.all.H_Name := C.Strings.New_Char_Array (To_C (Host_Name)); Local_Hostent.all.H_Name := C.Strings.New_Char_Array (To_C (Host_Name));
...@@ -515,7 +523,6 @@ package body GNAT.Sockets.Thin is ...@@ -515,7 +523,6 @@ package body GNAT.Sockets.Thin is
function Non_Blocking_Socket (S : C.int) return Boolean is function Non_Blocking_Socket (S : C.int) return Boolean is
R : Boolean; R : Boolean;
begin begin
Task_Lock.Lock; Task_Lock.Lock;
R := (Is_Socket_In_Set (Non_Blocking_Sockets, S) /= 0); R := (Is_Socket_In_Set (Non_Blocking_Sockets, S) /= 0);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2002-2005 Ada Core Technologies, Inc. -- -- Copyright (C) 2002-2005, AdaCore --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -63,15 +63,28 @@ package GNAT.Sockets.Thin is ...@@ -63,15 +63,28 @@ package GNAT.Sockets.Thin is
-- Returns the error message string for the error number Errno. If Errno is -- Returns the error message string for the error number Errno. If Errno is
-- not known it returns "Unknown system error". -- not known it returns "Unknown system error".
function Host_Errno return Integer;
pragma Import (C, Host_Errno, "__gnat_get_h_errno");
-- Returns last host error number
subtype Fd_Set_Access is System.Address; subtype Fd_Set_Access is System.Address;
No_Fd_Set : constant Fd_Set_Access := System.Null_Address; No_Fd_Set : constant Fd_Set_Access := System.Null_Address;
type Timeval_Unit is new C.int; type time_t is
pragma Convention (C, Timeval_Unit); 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;
for suseconds_t'Size use 8 * Constants.SIZEOF_tv_usec;
pragma Convention (C, suseconds_t);
type Timeval is record type Timeval is record
Tv_Sec : Timeval_Unit; Tv_Sec : time_t;
Tv_Usec : Timeval_Unit; Tv_Usec : suseconds_t;
end record; end record;
pragma Convention (C, Timeval); pragma Convention (C, Timeval);
...@@ -199,94 +212,78 @@ package GNAT.Sockets.Thin is ...@@ -199,94 +212,78 @@ package GNAT.Sockets.Thin is
function C_Accept function C_Accept
(S : C.int; (S : C.int;
Addr : System.Address; Addr : System.Address;
Addrlen : access C.int) Addrlen : access C.int) return C.int;
return C.int;
function C_Bind function C_Bind
(S : C.int; (S : C.int;
Name : System.Address; Name : System.Address;
Namelen : C.int) Namelen : C.int) return C.int;
return C.int;
function C_Close function C_Close
(Fd : C.int) (Fd : C.int) return C.int;
return C.int;
function C_Connect function C_Connect
(S : C.int; (S : C.int;
Name : System.Address; Name : System.Address;
Namelen : C.int) Namelen : C.int) return C.int;
return C.int;
function C_Gethostbyaddr function C_Gethostbyaddr
(Addr : System.Address; (Addr : System.Address;
Len : C.int; Len : C.int;
Typ : C.int) Typ : C.int) return Hostent_Access;
return Hostent_Access;
function C_Gethostbyname function C_Gethostbyname
(Name : C.char_array) (Name : C.char_array) return Hostent_Access;
return Hostent_Access;
function C_Gethostname function C_Gethostname
(Name : System.Address; (Name : System.Address;
Namelen : C.int) Namelen : C.int) return C.int;
return C.int;
function C_Getpeername function C_Getpeername
(S : C.int; (S : C.int;
Name : System.Address; Name : System.Address;
Namelen : access C.int) Namelen : access C.int) return C.int;
return C.int;
function C_Getservbyname function C_Getservbyname
(Name : C.char_array; (Name : C.char_array;
Proto : C.char_array) Proto : C.char_array) return Servent_Access;
return Servent_Access;
function C_Getservbyport function C_Getservbyport
(Port : C.int; (Port : C.int;
Proto : C.char_array) Proto : C.char_array) return Servent_Access;
return Servent_Access;
function C_Getsockname function C_Getsockname
(S : C.int; (S : C.int;
Name : System.Address; Name : System.Address;
Namelen : access C.int) Namelen : access C.int) return C.int;
return C.int;
function C_Getsockopt function C_Getsockopt
(S : C.int; (S : C.int;
Level : C.int; Level : C.int;
Optname : C.int; Optname : C.int;
Optval : System.Address; Optval : System.Address;
Optlen : access C.int) Optlen : access C.int) return C.int;
return C.int;
function C_Inet_Addr function C_Inet_Addr
(Cp : C.Strings.chars_ptr) (Cp : C.Strings.chars_ptr) return C.int;
return C.int;
function C_Ioctl function C_Ioctl
(S : C.int; (S : C.int;
Req : C.int; Req : C.int;
Arg : Int_Access) Arg : Int_Access) return C.int;
return C.int;
function C_Listen (S, Backlog : C.int) return C.int; function C_Listen (S, Backlog : C.int) return C.int;
function C_Readv function C_Readv
(Fd : C.int; (Fd : C.int;
Iov : System.Address; Iov : System.Address;
Iovcnt : C.int) Iovcnt : C.int) return C.int;
return C.int;
function C_Recv function C_Recv
(S : C.int; (S : C.int;
Msg : System.Address; Msg : System.Address;
Len : C.int; Len : C.int;
Flags : C.int) Flags : C.int) return C.int;
return C.int;
function C_Recvfrom function C_Recvfrom
(S : C.int; (S : C.int;
...@@ -294,23 +291,20 @@ package GNAT.Sockets.Thin is ...@@ -294,23 +291,20 @@ package GNAT.Sockets.Thin is
Len : C.int; Len : C.int;
Flags : C.int; Flags : C.int;
From : Sockaddr_In_Access; From : Sockaddr_In_Access;
Fromlen : access C.int) Fromlen : access C.int) return C.int;
return C.int;
function C_Select function C_Select
(Nfds : C.int; (Nfds : C.int;
Readfds : Fd_Set_Access; Readfds : Fd_Set_Access;
Writefds : Fd_Set_Access; Writefds : Fd_Set_Access;
Exceptfds : Fd_Set_Access; Exceptfds : Fd_Set_Access;
Timeout : Timeval_Access) Timeout : Timeval_Access) return C.int;
return C.int;
function C_Send function C_Send
(S : C.int; (S : C.int;
Msg : System.Address; Msg : System.Address;
Len : C.int; Len : C.int;
Flags : C.int) Flags : C.int) return C.int;
return C.int;
function C_Sendto function C_Sendto
(S : C.int; (S : C.int;
...@@ -318,41 +312,34 @@ package GNAT.Sockets.Thin is ...@@ -318,41 +312,34 @@ package GNAT.Sockets.Thin is
Len : C.int; Len : C.int;
Flags : C.int; Flags : C.int;
To : Sockaddr_In_Access; To : Sockaddr_In_Access;
Tolen : C.int) Tolen : C.int) return C.int;
return C.int;
function C_Setsockopt function C_Setsockopt
(S : C.int; (S : C.int;
Level : C.int; Level : C.int;
Optname : C.int; Optname : C.int;
Optval : System.Address; Optval : System.Address;
Optlen : C.int) Optlen : C.int) return C.int;
return C.int;
function C_Shutdown function C_Shutdown
(S : C.int; (S : C.int;
How : C.int) How : C.int) return C.int;
return C.int;
function C_Socket function C_Socket
(Domain : C.int; (Domain : C.int;
Typ : C.int; Typ : C.int;
Protocol : C.int) Protocol : C.int) return C.int;
return C.int;
function C_Strerror function C_Strerror
(Errnum : C.int) (Errnum : C.int) return C.Strings.chars_ptr;
return C.Strings.chars_ptr;
function C_System function C_System
(Command : System.Address) (Command : System.Address) return C.int;
return C.int;
function C_Writev function C_Writev
(Fd : C.int; (Fd : C.int;
Iov : System.Address; Iov : System.Address;
Iovcnt : C.int) Iovcnt : C.int) return C.int;
return C.int;
procedure Free_Socket_Set procedure Free_Socket_Set
(Set : Fd_Set_Access); (Set : Fd_Set_Access);
...@@ -389,8 +376,7 @@ package GNAT.Sockets.Thin is ...@@ -389,8 +376,7 @@ package GNAT.Sockets.Thin is
-- set back to the real largest socket in the socket set. -- set back to the real largest socket in the socket set.
function New_Socket_Set function New_Socket_Set
(Set : Fd_Set_Access) (Set : Fd_Set_Access) return Fd_Set_Access;
return Fd_Set_Access;
-- Allocate a new socket set which is a system-dependent structure -- Allocate a new socket set which is a system-dependent structure
-- and initialize by copying Set if it is non-null, by making it -- and initialize by copying Set if it is non-null, by making it
-- empty otherwise. -- empty otherwise.
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2001-2005 Ada Core Technologies, Inc. -- -- Copyright (C) 2001-2005, AdaCore --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -65,15 +65,28 @@ package GNAT.Sockets.Thin is ...@@ -65,15 +65,28 @@ package GNAT.Sockets.Thin is
-- Returns the error message string for the error number Errno. If Errno is -- Returns the error message string for the error number Errno. If Errno is
-- not known it returns "Unknown system error". -- not known it returns "Unknown system error".
function Host_Errno return Integer;
pragma Import (C, Host_Errno, "__gnat_get_h_errno");
-- Returns last host error number
subtype Fd_Set_Access is System.Address; subtype Fd_Set_Access is System.Address;
No_Fd_Set : constant Fd_Set_Access := System.Null_Address; No_Fd_Set : constant Fd_Set_Access := System.Null_Address;
type Timeval_Unit is new C.int; type time_t is
pragma Convention (C, Timeval_Unit); 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;
for suseconds_t'Size use 8 * Constants.SIZEOF_tv_usec;
pragma Convention (C, suseconds_t);
type Timeval is record type Timeval is record
Tv_Sec : Timeval_Unit; Tv_Sec : time_t;
Tv_Usec : Timeval_Unit; Tv_Usec : suseconds_t;
end record; end record;
pragma Convention (C, Timeval); pragma Convention (C, Timeval);
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* * * *
* G E N - S O C C O N * * G E N - S O C C O N *
* * * *
* Copyright (C) 2004-2005 Free Software Foundation, Inc. * * Copyright (C) 2004-2005, Free Software Foundation, Inc. *
* * * *
* GNAT is free software; you can redistribute it and/or modify it under * * 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- * * terms of the GNU General Public License as published by the Free Soft- *
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
/* This program generates g-soccon.ads */ /* This program generates g-soccon.ads */
/* To build using DEC C: /* To build using DEC C:
CC/DEFINE="TARGET=OpenVMS" gen-soccon CC/DEFINE="TARGET=""OpenVMS""" gen-soccon
LINK gen-soccon LINK gen-soccon
RUN gen-soccon RUN gen-soccon
*/ */
...@@ -37,6 +37,11 @@ ...@@ -37,6 +37,11 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <limits.h>
#ifdef __MINGW32__
#include <fcntl.h>
#endif
#include "gsocket.h" #include "gsocket.h"
...@@ -55,8 +60,8 @@ struct line *first = NULL, *last = NULL; ...@@ -55,8 +60,8 @@ struct line *first = NULL, *last = NULL;
#define _NL TXT("") #define _NL TXT("")
/* Empty line */ /* Empty line */
#define itoad(n) f_itoa ("%d", n) #define itoad(n) f_itoa ("%d", (n))
#define itoax(n) f_itoa ("16#%08x#", n) #define itoax(n) f_itoa ("16#%08x#", (n))
#define CND(name,comment) add_line(#name, itoad (name), comment); #define CND(name,comment) add_line(#name, itoad (name), comment);
/* Constant (decimal) */ /* Constant (decimal) */
...@@ -78,6 +83,10 @@ char *f_itoa (char *, int); ...@@ -78,6 +83,10 @@ char *f_itoa (char *, int);
void add_line (char *, char*, char*); void add_line (char *, char*, char*);
#ifdef __MINGW32__
unsigned int _CRT_fmode = _O_BINARY;
#endif
int int
main (void) { main (void) {
...@@ -89,7 +98,7 @@ TXT("-- G N A T . S O C K E T S . C O N S T A N T S ...@@ -89,7 +98,7 @@ TXT("-- G N A T . S O C K E T S . C O N S T A N T S
TXT("-- --") TXT("-- --")
TXT("-- S p e c --") TXT("-- S p e c --")
TXT("-- --") TXT("-- --")
TXT("-- Copyright (C) 2000-2005 Free Software Foundation, Inc. --") TXT("-- Copyright (C) 2000-2005, Free Software Foundation, Inc. --")
TXT("-- --") TXT("-- --")
TXT("-- GNAT is free software; you can redistribute it and/or modify it under --") TXT("-- GNAT is free software; you can redistribute it and/or modify it under --")
TXT("-- terms of the GNU General Public License as published by the Free Soft- --") TXT("-- terms of the GNU General Public License as published by the Free Soft- --")
...@@ -118,7 +127,7 @@ TXT("-- This package provides target dependent definitions of constant for use" ...@@ -118,7 +127,7 @@ TXT("-- This package provides target dependent definitions of constant for use"
TXT("-- by the GNAT.Sockets package (g-socket.ads). This package should not be") TXT("-- by the GNAT.Sockets package (g-socket.ads). This package should not be")
TXT("-- directly with'ed by an applications program.") TXT("-- directly with'ed by an applications program.")
_NL _NL
TXT("-- This is the version for " STR (TARGET)) TXT("-- This is the version for " TARGET)
TXT("-- This file is generated automatically, do not modify it by hand! Instead,") TXT("-- This file is generated automatically, do not modify it by hand! Instead,")
TXT("-- make changes to gen-soccon.c and re-run it on each target.") TXT("-- make changes to gen-soccon.c and re-run it on each target.")
_NL _NL
...@@ -565,6 +574,36 @@ _NL ...@@ -565,6 +574,36 @@ _NL
CND(IOV_MAX, "Maximum writev iovcnt") CND(IOV_MAX, "Maximum writev iovcnt")
_NL _NL
TXT(" ----------------------")
TXT(" -- Type definitions --")
TXT(" ----------------------")
_NL
{
struct timeval tv;
TXT(" -- Sizes (in bytes) of the components of struct timeval")
_NL
#define SIZEOF_tv_sec (sizeof tv.tv_sec)
CND(SIZEOF_tv_sec, "tv_sec")
#define SIZEOF_tv_usec (sizeof tv.tv_usec)
CND(SIZEOF_tv_usec, "tv_usec")
}
#ifdef __vxworks
_NL
TXT(" --------------------------------")
TXT(" -- VxWorks-specific constants --")
TXT(" --------------------------------")
_NL
TXT(" -- These constants may be used only within the VxWorks version of")
TXT(" -- GNAT.Sockets.Thin.")
_NL
CND(OK, "VxWorks generic success")
CND(ERROR, "VxWorks generic error")
#endif
_NL
TXT("end GNAT.Sockets.Constants;") TXT("end GNAT.Sockets.Constants;")
output (); output ();
...@@ -614,6 +653,7 @@ f_itoa (char *fmt, int n) { ...@@ -614,6 +653,7 @@ f_itoa (char *fmt, int n) {
void void
add_line (char *_text, char *_value, char *_comment) { add_line (char *_text, char *_value, char *_comment) {
struct line *l = (struct line *) malloc (sizeof (struct line)); struct line *l = (struct line *) malloc (sizeof (struct line));
l->text = _text; l->text = _text;
l->value = _value; l->value = _value;
l->comment = _comment; l->comment = _comment;
......
...@@ -55,6 +55,8 @@ ...@@ -55,6 +55,8 @@
#if defined(__vxworks) #if defined(__vxworks)
#include <vxWorks.h> #include <vxWorks.h>
#include <ioLib.h> #include <ioLib.h>
#include <hostLib.h>
#include <resolvLib.h>
#define SHUT_RD 0 #define SHUT_RD 0
#define SHUT_WR 1 #define SHUT_WR 1
#define SHUT_RDWR 2 #define SHUT_RDWR 2
...@@ -131,7 +133,9 @@ ...@@ -131,7 +133,9 @@
#include <errno.h> #include <errno.h>
#endif #endif
#ifndef __vxworks #ifdef __vxworks
#include <sys/times.h>
#else
#include <sys/time.h> #include <sys/time.h>
#endif #endif
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
/* Required for __gnat_malloc() */ /* Required for __gnat_malloc() */
#include <string.h> #include <string.h>
/* Required for memcpy() */
extern void __gnat_disable_sigpipe (int fd); extern void __gnat_disable_sigpipe (int fd);
extern void __gnat_free_socket_set (fd_set *); extern void __gnat_free_socket_set (fd_set *);
...@@ -49,8 +50,10 @@ extern void __gnat_insert_socket_in_set (fd_set *, int); ...@@ -49,8 +50,10 @@ extern void __gnat_insert_socket_in_set (fd_set *, int);
extern int __gnat_is_socket_in_set (fd_set *, int); extern int __gnat_is_socket_in_set (fd_set *, int);
extern fd_set *__gnat_new_socket_set (fd_set *); extern fd_set *__gnat_new_socket_set (fd_set *);
extern void __gnat_remove_socket_from_set (fd_set *, int); extern void __gnat_remove_socket_from_set (fd_set *, int);
extern int __gnat_get_h_errno (void);
/* Disable the sending of SIGPIPE for writes on a broken stream */ /* Disable the sending of SIGPIPE for writes on a broken stream */
void void
__gnat_disable_sigpipe (int fd) __gnat_disable_sigpipe (int fd)
{ {
...@@ -152,3 +155,41 @@ __gnat_remove_socket_from_set (fd_set *set, int socket) ...@@ -152,3 +155,41 @@ __gnat_remove_socket_from_set (fd_set *set, int socket)
{ {
FD_CLR (socket, set); FD_CLR (socket, set);
} }
/* Get the value of the last host error */
int
__gnat_get_h_errno (void) {
#ifdef __vxworks
int vxw_errno = errno;
switch (vxw_errno) {
case 0:
return 0;
case S_resolvLib_HOST_NOT_FOUND:
case S_hostLib_UNKNOWN_HOST:
return HOST_NOT_FOUND;
case S_resolvLib_TRY_AGAIN:
return TRY_AGAIN;
case S_resolvLib_NO_RECOVERY:
case S_resolvLib_BUFFER_2_SMALL:
case S_resolvLib_INVALID_PARAMETER:
case S_resolvLib_INVALID_ADDRESS:
case S_hostLib_INVALID_PARAMETER:
return NO_RECOVERY;
case S_resolvLib_NO_DATA:
return NO_DATA;
default:
return -1;
}
#elif defined(VMS)
return errno;
#else
return h_errno;
#endif
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment