+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.
/* 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
# 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
# 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
-# 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.
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])
])
-# 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,
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])
])
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:
-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
-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