summaryrefslogtreecommitdiff
path: root/gcc/ada/g-socthi.ads
diff options
context:
space:
mode:
authorThomas Quinot <quinot@adacore.com>2007-04-06 11:15:09 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2007-04-06 11:15:09 +0200
commit3d3bf932b985baee7ac3973208c0d775dcb93b5d (patch)
treed2a9f2de1b4f8ce5a655a929362077213fa220da /gcc/ada/g-socthi.ads
parentbaa3441ddf0daabf8b0127a577121348906aa8b6 (diff)
downloadgcc-3d3bf932b985baee7ac3973208c0d775dcb93b5d.tar.gz
g-stsifd-sockets.adb: New file.
2007-04-06 Thomas Quinot <quinot@adacore.com> Pat Rogers <rogers@adacore.com> Pascal Obry <obry@adacore.com> * g-stsifd-sockets.adb: New file. * g-socthi.ads, g-socket.adb, g-socthi-vxworks.adb, g-socthi-vxworks.ads, g-socthi-mingw.ads, g-socthi-vms.ads, g-socthi-vms.adb: Move signalling fd management to a nested package, so that they can conveniently be moved to a subunit that is shared across Windows, VMS, and VxWorks (Ada implementation) or completed with imported bodies from socket.c (UNIX case). (Read_Signalling_Fd, Write_Signalling_Fd, Create_Signalling_Fds): New subprograms. (Check_Selector): Use Read_Signalling_Fd to read and discard data from the signalling file descriptor. (Abort_Selector): Use Write_Signalling_Fd to write dummy data to the signalling file descriptor. (Create_Selector): Use new C-imported subprogram Create_Signalling_Fds instead of creating a pair of sockets for signalling here. * g-socthi.adb: Ditto. Set the runtime process to ignore SIGPIPEs on platforms that support neither SO_NOSIGPIPE nor MSG_NOSIGNAL functionality. * g-socthi-mingw.adb: Ditto. (WS_Version): Use Windows 2.2. Use Winsock 2.2 (instead of 1.1) for the GNAT.Socket API. * g-soliop-mingw.ads: Link with ws2_32 for Windows 2.x support. Use Winsock 2.2 (instead of 1.1) for the GNAT.Socket API. * Makefile.in: New libgnat pair g-stsifd.adb<g-stsifd-sockets.adb. added GNAT byte swapping facility Update FreeBSD THREADSLIB from -lc_r to -lpthread, for FreeBSD 6. * g-bytswa.adb, g-bytswa-x86.adb, g-bytswa.ads: New files. * socket.c (__gnat_read_signalling_fd, __gnat_write_controlling_fd): New subprograms. (__gnat_create_signalling_fds): New subprogram. Set the runtime process to ignore SIGPIPEs on platforms that support neither SO_NOSIGPIPE nor MSG_NOSIGNAL functionality. From-SVN: r123542
Diffstat (limited to 'gcc/ada/g-socthi.ads')
-rw-r--r--gcc/ada/g-socthi.ads49
1 files changed, 40 insertions, 9 deletions
diff --git a/gcc/ada/g-socthi.ads b/gcc/ada/g-socthi.ads
index 5d06d99bcae..ce3f7586f1b 100644
--- a/gcc/ada/g-socthi.ads
+++ b/gcc/ada/g-socthi.ads
@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
--- Copyright (C) 2001-2005, AdaCore --
+-- Copyright (C) 2001-2006, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -39,6 +39,7 @@
with Interfaces.C.Pointers;
with Interfaces.C.Strings;
+
with GNAT.Sockets.Constants;
with GNAT.OS_Lib;
@@ -204,14 +205,24 @@ package GNAT.Sockets.Thin is
pragma Convention (C, Servent_Access);
-- Access to service entry
- type Two_Int is array (0 .. 1) of C.int;
- pragma Convention (C, Two_Int);
- -- Used with pipe()
+ type Two_Ints is array (0 .. 1) of C.int;
+ pragma Convention (C, Two_Ints);
+ -- Container for two int values
+
+ subtype Fd_Pair is Two_Ints;
+ -- Two_Ints as used for Create_Signalling_Fds: a pair of connected file
+ -- descriptors, one of which (the "read end" of the connection) being used
+ -- for reading, the other one (the "write end") being used for writing.
+
+ Read_End : constant := 0;
+ Write_End : constant := 1;
+ -- Indices into an Fd_Pair value providing access to each of the connected
+ -- file descriptors.
function C_Accept
(S : C.int;
Addr : System.Address;
- Addrlen : access C.int) return C.int;
+ Addrlen : not null access C.int) return C.int;
function C_Bind
(S : C.int;
@@ -241,7 +252,7 @@ package GNAT.Sockets.Thin is
function C_Getpeername
(S : C.int;
Name : System.Address;
- Namelen : access C.int) return C.int;
+ Namelen : not null access C.int) return C.int;
function C_Getservbyname
(Name : C.char_array;
@@ -254,14 +265,14 @@ package GNAT.Sockets.Thin is
function C_Getsockname
(S : C.int;
Name : System.Address;
- Namelen : access C.int) return C.int;
+ Namelen : not null access C.int) return C.int;
function C_Getsockopt
(S : C.int;
Level : C.int;
Optname : C.int;
Optval : System.Address;
- Optlen : access C.int) return C.int;
+ Optlen : not null access C.int) return C.int;
function C_Inet_Addr
(Cp : C.Strings.chars_ptr) return C.int;
@@ -292,7 +303,7 @@ package GNAT.Sockets.Thin is
Len : C.int;
Flags : C.int;
From : Sockaddr_In_Access;
- Fromlen : access C.int) return C.int;
+ Fromlen : not null access C.int) return C.int;
function C_Select
(Nfds : C.int;
@@ -342,6 +353,25 @@ package GNAT.Sockets.Thin is
Iov : System.Address;
Iovcnt : C.int) return C.int;
+ package Signalling_Fds is
+
+ function Create (Fds : not null access Fd_Pair) return C.int;
+ pragma Convention (C, Create);
+ -- Create a pair of connected descriptors suitable for use with C_Select
+ -- (used for signalling in Selector objects).
+
+ function Read (Rsig : C.int) return C.int;
+ pragma Convention (C, Read);
+ -- Read one byte of data from rsig, the read end of a pair of signalling
+ -- fds created by Create_Signalling_Fds.
+
+ function Write (Wsig : C.int) return C.int;
+ pragma Convention (C, Write);
+ -- Write one byte of data to wsig, the write end of a pair of signalling
+ -- fds created by Create_Signalling_Fds.
+
+ end Signalling_Fds;
+
procedure Free_Socket_Set
(Set : Fd_Set_Access);
-- Free system-dependent socket set
@@ -418,4 +448,5 @@ private
pragma Import (C, New_Socket_Set, "__gnat_new_socket_set");
pragma Import (C, Insert_Socket_In_Set, "__gnat_insert_socket_in_set");
pragma Import (C, Remove_Socket_From_Set, "__gnat_remove_socket_from_set");
+
end GNAT.Sockets.Thin;