cURL / Mailing Lists / curl-library / Single Mail

curl-library

[patch] several Cygwin fixes

From: Brian Dessent <brian_at_dessent.net>
Date: Wed, 07 Jun 2006 22:42:02 -0700

Attached are some various Cygwin fixes; I've left them as three separate
patches for easier review.

The first modifies {lib,src}/setup.h to not include the winsock headers
under Cygwin. This fixes the reported build problem. Cygwin attempts
as much as possible to emulate a posix environment under Windows. This
means that WIN32 is *not* #defined and (to the extent possible)
everything is done as it would be on a *ix type system. Thus
<sys/socket.h> is the proper include, and even though winsock2.h is
present, including it just introduces a whole bunch of incompatible
socket API stuff.

The second is a patch I've included in the Cygwin binary packages for a
while. It skips two unnecessary library checks (-lwinmm and -lgdi32).
The checks are innocuous and they do succeed, but they pollute LIBS with
unnecessary stuff which gets recorded as such in the libcurl.la file,
which brings them into the build of any libcurl-downstream. As far as I
know these libs are really only necessary for mingw, so alternatively
they could be designed to only run if $host matches *-*-mingw* but I
took the safer route of skipping them for *-*-cygwin*.

The third patch replaces all uses of the ancient and obsolete
__CYGWIN32__ with __CYGWIN__. Ref:
<http://cygwin.com/ml/cygwin/2003-09/msg01520.html>.

With these patches and current CVS every test except for 160 passes
under Cygwin. I'm not exactly sure what's wrong there. The output of
runtest.pl -v 160 is below, maybe it rings a bell:

********* System characteristics ********
* curl 7.15.4-CVS (i686-pc-cygwin)
* libcurl/7.15.4-CVS OpenSSL/0.9.8a zlib/1.2.3
* Features: Largefile NTLM SSL libz
* Host: booch
* System: CYGWIN_NT-5.1 booch 1.5.20(0.155/4/2) 2006-06-04 16:33 i686
Cygwin
* Server SSL: OFF
* libcurl SSL: ON
* libcurl debug: OFF
* valgrind: OFF
* HTTP IPv6 OFF
* FTP IPv6 OFF
* HTTP port: 8990
* FTP port: 8992
* FTP port 2: 8995
* TFTP port: 8997
* SSL library: OpenSSL
* Libtool lib: ON
*****************************************
startnew: perl -I/usr/src/curl/tests /usr/src/curl/tests/httpserver.pl
-p .http.pid -d "/usr/src/curl/tests" 8990
CMD; ../src/curl -m13 -o log/verifiedserver -ksvg
"http://127.0.0.1:8990/verifiedserver" 2>log/verifyhttp
RUN: HTTP server is now running PID 1548
* pid http => 1548 1548
test 160...[HTTP with delayed close, conn reuse, connection reset and
retry]
../src/curl --include -v --trace-time http://127.0.0.1:8990/want/160
http://127.0.0.1:8990/wantmore/1600001 >>log/stdout160 2>>log/stderr160

 stdout FAILED:
--- log/check-expected 2006-06-07 22:20:59.093750000 -0700
+++ log/check-generated 2006-06-07 22:20:59.093750000 -0700
@@ -3,8 +3,3 @@
 Content-Length: 9
 
 surprise
-HTTP/1.1 200 OK swsclose
-Date: Thu, 09 Nov 2010 14:49:00 GMT
-Connection: close
-
-surprise2

 - abort tests
* kill pid for http => 1548
RUN: Test server pid 1548 signalled to die
TESTDONE: 0 tests out of 1 reported OK: 0%
TESTFAIL: These test cases failed: 160
TESTDONE: 1 tests were considered during 4 seconds.

Brian

