bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: link-warning usage improvements


From: Bruno Haible
Subject: Re: link-warning usage improvements
Date: Thu, 24 Dec 2009 21:46:23 +0100
User-agent: KMail/1.9.9

Eric Blake wrote:
> Any objections to a patch that
> makes replacement of these headers unconditional, so that
> GNULIB_POSIXCHECK will work better?
> 
> modules/arpa_inet:BUILT_SOURCES += $(ARPA_INET_H)
> modules/ctype:BUILT_SOURCES += $(CTYPE_H)
> modules/dirent:BUILT_SOURCES += $(DIRENT_H)
> modules/inttypes:BUILT_SOURCES += $(INTTYPES_H)
> modules/spawn:BUILT_SOURCES += $(SPAWN_H)
> modules/sys_file:BUILT_SOURCES += $(SYS_FILE_H)
> modules/sys_ioctl:BUILT_SOURCES += $(SYS_IOCTL_H)
> modules/sys_select:BUILT_SOURCES += $(SYS_SELECT_H)
> modules/sys_socket:BUILT_SOURCES += $(SYS_SOCKET_H)
> modules/sys_times:BUILT_SOURCES += $(SYS_TIMES_H)
> modules/sys_utsname:BUILT_SOURCES += $(SYS_UTSNAME_H)
> modules/sys_wait:BUILT_SOURCES += $(SYS_WAIT_H)
> modules/wchar:BUILT_SOURCES += $(WCHAR_H)

No objection in principle. I hardly ever notice in my builds whether on glibc
systems the replacement header is used or not.

modules/spawn and modules/sys_times will be some work, because currently the
replacement header file will not work on systems which already have the
typedefs.

Also, let's be careful not to pollute the namespace with extra definitions
on glibc systems. (I don't consider <sys/types.h> and <stddef.h> here; they
are small and pretty much omnipresent.) To this effect, I'm adding an
include guard:


2009-12-24  Bruno Haible  <address@hidden>

        Avoid future namespace pollution on glibc systems.
        * lib/arpa_inet.in.h: Don't include <sys/socket.h> on glibc systems.
        * lib/sys_ioctl.in.h: Don't include <unistd.h> on glibc systems.
        * lib/sys_select.in.h: Don't include <sys/time.h> and <string.h> on
        glibc systems.

--- lib/arpa_inet.in.h.orig     Thu Dec 24 21:41:52 2009
+++ lib/arpa_inet.in.h  Thu Dec 24 21:33:03 2009
@@ -19,8 +19,11 @@
 #ifndef _GL_ARPA_INET_H
 
 /* Gnulib's sys/socket.h is responsible for pulling in winsock2.h etc
-   under MinGW. */
-#include <sys/socket.h>
+   under MinGW.
+   But avoid namespace pollution on glibc systems.  */
+#ifndef __GLIBC__
+# include <sys/socket.h>
+#endif
 
 #if @HAVE_ARPA_INET_H@
 
--- lib/sys_ioctl.in.h.orig     Thu Dec 24 21:41:52 2009
+++ lib/sys_ioctl.in.h  Thu Dec 24 21:39:08 2009
@@ -30,8 +30,11 @@
 #define _GL_SYS_IOCTL_H
 
 /* AIX 5.1 and Solaris 10 declare ioctl() in <unistd.h> and in <stropts.h>,
-   but not in <sys/ioctl.h>.  */
-#include <unistd.h>
+   but not in <sys/ioctl.h>.
+   But avoid namespace pollution on glibc systems.  */
+#ifndef __GLIBC__
+# include <unistd.h>
+#endif
 
 /* The definition of GL_LINK_WARNING is copied here.  */
 
--- lib/sys_select.in.h.orig    Thu Dec 24 21:41:52 2009
+++ lib/sys_select.in.h Thu Dec 24 21:41:19 2009
@@ -42,12 +42,18 @@
 # include <sys/types.h>
 
 /* On OSF/1 4.0, <sys/select.h> provides only a forward declaration
-   of 'struct timeval', and no definition of this type.  */
-# include <sys/time.h>
+   of 'struct timeval', and no definition of this type.
+   But avoid namespace pollution on glibc systems.  */
+# ifndef __GLIBC__
+#  include <sys/time.h>
+# endif
 
 /* On Solaris 10, <sys/select.h> provides an FD_ZERO implementation
-   that relies on memset(), but without including <string.h>.  */
-# include <string.h>
+   that relies on memset(), but without including <string.h>.
+   But avoid namespace pollution on glibc systems.  */
+# ifndef __GLIBC__
+#  include <string.h>
+# endif
 
 /* The include_next requires a split double-inclusion guard.  */
 # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@




reply via email to

[Prev in Thread] Current Thread [Next in Thread]