From 1dfddbb4d341548f0b196873f0d2b9c9b058b8a4 Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Mon, 30 Nov 2009 11:07:32 +0100 Subject: [multiple changes] 2009-11-30 Thomas Quinot * s-crtl.ads, g-stseme.adb, s-fileio.adb (System.CRTL.strerror): Change return type to Interfaces.C.Strings.chars_ptr to eliminate need for dubious unchecked conversion at call sites. * s-errrep.adb, s-errrep.ads, Makefile.rtl (System.Error_Reporting): Remove obsolete, unused runtime unit. * gcc-interface/Make-lang.in: Update dependencies. * gcc-interface/Makefile.in: Remove VMS specialization of s-crtl, not required anymore. 2009-11-30 Vincent Celier * gnatlink.adb: Delete an eventual existing executable file, in case it is a symbolic link, to avoid modifying the target of the symbolic link. 2009-11-30 Bob Duff * socket.c: Add accessor functions for struct servent. * g-sothco.ads (Servent): Declare interfaces to C accessor functions for struct servent. * g-socket.adb (To_Service_Entry): Use accessor functions for struct servent. 2009-11-30 Robert Dewar * g-arrspl.adb: Minor reformatting * g-dyntab.adb: Add missing pragma Compiler_Unit From-SVN: r154769 --- gcc/ada/socket.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'gcc/ada/socket.c') diff --git a/gcc/ada/socket.c b/gcc/ada/socket.c index df3b120..ecafb8a 100644 --- a/gcc/ada/socket.c +++ b/gcc/ada/socket.c @@ -59,6 +59,9 @@ #include /* Required for memcpy() */ +extern const size_t __gnat_sizeof_servent = sizeof(struct servent); +/* For passing the size of servent to Ada code. */ + extern void __gnat_disable_sigpipe (int fd); extern void __gnat_disable_all_sigpipes (void); extern int __gnat_create_signalling_fds (int *fds); @@ -74,6 +77,10 @@ extern void __gnat_remove_socket_from_set (fd_set *, int); extern void __gnat_reset_socket_set (fd_set *); extern int __gnat_get_h_errno (void); extern int __gnat_socket_ioctl (int, int, int *); +extern char * __gnat_servent_s_name (struct servent *); +extern char ** __gnat_servent_s_aliases (struct servent *); +extern int __gnat_servent_s_port (struct servent *); +extern char * __gnat_servent_s_proto (struct servent *); #if defined (__vxworks) || defined (_WIN32) extern int __gnat_inet_pton (int, const char *, void *); #endif @@ -488,6 +495,61 @@ __gnat_inet_pton (int af, const char *src, void *dst) { } #endif +/* + * Accessor functions for struct servent. + * + * These are needed because servent has different representations on different + * platforms, and we don't want to deal with that on the Ada side. For example, + * on Linux, we have (see /usr/include netdb.h): + * + * struct servent + * { + * char *s_name; + * char **s_aliases; + * int s_port; + * char *s_proto; + * }; + * + * and on Windows (see mingw's socket.h): + * + * struct servent { + * char *s_name; + * char **s_aliases; + * #ifdef _WIN64 + * char *s_proto; + * short s_port; + * #else + * short s_port; + * char *s_proto; + * #endif + * }; + */ + +char * +__gnat_servent_s_name (struct servent * s) +{ + return s->s_name; +} + +char ** +__gnat_servent_s_aliases (struct servent * s) +{ + return s->s_aliases; +} + +int +__gnat_servent_s_port (struct servent * s) +{ + return s->s_port; +} + +char * +__gnat_servent_s_proto (struct servent * s) +{ + return s->s_proto; +} + + #else # warning Sockets are not supported on this platform #endif /* defined(HAVE_SOCKETS) */ -- cgit v1.1