diff options
author | Dmitriy Anisimkov <anisimko@adacore.com> | 2019-07-01 13:37:16 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2019-07-01 13:37:16 +0000 |
commit | a2902a6f2347f480952b53f08d7868afc8116071 (patch) | |
tree | 31042efc8bb4acd160533cad026d6998eecfd143 /gcc | |
parent | d8f8b16648d012d68ccb148a808c9a404960ea20 (diff) | |
download | gcc-a2902a6f2347f480952b53f08d7868afc8116071.zip gcc-a2902a6f2347f480952b53f08d7868afc8116071.tar.gz gcc-a2902a6f2347f480952b53f08d7868afc8116071.tar.bz2 |
[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 <anisimko@adacore.com>
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/ada/gsocket.h | 8 |
2 files changed, 8 insertions, 6 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index f2e8f39..90ee4f1 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2019-07-01 Dmitriy Anisimkov <anisimko@adacore.com> + + * 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 <schonberg@adacore.com> * sem_prag.adb (Analyze_Pragma, case Weak_External): Pragma only diff --git a/gcc/ada/gsocket.h b/gcc/ada/gsocket.h index 200edaba..1821b1b 100644 --- a/gcc/ada/gsocket.h +++ b/gcc/ada/gsocket.h @@ -185,6 +185,7 @@ #include <limits.h> #include <errno.h> +#include <stddef.h> #if defined (__vxworks) && ! defined (__RTP__) #include <sys/times.h> @@ -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 |