This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Archive rebuild to test potential stdlib.h / sys/types.h changes in glibc 2.23


glibc upstream would like to fix a long-standing problem involving
<stdlib.h> polluting the user namespace with macros named 'major' and
'minor'.  This is not technically an ISO nor POSIX conformance violation
since it only happens in extended compilation modes, but extensions are
on by default (and worse, g++ unconditionally defines _GNU_SOURCE
regardless of conformance mode - which is agreed to be a bug, but very
difficult to fix due to libstdc++ headers needing some of those
extensions) so it's likely to trip people up.  For more detail see
https://sourceware.org/bugzilla/show_bug.cgi?id=19239 and the libc-alpha
discussion starting at
https://sourceware.org/ml/libc-alpha/2015-11/msg00253.html .

We have identified two potential changes which could fix this problem;
unfortunately both of them have fairly high risk of breaking software
which expects stdlib.h to include sys/types.h, sys/types.h to include
sys/sysmacros.h, or both.  (Neither of those is guaranteed by any
standard, but I think we all know how little that means.)  We would
therefore like to ask for an archive-rebuild test using the modified
glibc.  This would involve updating the glibc packages to 2.23-dev
first, and then applying one or both of the attached patches.  (Ideally
there would be four tests - 2.23-dev baseline, patch 1 only, patch 2
only, and both patches.  But we realize that this is an expensive
proposition.)

How can we arrange for this to happen?

Thanks,
zw
[PATCH 2/2] Don't include sys/types.h from stdlib.h.

	BZ #19239
	* posix/sys/types.h, sysdeps/generic/stdint.h: New macro
	__int32_t_defined.  Only define int32_t (and __int32_t_defined)
	if __int32_t_defined is not already defined.
	* stdlib/stdlib.h: Don't include sys/types.h.
	Instead, define int32_t if necessary.
---
 posix/sys/types.h        | 6 ++++++
 stdlib/stdlib.h          | 7 +++++--
 sysdeps/generic/stdint.h | 3 +++
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/posix/sys/types.h b/posix/sys/types.h
index 8fa8b08..3330f90 100644
--- a/posix/sys/types.h
+++ b/posix/sys/types.h
@@ -161,7 +161,10 @@ typedef unsigned int uint;
 #  define __int8_t_defined
 typedef	char int8_t;
 typedef	short int int16_t;
+#  ifndef __int32_t_defined
 typedef	int int32_t;
+#   define __int32_t_defined
+#  endif
 #  if __WORDSIZE == 64
 typedef long int int64_t;
 #  else
@@ -193,7 +196,10 @@ typedef int register_t;
 #  define __int8_t_defined
 __intN_t (8, __QI__);
 __intN_t (16, __HI__);
+#   ifndef __int32_t_defined
 __intN_t (32, __SI__);
+#    define __int32_t_defined
+#   endif
 __intN_t (64, __DI__);
 # endif
 
diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h
index 0134378..b67dca9 100644
--- a/stdlib/stdlib.h
+++ b/stdlib/stdlib.h
@@ -311,8 +311,6 @@ extern long int a64l (const char *__s)
 #endif	/* Use misc || extended X/Open.  */
 
 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
-# include <sys/types.h>	/* we need int32_t... */
-
 /* These are the functions that actually do things.  The `random', `srandom',
    `initstate' and `setstate' functions are those from BSD Unices.
    The `rand' and `srand' functions are required by the ANSI standard.
@@ -340,6 +338,11 @@ extern char *setstate (char *__statebuf) __THROW __nonnull ((1));
    These functions all use the following data structure to contain
    state, rather than global state variables.  */
 
+#ifndef __int32_t_defined
+typedef	int int32_t;
+# define __int32_t_defined
+#endif
+
 struct random_data
   {
     int32_t *fptr;		/* Front pointer.  */
diff --git a/sysdeps/generic/stdint.h b/sysdeps/generic/stdint.h
index 5c9f0ff..16c1f6a 100644
--- a/sysdeps/generic/stdint.h
+++ b/sysdeps/generic/stdint.h
@@ -35,7 +35,10 @@
 # define __int8_t_defined
 typedef signed char		int8_t;
 typedef short int		int16_t;
+#ifndef __int32_t_defined
 typedef int			int32_t;
+# define __int32_t_defined
+#endif
 # if __WORDSIZE == 64
 typedef long int		int64_t;
 # else
-- 
2.6.2

[PATCH 1/2] Don't include sys/sysmacros.h from sys/types.h.

	BZ #19239
	* posix/sys/types.h [__USE_MISC]: Don't include sys/sysmacros.h.
---
 posix/sys/types.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/posix/sys/types.h b/posix/sys/types.h
index bf30873..8fa8b08 100644
--- a/posix/sys/types.h
+++ b/posix/sys/types.h
@@ -217,9 +217,6 @@ typedef int register_t __attribute__ ((__mode__ (__word__)));
 
 /* It also defines `fd_set' and the FD_* macros for `select'.  */
 # include <sys/select.h>
-
-/* BSD defines these symbols, so we follow.  */
-# include <sys/sysmacros.h>
 #endif /* Use misc.  */
 
 
-- 
2.6.2


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]