Implemented fixes allowing libwebsockets to be built under Windows using MinGM/MSYS
authorStephan Eberle <stephaneberle9@gmail.com>
Fri, 23 Oct 2015 06:10:55 +0000 (08:10 +0200)
committerJoakim Söderberg <joakim.soderberg@gmail.com>
Thu, 29 Oct 2015 23:16:40 +0000 (00:16 +0100)
Improvemed patches to address travis and appveyor build errors

Reduced WINVER and _WIN32_WINNT to 0x0501 to be less restrictive

Refined CMakeLists.txt to allow for normal Windows and MinGW-specific OpenSSL certificate generation

Simplified include path to gettimeofday.h

Removed unnecessary list(APPEND LWS_LIBRARIES zlib_internal) export

Added back #include <windows.h> to gettimeofday.c to fix build for normal Windows

Made sure that pollfd gets defined on libwebsockets side when _WIN32_WINNT < 0x0600

Made sure that WINVER and _WIN32_WINNT don't get overridden by libwebsockets headers when already set to something greater than 0x0501

Added missing declaration of WSAPoll function for WINVER < 0x0600 in libwebsockets.h, eliminated invalid usages of pollfd instead of libwebsocket_pollfd in test-server.c

Cleaned up duplicate content in gettimeofday.c, removed header inclusions from gettimeofday.h and fixed include order in test-echo.c, test-ping.c and test-server.c to enable build with normal Windows and MinGW

Re-enabled debug_level in test-echo.c and made sure that the call to lws_set_log_level() is also active under Windows (just like in test-server.c); replaced all WIN32 occurrences by _WIN32 in test-echo.c, test-ping.c, and test-server.c

Removed build-msys.sh and added new section about how to build libwebsockets using MinGW to README.build.md

16 files changed:
CMakeLists.txt
README.build.md
lib/client-handshake.c
lib/client.c
lib/context.c
lib/libwebsockets.h
lib/output.c
lib/private-libwebsockets.h
lib/ssl.c
test-server/test-echo.c
test-server/test-ping.c
test-server/test-server.c
win32port/win32helpers/gettimeofday.c
win32port/win32helpers/gettimeofday.h
win32port/zlib/gzguts.h
win32port/zlib/zutil.h

index b805820..fcabdfb 100644 (file)
@@ -211,6 +211,7 @@ endif()
 
 if (MINGW)
        set(LWS_MINGW_SUPPORT 1)
+       set(CMAKE_C_FLAGS "-D__USE_MINGW_ANSI_STDIO ${CMAKE_C_FLAGS}")
 endif()
 
 include_directories("${PROJECT_BINARY_DIR}")
@@ -736,27 +737,34 @@ if (NOT LWS_WITHOUT_TESTAPPS)
                        set(TEST_SERVER_SSL_CERT "${PROJECT_BINARY_DIR}/libwebsockets-test-server.pem")
 
                        if (WIN32)
