g-soccon.ads: Minor reformatting.
authorThomas Quinot <quinot@adacore.com>
Tue, 15 Nov 2005 13:50:37 +0000 (14:50 +0100)
committerArnaud Charlet <charlet@gcc.gnu.org>
Tue, 15 Nov 2005 13:50:37 +0000 (14:50 +0100)
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

27 files changed:
gcc/ada/g-soccon-aix.ads
gcc/ada/g-soccon-darwin.ads
gcc/ada/g-soccon-freebsd.ads
gcc/ada/g-soccon-hpux-ia64.ads [new file with mode: 0644]
gcc/ada/g-soccon-hpux.ads
gcc/ada/g-soccon-irix.ads
gcc/ada/g-soccon-linux-64.ads [new file with mode: 0644]
gcc/ada/g-soccon-linux-ppc.ads [new file with mode: 0644]
gcc/ada/g-soccon-linux-x86.ads [new file with mode: 0644]
gcc/ada/g-soccon-mingw.ads
gcc/ada/g-soccon-solaris-64.ads [new file with mode: 0644]
gcc/ada/g-soccon-solaris.ads
gcc/ada/g-soccon-tru64.ads
gcc/ada/g-soccon-vms.ads
gcc/ada/g-soccon-vxworks.ads
gcc/ada/g-soccon.ads
gcc/ada/g-socket.adb
gcc/ada/g-socket.ads
gcc/ada/g-socthi-mingw.adb
gcc/ada/g-socthi-mingw.ads
gcc/ada/g-socthi-vms.ads
gcc/ada/g-socthi-vxworks.adb
gcc/ada/g-socthi-vxworks.ads
gcc/ada/g-socthi.ads
gcc/ada/gen-soccon.c
gcc/ada/gsocket.h
gcc/ada/socket.c

index 3b361b51a1421f7ec6dd2bdabffbd05d82e776c6..06773f24c08e2428fe0459be47266c233defdb1f 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 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 --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -35,7 +35,7 @@
 --  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-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,
 --  make changes to gen-soccon.c and re-run it on each target.
 
@@ -169,4 +169,13 @@ package GNAT.Sockets.Constants is
 
    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;
index 3927b7897985ad3b432cab0aecf71fa9ce49e6ec..4ae827d35741cfd581a1f36de00252eda8994831 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 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 --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -169,4 +169,13 @@ package GNAT.Sockets.Constants is
 
    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;
index 29319a2bc0b25f749ce22e6cac6423d74da49060..964e75bc83be608b7024b32d52c5bea60bd520ea 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 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 --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -169,4 +169,13 @@ package GNAT.Sockets.Constants is
 
    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;
diff --git a/gcc/ada/g-soccon-hpux-ia64.ads b/gcc/ada/g-soccon-hpux-ia64.ads
new file mode 100644 (file)
index 0000000..ea7a63d
--- /dev/null
@@ -0,0 +1,181 @@
+------------------------------------------------------------------------------
+--                                                                          --
+--                         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;
index 9145146da38f0aea3f5a6bdde25947d1c771e799..0b6012e0ee606fcc6221d26096b966eb9bec00b8 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 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 --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -169,4 +169,13 @@ package GNAT.Sockets.Constants is
 
    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;
index b07191f102c0c0e8c854e8424c0ec35adc6a1b1d..3fd365c3470bce1858d662a25420531dd6572d03 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 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 --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -169,4 +169,13 @@ package GNAT.Sockets.Constants is
 
    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;
diff --git a/gcc/ada/g-soccon-linux-64.ads b/gcc/ada/g-soccon-linux-64.ads
new file mode 100644 (file)
index 0000000..fc8c507
--- /dev/null
@@ -0,0 +1,181 @@
+------------------------------------------------------------------------------
+--                                                                          --
+--                         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;
diff --git a/gcc/ada/g-soccon-linux-ppc.ads b/gcc/ada/g-soccon-linux-ppc.ads
new file mode 100644 (file)
index 0000000..185a8da
--- /dev/null
@@ -0,0 +1,181 @@
+------------------------------------------------------------------------------
+--                                                                          --
+--                         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;
diff --git a/gcc/ada/g-soccon-linux-x86.ads b/gcc/ada/g-soccon-linux-x86.ads
new file mode 100644 (file)
index 0000000..6b0521f
--- /dev/null
@@ -0,0 +1,181 @@
+------------------------------------------------------------------------------
+--                                                                          --
+--                         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;
index 3577c17c596bc01e3b5cbc69b0de97ffc63b4473..f0c25c392b599f86ecf36b3b500b39302e0b482e 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 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 --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -169,4 +169,13 @@ package GNAT.Sockets.Constants is
 
    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;
diff --git a/gcc/ada/g-soccon-solaris-64.ads b/gcc/ada/g-soccon-solaris-64.ads
new file mode 100644 (file)
index 0000000..be1fc4f
--- /dev/null
@@ -0,0 +1,181 @@
+------------------------------------------------------------------------------
+--                                                                          --
+--                         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;
index 07de5cdbc29df783787298de937882bea74f57d5..7204e975c510f89f7761966b58ac0e5eb7c4be88 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 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 --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -169,4 +169,13 @@ package GNAT.Sockets.Constants is
 
    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;
index be7578f3521e61eca5b75aeabba0409f949ed2a3..b6d6836452d4cd3719dc62630bbfc50cc6936452 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 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 --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -169,4 +169,13 @@ package GNAT.Sockets.Constants is
 
    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;
index 3b0f20fe61c9c5e97dd53baf74965ede3bae6248..85996efa3cd488d831b48b731301395b58aa4a1c 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 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 --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -169,4 +169,13 @@ package GNAT.Sockets.Constants is
 
    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;
index d31337f675cb5d34871899002f0020de91864b29..1accc7cc812795e401419fe45a6b5f97f9d6cdb2 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 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 --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -169,4 +169,23 @@ package GNAT.Sockets.Constants is
 
    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;