Index: lib/setup.h
===================================================================
RCS file: /cvsroot/curl/curl/lib/setup.h,v
retrieving revision 1.109
diff -u -p -u -p -r1.109 setup.h
--- lib/setup.h 26 Apr 2006 17:11:05 -0000 1.109
+++ lib/setup.h 8 Jun 2006 05:11:31 -0000
@@ -79,10 +79,12 @@
  * Include header files for windows builds before redefining anything.
  * Use this preproessor block only to include or exclude windows.h,
  * winsock2.h, ws2tcpip.h or winsock.h. Any other windows thing belongs
- * to any other further and independant block.
+ * to any other further and independant block. Under Cygwin things work
+ * just as under linux (e.g. <sys/socket.h>) and the winsock headers should
+ * never be included.
  */
 
-#ifdef HAVE_WINDOWS_H
+#if defined(HAVE_WINDOWS_H) && !defined(__CYGWIN__)
 # ifndef WIN32_LEAN_AND_MEAN
 # define WIN32_LEAN_AND_MEAN
 # endif
Index: src/setup.h
===================================================================
RCS file: /cvsroot/curl/curl/src/setup.h,v
retrieving revision 1.40
diff -u -p -u -p -r1.40 setup.h
--- src/setup.h 7 Apr 2006 21:50:47 -0000 1.40
+++ src/setup.h 8 Jun 2006 05:11:31 -0000
@@ -81,10 +81,12 @@
  * Include header files for windows builds before redefining anything.
  * Use this preproessor block only to include or exclude windows.h,
  * winsock2.h, ws2tcpip.h or winsock.h. Any other windows thing belongs
- * to any other further and independant block.
+ * to any other further and independant block. Under Cygwin things work
+ * just as under linux (e.g. <sys/socket.h>) and the winsock headers should
+ * never be included.
  */
 
-#ifdef HAVE_WINDOWS_H
+#if defined(HAVE_WINDOWS_H) && !defined(__CYGWIN__)
 # ifndef WIN32_LEAN_AND_MEAN
 # define WIN32_LEAN_AND_MEAN
 # endif

Index: configure.ac
===================================================================
RCS file: /cvsroot/curl/curl/configure.ac,v
retrieving revision 1.195
diff -u -p -u -p -r1.195 configure.ac
--- configure.ac 23 May 2006 22:55:46 -0000 1.195
+++ configure.ac 8 Jun 2006 05:12:22 -0000
@@ -472,20 +472,31 @@ dnl ************************************
 dnl Check for the presence of the winmm library.
 dnl **********************************************************************
 
-AC_MSG_CHECKING([for timeGetTime in winmm])
-my_ac_save_LIBS=$LIBS
-LIBS="-lwinmm $LIBS"
-AC_TRY_LINK([#include <windef.h>
- #include <mmsystem.h>
- ],
- [timeGetTime();],
- [ dnl worked!
- AC_MSG_RESULT([yes])
- ],
- [ dnl failed, restore LIBS
- LIBS=$my_ac_save_LIBS
- AC_MSG_RESULT(no)]
- )
+case $host in
+ *-*-cygwin*)
+ dnl Under Cygwin, winmm exists but is not needed as WIN32 is not #defined
+ dnl and gettimeofday() will be used regardless of the outcome of this test.
+ dnl Skip this test, otherwise -lwinmm will be needlessly added to LIBS
+ dnl (and recorded as such in the .la file, potentially affecting downstream
+ dnl clients of the library.)
+ ;;
+ *)
+ AC_MSG_CHECKING([for timeGetTime in winmm])
+ my_ac_save_LIBS=$LIBS
+ LIBS="-lwinmm $LIBS"
+ AC_TRY_LINK([#include <windef.h>
+ #include <mmsystem.h>
+ ],
+ [timeGetTime();],
+ [ dnl worked!
+ AC_MSG_RESULT([yes])
+ ],
+ [ dnl failed, restore LIBS
+ LIBS=$my_ac_save_LIBS
+ AC_MSG_RESULT(no)]
+ )
+ ;;
+esac
 
 dnl **********************************************************************
 dnl Checks for IPv6
@@ -888,18 +899,26 @@ if test X"$OPT_SSL" != Xno; then
   fi
 
   dnl This is for Msys/Mingw
