]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Windows cross-compile cleanup
authorAlon Bar-Lev <alon.barlev@gmail.com>
Fri, 4 Mar 2011 21:14:33 +0000 (23:14 +0200)
committerDavid Sommerseth <davids@redhat.com>
Thu, 24 Mar 2011 20:58:25 +0000 (21:58 +0100)
It should be sufficient to just try to see if socklen_t is defined.
Next, on all platforms it would be int in all other platforms.
And, there is no need to check for the type in monolitic environment
like Windows, as it will be always the same.

Currently it fails cross compile windows in mingw-w64 compiler, as
winsock.h is as follows:
   """
     /* define WINSOCK_API_LINKAGE and WSAAPI for less
      * diff output between winsock.h and winsock2.h, but
      * remember to undefine them at the end of file */
   """
And the macro uses these macros which are internal winsock macros and
should not be used anyway.

Also, when did the autodefs.h went mandatory? Why is it in
tap-win32/common.h while no constant is actually used?

The use of WSA_IO_INCOMPLETE without including winsock2.h is invalid!
Look at http://msdn.microsoft.com/en-us/library/aa921087.aspx

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: James Yonan <james@openvpn.net>
Signed-off-by: David Sommerseth <davids@redhat.com>
acinclude.m4
configure.ac
syshead.h
tap-win32/common.h

index f037484c4493465766b8afd5c3f04a6b3ff0f871..185907f9f876fe4f0fdd7ceeedb1dfd8341c6849 100644 (file)
@@ -90,34 +90,30 @@ AC_DEFUN([TYPE_SOCKLEN_T],
       AC_MSG_CHECKING([for socklen_t equivalent])
       AC_CACHE_VAL([curl_cv_socklen_t_equiv],
       [
-         # Systems have either "struct sockaddr *" or
-         # "void *" as the second argument to getpeername
-         curl_cv_socklen_t_equiv=
-         for arg2 in "struct sockaddr" void; do
-            for t in int size_t unsigned long "unsigned long"; do
-               AC_TRY_COMPILE([
-                  #ifdef _WIN32
-                  #include <windows.h>
-                  #define PREFIX1 WINSOCK_API_LINKAGE
-                  #define PREFIX2 PASCAL
-                  #else
-                  #include <sys/types.h>
-                  #include <sys/socket.h>
-                  #define PREFIX1
-                  #define PREFIX2
-                  #define SOCKET int
-                  #endif
+         case "$host" in
+        *-mingw*) curl_cv_socklen_t_equiv=int ;;
+        *)
+            # Systems have either "struct sockaddr *" or
+            # "void *" as the second argument to getpeername
+            curl_cv_socklen_t_equiv=
+            for arg2 in "struct sockaddr" void; do
+               for t in int size_t unsigned long "unsigned long"; do
+                  AC_TRY_COMPILE([
+                     #include <sys/types.h>
+                     #include <sys/socket.h>
 
-                  PREFIX1 int PREFIX2 getpeername (SOCKET, $arg2 *, $t *);
-               ],[
-                  $t len;
-                  getpeername(0,0,&len);
-               ],[
-                  curl_cv_socklen_t_equiv="$t"
-                  break
-               ])
+                     int getpeername (int, $arg2 *, $t *);
+                  ],[
+                     $t len;
+                     getpeername(0,0,&len);
+                  ],[
+                     curl_cv_socklen_t_equiv="$t"
+                     break
+                  ])
+               done
             done
-         done
+        ;;
+        esac
 
          if test "x$curl_cv_socklen_t_equiv" = x; then
             AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
index e30f990486ebf0e5cee63ed2a472fae8e0528205..e0847bccd20f95b772bf9e6a0fae8c30525c8f54 100644 (file)
@@ -320,6 +320,7 @@ case "$host" in
        ;;
 *-mingw*)
        AC_DEFINE(TARGET_WIN32, 1, [Are we running WIN32?])
+       CPPFLAGS="${CPPFLAGS} -DWIN32_LEAN_AND_MEAN"
        OPENVPN_ADD_LIBS(-lgdi32)
        OPENVPN_ADD_LIBS(-lws2_32)
        OPENVPN_ADD_LIBS(-lwininet)
index cef7dbfa5102279c949c73c60e27adc3912301af..63b82babc73d76dcaed42e4dd805108db58e1bc3 100644 (file)
--- a/syshead.h
+++ b/syshead.h
@@ -47,6 +47,7 @@
 
 #ifdef WIN32
 #include <windows.h>
+#include <winsock2.h>
 #define sleep(x) Sleep((x)*1000)
 #define random rand
 #define srandom srand
index 6785a33fdea1c22a60378b15cdf6d70c1c38077c..bb8ab903516f90343eef511213b316b68c287c11 100755 (executable)
@@ -28,7 +28,9 @@
 // common to both.
 //===============================================
 
+#ifndef HAVE_CONFIG_H
 #include "autodefs.h"
+#endif
 
 //=============
 // TAP IOCTLs