Make it possible to use module 'gethostname' without module 'close' or 'ioctl'.
authorBruno Haible <bruno@clisp.org>
Mon, 10 Aug 2009 21:00:13 +0000 (23:00 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 10 Aug 2009 21:00:13 +0000 (23:00 +0200)
ChangeLog
lib/sys_ioctl.in.h
lib/unistd.in.h
m4/sys_ioctl_h.m4
m4/unistd_h.m4
modules/socket
modules/sys_ioctl
modules/unistd

index cf2f2b5..7784e0c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,25 @@
 2009-08-10  Bruno Haible  <bruno@clisp.org>
 
+       Make it possible to use module 'gethostname' without module 'close'.
+       * lib/unistd.in.h (close): Evoke a link error only if
+       UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS is set.
+       * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize
+       UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS.
+       * modules/unistd (Makefile.am): Substitute
+       UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS.
+       * lib/sys_ioctl.in.h (ioctl): Evoke a link error only if
+       SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS is set.
+       * m4/sys_ioctl_h.m4 (gl_SYS_IOCTL_H_DEFAULTS): Initialize
+       SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS.
+       * modules/sys_ioctl (Makefile.am): Substitute
+       SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS.
+       * modules/socket (configure.ac): On native Windows, set
+       UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS and
+       SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS.
+       Reported by Sam Steingold <sds@gnu.org>.
+
+2009-08-10  Bruno Haible  <bruno@clisp.org>
+
        * m4/close.m4 (gl_FUNC_CLOSE): Add comment.
        * modules/ioctl (configure.ac): Likewise.
 
index 44b0f85..55d3b35 100644 (file)
@@ -1,5 +1,5 @@
 /* Substitute for and wrapper around <sys/ioctl.h>.
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008-2009 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -49,7 +49,7 @@ extern "C" {
 #  define ioctl rpl_ioctl
 extern int ioctl (int fd, int request, ... /* {void *,char *} arg */);
 # endif
-#elif @SYS_IOCTL_H_HAVE_WINSOCK2_H@
+#elif @SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
 # undef ioctl
 # define ioctl ioctl_used_without_requesting_gnulib_module_ioctl
 #elif defined GNULIB_POSIXCHECK
index 93edb48..28d52e5 100644 (file)
@@ -137,7 +137,7 @@ extern int chown (const char *file, uid_t uid, gid_t gid);
 #  define close rpl_close
 extern int close (int);
 # endif
-#elif @UNISTD_H_HAVE_WINSOCK2_H@
+#elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
 # undef close
 # define close close_used_without_requesting_gnulib_module_close
 #elif defined GNULIB_POSIXCHECK
index e0396de..22aa83e 100644 (file)
@@ -1,5 +1,5 @@
-# sys_ioctl_h.m4 serial 2
-dnl Copyright (C) 2008 Free Software Foundation, Inc.
+# sys_ioctl_h.m4 serial 3
+dnl Copyright (C) 2008-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -59,5 +59,7 @@ AC_DEFUN([gl_SYS_IOCTL_H_DEFAULTS],
   GNULIB_IOCTL=0;         AC_SUBST([GNULIB_IOCTL])
   dnl Assume proper GNU behavior unless another module says otherwise.
   SYS_IOCTL_H_HAVE_WINSOCK2_H=0; AC_SUBST([SYS_IOCTL_H_HAVE_WINSOCK2_H])
+  SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0;
+                        AC_SUBST([SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS])
   SYS_IOCTL_H='';                AC_SUBST([SYS_IOCTL_H])
 ])
index 96fddba..16c40e5 100644 (file)
@@ -1,4 +1,4 @@
-# unistd_h.m4 serial 18
+# unistd_h.m4 serial 19
 dnl Copyright (C) 2006-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -81,4 +81,6 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   REPLACE_LSEEK=0;        AC_SUBST([REPLACE_LSEEK])
   REPLACE_WRITE=0;        AC_SUBST([REPLACE_WRITE])
   UNISTD_H_HAVE_WINSOCK2_H=0; AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H])
+  UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0;
+                           AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS])
 ])
index b736fd1..f5daa49 100644 (file)
@@ -15,6 +15,15 @@ AC_REQUIRE([gl_HEADER_SYS_SOCKET])
 if test "$ac_cv_header_winsock2_h" = yes; then
   AC_LIBOBJ([socket])
 fi
+# When this module is used, sockets may actually occur as file descriptors,
+# hence it is worth warning if the modules 'close' and 'ioctl' are not used.
+m4_ifdef([gl_UNISTD_H_DEFAULTS], [AC_REQUIRE([gl_UNISTD_H_DEFAULTS])])
+m4_ifdef([gl_SYS_IOCTL_H_DEFAULTS], [AC_REQUIRE([gl_SYS_IOCTL_H_DEFAULTS])])
+AC_REQUIRE([gl_PREREQ_SYS_H_WINSOCK2])
+if test "$ac_cv_header_winsock2_h" = yes; then
+  UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=1
+  SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=1
+fi
 gl_SYS_SOCKET_MODULE_INDICATOR([socket])
 
 Makefile.am:
index a00893c..73ae825 100644 (file)
@@ -29,6 +29,7 @@ sys/ioctl.h: sys_ioctl.in.h
              -e 's|@''NEXT_SYS_IOCTL_H''@|$(NEXT_SYS_IOCTL_H)|g' \
              -e 's|@''GNULIB_IOCTL''@|$(GNULIB_IOCTL)|g' \
              -e 's|@''SYS_IOCTL_H_HAVE_WINSOCK2_H''@|$(SYS_IOCTL_H_HAVE_WINSOCK2_H)|g' \
+             -e 's|@''SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|g' \
              -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
              < $(srcdir)/sys_ioctl.in.h; \
        } > $@-t
index 7f7495d..0091a12 100644 (file)
@@ -72,6 +72,7 @@ unistd.h: unistd.in.h
              -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \
              -e 's|@''REPLACE_WRITE''@|$(REPLACE_WRITE)|g' \
              -e 's|@''UNISTD_H_HAVE_WINSOCK2_H''@|$(UNISTD_H_HAVE_WINSOCK2_H)|g' \
+             -e 's|@''UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|g' \
              -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
              < $(srcdir)/unistd.in.h; \
        } > $@-t