-                               file(WRITE "${PROJECT_BINARY_DIR}/openssl_input.txt"
-                                       "GB\n"
-                                       "Erewhon\n"
-                                       "All around\n"
-                                       "libwebsockets-test\n"
-                                       "localhost\n"
-                                       "none@invalid.org\n\n"
-                                       )
-
-                               # The "type" command is a bit picky with paths.
-                               file(TO_NATIVE_PATH "${PROJECT_BINARY_DIR}/openssl_input.txt" OPENSSL_INPUT_WIN_PATH)
-                               message("OPENSSL_INPUT_WIN_PATH = ${OPENSSL_INPUT_WIN_PATH}")
-                               message("cmd = \"${OPENSSL_EXECUTABLE}\" req -new -newkey rsa:1024 -days 10000 -nodes -x509 -keyout \"${TEST_SERVER_SSL_KEY}\" -out \"${TEST_SERVER_SSL_CERT}\"")
-
-                               execute_process(
-                                       COMMAND cmd /c type "${OPENSSL_INPUT_WIN_PATH}"
-                                       COMMAND "${OPENSSL_EXECUTABLE}" req -new -newkey rsa:1024 -days 10000 -nodes -x509 -keyout "${TEST_SERVER_SSL_KEY}" -out "${TEST_SERVER_SSL_CERT}"
-                                       RESULT_VARIABLE OPENSSL_RETURN_CODE
-                                       OUTPUT_QUIET ERROR_QUIET)
-
-                               message("\n")
+                               if (MINGW)
+                                       message("cmd = \"${OPENSSL_EXECUTABLE}\" req -new -newkey rsa:1024 -days 10000 -nodes -x509 -subj \"/C=GB/ST=Erewhon/L=All around/O=libwebsockets-test/CN=localhost\" -keyout \"${TEST_SERVER_SSL_KEY}\" -out \"${TEST_SERVER_SSL_CERT}\"")
+                                       execute_process(
+                                               COMMAND "${OPENSSL_EXECUTABLE}" req -new -newkey rsa:1024 -days 10000 -nodes -x509 -subj "/C=GB/ST=Erewhon/L=All around/O=libwebsockets-test/CN=localhost" -keyout "${TEST_SERVER_SSL_KEY}" -out "${TEST_SERVER_SSL_CERT}"
+                                               RESULT_VARIABLE OPENSSL_RETURN_CODE)
+                               else()
+                                       file(WRITE "${PROJECT_BINARY_DIR}/openssl_input.txt"
+                                               "GB\n"
+                                               "Erewhon\n"
+                                               "All around\n"
+                                               "libwebsockets-test\n"
+                                               "localhost\n"
+                                               "none@invalid.org\n\n"
+                                               )
+
+                                       # The "type" command is a bit picky with paths.
+                                       file(TO_NATIVE_PATH "${PROJECT_BINARY_DIR}/openssl_input.txt" OPENSSL_INPUT_WIN_PATH)
+                                       message("OPENSSL_INPUT_WIN_PATH = ${OPENSSL_INPUT_WIN_PATH}")
+                                       message("cmd = \"${OPENSSL_EXECUTABLE}\" req -new -newkey rsa:1024 -days 10000 -nodes -x509 -keyout \"${TEST_SERVER_SSL_KEY}\" -out \"${TEST_SERVER_SSL_CERT}\"")
+
+                                       execute_process(
+                                               COMMAND cmd /c type "${OPENSSL_INPUT_WIN_PATH}"
+                                               COMMAND "${OPENSSL_EXECUTABLE}" req -new -newkey rsa:1024 -days 10000 -nodes -x509 -keyout "${TEST_SERVER_SSL_KEY}" -out "${TEST_SERVER_SSL_CERT}"
+                                               RESULT_VARIABLE OPENSSL_RETURN_CODE
+                                               OUTPUT_QUIET ERROR_QUIET)
+
+                                       message("\n")
+                               endif()
 
                                if (OPENSSL_RETURN_CODE)
                                        message(WARNING "!!! Failed to generate SSL certificate for Test Server using cmd.exe !!!:\nOpenSSL return code = ${OPENSSL_RETURN_CODE}")
@@ -983,7 +991,9 @@ endif()
 message("---------------------------------------------------------------------")
 message("  Settings:  (For more help do cmake -LH <srcpath>)")
 message("---------------------------------------------------------------------")
-message(" LWS_WITH_SSL = ${LWS_WITH_SSL}  (SSL Support)")
+message(" LWS_WITH_STATIC = ${LWS_WITH_STATIC}")
+message(" LWS_WITH_SHARED = ${LWS_WITH_SHARED}")
+message(" LWS_WITH_SSL = ${LWS_WITH_SSL} (SSL Support)")
 message(" LWS_SSL_CLIENT_USE_OS_CA_CERTS = ${LWS_SSL_CLIENT_USE_OS_CA_CERTS}")
 message(" LWS_USE_WOLFSSL = ${LWS_USE_WOLFSSL} (wolfSSL/CyaSSL replacement for OpenSSL)")
 if (LWS_USE_WOLFSSL)
