summaryrefslogtreecommitdiff
path: root/gcc/ada/socket.c
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2009-04-20 12:18:48 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2009-04-20 12:18:48 +0200
commit9013065bc05ad988ff59dda83b1847880757f20d (patch)
treed29723f3d3f8d6cc89ae08b5d744fe3c8fa864b0 /gcc/ada/socket.c
parent7289b80c09ea86586ad7663e76400878bf2a8b7e (diff)
downloadgcc-9013065bc05ad988ff59dda83b1847880757f20d.tar.gz
[multiple changes]
2009-04-20 Javier Miranda <miranda@adacore.com> * einfo.ads, einfo.adb (Is_Underlying_Record_View): New subprogram (Set_Is_Underlying_Record_View): New subprogram * sem_aggr.adb (Discr_Present, Resolve_Record_Aggregate): In case of private types with unknown discriminants use the underlying record view if available. * sem_ch3.adb (Build_Derived_Private_Type): Enable construction of the underlying record view in the full view of private types whose parent has unknown discriminants. (Build_Derived_Record_Type): Avoid generating the class-wide entity associated with an underlying record view. (Derived_Type_Declaration): Avoid deriving parent primitives in underlying record views. * sem_ch6.adb (Check_Return_Subtype_Indication): Add support for records with unknown discriminants. * sem_type.adb (Covers): Handle underlying record views. (Is_Ancestor): Add support for underlying record views. * exp_attr.adb (Expand_Attribute): Expand attribute 'size into a dispatching call if the type of the target object is tagged and has unknown discriminants. * exp_aggr.adb (Resolve_Record_Aggregate): Add support for records with unknown discriminants. * exp_disp.adb (Build_Dispatch_Tables): Avoid generating dispatch tables for internally built underlying record views. * sprint.adb (sprint_node_actual): Improve output of aggregates with an empty list of component associations. 2009-04-20 Thomas Quinot <quinot@adacore.com> * sem_ch10.adb: Minor reformatting * socket.c, g-socthi-vms.adb, g-socthi-vms.ads, g-socthi-vxworks.ads, g-socthi-mingw.ads, g-socthi.ads, g-socket.adb (GNAT.Sockets.Inet_Addr): Do not use non-portable inet_aton, instead use standard inet_pton API (and emulate it on platforms that do not support it). (GNAT.Sockets.Thin.Inet_Pton, VMS case): Implement in terms of DECC$INET_ADDR, imported in Ada. (GNAT.Sockets.Thin.Inet_Pton, VxWorks and Windows cases): Use C implementation provided by GNAT runtime. (__gnat_inet_pton): C implementation of inet_pton(3) for VxWorks and Windows. From-SVN: r146391
Diffstat (limited to 'gcc/ada/socket.c')
-rw-r--r--gcc/ada/socket.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/gcc/ada/socket.c b/gcc/ada/socket.c
index 33a06397467..5ddaa39d6a2 100644
--- a/gcc/ada/socket.c
+++ b/gcc/ada/socket.c
@@ -62,8 +62,11 @@ 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 void __gnat_reset_socket_set (fd_set *set);
+extern void __gnat_reset_socket_set (fd_set *);
extern int __gnat_get_h_errno (void);
+#if defined (__vxworks) || defined (_WIN32)
+extern int __gnat_inet_pton (int, const char *, void *);
+#endif
/* Disable the sending of SIGPIPE for writes on a broken stream */
@@ -397,6 +400,46 @@ __gnat_get_h_errno (void) {
#endif
}
+#if defined (__vxworks) || defined (_WIN32)
+int
+__gnat_inet_pton (int af, const char *src, void *dst) {
+ switch (af) {
+#if defined (_WIN32) && defined (AF_INET6)
+ case AF_INET6:
+#endif
+ case AF_INET:
+ break;
+ default:
+ errno = EAFNOSUPPORT;
+ return -1;
+ }
+
+#ifdef __vxworks
+ return (inet_aton (src, dst) == OK);
+#else
+ struct sockaddr_storage ss;
+ int sslen = sizeof ss;
+ int rc;
+
+ ss.ss_family = af;
+ rc = WSAStringToAddress (src, af, NULL, (struct sockaddr *)&ss, &sslen);
+ if (rc > 0) {
+ switch (af) {
+ case AF_INET:
+ *(struct in_addr *)dst = ((struct sockaddr_in *)&ss)->sin_addr;
+ break;
+#ifdef AF_INET6
+ case AF_INET6:
+ *(struct in6_addr *)dst = ((struct sockaddr_in6 *)&ss)->sin6_addr;
+ break;
+#endif
+ }
+ }
+ return rc;
+#endif
+}
+#endif
+
#else
#warning Sockets are not supported on this platform
#endif /* defined(HAVE_SOCKETS) */