index 202f442ec307c2749987119fb1271948e15fb7e1..5fa72f5f27f42f2bceb6c30c160574474821774d 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 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 --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -36,6 +36,9 @@
 --  directly with'ed by an applications program.
 
 --  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,
 --  make changes to gen-soccon.c and re-run it on each target.
 
@@ -169,4 +172,13 @@ package GNAT.Sockets.Constants is
 
    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;
index a7af20b87d23a2a867f82123caeb6f8aa87a5648..163dd2d0710efb700273eb4b734575b33034c6f1 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 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 --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -92,8 +92,11 @@ package body GNAT.Sockets is
       No_Delay        => Constants.TCP_NODELAY,
       Add_Membership  => Constants.IP_ADD_MEMBERSHIP,
       Drop_Membership => Constants.IP_DROP_MEMBERSHIP,
+      Multicast_If    => Constants.IP_MULTICAST_IF,
       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 :=
             (0 => Constants.MSG_OOB,     --  Process_Out_Of_Band_Data
@@ -110,6 +113,9 @@ package body GNAT.Sockets is
    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 Err_Code_Image (E : Integer) return String;
+   --  Return the value of E surrounded with brackets
+
    -----------------------
    -- Local subprograms --
    -----------------------
@@ -160,15 +166,20 @@ package body GNAT.Sockets is
    function To_Service_Entry (E : Servent) return Service_Entry_Type;
    --  Conversion function
 
-   function To_Timeval (Val : Selector_Duration) return Timeval;
+   function To_Timeval (Val : Timeval_Duration) return Timeval;
    --  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);
    --  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
-   --  hstrerror seems to be obsolete).
+   --  hstrerror seems to be obsolete) from h_errno.
 
    procedure Narrow (Item : in out Socket_Set_Type);
    --  Update Last as it may be greater than the real last socket
@@ -384,6 +395,7 @@ package body GNAT.Sockets is
    is
       Res  : C.int;
       Last : C.int;
+      RSig : Socket_Type renames Selector.R_Sig_Socket;
       RSet : Socket_Set_Type;
       WSet : Socket_Set_Type;
       ESet : Socket_Set_Type;
@@ -391,102 +403,116 @@ package body GNAT.Sockets is
       TPtr : Timeval_Access;
 
    begin
-      Status := Completed;
+      begin
+         Status := Completed;
 
-      --  No timeout or Forever is indicated by a null timeval pointer
+         --  No timeout or Forever is indicated by a null timeval pointer
 
-      if Timeout = Forever then
-         TPtr := null;
-      else
-         TVal := To_Timeval (Timeout);
-         TPtr := TVal'Unchecked_Access;
-      end if;
+         if Timeout = Forever then
+            TPtr := null;
+         else
+            TVal := To_Timeval (Timeout);
+            TPtr := TVal'Unchecked_Access;
+         end if;
 
-      --  Copy R_Socket_Set in RSet and add read signalling socket
+         --  Copy R_Socket_Set in RSet and add read signalling socket
 
-      RSet := (Set  => New_Socket_Set (R_Socket_Set.Set),
-               Last => R_Socket_Set.Last);
-      Set (RSet, Selector.R_Sig_Socket);
+         RSet := (Set  => New_Socket_Set (R_Socket_Set.Set),
+                  Last => R_Socket_Set.Last);
+         Set (RSet, RSig);
 
-      --  Copy W_Socket_Set in WSet
+         --  Copy W_Socket_Set in WSet
 
-      WSet := (Set  => New_Socket_Set (W_Socket_Set.Set),
-               Last => W_Socket_Set.Last);
+         WSet := (Set  => New_Socket_Set (W_Socket_Set.Set),
+                  Last => W_Socket_Set.Last);
 
-      --  Copy E_Socket_Set in ESet
+         --  Copy E_Socket_Set in ESet
 
-      ESet := (Set  => New_Socket_Set (E_Socket_Set.Set),
-               Last => E_Socket_Set.Last);
+         ESet := (Set  => New_Socket_Set (E_Socket_Set.Set),
+                  Last => E_Socket_Set.Last);
 
-      Last := C.int'Max (C.int'Max (C.int (RSet.Last),
-                                    C.int (WSet.Last)),
-                                    C.int (ESet.Last));
+         Last := C.int'Max (C.int'Max (C.int (RSet.Last),
+                                       C.int (WSet.Last)),
+                                       C.int (ESet.Last));
 
-      Res :=
-        C_Select
-         (Last + 1,
-          RSet.Set,
-          WSet.Set,
-          ESet.Set,
-          TPtr);
+         Res :=
+           C_Select
+            (Last + 1,
+             RSet.Set,
+             WSet.Set,
+             ESet.Set,
+             TPtr);
 
-      if Res = Failure then
-         Raise_Socket_Error (Socket_Errno);
-      end if;
+         if Res = Failure then
+            Raise_Socket_Error (Socket_Errno);
+         end if;
 
-      --  If Select was resumed because of read signalling socket, read this
-      --  data and remove socket from set.
+         --  If Select was resumed because of read signalling socket, read this
+         --  data and remove socket from set.
 
-      if Is_Set (RSet, Selector.R_Sig_Socket) then
-         Clear (RSet, Selector.R_Sig_Socket);
+         if Is_Set (RSet, RSig) then
+            Clear (RSet, RSig);
 
-         declare
-            Buf : Character;
+            declare
+               Buf : Character;
 
