From 7f8441f9767253da8deb1f6c73a488220fcbcdd7 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 10 Aug 2009 23:00:13 +0200 Subject: [PATCH] Make it possible to use module 'gethostname' without module 'close' or 'ioctl'. --- ChangeLog | 20 ++++++++++++++++++++ lib/sys_ioctl.in.h | 4 ++-- lib/unistd.in.h | 2 +- m4/sys_ioctl_h.m4 | 6 ++++-- m4/unistd_h.m4 | 4 +++- modules/socket | 9 +++++++++ modules/sys_ioctl | 1 + modules/unistd | 1 + 8 files changed, 41 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index cf2f2b57c..7784e0c44 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,25 @@ 2009-08-10 Bruno Haible + 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 . + +2009-08-10 Bruno Haible + * m4/close.m4 (gl_FUNC_CLOSE): Add comment. * modules/ioctl (configure.ac): Likewise. diff --git a/lib/sys_ioctl.in.h b/lib/sys_ioctl.in.h index 44b0f8516..55d3b350d 100644 --- a/lib/sys_ioctl.in.h +++ b/lib/sys_ioctl.in.h @@ -1,5 +1,5 @@ /* Substitute for and wrapper around . - 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 diff --git a/lib/unistd.in.h b/lib/unistd.in.h index 93edb487e..28d52e5a4 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -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 diff --git a/m4/sys_ioctl_h.m4 b/m4/sys_ioctl_h.m4 index e0396de85..22aa83ee5 100644 --- a/m4/sys_ioctl_h.m4 +++ b/m4/sys_ioctl_h.m4 @@ -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]) ]) diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4 index 96fddba7f..16c40e539 100644 --- a/m4/unistd_h.m4 +++ b/m4/unistd_h.m4 @@ -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]) ]) diff --git a/modules/socket b/modules/socket index b736fd1d3..f5daa4919 100644 --- a/modules/socket +++ b/modules/socket @@ -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: diff --git a/modules/sys_ioctl b/modules/sys_ioctl index a00893c96..73ae82522 100644 --- a/modules/sys_ioctl +++ b/modules/sys_ioctl @@ -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 diff --git a/modules/unistd b/modules/unistd index 7f7495d97..0091a1218 100644 --- a/modules/unistd +++ b/modules/unistd @@ -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 -- 2.11.0