+2008-10-25 Ben Pfaff <blp@cs.stanford.edu>
+ Bruno Haible <bruno@clisp.org>
+
+ * lib/unistd.in.h: Include <winsock2.h>.
+ (socket, connect,accept, bind, getpeername, getsockname, getsockopt,
+ listen, recv, send, recvfrom, sendto, setsockopt, shutdown, select):
+ Provide dummy declarations.
+ (gethostname): Override.
+ * lib/sys_socket.in.h (gethostname): Provide dummy declaration.
+ * m4/gethostname.m4 (gl_FUNC_GETHOSTNAME): Invoke
+ gl_PREREQ_SYS_H_WINSOCK2.
+ * modules/gethostname (Files): Add m4/sys_socket_h.m4.
+ * doc/posix-functions/gethostname.texi: More details.
+
2008-10-25 Bruno Haible <bruno@clisp.org>
* m4/sys_socket_h.m4 (gl_PREREQ_SYS_H_WINSOCK2): Require
Portability problems fixed by Gnulib:
@itemize
@item
-This function is missing on some platforms:
-mingw.
+On mingw, this function has a prototype that differs from that
+specified by POSIX, and it is defined only in the ws2_32 library.
@end itemize
Portability problems not fixed by Gnulib:
# define close close_used_without_including_unistd_h
# endif
+# if @HAVE_WINSOCK2_H@ && !defined _GL_UNISTD_H
+# undef gethostname
+# define gethostname gethostname_used_without_including_unistd_h
+# endif
+
# if @GNULIB_SOCKET@
# if @HAVE_WINSOCK2_H@
# undef socket
# include <sys/types.h>
#endif
+#if @GNULIB_GETHOSTNAME@
+/* Get all possible declarations of gethostname(). */
+# if @UNISTD_H_HAVE_WINSOCK2_H@
+# include <winsock2.h>
+# if !defined _GL_SYS_SOCKET_H
+# undef socket
+# define socket socket_used_without_including_sys_socket_h
+# undef connect
+# define connect connect_used_without_including_sys_socket_h
+# undef accept
+# define accept accept_used_without_including_sys_socket_h
+# undef bind
+# define bind bind_used_without_including_sys_socket_h
+# undef getpeername
+# define getpeername getpeername_used_without_including_sys_socket_h
+# undef getsockname
+# define getsockname getsockname_used_without_including_sys_socket_h
+# undef getsockopt
+# define getsockopt getsockopt_used_without_including_sys_socket_h
+# undef listen
+# define listen listen_used_without_including_sys_socket_h
+# undef recv
+# define recv recv_used_without_including_sys_socket_h
+# undef send
+# define send send_used_without_including_sys_socket_h
+# undef recvfrom
+# define recvfrom recvfrom_used_without_including_sys_socket_h
+# undef sendto
+# define sendto sendto_used_without_including_sys_socket_h
+# undef setsockopt
+# define setsockopt setsockopt_used_without_including_sys_socket_h
+# undef shutdown
+# define shutdown shutdown_used_without_including_sys_socket_h
+# endif
+# if !defined _GL_SYS_SELECT_H
+# undef select
+# define select select_used_without_including_sys_select_h
+# endif
+# endif
+#endif
+
/* The definition of GL_LINK_WARNING is copied here. */
Null terminate it if the name is shorter than LEN.
If the host name is longer than LEN, set errno = EINVAL and return -1.
Return 0 if successful, otherwise set errno and return -1. */
-# if !@HAVE_GETHOSTNAME@
+# if @UNISTD_H_HAVE_WINSOCK2_H@
+# undef gethostname
+# define gethostname rpl_gethostname
+# endif
+# if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@
extern int gethostname(char *name, size_t len);
# endif
+#elif @UNISTD_H_HAVE_WINSOCK2_H@
+# undef gethostname
+# define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
#elif defined GNULIB_POSIXCHECK
# undef gethostname
# define gethostname(n,l) \
-# gethostname.m4 serial 3
+# gethostname.m4 serial 4
dnl Copyright (C) 2002, 2008 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
AC_DEFUN([gl_FUNC_GETHOSTNAME],
[
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+ gl_PREREQ_SYS_H_WINSOCK2
AC_REPLACE_FUNCS(gethostname)
if test $ac_cv_func_gethostname = no; then
HAVE_GETHOSTNAME=0
Files:
lib/gethostname.c
m4/gethostname.m4
+m4/sys_socket_h.m4
Depends-on:
unistd