-         begin
-            Res := C_Recv (C.int (Selector.R_Sig_Socket), Buf'Address, 1, 0);
+            begin
+               Res := C_Recv (C.int (RSig), Buf'Address, 1, 0);
 
-            if Res = Failure then
-               Raise_Socket_Error (Socket_Errno);
-            end if;
-         end;
+               if Res = Failure then
+                  Raise_Socket_Error (Socket_Errno);
+               end if;
+            end;
 
-         Status := Aborted;
+            Status := Aborted;
 
-      elsif Res = 0 then
-         Status := Expired;
-      end if;
+         elsif Res = 0 then
+            Status := Expired;
+         end if;
 
-      --  Update RSet, WSet and ESet in regard to their new socket sets
+         --  Update RSet, WSet and ESet in regard to their new socket sets
 
-      Narrow (RSet);
-      Narrow (WSet);
-      Narrow (ESet);
+         Narrow (RSet);
+         Narrow (WSet);
+         Narrow (ESet);
 
-      --  Reset RSet as it should be if R_Sig_Socket was not added
+         --  Reset RSet as it should be if R_Sig_Socket was not added
 
-      if Is_Empty (RSet) then
-         Empty (RSet);
-      end if;
+         if Is_Empty (RSet) then
+            Empty (RSet);
+         end if;
 
-      if Is_Empty (WSet) then
-         Empty (WSet);
-      end if;
+         if Is_Empty (WSet) then
+            Empty (WSet);
+         end if;
 
-      if Is_Empty (ESet) then
-         Empty (ESet);
-      end if;
+         if Is_Empty (ESet) then
+            Empty (ESet);
+         end if;
 
-      --  Deliver RSet, WSet and ESet
+         --  Deliver RSet, WSet and ESet
 
-      Empty (R_Socket_Set);
-      R_Socket_Set := RSet;
+         Empty (R_Socket_Set);
+         R_Socket_Set := RSet;
 
-      Empty (W_Socket_Set);
-      W_Socket_Set := WSet;
+         Empty (W_Socket_Set);
+         W_Socket_Set := WSet;
 
-      Empty (E_Socket_Set);
-      E_Socket_Set := ESet;
+         Empty (E_Socket_Set);
+         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;
 
    -----------
@@ -510,11 +536,16 @@ package body GNAT.Sockets is
    -- Close_Selector --
    --------------------
 
-   --  Comments needed below ???
-   --  Why are exceptions ignored ???
-
    procedure Close_Selector (Selector : in out Selector_Type) is
    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
          Close_Socket (Selector.R_Sig_Socket);
       exception
@@ -772,6 +803,17 @@ package body GNAT.Sockets is
       Item.Last := No_Socket;
    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 --
    --------------
@@ -845,7 +887,7 @@ package body GNAT.Sockets is
       Res := C_Gethostbyaddr (HA'Address, HA'Size / 8, Constants.AF_INET);
 
       if Res = null then
-         Err := Socket_Errno;
+         Err := Host_Errno;
          Task_Lock.Unlock;
          Raise_Host_Error (Err);
       end if;
@@ -884,7 +926,7 @@ package body GNAT.Sockets is
       Res := C_Gethostbyname (HN);
 
       if Res = null then
-         Err := Socket_Errno;
+         Err := Host_Errno;
          Task_Lock.Unlock;
          Raise_Host_Error (Err);
       end if;
@@ -1027,6 +1069,7 @@ package body GNAT.Sockets is
       V8  : aliased Two_Int;
       V4  : aliased C.int;
       V1  : aliased C.unsigned_char;
+      VT  : aliased Timeval;
       Len : aliased C.int;
       Add : System.Address;
       Res : C.int;
@@ -1045,10 +1088,16 @@ package body GNAT.Sockets is
               No_Delay        |
               Send_Buffer     |
               Receive_Buffer  |
+              Multicast_If    |
               Error           =>
             Len := V4'Size / 8;
             Add := V4'Address;
 
+         when Send_Timeout    |
+              Receive_Timeout =>
+            Len := VT'Size / 8;
+            Add := VT'Address;
+
          when Linger          |
               Add_Membership  |
               Drop_Membership =>
@@ -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'Last)), Opt.Local_Interface);
 
+         when Multicast_If    =>
+            To_Inet_Addr (To_In_Addr (V4), Opt.Outgoing_If);
+
          when Multicast_TTL   =>
             Opt.Time_To_Live := Integer (V1);
 
          when Multicast_Loop  =>
             Opt.Enabled := (V1 /= 0);
 
+         when Send_Timeout    |
+              Receive_Timeout =>
+            Opt.Timeout := To_Duration (VT);
+
       end case;
 
       return Opt;
@@ -1379,12 +1435,11 @@ package body GNAT.Sockets is
    -- Raise_Host_Error --
    ----------------------
 
-   procedure Raise_Host_Error (Error : Integer) is
+   procedure Raise_Host_Error (H_Error : Integer) is
 
       function Host_Error_Message return String;
-      --  We do not use a C function like strerror because hstrerror
-      --  that would correspond seems to be obsolete. Return
-      --  appropriate string for error value.
+      --  We do not use a C function like strerror because hstrerror that would
+      --  correspond is obsolete. Return appropriate string for error value.
 
       ------------------------
       -- Host_Error_Message --
@@ -1392,7 +1447,7 @@ package body GNAT.Sockets is
 
       function Host_Error_Message return String is
       begin
-         case Error is
+         case H_Error is
             when Constants.HOST_NOT_FOUND => return "Host not found";
             when Constants.TRY_AGAIN      => return "Try again";
             when Constants.NO_RECOVERY    => return "No recovery";
@@ -1404,7 +1459,9 @@ package body GNAT.Sockets is
    --  Start of processing for Raise_Host_Error
 
    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;
 
    ------------------------
@@ -1413,26 +1470,10 @@ package body GNAT.Sockets is
 
    procedure Raise_Socket_Error (Error : Integer) is
       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
-      Ada.Exceptions.Raise_Exception
-        (Socket_Error'Identity,
-         Image (Error) & C.Strings.Value (Socket_Error_Message (Error)));
+      Ada.Exceptions.Raise_Exception (Socket_Error'Identity,
+        Err_Code_Image (Error)
+        & C.Strings.Value (Socket_Error_Message (Error)));
    end Raise_Socket_Error;
 
    ----------
@@ -1639,11 +1680,12 @@ package body GNAT.Sockets is
    is
       Id    : constant Exception_Id := Exception_Identity (Occurrence);
       Msg   : constant String       := Exception_Message (Occurrence);
-      First : Natural               := Msg'First;
+      First : Natural;
       Last  : Natural;
       Val   : Integer;
 
    begin
+      First := Msg'First;
       while First <= Msg'Last
         and then Msg (First) not in '0' .. '9'
       loop
@@ -1655,7 +1697,6 @@ package body GNAT.Sockets is
       end if;
 
       Last := First;
-
       while Last < Msg'Last
         and then Msg (Last + 1) in '0' .. '9'
       loop
@@ -1854,7 +1895,8 @@ package body GNAT.Sockets is
       V8  : aliased Two_Int;
       V4  : aliased C.int;
       V1  : aliased C.unsigned_char;
-      Len : aliased C.int;
+      VT  : aliased Timeval;
+      Len : C.int;
       Add : System.Address := Null_Address;
       Res : C.int;
 
@@ -1892,6 +1934,11 @@ package body GNAT.Sockets is
             Len := V8'Size / 8;
             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   =>
             V1  := C.unsigned_char (Option.Time_To_Live);
             Len := V1'Size / 8;
@@ -1902,6 +1949,12 @@ package body GNAT.Sockets is
             Len := V1'Size / 8;
             Add := V1'Address;
 
+         when Send_Timeout    |
+              Receive_Timeout =>
+            VT  := To_Timeval (Option.Timeout);
+            Len := VT'Size / 8;
+            Add := VT'Address;
+
       end case;
 
       Res := C_Setsockopt
@@ -1999,6 +2052,15 @@ package body GNAT.Sockets is
       return Integer (Socket);
    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 --
    -------------------
@@ -2100,6 +2162,7 @@ package body GNAT.Sockets is
             if Flags (J) = -1 then
                Raise_Socket_Error (Constants.EOPNOTSUPP);
             end if;
+
             Result := Result + Flags (J);
          end if;
 
@@ -2176,25 +2239,25 @@ package body GNAT.Sockets is
    -- To_Timeval --
    ----------------
 
-   function To_Timeval (Val : Selector_Duration) return Timeval is
-      S  : Timeval_Unit;
-      MS : Timeval_Unit;
+   function To_Timeval (Val : Timeval_Duration) return Timeval is
+      S  : time_t;
+      uS : suseconds_t;
 
    begin
       --  If zero, set result as zero (otherwise it gets rounded down to -1)
 
       if Val = 0.0 then
          S  := 0;
-         MS := 0;
+         uS := 0;
 
       --  Normal case where we do round down
 
       else
-         S  := Timeval_Unit (Val - 0.5);
-         MS := Timeval_Unit (1_000_000 * (Val - Selector_Duration (S)));
+         S  := time_t (Val - 0.5);
+         uS := suseconds_t (1_000_000 * (Val - Selector_Duration (S)));
       end if;
 
-      return (S, MS);
+      return (S, uS);
    end To_Timeval;
 
    -----------
index 7529c050892be204164b0857ac1d188f91b2595b..6268545a5fa867fedb12c4324464d7acc61a3a5b 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 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 --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -489,7 +489,7 @@ package GNAT.Sockets is
    Host_Error : exception;
    --  Exception raised by the two following procedures. Once raised, its
    --  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
      (Address : Inet_Addr_Type;
@@ -595,6 +595,16 @@ package GNAT.Sockets is
       Unknown_Server_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
    --  with a socket. Options may exist at multiple protocol levels in the
    --  communication stack. Socket_Level is the uppermost socket level.
@@ -610,18 +620,21 @@ package GNAT.Sockets is
    --  a boolean to enable or disable this option.
 
    type Option_Name is (
-     Keep_Alive,      -- Enable sending of keep-alive messages
-     Reuse_Address,   -- Allow bind to reuse local address
-     Broadcast,       -- Enable datagram sockets to recv/send broadcast packets
-     Send_Buffer,     -- Set/get the maximum socket send 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
-     Error,           -- Get and clear the pending socket error
-     No_Delay,        -- Do not delay send to coalesce packets (TCP_NODELAY)
-     Add_Membership,  -- Join a multicast group
-     Drop_Membership, -- Leave a multicast group
-     Multicast_TTL,   -- Indicate the time-to-live of sent multicast packets
-     Multicast_Loop); -- Sent multicast packets are looped to the local socket
+     Keep_Alive,       -- Enable sending of keep-alive messages
+     Reuse_Address,    -- Allow bind to reuse local address
+     Broadcast,        -- Enable datagram sockets to recv/send broadcasts
+     Send_Buffer,      -- Set/get the maximum socket send 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
+     Error,            -- Get and clear the pending socket error
+     No_Delay,         -- Do not delay send to coalesce packets (TCP_NODELAY)
+     Add_Membership,   -- Join 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_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
       case Name is
@@ -652,9 +665,16 @@ package GNAT.Sockets is
             Multicast_Address : Inet_Addr_Type;
             Local_Interface   : Inet_Addr_Type;
 
+         when Multicast_If    =>
+            Outgoing_If : Inet_Addr_Type;
+
          when Multicast_TTL   =>
             Time_To_Live : Natural;
 
+         when Send_Timeout |
+              Receive_Timeout =>
+            Timeout : Timeval_Duration;
+
       end case;
    end record;
 
@@ -935,15 +955,7 @@ package GNAT.Sockets is
    type Selector_Type is limited private;
    type Selector_Access is access all Selector_Type;
 
-   --  Selector_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 Selector_Duration is Duration range Immediate .. Forever;
+   subtype Selector_Duration is Timeval_Duration;
 
    procedure Create_Selector (Selector : out Selector_Type);
    --  Create a new selector
index e525cc839e3f289439e47f1170d510397f4c6a57..862305dbd2ef99814ac2a482d4a90325faf376a7 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 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 --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -59,8 +59,7 @@ package body GNAT.Sockets.Thin is
    function Standard_Connect
      (S       : C.int;
       Name    : System.Address;
-      Namelen : C.int)
-      return    C.int;
+      Namelen : C.int) return C.int;
    pragma Import (Stdcall, Standard_Connect, "connect");
 
    function Standard_Select
@@ -68,8 +67,7 @@ package body GNAT.Sockets.Thin is
       Readfds   : Fd_Set_Access;
       Writefds  : Fd_Set_Access;
       Exceptfds : Fd_Set_Access;
-      Timeout   : Timeval_Access)
-      return      C.int;
+      Timeout   : Timeval_Access) return C.int;
    pragma Import (Stdcall, Standard_Select, "select");
 
    type Error_Type is
