This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
IN6_* macros and _POSIX_C_SOURCE (with patch)
- From: Octavio Alvarez <alvarezp at alvarezp dot ods dot org>
- To: libc-alpha at sourceware dot org
- Date: Fri, 24 Jan 2014 18:54:33 -0800
- Subject: IN6_* macros and _POSIX_C_SOURCE (with patch)
- Authentication-results: sourceware.org; auth=none
Hello.
(I'm not subscribed. I'd appreciate Cc-ing me when replying.)
While using the IN6_IS_* and IN6_ARE_* macros with -D_POSIX_C_SOURCE we
get an error regarding the lack of a member called s6_addr32.
The problem lies in that POSIX [1] only requires a struct member called
s6_addr, which is not available for the macros if _POSIX_C_SOURCE is
defined.
[1]
http://pubs.opengroup.org/onlinepubs/000095399/basedefs/netinet/in.h.html
Even though the standard does not require other macros not to be
defined, s6_* could probably be used in the future, as suggested in BZ
#16421 [2].
[2] https://sourceware.org/bugzilla/show_bug.cgi?id=16421
This patch will fix this.
The problem was reported on April 20th, 2013 [3]. A patch was supplied
but no follow-up was given.
[3] https://sourceware.org/ml/libc-alpha/2013-04/msg00563.html
Maybe there are better or more optimal fixes, (like unconditionally
exposing __in6_u.__u6_addr16 and 32 and letting the macros use them),
but at least this small patch makes it work properly again, without
requiring additional symbol exposure.
We're currently in the need of working around this by undefining the
macros and redefining them ourselves because it's broken in glibc and
derivates.
I'm also attaching the patch in case my mail client word-wraps it.
===== PATCH START, using git format-patch =====
From bfd6f2fc7d036ce694759be882c3d91bffa8f249 Mon Sep 17 00:00:00 2001
From: Octavio Alvarez <octavio.alvarez@globalsat.com.mx>
Date: Fri, 24 Jan 2014 18:25:58 -0800
Subject: [PATCH] Fix POSIX compilation for IN6_IS_* macros in in.h
Fixes BZ #16421
When compiling with gcc -std=c99 -D_POSIX_C_SOURCE, macros like
IN6_IS_ADDR_UNSPECIFIED try to use s6_addr32 even though glibc's
netinet/in.h provide an alternative implementation that doesn't
use that symbol.
s6_addr32 is not defined in POSIX [1], only s6_addr.
This breaks compilation for software that uses those macros like
TurnServer.org and IPv6 Toolkit.
This patch by Sebastien Vincent fixes it.
---
inet/netinet/in.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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); \
--
1.8.1.2
Thanks a lot.
>From bfd6f2fc7d036ce694759be882c3d91bffa8f249 Mon Sep 17 00:00:00 2001
From: Octavio Alvarez <octavio.alvarez@globalsat.com.mx>
Date: Fri, 24 Jan 2014 18:25:58 -0800
Subject: [PATCH] Fix POSIX compilation for IN6_IS_* macros in in.h
Fixes BZ #16421
When compiling with gcc -std=c99 -D_POSIX_C_SOURCE, macros like
IN6_IS_ADDR_UNSPECIFIED try to use s6_addr32 even though glibc's
netinet/in.h provide an alternative implementation that doesn't
use that symbol.
s6_addr32 is not defined in POSIX [1], only s6_addr.
This breaks compilation for software that uses those macros like
TurnServer.org and IPv6 Toolkit.
This patch by Sebastien Vincent fixes it.
---
inet/netinet/in.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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); \
--
1.8.1.2