bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: canon-host problems in cygwin


From: Eric Blake
Subject: Re: canon-host problems in cygwin
Date: Thu, 16 Feb 2006 14:30:14 -0700
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[dropping bug-gnulib, now that patch has been applied there]

It turns out
http://lists.gnu.org/archive/html/bug-coreutils/2006-02/msg00083.html
wasn't entirely safe.

According to Eric Blake on 2/15/2006 4:28 PM:
> And here is a patch.  The cygwin list confirmed that <sys/socket.h>
> and <ws2tcpip.h> are intentionally incompatible, and that
> although the later is available for use in mingw compiles, it
> purposefully errors out if <sys/socket.h> was already in use.

Rewritten for application to coreutils CVS.  Without this patch, building
on cygwin fails with a link error due to trying to pull in a non-cygwin
implementation of getaddrinfo from the non-standard winsock libraries.

m4/ChangeLog:
2006-02-16  Eric Blake  <address@hidden>

        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.

- --
Life is short - so eat dessert first!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFD9O7l84KuGfSFAYARAp3qAKC+H5P5CnqxvkZ+mTcs3GmA+1J3+wCfUSiS
boC91M+q8LeODokjQcPdtvI=
=sLpB
-----END PGP SIGNATURE-----
Index: m4/getaddrinfo.m4
===================================================================
RCS file: /sources/coreutils/coreutils/m4/getaddrinfo.m4,v
retrieving revision 1.10
diff -u -p -r1.10 getaddrinfo.m4
--- m4/getaddrinfo.m4   14 Feb 2006 23:09:00 -0000      1.10
+++ m4/getaddrinfo.m4   16 Feb 2006 21:19:45 -0000
@@ -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 <ws2tcpip.h>
+#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
Index: m4/socklen.m4
===================================================================
RCS file: /sources/coreutils/coreutils/m4/socklen.m4,v
retrieving revision 1.3
diff -u -p -r1.3 socklen.m4
--- m4/socklen.m4       14 Feb 2006 23:09:00 -0000      1.3
+++ m4/socklen.m4       16 Feb 2006 21:19:45 -0000
@@ -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 
 
 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 <sys/types.h>
-                #include <sys/socket.h>
+               #include <sys/socket.h>
 
                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 <sys/types.h>
       #if HAVE_SYS_SOCKET_H
       # include <sys/socket.h>
-      #endif
-      #if HAVE_WS2TCPIP_H
+      #elif HAVE_WS2TCPIP_H
       # include <ws2tcpip.h>
       #endif])])
Index: m4/sys_socket_h.m4
===================================================================
RCS file: m4/sys_socket_h.m4
diff -N m4/sys_socket_h.m4
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ m4/sys_socket_h.m4  16 Feb 2006 21:19:45 -0000
@@ -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)
+])

reply via email to

[Prev in Thread] Current Thread [Next in Thread]