- AC_MSG_CHECKING([for gdi32])
- my_ac_save_LIBS=$LIBS
- LIBS="-lgdi32 $LIBS"
- AC_TRY_LINK([#include <windef.h>
- #include <wingdi.h>],
- [GdiFlush();],
- [ dnl worked!
- AC_MSG_RESULT([yes])],
- [ dnl failed, restore LIBS
- LIBS=$my_ac_save_LIBS
- AC_MSG_RESULT(no)]
- )
+ case $host in
+ *-*-cygwin*)
+ dnl Under Cygwin this is extraneous and causes an unnecessary -lgdi32
+ dnl to be added to LIBS and recorded in the .la file.
+ ;;
+ *)
+ AC_MSG_CHECKING([for gdi32])
+ my_ac_save_LIBS=$LIBS
+ LIBS="-lgdi32 $LIBS"
+ AC_TRY_LINK([#include <windef.h>
+ #include <wingdi.h>],
+ [GdiFlush();],
+ [ dnl worked!
+ AC_MSG_RESULT([yes])],
+ [ dnl failed, restore LIBS
+ LIBS=$my_ac_save_LIBS
+ AC_MSG_RESULT(no)]
+ )
+ ;;
+ esac
 
   AC_CHECK_LIB(crypto, CRYPTO_lock,[
      HAVECRYPTO="yes"

Index: lib/if2ip.c
===================================================================
RCS file: /cvsroot/curl/curl/lib/if2ip.c,v
retrieving revision 1.44
diff -u -p -u -p -r1.44 if2ip.c
--- lib/if2ip.c 13 Jul 2005 18:06:40 -0000 1.44
+++ lib/if2ip.c 8 Jun 2006 05:13:26 -0000
@@ -33,7 +33,7 @@
 
 #include "if2ip.h"
 
-#if !defined(WIN32) && !defined(__BEOS__) && !defined(__CYGWIN32__) && \
+#if !defined(WIN32) && !defined(__BEOS__) && !defined(__CYGWIN__) && \
     !defined(__riscos__) && !defined(__INTERIX) && !defined(NETWARE) && \
     !defined(_AMIGASF)
 
Index: lib/url.c
===================================================================
RCS file: /cvsroot/curl/curl/lib/url.c,v
retrieving revision 1.504
diff -u -p -u -p -r1.504 url.c
--- lib/url.c 26 May 2006 11:26:42 -0000 1.504
+++ lib/url.c 8 Jun 2006 05:13:26 -0000
@@ -157,7 +157,7 @@ static long ConnectionStore(struct Sessi
 #ifndef USE_ARES
 /* not for Win32, unless it is cygwin
    not for ares builds */
-#if !defined(WIN32) || defined(__CYGWIN32__)
+#if !defined(WIN32) || defined(__CYGWIN__)
 
 #ifndef RETSIGTYPE
 #define RETSIGTYPE void
Index: src/main.c
===================================================================
RCS file: /cvsroot/curl/curl/src/main.c,v
retrieving revision 1.358
diff -u -p -u -p -r1.358 main.c
--- src/main.c 25 Apr 2006 21:41:05 -0000 1.358
+++ src/main.c 8 Jun 2006 05:13:27 -0000
@@ -3242,7 +3242,7 @@ static void free_config_fields(struct Co
   curl_slist_free_all(config->headers);
 }
 
-#if defined(WIN32) && !defined(__CYGWIN32__)
+#if defined(WIN32) && !defined(__CYGWIN__)
 
 /* Function to find CACert bundle on a Win32 platform using SearchPath.
  * (SearchPath is already declared via inclusions done in setup header file)
@@ -3485,7 +3485,7 @@ operate(struct Configurable *config, int
 
     if(env)
       curl_free(env);
-#if defined(WIN32) && !defined(__CYGWIN32__)
+#if defined(WIN32) && !defined(__CYGWIN__)
     else
       FindWin32CACert(config, "curl-ca-bundle.crt");
 #endif
Received on 2006-06-08