diff options
author | Thomas Quinot <quinot@adacore.com> | 2009-04-20 10:45:28 +0000 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2009-04-20 12:45:28 +0200 |
commit | 2907036db71b583f6a7c627e1e1753e85c779312 (patch) | |
tree | abccfec98396bda557b30cfec0ba8b9cbd863c15 /gcc/ada/socket.c | |
parent | d50633515b970d72c074e5face5eecf2dd3fa74a (diff) | |
download | gcc-2907036db71b583f6a7c627e1e1753e85c779312.zip gcc-2907036db71b583f6a7c627e1e1753e85c779312.tar.gz gcc-2907036db71b583f6a7c627e1e1753e85c779312.tar.bz2 |
socket.c, [...] (__gnat_inet_pton): Needs to be enabled for HP-UX as well...
2009-04-20 Thomas Quinot <quinot@adacore.com>
* socket.c, g-socthi-vms.adb, g-socthi-vms.ads, g-socthi-vxworks.ads,
s-oscons-tmplt.c, gsocket.h, g-socthi-mingw.ads, g-socthi.ads,
g-sothco.ads (__gnat_inet_pton): Needs to be enabled for HP-UX as well,
since HP-UX supports neither inet_aton nor inet_pton (altough the
latter is part of the Single UNIX Specification!).
So reorganize code, and share C implementation based on inet_addr(3)
with VMS (instead of having a VMS specific Ada implementation in
g-socthi-vms.adb).
From-SVN: r146396
Diffstat (limited to 'gcc/ada/socket.c')
-rw-r--r-- | gcc/ada/socket.c | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/gcc/ada/socket.c b/gcc/ada/socket.c index 4633ebf..4ac17e2 100644 --- a/gcc/ada/socket.c +++ b/gcc/ada/socket.c @@ -400,7 +400,13 @@ __gnat_get_h_errno (void) { #endif } -#if defined (__vxworks) || defined (_WIN32) +#ifndef HAVE_INET_PTON + +#ifdef VMS +# define in_addr_t int +# define inet_addr decc$inet_addr +#endif + int __gnat_inet_pton (int af, const char *src, void *dst) { switch (af) { @@ -414,9 +420,10 @@ __gnat_inet_pton (int af, const char *src, void *dst) { return -1; } -#ifdef __vxworks +#if defined (__vxworks) return (inet_aton (src, dst) == OK); -#else + +#elif defined (_WIN32) struct sockaddr_storage ss; int sslen = sizeof ss; int rc; @@ -436,10 +443,30 @@ __gnat_inet_pton (int af, const char *src, void *dst) { } } return (rc == 0); + +#elif defined (__hpux__) || defined (VMS) + in_addr_t addr; + int rc = -1; + + if (src == NULL || dst == NULL) { + errno = EINVAL; + + } else if (!strcmp (src, "255.255.255.255")) { + addr = 0xffffffff; + rc = 1; + + } else { + addr = inet_addr (src); + rc = (addr != 0xffffffff); + } + if (rc == 1) { + *(in_addr_t *)dst = addr; + } + return rc; #endif } #endif #else -#warning Sockets are not supported on this platform +# warning Sockets are not supported on this platform #endif /* defined(HAVE_SOCKETS) */ |