aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/socket.c
diff options
context:
space:
mode:
authorThomas Quinot <quinot@adacore.com>2005-11-15 14:50:37 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2005-11-15 14:50:37 +0100
commit3e1fd98f3dcc4c06007d1dfbe9fc913e0032a38c (patch)
treed1576a6497bfbada92fc3b0b451f8c360df4d37d /gcc/ada/socket.c
parentb4f32d07aa53d6831a12a7aabb1c74ee4e7ba269 (diff)
downloadgcc-3e1fd98f3dcc4c06007d1dfbe9fc913e0032a38c.zip
gcc-3e1fd98f3dcc4c06007d1dfbe9fc913e0032a38c.tar.gz
gcc-3e1fd98f3dcc4c06007d1dfbe9fc913e0032a38c.tar.bz2
g-soccon.ads: Minor reformatting.
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
Diffstat (limited to 'gcc/ada/socket.c')
-rw-r--r--gcc/ada/socket.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/gcc/ada/socket.c b/gcc/ada/socket.c
index 3213523..d02763a 100644
--- a/gcc/ada/socket.c
+++ b/gcc/ada/socket.c
@@ -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);
/* 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
+}