@@ -239,8 +237,7 @@ package body GNAT.Sockets.Thin is
    function C_Connect
      (S       : C.int;
       Name    : System.Address;
-      Namelen : C.int)
-      return    C.int
+      Namelen : C.int) return C.int
    is
       Res : C.int;
 
@@ -263,8 +260,7 @@ package body GNAT.Sockets.Thin is
    function C_Readv
      (Socket : C.int;
       Iov    : System.Address;
-      Iovcnt : C.int)
-      return  C.int
+      Iovcnt : C.int) return C.int
    is
       Res : C.int;
       Count : C.int := 0;
@@ -299,8 +295,7 @@ package body GNAT.Sockets.Thin is
       Readfds   : Fd_Set_Access;
       Writefds  : Fd_Set_Access;
       Exceptfds : Fd_Set_Access;
-      Timeout   : Timeval_Access)
-      return      C.int
+      Timeout   : Timeval_Access) return C.int
    is
       pragma Warnings (Off, Exceptfds);
 
@@ -441,8 +436,7 @@ package body GNAT.Sockets.Thin is
    function C_Writev
      (Socket : C.int;
       Iov    : System.Address;
-      Iovcnt : C.int)
-      return   C.int
+      Iovcnt : C.int) return C.int
    is
       Res : C.int;
       Count : C.int := 0;
