From 4492bcd9ef1f625c8acc56f637c77ca1f1c693ea Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 16 Feb 2006 23:34:00 +0000 Subject: Sync from gnulib. --- m4/ChangeLog | 12 ++++++++++++ m4/getaddrinfo.m4 | 13 ++++++++----- m4/socklen.m4 | 30 +++++++++++++++--------------- m4/sys_socket_h.m4 | 23 +++++++++++++++++++++++ 4 files changed, 58 insertions(+), 20 deletions(-) create mode 100644 m4/sys_socket_h.m4 (limited to 'm4') diff --git a/m4/ChangeLog b/m4/ChangeLog index 699fe70ac..4af8ed81d 100644 --- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,15 @@ +2006-02-16 Eric Blake + + Sync from gnulib. + * sys_socket_h.m4: New file. Solves 'present but cannot compile' + warnings on cygwin, which cannot use ws2tcpip.h. + * socklen.m4 (gl_TYPE_SOCKLEN_T): Use gl_HEADER_SYS_SOCKET. + Don't use ws2tcpip.h if sys/socket.h works. + * getaddrinfo.m4 (gl_PREREQ_GETADDRINFO): Use + gl_HEADER_SYS_SOCKET. + (gl_GETADDRINFO): Don't use ws2tcpip.h when sys/socket.h is + present. + 2006-02-14 Simon Josefsson Sync from gnulib. diff --git a/m4/getaddrinfo.m4 b/m4/getaddrinfo.m4 index 006cdab2a..3c6a86915 100644 --- a/m4/getaddrinfo.m4 +++ b/m4/getaddrinfo.m4 @@ -1,4 +1,4 @@ -# getaddrinfo.m4 serial 7 +# getaddrinfo.m4 serial 8 dnl Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -11,19 +11,21 @@ AC_DEFUN([gl_GETADDRINFO], AC_SEARCH_LIBS(getaddrinfo, [nsl socket]) AC_CHECK_FUNCS(getaddrinfo,, [ AC_CACHE_CHECK(for getaddrinfo in ws2tcpip.h and -lws2_32, - gl_cv_w32_getaddrinfo, [ + gl_cv_w32_getaddrinfo, [ gl_cv_w32_getaddrinfo=no am_save_LIBS="$LIBS" LIBS="$LIBS -lws2_32" AC_TRY_LINK([ +#ifdef HAVE_WS2TCPIP_H #define WINVER 0x0501 #include +#endif ], [getaddrinfo(0, 0, 0, 0);], gl_cv_w32_getaddrinfo=yes) LIBS="$am_save_LIBS" if test "$gl_cv_w32_getaddrinfo" = "yes"; then - LIBS="$LIBS -lws2_32" + LIBS="$LIBS -lws2_32" else - AC_LIBOBJ(getaddrinfo) + AC_LIBOBJ(getaddrinfo) fi ])]) @@ -37,9 +39,10 @@ AC_DEFUN([gl_PREREQ_GETADDRINFO], [ AC_SEARCH_LIBS(getservbyname, [inet nsl socket xnet]) AC_REQUIRE([gl_C_RESTRICT]) AC_REQUIRE([gl_SOCKET_FAMILIES]) + AC_REQUIRE([gl_HEADER_SYS_SOCKET]) AC_REQUIRE([AC_C_INLINE]) AC_REQUIRE([AC_GNU_SOURCE]) - AC_CHECK_HEADERS_ONCE(netinet/in.h sys/socket.h netdb.h ws2tcpip.h) + AC_CHECK_HEADERS_ONCE(netinet/in.h netdb.h) AC_CHECK_DECLS([getaddrinfo, freeaddrinfo, gai_strerror],,,[ /* sys/types.h is not needed according to POSIX, but the sys/socket.h in i386-unknown-freebsd4.10 and diff --git a/m4/socklen.m4 b/m4/socklen.m4 index 01da2b547..5e3765a64 100644 --- a/m4/socklen.m4 +++ b/m4/socklen.m4 @@ -1,4 +1,4 @@ -# socklen.m4 serial 3 +# socklen.m4 serial 4 dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -13,40 +13,40 @@ dnl have to test to find something that will work. dnl On mingw32, socklen_t is in ws2tcpip.h ('int'), so we try to find dnl it there first. That file is included by gnulib's socket_.h, which -dnl all users of this module should include. +dnl all users of this module should include. Cygwin must not include +dnl ws2tcpip.h. AC_DEFUN([gl_TYPE_SOCKLEN_T], - [AC_CHECK_HEADERS_ONCE([sys/socket.h ws2tcpip.h]) + [AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl AC_CHECK_TYPE([socklen_t], , [AC_MSG_CHECKING([for socklen_t equivalent]) AC_CACHE_VAL([gl_cv_gl_cv_socklen_t_equiv], - [# Systems have either "struct sockaddr *" or - # "void *" as the second argument to getpeername - gl_cv_socklen_t_equiv= - for arg2 in "struct sockaddr" void; do + [# Systems have either "struct sockaddr *" or + # "void *" as the second argument to getpeername + gl_cv_socklen_t_equiv= + for arg2 in "struct sockaddr" void; do for t in int size_t "unsigned int" "long int" "unsigned long int"; do AC_TRY_COMPILE( [#include - #include + #include int getpeername (int, $arg2 *, $t *);], - [$t len; + [$t len; getpeername (0, 0, &len);], [gl_cv_socklen_t_equiv="$t"]) - test "$gl_cv_socklen_t_equiv" != "" && break + test "$gl_cv_socklen_t_equiv" != "" && break done - test "$gl_cv_socklen_t_equiv" != "" && break - done + test "$gl_cv_socklen_t_equiv" != "" && break + done ]) if test "$gl_cv_socklen_t_equiv" = ""; then AC_MSG_ERROR([Cannot find a type to use in place of socklen_t]) fi AC_MSG_RESULT([$gl_cv_socklen_t_equiv]) AC_DEFINE_UNQUOTED([socklen_t], [$gl_cv_socklen_t_equiv], - [type to use in place of socklen_t if not defined])], + [type to use in place of socklen_t if not defined])], [#include #if HAVE_SYS_SOCKET_H # include - #endif - #if HAVE_WS2TCPIP_H + #elif HAVE_WS2TCPIP_H # include #endif])]) diff --git a/m4/sys_socket_h.m4 b/m4/sys_socket_h.m4 new file mode 100644 index 000000000..d3e45b48c --- /dev/null +++ b/m4/sys_socket_h.m4 @@ -0,0 +1,23 @@ +# sys_socket_h.m4 serial 2 +dnl Copyright (C) 2005, 2006 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. + +dnl From Simon Josefsson. + +AC_DEFUN([gl_HEADER_SYS_SOCKET], +[ + AC_CHECK_HEADERS_ONCE([sys/socket.h]) + if test $ac_cv_header_sys_socket_h = yes; then + SYS_SOCKET_H='' + else + dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make + dnl the check for those headers unconditional; yet cygwin reports + dnl that the headers are present but cannot be compiled (since on + dnl cygwin, all socket information should come from sys/socket.h). + AC_CHECK_HEADERS([winsock2.h ws2tcpip.h]) + SYS_SOCKET_H='sys/socket.h' + fi + AC_SUBST(SYS_SOCKET_H) +]) -- cgit v1.2.3-54-g00ecf