This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[Patches] IN6_IS_* macro and POSIX compilation
- From: Sebastien Vincent <sebastien dot vincent at turnserver dot org>
- To: libc-alpha at sourceware dot org
- Cc: Emil Ivov <emcho at jitsi dot org>, Daniel Pocock <daniel at pocock dot com dot au>
- Date: Sat, 20 Apr 2013 08:50:06 +0200
- Subject: [Patches] IN6_IS_* macro and POSIX compilation
- Reply-to: sebastien dot vincent at turnserver dot org
Hi all,
We encounter some problems compiling a project (TurnServer.org) with
latest eglibc/glibc 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/glibc
it complains about:
"'const struct in6_addr' has no member named 's6_addr32'"
In inet/netinet/in.h (of the glibc 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
};
The IN6_IS_* macros are 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 -D_XOPEN_SOURCE=600) the __USE_MISC and
__USE_GNU are not defined so the s6_addr32 is not available for the
comparison.
So one possibility is to enforce the #ifdef __GNUC__ with the __USE_MISC
or __USE_GNU definition => patch in attachment.
Best regards,
--
Sebastien Vincent
diff --git a/inet/netinet/in.h b/inet/netinet/in.h
index 89e3813..b4adfcb 100644
--- a/inet/netinet/in.h
+++ b/inet/netinet/in.h
@@ -394,7 +394,7 @@ extern uint16_t htons (uint16_t __hostshort)
# 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); \