diff options
author | Thomas Quinot <quinot@adacore.com> | 2007-04-06 11:15:09 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2007-04-06 11:15:09 +0200 |
commit | 3d3bf932b985baee7ac3973208c0d775dcb93b5d (patch) | |
tree | d2a9f2de1b4f8ce5a655a929362077213fa220da /gcc/ada/socket.c | |
parent | baa3441ddf0daabf8b0127a577121348906aa8b6 (diff) | |
download | gcc-3d3bf932b985baee7ac3973208c0d775dcb93b5d.zip gcc-3d3bf932b985baee7ac3973208c0d775dcb93b5d.tar.gz gcc-3d3bf932b985baee7ac3973208c0d775dcb93b5d.tar.bz2 |
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/socket.c')
-rw-r--r-- | gcc/ada/socket.c | 60 |
1 files changed, 57 insertions, 3 deletions
diff --git a/gcc/ada/socket.c b/gcc/ada/socket.c index bb79ac3..ef8e265 100644 --- a/gcc/ada/socket.c +++ b/gcc/ada/socket.c @@ -6,7 +6,7 @@ * * * C Implementation File * * * - * Copyright (C) 2003-2005 Free Software Foundation, Inc. * + * Copyright (C) 2003-2006, 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,11 @@ /* Include all the necessary system-specific headers and define the necessary macros (shared with gen-soccon). */ +#if !defined(SO_NOSIGPIPE) && !defined (MSG_NOSIGNAL) +#include <signal.h> +#endif +/* Required if we will be calling signal() in __gnat_disable_all_sigpipes() */ + #include "raise.h" /* Required for __gnat_malloc() */ @@ -43,6 +48,10 @@ /* Required for memcpy() */ extern void __gnat_disable_sigpipe (int fd); +extern void __gnat_disable_all_sigpipes (void); +extern int __gnat_create_signalling_fds (int *fds); +extern int __gnat_read_signalling_fd (int rsig); +extern int __gnat_write_signalling_fd (int wsig); extern void __gnat_free_socket_set (fd_set *); extern void __gnat_last_socket_in_set (fd_set *, int *); extern void __gnat_get_socket_from_set (fd_set *, int *, int *); @@ -50,7 +59,7 @@ 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); +extern int __gnat_get_h_errno (void); /* Disable the sending of SIGPIPE for writes on a broken stream */ @@ -63,6 +72,51 @@ __gnat_disable_sigpipe (int fd) #endif } +void +__gnat_disable_all_sigpipes (void) +{ +#if !defined(SO_NOSIGPIPE) && !defined(MSG_NOSIGNAL) && defined(SIGPIPE) + (void) signal (SIGPIPE, SIG_IGN); +#endif +} + +#if defined (_WIN32) || defined (__vxworks) || defined (VMS) +/* + * Signalling FDs operations are implemented in Ada for these platforms + * (see subunit GNAT.Sockets.Thin.Signalling_Fds). + */ +#else +/* + * Create a pair of connected file descriptors fds[0] and fds[1] used for + * signalling by a Selector object. fds[0] is the read end, and fds[1] the + * write end. + */ +int +__gnat_create_signalling_fds (int *fds) { + return pipe (fds); +} + +/* + * Read one byte of data from rsig, the read end of a pair of signalling fds + * created by __gnat_create_signalling_fds. + */ +int +__gnat_read_signalling_fd (int rsig) { + char c; + return read (rsig, &c, 1); +} + +/* + * Write one byte of data to wsig, the write end of a pair of signalling fds + * created by __gnat_create_signalling_fds. + */ +int +__gnat_write_signalling_fd (int wsig) { + char c = 0; + return write (wsig, &c, 1); +} +#endif + /* Free socket set. */ void @@ -83,7 +137,7 @@ __gnat_last_socket_in_set (fd_set *set, int *last) int l; l = -1; -#ifdef WINNT +#ifdef _WIN32 /* More efficient method for NT. */ for (s = 0; s < set->fd_count; s++) if ((int) set->fd_array[s] > l) |