[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Patches] IN6_IS_* macro and POSIX compilation



Hi all,

We encounter some problem compiling a project (TurnServer.org) with latest eglibc and gcc. The compilation of Turnserver.org requires C99 and POSIX (no GNU capabilities).

List of issues reported:
https://sourceforge.net/p/turnserver/bugs/4/
https://bugs.launchpad.net/ubuntu/+source/eglibc/+bug/1086787
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=701428


The compilation runs fine with eglibc 2.13 but with recent eglibc it complains about:
"'const struct in6_addr' has no member named 's6_addr32'"

In libc/inet/netinet/in.h (of the eglibc trunk sources) the struct in6_addr is defined this way:
/* IPv6 address */
struct in6_addr
  {
    union
      {
  uint8_t __u6_addr8[16];
#if defined __USE_MISC || defined __USE_GNU
  uint16_t __u6_addr16[8];
  uint32_t __u6_addr32[4];
#endif
      } __in6_u;
#define s6_addr     __in6_u.__u6_addr8
#if defined __USE_MISC || defined __USE_GNU
# define s6_addr16    __in6_u.__u6_addr16
# define s6_addr32    __in6_u.__u6_addr32
#endif
  };


One of the IN6_IS_* macro is defined this way IF __GNUC__ (which is always the case if gcc is used) :
#ifdef __GNUC__
# define IN6_IS_ADDR_UNSPECIFIED(a) \
  (__extension__                    \
   ({ const struct in6_addr *__a = (const struct in6_addr *) (a);       \
      __a->s6_addr32[0] == 0                  \
      && __a->s6_addr32[1] == 0                 \
      && __a->s6_addr32[2] == 0                 \
      && __a->s6_addr32[3] == 0; }))
...
#endif

In case of a strict C99 / POSIX compilation (-std=c99 -D_POSIX_C_SOURCE=200112L) the __USE_MISC and __USE_GNU are not defined so the s6_addr32 are not available for the comparaison.

So one possibility is to enforce the #ifdef __GNUC__ with the __USE_MISC or __USE_GNU definition => patch in attachment.

Best regards,
--
Sebastien Vincent



Index: libc/inet/netinet/in.h
===================================================================
--- libc/inet/netinet/in.h	(revision 22828)
+++ libc/inet/netinet/in.h	(working copy)
@@ -394,7 +394,7 @@
 # endif
 #endif
 
-#ifdef __GNUC__
+#if (defined __GNUC__ && (defined __USE_MISC || defined __USE_GNU))
 # define IN6_IS_ADDR_UNSPECIFIED(a) \
   (__extension__							      \
    ({ const struct in6_addr *__a = (const struct in6_addr *) (a);	      \
_______________________________________________
Patches mailing list
Patches@xxxxxxxxxx
http://eglibc.org/cgi-bin/mailman/listinfo/patches