From: Bruno Haible Date: Thu, 24 Dec 2009 15:59:36 +0000 (+0100) Subject: Reduce namespace pollution on glibc systems. X-Git-Tag: v0.1~4996 X-Git-Url: http://erislabs.net/gitweb/?a=commitdiff_plain;h=d19dfc69437add5301e0e1dd28dbfda2c694cbbc;p=gnulib.git Reduce namespace pollution on glibc systems. --- diff --git a/ChangeLog b/ChangeLog index c7ced82fb..7c8f7daca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 2009-12-24 Bruno Haible + Reduce namespace pollution on glibc systems. + * lib/inttypes.in.h: Don't include on glibc systems. + * lib/stdlib.in.h: Don't include , on glibc + systems. + * lib/unistd.in.h: Don't include , , , + on glibc systems. + * lib/fcntl.in.h: Don't include , on glibc + systems. + * lib/fcntl.c: Include here instead. + +2009-12-24 Bruno Haible + * lib/stdlib.in.h (includes): Fix typo in today's commit. 2009-12-24 Eric Blake diff --git a/lib/fcntl.c b/lib/fcntl.c index 05d73a94f..5069eec0b 100644 --- a/lib/fcntl.c +++ b/lib/fcntl.c @@ -25,6 +25,7 @@ #include #include #include +#include #if !HAVE_FCNTL # define rpl_fcntl fcntl diff --git a/lib/fcntl.in.h b/lib/fcntl.in.h index 1a4602bfc..d3eb27fc5 100644 --- a/lib/fcntl.in.h +++ b/lib/fcntl.in.h @@ -25,8 +25,10 @@ /* Special invocation convention. */ #include -#include -#include +#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */ +# include +# include +#endif #@INCLUDE_NEXT@ @NEXT_FCNTL_H@ #else @@ -35,8 +37,10 @@ #ifndef _GL_FCNTL_H #include -#include -#include +#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */ +# include +# include +#endif /* The include_next requires a split double-inclusion guard. */ #@INCLUDE_NEXT@ @NEXT_FCNTL_H@ diff --git a/lib/inttypes.in.h b/lib/inttypes.in.h index cfb6fc7d5..2fac7e5e6 100644 --- a/lib/inttypes.in.h +++ b/lib/inttypes.in.h @@ -36,8 +36,11 @@ #if ! defined INTTYPES_H && ! defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H #define INTTYPES_H -/* Include or the gnulib replacement. */ -#include +/* Include or the gnulib replacement. + But avoid namespace pollution on glibc systems. */ +#ifndef __GLIBC__ +# include +#endif /* Get CHAR_BIT. */ #include diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index 5f2766a99..edee74c4a 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -49,8 +49,8 @@ # include #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 #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 declares mkstemp. */ /* On Cygwin 1.7.1, only declares getsubopt. */ +/* But avoid namespace pollution on glibc systems. */ # include #endif diff --git a/lib/unistd.in.h b/lib/unistd.in.h index 1a11d1a89..af2d56332 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -34,20 +34,26 @@ /* mingw doesn't define the SEEK_* or *_FILENO macros in . */ /* Cygwin 1.7.1 declares symlinkat in , not in . */ +/* 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 #endif /* Cygwin 1.7.1 declares unlinkat in , not in . */ -#if @GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK +/* But avoid namespace pollution on glibc systems. */ +#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ # include #endif /* mingw fails to declare _exit in . */ /* mingw, BeOS, Haiku declare environ in , not in . */ /* Solaris declares getcwd not only in but also in . */ -#include +/* But avoid namespace pollution on glibc systems. */ +#ifndef __GLIBC__ +# include +#endif /* mingw declares getcwd in , not in . */ #if ((@GNULIB_GETCWD@ || defined GNULIB_POSIXCHECK) \ @@ -63,8 +69,9 @@ # include #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 #endif