Reduce namespace pollution on glibc systems.
authorBruno Haible <bruno@clisp.org>
Thu, 24 Dec 2009 15:59:36 +0000 (16:59 +0100)
committerBruno Haible <bruno@clisp.org>
Thu, 24 Dec 2009 15:59:36 +0000 (16:59 +0100)
ChangeLog
lib/fcntl.c
lib/fcntl.in.h
lib/inttypes.in.h
lib/stdlib.in.h
lib/unistd.in.h

index c7ced82fb4618761ed0112ae3ed61bc47ea7d042..7c8f7dacaf70166bee80f1464fd9b0c914a267e0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2009-12-24  Bruno Haible  <bruno@clisp.org>
+
+       Reduce namespace pollution on glibc systems.
+       * lib/inttypes.in.h: Don't include <stdint.h> on glibc systems.
+       * lib/stdlib.in.h: Don't include <stdint.h>, <unistd.h> on glibc
+       systems.
+       * lib/unistd.in.h: Don't include <stdio.h>, <fcntl.h>, <stdlib.h>,
+       <getopt.h> on glibc systems.
+       * lib/fcntl.in.h: Don't include <sys/stat.h>, <unistd.h> on glibc
+       systems.
+       * lib/fcntl.c: Include <unistd.h> here instead.
+
 2009-12-24  Bruno Haible  <bruno@clisp.org>
 
        * lib/stdlib.in.h (includes): Fix typo in today's commit.
index 05d73a94fb7a4b20ca2d41947a5c8f271b0498fa..5069eec0b5255cdff170caafd4217cb2ee1e9b50 100644 (file)
@@ -25,6 +25,7 @@
 #include <errno.h>
 #include <limits.h>
 #include <stdarg.h>
+#include <unistd.h>
 
 #if !HAVE_FCNTL
 # define rpl_fcntl fcntl
index 1a4602bfc0dea38e973bbea90969fde10994071c..d3eb27fc52b099c23c861216e27046ec046139a4 100644 (file)
 /* Special invocation convention.  */
 
 #include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
+#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems.  */
+# include <sys/stat.h>
+# include <unistd.h>
+#endif
 #@INCLUDE_NEXT@ @NEXT_FCNTL_H@
 
 #else
 #ifndef _GL_FCNTL_H
 
 #include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
+#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems.  */
+# include <sys/stat.h>
+# include <unistd.h>
+#endif
 /* The include_next requires a split double-inclusion guard.  */
 #@INCLUDE_NEXT@ @NEXT_FCNTL_H@
 
index cfb6fc7d571b817a81e1b03c21d1927f3bd37720..2fac7e5e63b4a96dca588f8240ebd05099b394a5 100644 (file)
 #if ! defined INTTYPES_H && ! defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
 #define INTTYPES_H
 
-/* Include <stdint.h> or the gnulib replacement.  */
-#include <stdint.h>
+/* Include <stdint.h> or the gnulib replacement.
+   But avoid namespace pollution on glibc systems.  */
+#ifndef __GLIBC__
+# include <stdint.h>
+#endif
 /* Get CHAR_BIT.  */
 #include <limits.h>
 
index 5f2766a99fc9f6eacf41cef4f96a8bf9efadb0d9..edee74c4a221bc70d864dd3e5481c8356f3b7cfb 100644 (file)
@@ -49,8 +49,8 @@
 # include <random.h>
 #endif
 
-#if (@GNULIB_RANDOM_R@ || !@HAVE_STRUCT_RANDOM_DATA@ \
-     || defined GNULIB_POSIXCHECK)
+#if !@HAVE_STRUCT_RANDOM_DATA@ || (@GNULIB_RANDOM_R@ && !@HAVE_RANDOM_R@) \
+    || defined GNULIB_POSIXCHECK
 # include <stdint.h>
 #endif
 
@@ -67,9 +67,10 @@ struct random_data
 };
 #endif
 
-#if @GNULIB_MKSTEMP@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK
+#if (@GNULIB_MKSTEMP@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__
 /* On MacOS X 10.3, only <unistd.h> declares mkstemp.  */
 /* On Cygwin 1.7.1, only <unistd.h> declares getsubopt.  */
+/* But avoid namespace pollution on glibc systems.  */
 # include <unistd.h>
 #endif
 
index 1a11d1a89d33bedef5b6d7b5d2792b971e24e7cf..af2d563321f96942b643639b2ea707502b1e9d21 100644 (file)
 
 /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>.  */
 /* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>.  */
+/* But avoid namespace pollution on glibc systems.  */
 #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
-     || @GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK)
+     || (@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK)) \
+    && ! defined __GLIBC__
 # include <stdio.h>
 #endif
 
 /* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>.  */
-#if @GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK
+/* But avoid namespace pollution on glibc systems.  */
+#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__
 # include <fcntl.h>
 #endif
 
 /* mingw fails to declare _exit in <unistd.h>.  */
 /* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>.  */
 /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>.  */
-#include <stdlib.h>
+/* But avoid namespace pollution on glibc systems.  */
+#ifndef __GLIBC__
+# include <stdlib.h>
+#endif
 
 /* mingw declares getcwd in <io.h>, not in <unistd.h>.  */
 #if ((@GNULIB_GETCWD@ || defined GNULIB_POSIXCHECK) \
@@ -63,8 +69,9 @@
 # include <sys/types.h>
 #endif
 
-/* Get getopt(), optarg, optind, opterr, optopt.  */
-#if @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT
+/* Get getopt(), optarg, optind, opterr, optopt.
+   But avoid namespace pollution on glibc systems.  */
+#if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
 # include <getopt.h>
 #endif