@@ -553,11 +547,8 @@ package body GNAT.Sockets.Thin is
    --------------------------
 
    function Socket_Error_Message
-     (Errno : Integer)
-     return  C.Strings.chars_ptr
+     (Errno : Integer) return C.Strings.chars_ptr
    is
-      use GNAT.Sockets.Constants;
-
    begin
       case Errno is
          when EINTR =>           return Error_Messages (N_EINTR);
index a73b0a7ce036198dc216dbfd07bedab5a3f64c5f..11509c095ea165b45debbec4ce5a4e494005810c 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 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 --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -61,20 +61,32 @@ package GNAT.Sockets.Thin is
    --  Set last socket error number
 
    function Socket_Error_Message
-     (Errno : Integer)
-      return  C.Strings.chars_ptr;
+     (Errno : Integer) return C.Strings.chars_ptr;
    --  Returns the error message string for the error number Errno. If
    --  Errno is not known it returns "Unknown system error".
 
+   function Host_Errno return Integer;
+   pragma Import (C, Host_Errno, "__gnat_get_h_errno");
+   --  Returns last host error number
+
    subtype Fd_Set_Access is System.Address;
    No_Fd_Set : constant Fd_Set_Access := System.Null_Address;
 
-   type Timeval_Unit is new C.long;
-   pragma Convention (C, Timeval_Unit);
+   type time_t is
+     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
-      Tv_Sec  : Timeval_Unit;
-      Tv_Usec : Timeval_Unit;
+      Tv_Sec  : time_t;
+      Tv_Usec : suseconds_t;
    end record;
    pragma Convention (C, Timeval);
 
index 6a19d2dc5f4604ab798dbac39e1ff57d0e67c753..1b05e4719bc19ca78f1dd87ca2c2bd08348ed9b8 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 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 --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -64,15 +64,28 @@ package GNAT.Sockets.Thin is
    --  Returns the error message string for the error number Errno. If
    --  Errno is not known it returns "Unknown system error".
 
+   function Host_Errno return Integer;
+   pragma Import (C, Host_Errno, "__gnat_get_h_errno");
+   --  Returns last host error number
+
    subtype Fd_Set_Access is System.Address;
    No_Fd_Set : constant Fd_Set_Access := System.Null_Address;
 
-   type Timeval_Unit is new C.int;
-   pragma Convention (C, Timeval_Unit);
+   type time_t is
+     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
-      Tv_Sec  : Timeval_Unit;
-      Tv_Usec : Timeval_Unit;
+      Tv_Sec  : time_t;
+      Tv_Usec : suseconds_t;
    end record;
    pragma Convention (C, Timeval);
 
@@ -197,94 +210,78 @@ package GNAT.Sockets.Thin is
    function C_Accept
      (S       : C.int;
       Addr    : System.Address;
-      Addrlen : access C.int)
-      return    C.int;
+      Addrlen : access C.int) return C.int;
 
    function C_Bind
      (S       : C.int;
       Name    : System.Address;
-      Namelen : C.int)
-      return    C.int;
+      Namelen : C.int) return C.int;
 
    function C_Close
-     (Fd   : C.int)
-      return C.int;
+     (Fd : C.int) return C.int;
 
    function C_Connect
      (S       : C.int;
       Name    : System.Address;
-      Namelen : C.int)
-      return    C.int;
+      Namelen : C.int) return C.int;
 
    function C_Gethostbyaddr
      (Addr : System.Address;
       Len  : C.int;
-      Typ  : C.int)
-      return Hostent_Access;
+      Typ  : C.int) return Hostent_Access;
 
    function C_Gethostbyname