index f2d0db8..7be216e 100644 (file)
@@ -12,7 +12,8 @@ simply remove your build directory.
 Libwebsockets has been tested to build successfully on the following platforms
 with SSL support (both OpenSSL/wolfSSL):
 
-- Windows
+- Windows (Visual Studio)
+- Windows (MinGW)
 - Linux (x86 and ARM)
 - OSX
 - NetBSD
@@ -91,7 +92,6 @@ Building on Unix:
        $ make
     ```
 
-
 Quirk of cmake
 --------------
 
@@ -99,14 +99,18 @@ When changing cmake options, for some reason the only way to get it to see the
 changes sometimes is delete the contents of your build directory and do the
 cmake from scratch.
 
-
 Building on Windows (Visual Studio)
 -----------------------------------
 1. Install CMake 2.6 or greater: http://cmake.org/cmake/resources/software.html
 
 2. Install OpenSSL binaries. http://www.openssl.org/related/binaries.html
-   (Preferably in the default location to make it easier for CMake to find them)
 
+   (**NOTE**: Preferably in the default location to make it easier for CMake to find them)
+
+   **NOTE2**: 
+   Be sure that OPENSSL_CONF environment variable is defined and points at 
+   <OpenSSL install location>\bin\openssl.cfg
+        
 3. Generate the Visual studio project by opening the Visual Studio cmd prompt:
 
    ```bash
@@ -117,10 +121,81 @@ Building on Windows (Visual Studio)
    ```
 
    (**NOTE**: There is also a cmake-gui available on Windows if you prefer that)
+   
+   **NOTE2**:
+   See this link to find out the version number corresponding to your Visual Studio edition:
+   http://superuser.com/a/194065
 
 4. Now you should have a generated Visual Studio Solution in  your
    `<path to src>/build` directory, which can be used to build.
 
+Building on Windows (MinGW)
+---------------------------
+1. Install MinGW: http://sourceforge.net/projects/mingw/files
+
+   (**NOTE**: Preferably in the default location C:\MinGW)
+
+2. Fix up MinGW headers
+
+   a) Add the following lines to C:\MinGW\include\winsock2.h:
+   
+#if(_WIN32_WINNT >= 0x0600)
+
+typedef struct pollfd {
+
+    SOCKET  fd;
+    SHORT   events;
+    SHORT   revents;
+
+} WSAPOLLFD, *PWSAPOLLFD, FAR *LPWSAPOLLFD;
+
+WINSOCK_API_LINKAGE int WSAAPI WSAPoll(LPWSAPOLLFD fdArray, ULONG fds, INT timeout);
+
+#endif // (_WIN32_WINNT >= 0x0600)
+
+   b) Create C:\MinGW\include\mstcpip.h and copy and paste the content from following link into it:
+    
+   http://wine-unstable.sourcearchive.com/documentation/1.1.32/mstcpip_8h-source.html
+
+3. Install CMake 2.6 or greater: http://cmake.org/cmake/resources/software.html
+
+4. Install OpenSSL binaries. http://www.openssl.org/related/binaries.html
+
+   (**NOTE**: Preferably in the default location to make it easier for CMake to find them)
+
+   **NOTE2**: 
+   Be sure that OPENSSL_CONF environment variable is defined and points at 
+   <OpenSSL install location>\bin\openssl.cfg
+
+5. Generate the build files (default is Make files) using MSYS shell:
+
+   ```bash
+   $ cd /drive/path/to/src
+   $ mkdir build
+   $ cd build
+   $ cmake -G "MSYS Makefiles" -DCMAKE_INSTALL_PREFIX=C:/MinGW ..
+   ```
+
+   (**NOTE**: The `build/`` directory can have any name and be located anywhere
+    on your filesystem, and that the argument `..` given to cmake is simply
+    the source directory of **libwebsockets** containing the [CMakeLists.txt](CMakeLists.txt)
+    project file. All examples in this file assumes you use "..")
+
+   **NOTE2**:
+   To generate build files allowing to create libwebsockets binaries with debug information
+   set the CMAKE_BUILD_TYPE flag to DEBUG:
+
+   ```bash
+   $ cmake -G "MSYS Makefiles" -DCMAKE_INSTALL_PREFIX=C:/MinGW -DCMAKE_BUILD_TYPE=DEBUG ..
+   ```
+
+6. Finally you can build using the generated Makefile and get the results deployed into your MinGW installation:
+
+   ```bash
+   $ make
+   $ make install
+   ```
+
 Setting compile options
 -----------------------
 
