Mercurial > hg > octave-kai > gnulib-hg
changeset 10716:16c473421488
Override the gethostname() declaration on native Windows systems.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sat, 25 Oct 2008 23:13:43 +0200 |
parents | 6549114b70b4 |
children | 386b7e3ee21a |
files | ChangeLog doc/posix-functions/gethostname.texi lib/sys_socket.in.h lib/unistd.in.h m4/gethostname.m4 modules/gethostname |
diffstat | 6 files changed, 73 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +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
--- a/doc/posix-functions/gethostname.texi +++ b/doc/posix-functions/gethostname.texi @@ -9,8 +9,8 @@ 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:
--- a/lib/sys_socket.in.h +++ b/lib/sys_socket.in.h @@ -145,6 +145,11 @@ # 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
--- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -42,6 +42,47 @@ # 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. */ @@ -284,9 +325,16 @@ 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) \
--- a/m4/gethostname.m4 +++ b/m4/gethostname.m4 @@ -1,4 +1,4 @@ -# 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, @@ -7,6 +7,7 @@ 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