-     (Name : C.char_array)
-      return Hostent_Access;
+     (Name : C.char_array) return Hostent_Access;
 
    function C_Gethostname
      (Name    : System.Address;
-      Namelen : C.int)
-      return    C.int;
+      Namelen : C.int) return C.int;
 
    function C_Getpeername
      (S       : C.int;
       Name    : System.Address;
-      Namelen : access C.int)
-      return    C.int;
+      Namelen : access C.int) return C.int;
 
    function C_Getservbyname
      (Name  : C.char_array;
-      Proto : C.char_array)
-      return Servent_Access;
+      Proto : C.char_array) return Servent_Access;
 
    function C_Getservbyport
      (Port  : C.int;
-      Proto : C.char_array)
-      return Servent_Access;
+      Proto : C.char_array) return Servent_Access;
 
    function C_Getsockname
      (S       : C.int;
       Name    : System.Address;
-      Namelen : access C.int)
-      return    C.int;
+      Namelen : access C.int) return C.int;
 
    function C_Getsockopt
      (S       : C.int;
       Level   : C.int;
       Optname : C.int;
       Optval  : System.Address;
-      Optlen  : access C.int)
-      return    C.int;
+      Optlen  : access C.int) return C.int;
 
    function C_Inet_Addr
-     (Cp   : C.Strings.chars_ptr)
-      return C.int;
+     (Cp   : C.Strings.chars_ptr) return C.int;
 
    function C_Ioctl
      (S    : C.int;
       Req  : C.int;
-      Arg  : Int_Access)
-      return C.int;
+      Arg  : Int_Access) return C.int;
 
    function C_Listen (S, Backlog : C.int) return C.int;
 
    function C_Readv
      (Fd     : C.int;
       Iov    : System.Address;
-      Iovcnt : C.int)
-      return   C.int;
+      Iovcnt : C.int) return C.int;
 
    function C_Recv
      (S     : C.int;
       Msg   : System.Address;
       Len   : C.int;
-      Flags : C.int)
-      return  C.int;
+      Flags : C.int) return C.int;
 
    function C_Recvfrom
      (S       : C.int;
@@ -292,23 +289,20 @@ package GNAT.Sockets.Thin is
       Len     : C.int;
       Flags   : C.int;
       From    : Sockaddr_In_Access;
-      Fromlen : access C.int)
-      return    C.int;
+      Fromlen : access C.int) return C.int;
 
    function C_Select
      (Nfds      : C.int;
       Readfds   : Fd_Set_Access;
       Writefds  : Fd_Set_Access;
       Exceptfds : Fd_Set_Access;
-      Timeout   : Timeval_Access)
-      return      C.int;
+      Timeout   : Timeval_Access) return C.int;
 
    function C_Send
      (S     : C.int;
       Msg   : System.Address;
       Len   : C.int;
-      Flags : C.int)
-      return  C.int;
+      Flags : C.int) return C.int;
 
    function C_Sendto
      (S     : C.int;
@@ -316,44 +310,37 @@ package GNAT.Sockets.Thin is
       Len   : C.int;
       Flags : C.int;
       To    : Sockaddr_In_Access;
-      Tolen : C.int)
-      return  C.int;
+      Tolen : C.int) return C.int;
 
    function C_Setsockopt
      (S       : C.int;
       Level   : C.int;
       Optname : C.int;
       Optval  : System.Address;
-      Optlen  : C.int)
-      return    C.int;
+      Optlen  : C.int) return C.int;
 
    function C_Shutdown
      (S    : C.int;
-      How  : C.int)
-      return C.int;
+      How  : C.int) return C.int;
 
    function C_Socket
      (Domain   : C.int;
       Typ      : C.int;
-      Protocol : C.int)
-      return     C.int;
+      Protocol : C.int) return C.int;
 
    function C_Strerror
-     (Errnum : C.int)
-      return   C.Strings.chars_ptr;
+     (Errnum : C.int) return C.Strings.chars_ptr;
 
    function C_System
-     (Command : System.Address)
-      return    C.int;
+     (Command : System.Address) return C.int;
 
    function C_Writev
      (Fd     : C.int;
       Iov    : System.Address;
-      Iovcnt : C.int)
-      return   C.int;
+      Iovcnt : C.int) return C.int;
 
    procedure Free_Socket_Set
-     (Set    : Fd_Set_Access);
+     (Set : Fd_Set_Access);
    --  Free system-dependent socket set
 
    procedure Get_Socket_From_Set
@@ -387,8 +374,7 @@ package GNAT.Sockets.Thin is
    --  set back to the real largest socket in the socket set.
 
    function  New_Socket_Set
-     (Set    : Fd_Set_Access)
-     return   Fd_Set_Access;
+     (Set : Fd_Set_Access) return Fd_Set_Access;
    --  Allocate a new socket set which is a system-dependent structure
    --  and initialize by copying Set if it is non-null, by making it
    --  empty otherwise.
index 95de193ecf798b2d80b41fb4db80ecfbb61fda23..02a0df3fe33facfb0e0fb263502d0857f433ce72 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 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 --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -267,14 +267,19 @@ package body GNAT.Sockets.Thin is
       function To_Pointer is
         new Unchecked_Conversion (System.Address, int_Access);
 
-      procedure VxWorks_Gethostbyaddr
-        (Addr : C.int; Buf : out C.char_array);
-      pragma Import (C, VxWorks_Gethostbyaddr, "hostGetByAddr");
+      function VxWorks_hostGetByAddr
+        (Addr : C.int; Buf : System.Address) return C.int;
+      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
-      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);
       Local_Hostent.all.H_Name := C.Strings.New_Char_Array (Host_Name);
@@ -289,14 +294,17 @@ package body GNAT.Sockets.Thin is
    function C_Gethostbyname
      (Name : C.char_array) return Hostent_Access
    is
-      function VxWorks_Gethostbyname
+      function VxWorks_hostGetByName
         (Name : C.char_array) return C.int;
-      pragma Import (C, VxWorks_Gethostbyname, "hostGetByName");
+      pragma Import (C, VxWorks_hostGetByName, "hostGetByName");
 
       Addr : C.int;
 
    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);
       Local_Hostent.all.H_Name := C.Strings.New_Char_Array (To_C (Host_Name));
@@ -515,7 +523,6 @@ package body GNAT.Sockets.Thin is
 
    function Non_Blocking_Socket (S : C.int) return Boolean is
       R : Boolean;
