Commit 82675755 by Thomas Quinot Committed by Arnaud Charlet

g-soccon-vms.adb: Renamed to g-soccon-vms.ads

2005-09-01  Thomas Quinot  <quinot@adacore.com>

	* g-soccon-vms.adb: Renamed to g-soccon-vms.ads

	* g-soccon-vms.ads: Renamed from g-soccon-vms.adb

	* g-soccon.ads, g-soccon-tru64.ads, g-soccon-aix.ads,
	g-soccon-darwin.ads, g-soccon-irix.ads, g-soccon-hpux.ads,
	g-soccon-solaris.ads, g-soccon-mingw.ads, g-soccon-vxworks.ads,
	g-soccon-freebsd.ads: Add new constants:
	 IP_MULTICAST_IF
	 SO_RCVTIMEO/SO_SNDTIMEO
	 IOV_MAX

	* gen-soccon.c:
	Move all target-specific file inclusions and macro definitions to
	gsocket.h, in order to ensure that any C code in socket.c will see a
	set of constants that is consistent with the contents of g-soccon.ads.

	* gsocket.h: Code imported from gen-soccon.c:
	Move all target-specific file inclusions and macro definitions to
	gsocket.h, in order to ensure that any C code in socket.c will see a set
	of constants that is consistent with the contents of g-soccon.ads.
	This change also makes gen-soccon self-contained (removing dependencies
	upon GCC internal headers).

	* g-socket.adb (Send_Vector): Make calls to Writev at most IOV_MAX
	iovecs at a time.
	(To_Inet_Addr): Now a procedure instead of a function, more efficient.

	* socket.c: Minor reformatting.

