# HG changeset patch # User Bruno Haible # Date 1249938013 -7200 # Node ID a29d6bab4448fdc1c535e32955dc622767f79edb # Parent 340d92316913b42ad0956af1e5469868699116ad Make it possible to use module 'gethostname' without module 'close' or 'ioctl'. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +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. diff --git a/lib/sys_ioctl.in.h b/lib/sys_ioctl.in.h --- 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 @@ # 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 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -137,7 +137,7 @@ # 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 --- 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 @@ 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 --- 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 @@ 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 --- a/modules/socket +++ b/modules/socket @@ -15,6 +15,15 @@ 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 --- a/modules/sys_ioctl +++ b/modules/sys_ioctl @@ -29,6 +29,7 @@ -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 --- a/modules/unistd +++ b/modules/unistd @@ -72,6 +72,7 @@ -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