-
    begin
       Task_Lock.Lock;
       R := (Is_Socket_In_Set (Non_Blocking_Sockets, S) /= 0);
index 2d818272983556b8ca749bae79ffa6953f75d0e9..6aee25d4ef4640a1aa6d2efce263e5611b15e5f7 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 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 --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -63,15 +63,28 @@ package GNAT.Sockets.Thin is
    --  Returns the error message string for the error number Errno. If Errno is
    --  not known it returns "Unknown system error".
 
+   function Host_Errno return Integer;
+   pragma Import (C, Host_Errno, "__gnat_get_h_errno");
+   --  Returns last host error number
+
    subtype Fd_Set_Access is System.Address;
    No_Fd_Set : constant Fd_Set_Access := System.Null_Address;
 
-   type Timeval_Unit is new C.int;
-   pragma Convention (C, Timeval_Unit);
+   type time_t is
+     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
-      Tv_Sec  : Timeval_Unit;
-      Tv_Usec : Timeval_Unit;
+      Tv_Sec  : time_t;
+      Tv_Usec : suseconds_t;
    end record;
    pragma Convention (C, Timeval);
 
@@ -199,94 +212,78 @@ package GNAT.Sockets.Thin is
    function C_Accept
      (S       : C.int;
       Addr    : System.Address;
-      Addrlen : access C.int)
-      return    C.int;
+      Addrlen : access C.int) return C.int;
 
    function C_Bind
      (S       : C.int;
       Name    : System.Address;
-      Namelen : C.int)
-      return    C.int;
+      Namelen : C.int) return C.int;
 
    function C_Close
-     (Fd   : C.int)
-      return C.int;
+     (Fd : C.int) return C.int;
 
    function C_Connect
      (S       : C.int;
       Name    : System.Address;
-      Namelen : C.int)
-      return    C.int;
+      Namelen : C.int) return C.int;
 
    function C_Gethostbyaddr
      (Addr : System.Address;
       Len  : C.int;
-      Typ  : C.int)
-      return Hostent_Access;
+      Typ  : C.int) return Hostent_Access;
 
    function C_Gethostbyname
-     (Name : C.char_array)
-      return Hostent_Access;
+     (Name : C.char_array) return Hostent_Access;
 
    function C_Gethostname
      (Name    : System.Address;
-      Namelen : C.int)
-      return    C.int;
+      Namelen : C.int) return C.int;
 
    function C_Getpeername
      (S       : C.int;
       Name    : System.Address;
-      Namelen : access C.int)
-      return    C.int;
+      Namelen : access C.int) return C.int;
 
    function C_Getservbyname
      (Name  : C.char_array;
-      Proto : C.char_array)
-      return Servent_Access;
+      Proto : C.char_array) return Servent_Access;
 
    function C_Getservbyport
      (Port  : C.int;
-      Proto : C.char_array)
-      return Servent_Access;
+      Proto : C.char_array) return Servent_Access;
 
    function C_Getsockname
      (S       : C.int;
       Name    : System.Address;
-      Namelen : access C.int)
-      return    C.int;
+      Namelen : access C.int) return C.int;
 
    function C_Getsockopt
      (S       : C.int;
       Level   : C.int;
       Optname : C.int;
       Optval  : System.Address;
-      Optlen  : access C.int)
-      return    C.int;
+      Optlen  : access C.int) return C.int;
 
    function C_Inet_Addr
-     (Cp   : C.Strings.chars_ptr)
-      return C.int;
+     (Cp : C.Strings.chars_ptr) return C.int;
 
    function C_Ioctl
-     (S    : C.int;
-      Req  : C.int;
-      Arg  : Int_Access)
-      return C.int;
+     (S   : C.int;
+      Req : C.int;
+      Arg : Int_Access) return C.int;
 
    function C_Listen (S, Backlog : C.int) return C.int;
 
    function C_Readv
      (Fd     : C.int;
       Iov    : System.Address;
-      Iovcnt : C.int)
-      return   C.int;
+      Iovcnt : C.int) return C.int;
 
    function C_Recv
      (S     : C.int;
       Msg   : System.Address;
       Len   : C.int;
-      Flags : C.int)
-      return  C.int;
+      Flags : C.int) return C.int;
 
    function C_Recvfrom
      (S       : C.int;
@@ -294,23 +291,20 @@ package GNAT.Sockets.Thin is
       Len     : C.int;
       Flags   : C.int;
       From    : Sockaddr_In_Access;
-      Fromlen : access C.int)
-      return    C.int;
+      Fromlen : access C.int) return C.int;
 
    function C_Select
      (Nfds      : C.int;
       Readfds   : Fd_Set_Access;
       Writefds  : Fd_Set_Access;
       Exceptfds : Fd_Set_Access;
-      Timeout   : Timeval_Access)
-      return      C.int;
+      Timeout   : Timeval_Access) return C.int;
 
    function C_Send
      (S     : C.int;
       Msg   : System.Address;
       Len   : C.int;
-      Flags : C.int)
-      return  C.int;
+      Flags : C.int) return C.int;
 
    function C_Sendto
      (S     : C.int;
@@ -318,44 +312,37 @@ package GNAT.Sockets.Thin is
       Len   : C.int;
       Flags : C.int;
       To    : Sockaddr_In_Access;
-      Tolen : C.int)
-      return  C.int;
+      Tolen : C.int) return C.int;
 
    function C_Setsockopt
      (S       : C.int;
       Level   : C.int;
       Optname : C.int;
       Optval  : System.Address;
-      Optlen  : C.int)
-      return    C.int;
+      Optlen  : C.int) return C.int;
 
    function C_Shutdown
-     (S    : C.int;
-      How  : C.int)
-      return C.int;
+     (S   : C.int;
+      How : C.int) return C.int;
 
    function C_Socket
      (Domain   : C.int;
       Typ      : C.int;
-      Protocol : C.int)
-      return     C.int;
+      Protocol : C.int) return C.int;
 
    function C_Strerror
-     (Errnum : C.int)
-      return   C.Strings.chars_ptr;
+     (Errnum : C.int) return C.Strings.chars_ptr;
 
    function C_System
-     (Command : System.Address)
-      return    C.int;
+     (Command : System.Address) return C.int;
 
    function C_Writev
      (Fd     : C.int;
       Iov    : System.Address;
-      Iovcnt : C.int)
-      return   C.int;
+      Iovcnt : C.int) return C.int;
 
    procedure Free_Socket_Set
-     (Set    : Fd_Set_Access);
+     (Set : Fd_Set_Access);
    --  Free system-dependent socket set
 
    procedure Get_Socket_From_Set
@@ -389,8 +376,7 @@ package GNAT.Sockets.Thin is
    --  set back to the real largest socket in the socket set.
 
    function  New_Socket_Set
-     (Set    : Fd_Set_Access)
-     return   Fd_Set_Access;
+     (Set : Fd_Set_Access) return Fd_Set_Access;
    --  Allocate a new socket set which is a system-dependent structure
    --  and initialize by copying Set if it is non-null, by making it
    --  empty otherwise.
index 10a9a2160e5f2ab8bf02ea816fa9bf94a5af39a2..5d06d99bcae09e9ed31355c297988a4f1f6018fe 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 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 --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -65,15 +65,28 @@ package GNAT.Sockets.Thin is
    --  Returns the error message string for the error number Errno. If Errno is
    --  not known it returns "Unknown system error".
 
+   function Host_Errno return Integer;
+   pragma Import (C, Host_Errno, "__gnat_get_h_errno");
+   --  Returns last host error number
+
    subtype Fd_Set_Access is System.Address;
    No_Fd_Set : constant Fd_Set_Access := System.Null_Address;
 
-   type Timeval_Unit is new C.int;
-   pragma Convention (C, Timeval_Unit);
+   type time_t is
+     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
-      Tv_Sec  : Timeval_Unit;
-      Tv_Usec : Timeval_Unit;
+      Tv_Sec  : time_t;
+      Tv_Usec : suseconds_t;
    end record;
    pragma Convention (C, Timeval);
 
index 363416a674ffaa54aa51530f9d4b9880f5f609bf..e8284335bcf2519d7120f9559c13c7c85523299b 100644 (file)
@@ -4,7 +4,7 @@
  *                                                                          *
  *                           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 *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -25,7 +25,7 @@
 /* This program generates g-soccon.ads */
 
 /* To build using DEC C:
-  CC/DEFINE="TARGET=OpenVMS" gen-soccon
+  CC/DEFINE="TARGET=""OpenVMS""" gen-soccon
   LINK gen-soccon
   RUN gen-soccon
 */
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include <limits.h>
+
+#ifdef __MINGW32__
+#include <fcntl.h>
+#endif
 
 #include "gsocket.h"
 
@@ -55,8 +60,8 @@ struct line *first = NULL, *last = NULL;
 #define _NL TXT("")
 /* Empty line */
 
-#define itoad(n) f_itoa ("%d", n)
-#define itoax(n) f_itoa ("16#%08x#", n)
+#define itoad(n) f_itoa ("%d", (n))
+#define itoax(n) f_itoa ("16#%08x#", (n))
 
 #define CND(name,comment) add_line(#name, itoad (name), comment);
 /* Constant (decimal) */
@@ -78,6 +83,10 @@ char *f_itoa (char *, int);
 
 void add_line (char *, char*, char*);
 
+#ifdef __MINGW32__
+unsigned int _CRT_fmode = _O_BINARY;
+#endif
+
 int
 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
 TXT("--                                                                          --")
 TXT("--                                 S p e c                                  --")
 TXT("--                                                                          --")
-TXT("--          Copyright (C) 2000-2005 Free Software Foundation, Inc.          --")
+TXT("--          Copyright (C) 2000-2005, Free Software Foundation, Inc.         --")
 TXT("--                                                                          --")
 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- --")
@@ -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("--  directly with'ed by an applications program.")
 _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("--  make changes to gen-soccon.c and re-run it on each target.")
 _NL
@@ -564,6 +573,36 @@ _NL
 #endif
 CND(IOV_MAX, "Maximum writev iovcnt")
 
+_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;")
 
@@ -614,6 +653,7 @@ f_itoa (char *fmt, int n) {
 void
 add_line (char *_text, char *_value, char *_comment) {
   struct line *l = (struct line *) malloc (sizeof (struct line));
+
   l->text = _text;
   l->value = _value;
   l->comment = _comment;
index f593acfaed46e6e9d6a87768280992f33d4b6a29..a380788995a305149e316fa15eff1b9de896317a 100644 (file)
@@ -55,6 +55,8 @@
 #if defined(__vxworks)
 #include <vxWorks.h>
 #include <ioLib.h>
+#include <hostLib.h>
+#include <resolvLib.h>
 #define SHUT_RD                0
 #define SHUT_WR                1
 #define SHUT_RDWR      2
 #include <errno.h>
 #endif
 
-#ifndef __vxworks
+#ifdef __vxworks
+#include <sys/times.h>
+#else
 #include <sys/time.h>
 #endif
 
index 32135237b5ab8a369500221f081d624116704741..d02763a9548ca04b4fa4896f2a32ffc085ff5039 100644 (file)
@@ -40,6 +40,7 @@
 /* Required for __gnat_malloc() */
 
 #include <string.h>
+/* Required for memcpy() */
 
 extern void __gnat_disable_sigpipe (int fd);
 extern void __gnat_free_socket_set (fd_set *);
@@ -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 fd_set *__gnat_new_socket_set (fd_set *);
 extern void __gnat_remove_socket_from_set (fd_set *, int);
+extern int __gnat_get_h_errno (void);
 \f
 /* Disable the sending of SIGPIPE for writes on a broken stream */
+
 void
 __gnat_disable_sigpipe (int fd)
 {
@@ -152,3 +155,41 @@ __gnat_remove_socket_from_set (fd_set *set, int socket)
 {
   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
+}