summaryrefslogtreecommitdiff
path: root/gcc/ada/socket.c
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2009-04-20 10:45:28 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2009-04-20 10:45:28 +0000
commit1469afd665e2628b6505fea115daec4b2b3bbff7 (patch)
treeabccfec98396bda557b30cfec0ba8b9cbd863c15 /gcc/ada/socket.c
parent60ca8da9bac8217dd8cf253418650878c47b8af5 (diff)
downloadgcc-1469afd665e2628b6505fea115daec4b2b3bbff7.tar.gz
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). git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@146396 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/socket.c')
-rw-r--r--gcc/ada/socket.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/gcc/ada/socket.c b/gcc/ada/socket.c
index 4633ebfd774..4ac17e2fbbf 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) */