From-SVN: r103853
parent b9260c3d
......@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
-- Copyright (C) 2000-2004 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- --
......@@ -148,16 +148,25 @@ package GNAT.Sockets.Constants is
--------------------
TCP_NODELAY : constant := 1; -- Do not coalesce packets
SO_SNDBUF : constant := 4097; -- Set/get send buffer size
SO_RCVBUF : constant := 4098; -- Set/get recv buffer size
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_ERROR : constant := 4103; -- Get/clear error status
SO_BROADCAST : constant := 32; -- Can send broadcast msgs
IP_ADD_MEMBERSHIP : constant := 12; -- Join a multicast group
IP_DROP_MEMBERSHIP : constant := 13; -- Leave a multicast group
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 := 9; -- Set/get mcast interface
IP_MULTICAST_TTL : constant := 10; -- Set/get multicast TTL
IP_MULTICAST_LOOP : constant := 11; -- Set/get mcast loopback
IP_ADD_MEMBERSHIP : constant := 12; -- Join a multicast group
IP_DROP_MEMBERSHIP : constant := 13; -- Leave a multicast group
-------------------
-- System limits --
-------------------
IOV_MAX : constant := 2147483647; -- Maximum writev iovcnt
end GNAT.Sockets.Constants;
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . S O C K E T S . C O N S T A N T S --
-- --
-- B o d y --
-- --
-- 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 Alpha/VMS
package GNAT.Sockets.Constants is
--------------
-- Families --
--------------
AF_INET : constant := 2; -- IPv4 address family
AF_INET6 : constant := 26; -- 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 := 48; -- Address already in use
EADDRNOTAVAIL : constant := 49; -- Cannot assign address
EAFNOSUPPORT : constant := 47; -- Addr family not supported
EALREADY : constant := 37; -- Operation in progress
EBADF : constant := 9; -- Bad file descriptor
ECONNABORTED : constant := 53; -- Connection aborted
ECONNREFUSED : constant := 61; -- Connection refused
ECONNRESET : constant := 54; -- Connection reset by peer
EDESTADDRREQ : constant := 39; -- Destination addr required
EFAULT : constant := 45; -- Bad address
EHOSTDOWN : constant := 64; -- Host is down
EHOSTUNREACH : constant := 65; -- No route to host
EINPROGRESS : constant := 36; -- Operation now in progress
EINTR : constant := 4; -- Interrupted system call
EINVAL : constant := 22; -- Invalid argument
EIO : constant := 5; -- Input output error
EISCONN : constant := 56; -- Socket already connected
ELOOP : constant := 62; -- Too many symbolic lynks
EMFILE : constant := 24; -- Too many open files
EMSGSIZE : constant := 40; -- Message too long
ENAMETOOLONG : constant := 63; -- Name too long
ENETDOWN : constant := 50; -- Network is down
ENETRESET : constant := 52; -- Disconn. on network reset
ENETUNREACH : constant := 51; -- Network is unreachable
ENOBUFS : constant := 55; -- No buffer space available
ENOPROTOOPT : constant := 42; -- Protocol not available
ENOTCONN : constant := 57; -- Socket not connected
ENOTSOCK : constant := 38; -- Operation on non socket
EOPNOTSUPP : constant := 95; -- Operation not supported
EPFNOSUPPORT : constant := 46; -- Unknown protocol family
EPROTONOSUPPORT : constant := 43; -- Unknown protocol
EPROTOTYPE : constant := 41; -- Unknown protocol type
ESHUTDOWN : constant := 58; -- Cannot send once shutdown
ESOCKTNOSUPPORT : constant := 44; -- Socket type not supported
ETIMEDOUT : constant := 60; -- Connection timed out
ETOOMANYREFS : constant := 59; -- Too many references
EWOULDBLOCK : constant := 35; -- 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 := 16#FFFF#; -- 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;
--------------------
-- Socket options --
--------------------
TCP_NODELAY : constant := 1; -- Do not coalesce packets
SO_SNDBUF : constant := 16#1001#; -- Set/get send buffer size
SO_RCVBUF : constant := 16#1002#; -- Set/get recv buffer size
SO_REUSEADDR : constant := 16#0004#; -- Bind reuse local address
SO_KEEPALIVE : constant := 16#0008#; -- Enable keep-alive msgs
SO_LINGER : constant := 16#0080#; -- Defer close to flush data
SO_ERROR : constant := 16#1007#; -- Get/clear error status
SO_BROADCAST : constant := 16#0020#; -- Can send broadcast msgs
IP_ADD_MEMBERSHIP : constant := 12; -- Join a multicast group
IP_DROP_MEMBERSHIP : constant := 13; -- Leave a multicast group
IP_MULTICAST_TTL : constant := 10; -- Set/get multicast TTL
IP_MULTICAST_LOOP : constant := 11; -- Set/get mcast loopback
end GNAT.Sockets.Constants;
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . S O C K E T S . C O N S T A N T S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2000-2005 Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package provides target dependent definitions of constant for use
-- by the GNAT.Sockets package (g-socket.ads). This package should not be
-- directly with'ed by an applications program.
-- This is the version for OpenVMS
-- 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 := 1; -- Stream socket
SOCK_DGRAM : constant := 2; -- Datagram socket
-------------------
-- Socket errors --
-------------------
EACCES : constant := 13; -- Permission denied
EADDRINUSE : constant := 48; -- Address already in use
EADDRNOTAVAIL : constant := 49; -- Cannot assign address
EAFNOSUPPORT : constant := 47; -- Addr family not supported
EALREADY : constant := 37; -- Operation in progress
EBADF : constant := 9; -- Bad file descriptor
ECONNABORTED : constant := 53; -- Connection aborted
ECONNREFUSED : constant := 61; -- Connection refused
ECONNRESET : constant := 54; -- Connection reset by peer
EDESTADDRREQ : constant := 39; -- Destination addr required
EFAULT : constant := 14; -- Bad address
EHOSTDOWN : constant := 64; -- Host is down
EHOSTUNREACH : constant := 65; -- No route to host
EINPROGRESS : constant := 36; -- Operation now in progress
EINTR : constant := 4; -- Interrupted system call
EINVAL : constant := 22; -- Invalid argument
EIO : constant := 5; -- Input output error
EISCONN : constant := 56; -- Socket already connected
ELOOP : constant := 62; -- Too many symbolic lynks
EMFILE : constant := 24; -- Too many open files
EMSGSIZE : constant := 40; -- Message too long
ENAMETOOLONG : constant := 63; -- Name too long
ENETDOWN : constant := 50; -- Network is down
ENETRESET : constant := 52; -- Disconn. on network reset
ENETUNREACH : constant := 51; -- Network is unreachable
ENOBUFS : constant := 55; -- No buffer space available
ENOPROTOOPT : constant := 42; -- Protocol not available
ENOTCONN : constant := 57; -- Socket not connected
ENOTSOCK : constant := 38; -- Operation on non socket
EOPNOTSUPP : constant := 45; -- Operation not supported
EPFNOSUPPORT : constant := 46; -- Unknown protocol family
EPROTONOSUPPORT : constant := 43; -- Unknown protocol
EPROTOTYPE : constant := 41; -- Unknown protocol type
ESHUTDOWN : constant := 58; -- Cannot send once shutdown
ESOCKTNOSUPPORT : constant := 44; -- Socket type not supported
ETIMEDOUT : constant := 60; -- Connection timed out
ETOOMANYREFS : constant := 59; -- Too many references
EWOULDBLOCK : constant := 35; -- 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 := 9; -- Set/get mcast interface
IP_MULTICAST_TTL : constant := 10; -- Set/get multicast TTL
IP_MULTICAST_LOOP : constant := 11; -- Set/get mcast loopback
IP_ADD_MEMBERSHIP : constant := 12; -- Join a multicast group
IP_DROP_MEMBERSHIP : constant := 13; -- Leave a multicast group
-------------------
-- System limits --
-------------------
IOV_MAX : constant := 1024; -- Maximum writev iovcnt
end GNAT.Sockets.Constants;
......@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
-- Copyright (C) 2000-2004 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,8 +35,9 @@
-- 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 GNU/Linux
-- Do not edit this file by hand, instead edit and re-run gen-soccon.c
-- 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
......@@ -140,22 +141,32 @@ package GNAT.Sockets.Constants is
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_SNDBUF : constant := 7; -- Set/get send buffer size
SO_RCVBUF : constant := 8; -- Set/get recv buffer size
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_ERROR : constant := 4; -- Get/clear error status
SO_BROADCAST : constant := 6; -- Can send broadcast msgs
IP_ADD_MEMBERSHIP : constant := 35; -- Join a multicast group
IP_DROP_MEMBERSHIP : constant := 36; -- Leave a multicast group
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
end GNAT.Sockets.Constants;
......@@ -149,7 +149,9 @@ package body GNAT.Sockets is
-- Return true when Name is an IP address in standard dot notation
function To_In_Addr (Addr : Inet_Addr_Type) return Thin.In_Addr;
function To_Inet_Addr (Addr : In_Addr) return Inet_Addr_Type;
procedure To_Inet_Addr
(Addr : In_Addr;
Result : out Inet_Addr_Type);
-- Conversion functions
function To_Host_Entry (E : Hostent) return Host_Entry_Type;
......@@ -258,7 +260,7 @@ package body GNAT.Sockets is
Socket := Socket_Type (Res);
Address.Addr := To_Inet_Addr (Sin.Sin_Addr);
To_Inet_Addr (Sin.Sin_Addr, Address.Addr);
Address.Port := Port_Type (Network_To_Short (Sin.Sin_Port));
end Accept_Socket;
......@@ -911,7 +913,7 @@ package body GNAT.Sockets is
Raise_Socket_Error (Socket_Errno);
end if;
Res.Addr := To_Inet_Addr (Sin.Sin_Addr);
To_Inet_Addr (Sin.Sin_Addr, Res.Addr);
Res.Port := Port_Type (Network_To_Short (Sin.Sin_Port));
return Res;
......@@ -1004,7 +1006,7 @@ package body GNAT.Sockets is
begin
Res := C_Getsockname (C.int (Socket), Sin'Address, Len'Access);
if Res /= Failure then
Addr.Addr := To_Inet_Addr (Sin.Sin_Addr);
To_Inet_Addr (Sin.Sin_Addr, Addr.Addr);
Addr.Port := Port_Type (Network_To_Short (Sin.Sin_Port));
end if;
......@@ -1086,8 +1088,8 @@ package body GNAT.Sockets is
when Add_Membership |
Drop_Membership =>
Opt.Multicast_Address := To_Inet_Addr (To_In_Addr (V8 (V8'First)));
Opt.Local_Interface := To_Inet_Addr (To_In_Addr (V8 (V8'Last)));
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_TTL =>
Opt.Time_To_Live := Integer (V1);
......@@ -1226,8 +1228,9 @@ package body GNAT.Sockets is
function Inet_Addr (Image : String) return Inet_Addr_Type is
use Interfaces.C.Strings;
Img : chars_ptr;
Res : C.int;
Img : chars_ptr;
Res : C.int;
Result : Inet_Addr_Type;
begin
-- Special case for the all-ones broadcast address: this address
......@@ -1252,7 +1255,8 @@ package body GNAT.Sockets is
Raise_Socket_Error (Constants.EINVAL);
end if;
return To_Inet_Addr (To_In_Addr (Res));
To_Inet_Addr (To_In_Addr (Res), Result);
return Result;
end Inet_Addr;
----------------
......@@ -1551,7 +1555,7 @@ package body GNAT.Sockets is
Last := Item'First + Ada.Streams.Stream_Element_Offset (Res - 1);
From.Addr := To_Inet_Addr (Sin.Sin_Addr);
To_Inet_Addr (Sin.Sin_Addr, From.Addr);
From.Port := Port_Type (Network_To_Short (Sin.Sin_Port));
end Receive_Socket;
......@@ -1772,20 +1776,39 @@ package body GNAT.Sockets is
Vector : Vector_Type;
Count : out Ada.Streams.Stream_Element_Count)
is
Res : C.int;
Res : C.int;
Iov_Count : C.int;
This_Iov_Count : C.int;
begin
Res :=
C_Writev
(C.int (Socket),
Vector (Vector'First)'Address,
Vector'Length);
Count := 0;
Iov_Count := 0;
while Iov_Count < Vector'Length loop
if Res = Failure then
Raise_Socket_Error (Socket_Errno);
end if;
pragma Warnings (Off);
-- Following test may be compile time known on some targets
Count := Ada.Streams.Stream_Element_Count (Res);
if Vector'Length - Iov_Count > Constants.IOV_MAX then
This_Iov_Count := Constants.IOV_MAX;
else
This_Iov_Count := Vector'Length - Iov_Count;
end if;
pragma Warnings (On);
Res :=
C_Writev
(C.int (Socket),
Vector (Vector'First + Integer (Iov_Count))'Address,
This_Iov_Count);
if Res = Failure then
Raise_Socket_Error (Socket_Errno);
end if;
Count := Count + Ada.Streams.Stream_Element_Count (Res);
Iov_Count := Iov_Count + This_Iov_Count;
end loop;
end Send_Vector;
---------
......@@ -2022,8 +2045,7 @@ package body GNAT.Sockets is
Source := Addresses'First;
Target := Result.Addresses'First;
while Target <= Result.Addresses_Length loop
Result.Addresses (Target) :=
To_Inet_Addr (Addresses (Source).all);
To_Inet_Addr (Addresses (Source).all, Result.Addresses (Target));
Source := Source + 1;
Target := Target + 1;
end loop;
......@@ -2051,16 +2073,14 @@ package body GNAT.Sockets is
-- To_Inet_Addr --
------------------
function To_Inet_Addr
(Addr : In_Addr) return Inet_Addr_Type
is
Result : Inet_Addr_Type;
procedure To_Inet_Addr
(Addr : In_Addr;
Result : out Inet_Addr_Type) is
begin
Result.Sin_V4 (1) := Inet_Addr_Comp_Type (Addr.S_B1);
Result.Sin_V4 (2) := Inet_Addr_Comp_Type (Addr.S_B2);
Result.Sin_V4 (3) := Inet_Addr_Comp_Type (Addr.S_B3);
Result.Sin_V4 (4) := Inet_Addr_Comp_Type (Addr.S_B4);
return Result;
end To_Inet_Addr;
------------
......
......@@ -24,20 +24,22 @@
/* This program generates g-soccon.ads */
/* To build using DEC C:
CC/DEFINE="TARGET=OpenVMS" gen-soccon
LINK gen-soccon
RUN gen-soccon
*/
#ifndef TARGET
# error Please define TARGET
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "gsocket.h"
#ifdef __MINGW32__
#include <winsock2.h>
#else
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <sys/ioctl.h>
#include <netdb.h>
#endif
struct line {
char *text;
char *value;
......@@ -65,6 +67,9 @@ struct line *first = NULL, *last = NULL;
#define CN_(name,comment) add_line(#name, name, comment);
/* Constant (generic) */
#define STR(p) STR1(p)
#define STR1(p) #p
void output (void);
/* Generate output spec */
......@@ -113,7 +118,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 " TARGET)
TXT("-- This is the version for " STR (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
......@@ -377,12 +382,12 @@ _NL
#ifndef FIONBIO
#define FIONBIO -1
#endif
CNX(FIONBIO, "Set/clear non-blocking io")
CND(FIONBIO, "Set/clear non-blocking io")
#ifndef FIONREAD
#define FIONREAD -1
#endif
CNX(FIONREAD, "How many bytes to read")
CND(FIONREAD, "How many bytes to read")
_NL
TXT(" --------------------")
TXT(" -- Shutdown modes --")
......@@ -549,6 +554,17 @@ CND(IP_ADD_MEMBERSHIP, "Join a multicast group")
CND(IP_DROP_MEMBERSHIP, "Leave a multicast group")
_NL
TXT(" -------------------")
TXT(" -- System limits --")
TXT(" -------------------")
_NL
#ifndef IOV_MAX
#define IOV_MAX INT_MAX
#endif
CND(IOV_MAX, "Maximum writev iovcnt")
_NL
TXT("end GNAT.Sockets.Constants;")
output ();
......@@ -587,9 +603,12 @@ output (void) {
char *
f_itoa (char *fmt, int n) {
char buf[32];
char buf[32], *ret;
sprintf (buf, fmt, n);
return strdup (buf);
ret = malloc (strlen (buf) + 1);
if (ret != NULL)
strcpy (ret, buf);
return ret;
}
void
......
......@@ -2,7 +2,7 @@
* *
* GNAT COMPILER COMPONENTS *
* *
* S O C K E T *
* G S O C K E T *
* *
* C Header File *
* *
......@@ -30,38 +30,115 @@
* *
****************************************************************************/
#ifdef __vxworks
#include "vxWorks.h"
#ifndef _XOPEN_SOURCE_EXTENDED
#define _XOPEN_SOURCE_EXTENDED 1
/* For HP-UX */
#endif
#ifdef IN_RTS
#include "tconfig.h"
#include "tsystem.h"
#ifndef BSD_COMP
#define BSD_COMP 1
/* For Solaris */
#endif
#ifndef _ALL_SOURCE
#define _ALL_SOURCE 1
/* For AIX */
#endif
#ifndef _OSF_SOURCE
#define _OSF_SOURCE 1
/* For Tru64 */
#endif
#include <limits.h>
#if defined (WINNT)
#if defined(__vxworks)
#include <vxWorks.h>
#include <ioLib.h>
#define SHUT_RD 0
#define SHUT_WR 1
#define SHUT_RDWR 2
#elif defined (WINNT)
#define FD_SETSIZE 1024
#include <windows.h>
#ifdef __MINGW32__
#include "mingw32.h"
#if STD_MINGW
#include <winsock.h>
#else
#include <windows32/sockets.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#define EACCES WSAEACCES
#define EADDRINUSE WSAEADDRINUSE
#define EADDRNOTAVAIL WSAEADDRNOTAVAIL
#define EAFNOSUPPORT WSAEAFNOSUPPORT
#define EALREADY WSAEALREADY
#define EBADF WSAEBADF
#define ECONNABORTED WSAECONNABORTED
#define ECONNREFUSED WSAECONNREFUSED
#define ECONNRESET WSAECONNRESET
#define EDESTADDRREQ WSAEDESTADDRREQ
#define EFAULT WSAEFAULT
#define EHOSTDOWN WSAEHOSTDOWN
#define EHOSTUNREACH WSAEHOSTUNREACH
#define EINPROGRESS WSAEINPROGRESS
#define EINTR WSAEINTR
#define EINVAL WSAEINVAL
#define EIO WSAEDISCON
#define EISCONN WSAEISCONN
#define ELOOP WSAELOOP
#define EMFILE WSAEMFILE
#define EMSGSIZE WSAEMSGSIZE
#define ENAMETOOLONG WSAENAMETOOLONG
#define ENETDOWN WSAENETDOWN
#define ENETRESET WSAENETRESET
#define ENETUNREACH WSAENETUNREACH
#define ENOBUFS WSAENOBUFS
#define ENOPROTOOPT WSAENOPROTOOPT
#define ENOTCONN WSAENOTCONN
#define ENOTSOCK WSAENOTSOCK
#define EOPNOTSUPP WSAEOPNOTSUPP
#define EPFNOSUPPORT WSAEPFNOSUPPORT
#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
#define ENOTSOCK WSAENOTSOCK
#define EOPNOTSUPP WSAEOPNOTSUPP
#define EPFNOSUPPORT WSAEPFNOSUPPORT
#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
#define EPROTOTYPE WSAEPROTOTYPE
#define ESHUTDOWN WSAESHUTDOWN
#define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
#define ETIMEDOUT WSAETIMEDOUT
#define ETOOMANYREFS WSAETOOMANYREFS
#define EWOULDBLOCK WSAEWOULDBLOCK
#define SHUT_RD SD_RECEIVE
#define SHUT_WR SD_SEND
#define SHUT_RDWR SD_BOTH
#endif
#elif defined(VMS)
#define FD_SETSIZE 4096
#ifndef IN_RTS
/* These DEC C headers are not available when building with GCC */
#include <in.h>
#include <tcp.h>
#include <ioctl.h>
#include <netdb.h>
#endif
#endif
#if defined (VMS)
#define FD_SETSIZE 4096
#include <sys/time.h>
#ifndef __MINGW32__
#include <errno.h>
#endif
#else
#include "config.h"
#include "system.h"
#ifndef __vxworks
#include <sys/time.h>
#endif
#if !(defined (VMS) || defined (__MINGW32__) || defined(__rtems__))
# include <sys/socket.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <sys/ioctl.h>
#include <netdb.h>
#endif
......@@ -33,7 +33,11 @@
/* This file provides a portable binding to the sockets API */
#include "gsocket.h"
/* Include all the necessary system-specific headers and define the
necessary macros (shared with gen-soccon). */
#include "raise.h"
/* Required for __gnat_malloc() */
extern void __gnat_disable_sigpipe (int fd);
extern void __gnat_free_socket_set (fd_set *);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment