summaryrefslogtreecommitdiff
path: root/gcc/ada/g-socthi.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2007-04-06 09:15:09 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2007-04-06 09:15:09 +0000
commit232e4d04f0263022b1379a7886e28e7f082f7eb8 (patch)
treed2a9f2de1b4f8ce5a655a929362077213fa220da /gcc/ada/g-socthi.adb
parent32c07c22100b9a6f342e6a5825ac36b1b72d036b (diff)
downloadgcc-232e4d04f0263022b1379a7886e28e7f082f7eb8.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@123542 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/g-socthi.adb')
-rw-r--r--gcc/ada/g-socthi.adb42
1 files changed, 37 insertions, 5 deletions
diff --git a/gcc/ada/g-socthi.adb b/gcc/ada/g-socthi.adb
index 914b787a41c..7ca1c1cdfdf 100644
--- a/gcc/ada/g-socthi.adb
+++ b/gcc/ada/g-socthi.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- 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- --
@@ -71,7 +71,7 @@ package body GNAT.Sockets.Thin is
function Syscall_Accept
(S : C.int;
Addr : System.Address;
- Addrlen : access C.int) return C.int;
+ Addrlen : not null access C.int) return C.int;
pragma Import (C, Syscall_Accept, "accept");
function Syscall_Connect
@@ -99,7 +99,7 @@ package body 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;
pragma Import (C, Syscall_Recvfrom, "recvfrom");
function Syscall_Send
@@ -127,6 +127,11 @@ package body GNAT.Sockets.Thin is
procedure Disable_SIGPIPE (S : C.int);
pragma Import (C, Disable_SIGPIPE, "__gnat_disable_sigpipe");
+ procedure Disable_All_SIGPIPEs;
+ pragma Import (C, Disable_All_SIGPIPEs, "__gnat_disable_all_sigpipes");
+ -- Sets the process to ignore all SIGPIPE signals on platforms that
+ -- don't support Disable_SIGPIPE for particular streams.
+
function Non_Blocking_Socket (S : C.int) return Boolean;
procedure Set_Non_Blocking_Socket (S : C.int; V : Boolean);
@@ -137,7 +142,7 @@ package body GNAT.Sockets.Thin is
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
is
R : C.int;
Val : aliased C.int := 1;
@@ -288,7 +293,7 @@ package body 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
is
Res : C.int;
@@ -404,6 +409,7 @@ package body GNAT.Sockets.Thin is
procedure Initialize (Process_Blocking_IO : Boolean) is
begin
Thread_Blocking_IO := not Process_Blocking_IO;
+ Disable_All_SIGPIPEs;
end Initialize;
-------------------------
@@ -487,6 +493,32 @@ package body GNAT.Sockets.Thin is
Sin.Sin_Port := Port;
end Set_Port;
+ --------------------
+ -- Signalling_Fds --
+ --------------------
+
+ package body Signalling_Fds is
+
+ -- In this default implementation, we use a C version of these
+ -- subprograms provided by socket.c.
+
+ function C_Create (Fds : not null access Fd_Pair) return C.int;
+ function C_Read (Rsig : C.int) return C.int;
+ function C_Write (Wsig : C.int) return C.int;
+
+ pragma Import (C, C_Create, "__gnat_create_signalling_fds");
+ pragma Import (C, C_Read, "__gnat_read_signalling_fd");
+ pragma Import (C, C_Write, "__gnat_write_signalling_fd");
+
+ function Create (Fds : not null access Fd_Pair) return C.int
+ renames C_Create;
+
+ function Read (Rsig : C.int) return C.int renames C_Read;
+
+ function Write (Wsig : C.int) return C.int renames C_Write;
+
+ end Signalling_Fds;
+
--------------------------
-- Socket_Error_Message --
--------------------------