@@ -184,7 +259,6 @@ cmake .. -DLWS_USE_CYASSL=1 \
 
 **NOTE**: On windows use the .lib file extension for `LWS_CYASSL_LIBRARIES` instead.
 
-
 Reproducing HTTP2.0 tests
 -------------------------
 
@@ -239,7 +313,6 @@ need to provide the cross libraries otherwise.
 Additional information on cross compilation with CMake:
        http://www.vtk.org/Wiki/CMake_Cross_Compiling
 
-
 Memory efficiency
 -----------------
 
index 0623f51..f8fd6de 100644 (file)
@@ -253,7 +253,7 @@ struct libwebsocket *libwebsocket_client_connect_2(
                        goto failed;
                wsi->u.hdr.ah->c_port = context->http_proxy_port;
 
-               n = send(wsi->sock, context->service_buffer, plen, MSG_NOSIGNAL);
+               n = send(wsi->sock, (char *)context->service_buffer, plen, MSG_NOSIGNAL);
                if (n < 0) {
                        lwsl_debug("ERROR writing to proxy socket\n");
                        goto failed;
index 5afd8ea..33a9d48 100644 (file)
@@ -83,7 +83,7 @@ int lws_client_socket_service(struct libwebsocket_context *context,
                        return 0;
                }
 
-               n = recv(wsi->sock, context->service_buffer,
+               n = recv(wsi->sock, (char *)context->service_buffer,
                                        sizeof(context->service_buffer), 0);
                if (n < 0) {
                        
index 6ac2440..385561d 100644 (file)
@@ -76,9 +76,6 @@ libwebsocket_create_context(struct lws_context_creation_info *info)
 {
        struct libwebsocket_context *context = NULL;
        char *p;
-#ifdef _WIN32
-       int i;
-#endif
        int pid_daemon = get_daemonize_pid();
 
        lwsl_notice("Initial logging level %d\n", log_level);
index 317a6e6..859ee96 100644 (file)
@@ -33,7 +33,12 @@ extern "C" {
 #include "lws_config.h"
 
 #if defined(WIN32) || defined(_WIN32)
-
+#if (WINVER < 0x0501)
+#undef WINVER
+#undef _WIN32_WINNT
+#define WINVER 0x0501
+#define _WIN32_WINNT WINVER
+#endif
 #ifndef WIN32_LEAN_AND_MEAN
 #define WIN32_LEAN_AND_MEAN
 #endif
@@ -238,12 +243,14 @@ struct libwebsocket_pollargs {
     int prev_events;   // the previous event mask
 };
 
-#ifdef _WIN32
+
+#if defined(_WIN32) && (_WIN32_WINNT < 0x0600) 
 struct libwebsocket_pollfd {
        SOCKET fd;
        SHORT events;
        SHORT revents;
 };
+WINSOCK_API_LINKAGE int WSAAPI WSAPoll(struct libwebsocket_pollfd fdArray[], ULONG fds, INT timeout);
 #else
 #define libwebsocket_pollfd pollfd
 #endif
index 785368c..977d1de 100644 (file)
@@ -581,7 +581,7 @@ lws_ssl_capable_read_no_ssl(struct libwebsocket_context *context,
 {
        int n;
 
-       n = recv(wsi->sock, buf, len, 0);
+       n = recv(wsi->sock, (char *)buf, len, 0);
        if (n >= 0)
                return n;
 
@@ -599,7 +599,7 @@ lws_ssl_capable_write_no_ssl(struct libwebsocket *wsi, unsigned char *buf, int l
 {
        int n;
        
-       n = send(wsi->sock, buf, len, MSG_NOSIGNAL);
+       n = send(wsi->sock, (char *)buf, len, MSG_NOSIGNAL);
        if (n >= 0)
                return n;
 
index c9c6996..da6a2d9 100644 (file)
 #endif
 
 #if defined(WIN32) || defined(_WIN32)
+#if (WINVER < 0x0501)
+#undef WINVER
+#undef _WIN32_WINNT
+#define WINVER 0x0501
+#define _WIN32_WINNT WINVER
+#endif
 #define LWS_NO_DAEMONIZE
 #define LWS_ERRNO WSAGetLastError()
 #define LWS_EAGAIN WSAEWOULDBLOCK
index 571c9e1..701ec8e 100644 (file)
--- a/lib/ssl.c
+++ b/lib/ssl.c
@@ -605,7 +605,7 @@ lws_server_socket_service_ssl(struct libwebsocket_context *context,
 
                lws_latency_pre(context, wsi);
 
-               n = recv(wsi->sock, context->service_buffer,
+               n = recv(wsi->sock, (char *)context->service_buffer,
                        sizeof(context->service_buffer), MSG_PEEK);
 
                /*
index 77795c5..6e12c5b 100644 (file)
 #include <assert.h>
 #include <signal.h>
 
+#include "../lib/libwebsockets.h"
+
 #ifndef _WIN32
 #include <syslog.h>
 #include <sys/time.h>
 #include <unistd.h>
+#else
+#include "gettimeofday.h"
+#include <process.h>
 #endif
 
-#include "../lib/libwebsockets.h"
-
 static volatile int force_exit = 0;
 static int versa, state;
 
@@ -189,10 +192,10 @@ int main(int argc, char **argv)
        struct libwebsocket_context *context;
        int opts = 0;
        char interface_name[128] = "";
-       const char *interface = NULL;
+       const char *_interface = NULL;
        char ssl_cert[256] = LOCAL_RESOURCE_PATH"/libwebsockets-test-server.pem";
        char ssl_key[256] = LOCAL_RESOURCE_PATH"/libwebsockets-test-server.key.pem";
-#ifndef WIN32
+#ifndef _WIN32
        int syslog_options = LOG_PID | LOG_PERROR;
 #endif
        int client = 0;
@@ -253,7 +256,7 @@ int main(int argc, char **argv)
 #ifndef LWS_NO_DAEMONIZE
                case 'D':
                        daemonize = 1;
-#ifndef WIN32
+#ifndef _WIN32
                        syslog_options &= ~LOG_PERROR;
 #endif
                        break;
@@ -284,7 +287,7 @@ int main(int argc, char **argv)
                case 'i':
                        strncpy(interface_name, optarg, sizeof interface_name);
                        interface_name[(sizeof interface_name) - 1] = '\0';
-                       interface = interface_name;
+                       _interface = interface_name;
                        break;
                case '?':
                case 'h':
@@ -323,15 +326,15 @@ int main(int argc, char **argv)
 #endif
 #endif
 
-#ifdef WIN32
-#else
+#ifndef _WIN32
        /* we will only try to log things according to our debug_level */
        setlogmask(LOG_UPTO (LOG_DEBUG));
        openlog("lwsts", syslog_options, LOG_DAEMON);
+#endif
 
        /* tell the library what debug level to emit and to send it to syslog */
        lws_set_log_level(debug_level, lwsl_emit_syslog);
-#endif
+
        lwsl_notice("libwebsockets echo test - "
                    "(C) Copyright 2010-2015 Andy Green <andy@warmcat.com> - "
                    "licensed under LGPL2.1\n");
@@ -357,7 +360,7 @@ int main(int argc, char **argv)
 #endif
 
        info.port = listen_port;
-       info.iface = interface;
+       info.iface = _interface;
        info.protocols = protocols;
 #ifndef LWS_NO_EXTENSIONS
        info.extensions = libwebsocket_get_internal_extensions();
@@ -422,8 +425,7 @@ bail:
        libwebsocket_context_destroy(context);
 
        lwsl_notice("libwebsockets-test-echo exited cleanly\n");
-#ifdef WIN32
-#else
+#ifndef _WIN32
        closelog();
 #endif
 
index f414b08..d5b7c8e 100644 (file)
@@ -26,6 +26,8 @@
 #include <signal.h>
 #include <sys/types.h>
 
+#include "../lib/libwebsockets.h"
+
 #ifndef _WIN32
 #include <netdb.h>
 #include <sys/socket.h>
 #include <sys/ioctl.h>
 #include <poll.h>
 #include <unistd.h>
+#else
+#include "gettimeofday.h"
 #endif
 
-#include "../lib/libwebsockets.h"
-
 /*
  * this is specified in the 04 standard, control frames can only have small
  * payload length styles
@@ -312,7 +314,7 @@ static struct option options[] = {
        { NULL, 0, 0, 0 }
 };
 
-#ifndef WIN32
+#ifndef _WIN32
 static void
 signal_handler(int sig, siginfo_t *si, void *v)
 {
@@ -331,7 +333,7 @@ int main(int argc, char **argv)
        struct libwebsocket_context *context;
        char protocol_name[256];
        char ip[30];
-#ifndef WIN32
+#ifndef _WIN32
        struct sigaction sa;
        struct winsize w;
 #endif
@@ -414,7 +416,7 @@ int main(int argc, char **argv)
                }
        }
 
-#ifndef WIN32
+#ifndef _WIN32
        if (isatty(STDOUT_FILENO))
                if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) != -1)
                        if (w.ws_col > 0)
@@ -456,7 +458,7 @@ int main(int argc, char **argv)
        fprintf(stderr, "Websocket PING %s (%s) %d bytes of data.\n",
                                                           peer_name, ip, size);
 
-#ifndef WIN32
+#ifndef _WIN32
        /* set the ^C handler */
        sa.sa_sigaction = signal_handler;
        sa.sa_flags = SA_SIGINFO;
index 8643c93..40b627c 100644 (file)
 #include <fcntl.h>
 #include <assert.h>
 
+#include "../lib/libwebsockets.h"
+
 #ifdef _WIN32
 #include <io.h>
 #ifdef EXTERNAL_POLL
 #define poll WSAPoll
 #endif
+#include "gettimeofday.h"
 #else
 #include <syslog.h>
 #include <sys/time.h>
 #include <unistd.h>
 #endif
 
-#include "../lib/libwebsockets.h"
-
 static int close_testing;
 int max_poll_elements;
 
 #ifdef EXTERNAL_POLL
-struct pollfd *pollfds;
+struct libwebsocket_pollfd *pollfds;
 int *fd_lookup;
 int count_pollfds;
 #endif
@@ -203,7 +204,7 @@ static int callback_http(struct libwebsocket_context *context,
 
                        p = buffer + LWS_SEND_BUFFER_PRE_PADDING;
                        end = p + sizeof(buffer) - LWS_SEND_BUFFER_PRE_PADDING;
-#ifdef WIN32
+#ifdef _WIN32
                        pss->fd = open(leaf_path, O_RDONLY | _O_BINARY);
 #else
                        pss->fd = open(leaf_path, O_RDONLY);
@@ -783,7 +784,7 @@ int main(int argc, char **argv)
        int opts = 0;
        char interface_name[128] = "";
        const char *iface = NULL;
-#ifndef WIN32
+#ifndef _WIN32
        int syslog_options = LOG_PID | LOG_PERROR;
 #endif
        unsigned int ms, oldms = 0;
@@ -808,7 +809,7 @@ int main(int argc, char **argv)
 #ifndef LWS_NO_DAEMONIZE
                case 'D':
                        daemonize = 1;
-                       #ifndef WIN32
+                       #ifndef _WIN32
                        syslog_options &= ~LOG_PERROR;
                        #endif
                        break;
@@ -863,7 +864,7 @@ int main(int argc, char **argv)
 
        signal(SIGINT, sighandler);
 
-#ifndef WIN32
+#ifndef _WIN32
        /* we will only try to log things according to our debug_level */
        setlogmask(LOG_UPTO (LOG_DEBUG));
        openlog("lwsts", syslog_options, LOG_DAEMON);
@@ -879,7 +880,7 @@ int main(int argc, char **argv)
        printf("Using resource path \"%s\"\n", resource_path);
 #ifdef EXTERNAL_POLL
        max_poll_elements = getdtablesize();
-       pollfds = malloc(max_poll_elements * sizeof (struct pollfd));
+       pollfds = malloc(max_poll_elements * sizeof (struct libwebsocket_pollfd));
        fd_lookup = malloc(max_poll_elements * sizeof (int));
        if (pollfds == NULL || fd_lookup == NULL) {
                lwsl_err("Out of memory pollfds=%d\n", max_poll_elements);
@@ -985,7 +986,7 @@ done:
 
        lwsl_notice("libwebsockets-test-server exited cleanly\n");
 
-#ifndef WIN32
+#ifndef _WIN32
        closelog();
 #endif
 
index cce86f8..08385c2 100644 (file)
@@ -1,23 +1,7 @@
 #include <time.h>\r
 #include <windows.h> //I've omitted context line\r
 \r
-#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)\r
-  #define DELTA_EPOCH_IN_MICROSECS  11644473600000000Ui64\r
-#else\r
-  #define DELTA_EPOCH_IN_MICROSECS  11644473600000000ULL\r
-#endif\r
-\r
-#ifdef __MINGW32__\r
-#else\r
- #ifdef __MINGW64__\r
- #else\r
-struct timezone \r
-{\r
-       int  tz_minuteswest;    /* minutes W of Greenwich */\r
-       int  tz_dsttime;        /* type of dst correction */\r
-};\r
- #endif\r
-#endif\r
+#include "gettimeofday.h"\r
 \r
 int gettimeofday(struct timeval *tv, struct timezone *tz)\r
 {\r
index 70d9631..720cb10 100644 (file)
@@ -1,15 +1,6 @@
 #ifndef _GET_TIME_OF_DAY_H
 #define _GET_TIME_OF_DAY_H
 
-#ifdef  __MINGW64__
-#else
-#ifdef  __MINGW32__
-#else
-#include < time.h >
-#endif
-#endif
-
-#include <windows.h> //I've omitted context line.
 #if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
   #define DELTA_EPOCH_IN_MICROSECS  11644473600000000Ui64
 #else
index 7ff93a8..f2b65d9 100755 (executable)
@@ -12,7 +12,7 @@
 #  endif\r
 #endif\r
 \r
-#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ)\r
+#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ) && !defined(_WIN32)\r
 #  define ZLIB_INTERNAL __attribute__((visibility ("hidden")))\r
 #else\r
 #  define ZLIB_INTERNAL\r
index a36a406..ef3b388 100644 (file)
@@ -13,7 +13,7 @@
 #ifndef ZUTIL_H\r
 #define ZUTIL_H\r
 \r
-#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ)\r
+#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ) && !defined(_WIN32)\r
 #  define ZLIB_INTERNAL __attribute__((visibility ("hidden")))\r
 #else\r
 #  define ZLIB_INTERNAL\r