bug-gnulib
[Top][All Lists]
Advanced

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

Re: setsockopt on mingw


From: Simon Josefsson
Subject: Re: setsockopt on mingw
Date: Mon, 28 Apr 2008 16:39:08 +0200
User-agent: Gnus/5.110009 (No Gnus v0.9) Emacs/22.2 (gnu/linux)

Bruno Haible <address@hidden> writes:

> Simon Josefsson wrote:
>> +# if defined _WIN32 || defined __WIN32__
>
> This is not the right preprocessor test for mingw: It may also evaluate to
> true on Cygwin. But Cygwin has the right declaration of setsockopt and does
> not need a fix. The right #if here is
>
> #if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
>
> or - since you are actually handling a problem in the include files, not
> in the operating system -:
>
> #if defined __MINGW32__

Since the problem is in win32's native include files too (as opposed to
in just mingw's include files), the first form seemed more appropriate
to me.  Patch below applied.

> This uses 'inline', so needs AC_REQUIRE([AC_C_INLINE]) in the *.m4 macros.
> (Otherwise a syntax error occurs when someone compiles with "gcc -ansi".)

Right.  Patch below applied.

Thanks,
/Simon

>From c404b31376e0fc0373e063a95195d678f970212e Mon Sep 17 00:00:00 2001
From: Simon Josefsson <address@hidden>
Date: Mon, 28 Apr 2008 16:38:34 +0200
Subject: [PATCH] Fix proper win32 checks and use of inline for setsockopt.
 Reported by Bruno Haible  <address@hidden>.

---
 ChangeLog           |    7 +++++++
 lib/sys_socket.in.h |    2 +-
 m4/sys_socket_h.m4  |    1 +
 3 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c0163e8..147e944 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-04-28  Simon Josefsson  <address@hidden>
+
+       * m4/sys_socket_h.m4: Require AC_C_INLINE when necessary.
+       * lib/sys_socket.in.h (setsockopt): Use proper win32 tests (don't
+       trigger for cygwin).
+       Reported by Bruno Haible  <address@hidden>.
+
 2008-04-28  Bruno Haible  <address@hidden>
 
        * doc/posix-functions/strdup.texi: Mention mingw problem.
diff --git a/lib/sys_socket.in.h b/lib/sys_socket.in.h
index d2a081f..ea39a35 100644
--- a/lib/sys_socket.in.h
+++ b/lib/sys_socket.in.h
@@ -102,7 +102,7 @@
 #  define ESHUTDOWN               WSAESHUTDOWN
 # endif
 
-# if defined _WIN32 || defined __WIN32__
+# if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
 #  define setsockopt(a,b,c,d,e) rpl_setsockopt(a,b,c,d,e)
 static inline int
 rpl_setsockopt(int socket, int level, int optname, const void *optval,
diff --git a/m4/sys_socket_h.m4 b/m4/sys_socket_h.m4
index 0e735a9..5526c06 100644
--- a/m4/sys_socket_h.m4
+++ b/m4/sys_socket_h.m4
@@ -45,6 +45,7 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET],
       HAVE_WINSOCK2_H=0
       HAVE_WS2TCPIP_H=0
     else
+      AC_REQUIRE([AC_C_INLINE])
       HAVE_SYS_SOCKET_H=0
       dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make
       dnl the check for those headers unconditional; yet cygwin reports
-- 
1.5.5





reply via email to

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