From: Dmitriy Anisimkov Date: Mon, 1 Jul 2019 13:37:16 +0000 (+0000) Subject: [Ada] GNAT.Sockets: refactor Has_Sockaddr_Len X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a2902a6f2347f480952b53f08d7868afc8116071;p=gcc.git [Ada] GNAT.Sockets: refactor Has_Sockaddr_Len Use a field offset computation trick to avoid maintaining a list of platforms. 2019-07-01 Dmitriy Anisimkov gcc/ada/ * gsocket.h (Has_Sockaddr_Len): Use the offset of sin_family offset in the sockaddr_in structure to determine the existence of length field before the sin_family. From-SVN: r272877 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index f2e8f39ff29..90ee4f1dbf0 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2019-07-01 Dmitriy Anisimkov + + * gsocket.h (Has_Sockaddr_Len): Use the offset of sin_family offset in + the sockaddr_in structure to determine the existence of length field + before the sin_family. + 2019-07-01 Ed Schonberg * sem_prag.adb (Analyze_Pragma, case Weak_External): Pragma only diff --git a/gcc/ada/gsocket.h b/gcc/ada/gsocket.h index 200edabaeed..1821b1b55d4 100644 --- a/gcc/ada/gsocket.h +++ b/gcc/ada/gsocket.h @@ -185,6 +185,7 @@ #include #include +#include #if defined (__vxworks) && ! defined (__RTP__) #include @@ -252,12 +253,7 @@ # endif #endif -#if defined (__FreeBSD__) || defined (__vxworks) || defined(__rtems__) \ - || defined (__DragonFly__) || defined (__NetBSD__) || defined (__OpenBSD__) -# define Has_Sockaddr_Len 1 -#else -# define Has_Sockaddr_Len 0 -#endif +# define Has_Sockaddr_Len (offsetof(struct sockaddr_in, sin_family) != 0) #if !(defined (_WIN32) || defined (__hpux__) || defined (VMS)) # define HAVE_INET_PTON