Support _WIN32 in addition to WIN32 define
authorAndreas Pakulat <andreas@froglogic.com>
Mon, 28 Oct 2013 14:18:04 +0000 (15:18 +0100)
committerAndy Green <andy.green@linaro.org>
Mon, 4 Nov 2013 02:04:31 +0000 (10:04 +0800)
MSVC8 and MSVC9 set only _WIN32, so support that define as well to be able
to compile libwebsockets with those compilers.

lib/libwebsockets.c
lib/libwebsockets.h
lib/parsers.c
lib/private-libwebsockets.h
lib/server.c
lib/sha-1.c

index 4378317..d3eb9c1 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "private-libwebsockets.h"
 
-#ifdef WIN32
+#if defined(WIN32) || defined(_WIN32)
 #include <tchar.h>
 #include <io.h>
 #include <mstcpip.h>
@@ -548,7 +548,7 @@ LWS_VISIBLE int libwebsockets_get_random(struct libwebsocket_context *context,
        int n;
        char *p = (char *)buf;
 
-#ifdef WIN32
+#if defined(WIN32) || defined(_WIN32)
        for (n = 0; n < len; n++)
                p[n] = (unsigned char)rand();
 #else
@@ -562,7 +562,7 @@ int lws_set_socket_options(struct libwebsocket_context *context, int fd)
 {
        int optval = 1;
        socklen_t optlen = sizeof(optval);
-#ifdef WIN32
+#if defined(WIN32) || defined(_WIN32)
        unsigned long optl = 0;
 #endif
 #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
@@ -623,7 +623,7 @@ int lws_set_socket_options(struct libwebsocket_context *context, int fd)
 #endif
 
        /* We are nonblocking... */
-#ifdef WIN32
+#if defined(WIN32) || defined(_WIN32)
        ioctlsocket(fd, FIONBIO, &optl);
 #else
        fcntl(fd, F_SETFL, O_NONBLOCK);
@@ -1219,7 +1219,7 @@ libwebsocket_context_destroy(struct libwebsocket_context *context)
 
 #endif
 
-#ifdef WIN32
+#if defined(WIN32) || defined(_WIN32)
 #else
        close(context->fd_random);
 #endif
@@ -1243,7 +1243,7 @@ libwebsocket_context_destroy(struct libwebsocket_context *context)
 
        free(context);
 
-#ifdef WIN32
+#if defined(WIN32) || defined(_WIN32)
        WSACleanup();
 #endif
 }
@@ -1869,7 +1869,7 @@ libwebsocket_create_context(struct lws_context_creation_info *info)
        context->last_timeout_check_s = 0;
        context->user_space = info->user;
 
-#ifdef WIN32
+#if defined(WIN32) || defined(_WIN32)
        context->fd_random = 0;
 #else
        context->fd_random = open(SYSTEM_RANDOM_FILEPATH, O_RDONLY);
@@ -1955,7 +1955,7 @@ libwebsocket_create_context(struct lws_context_creation_info *info)
 #endif
 
        /* ignore SIGPIPE */
-#ifdef WIN32
+#if defined(WIN32) || defined(_WIN32)
 #else
        signal(SIGPIPE, sigpipe_handler);
 #endif
@@ -2152,7 +2152,7 @@ libwebsocket_create_context(struct lws_context_creation_info *info)
                setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY,
                                              (const void *)&opt, sizeof(opt));
 
-               #ifdef WIN32
+               #if defined(WIN32) || defined(_WIN32)
                opt = 0;
                ioctlsocket(sockfd, FIONBIO, (unsigned long *)&opt);
                #else
@@ -2207,7 +2207,7 @@ libwebsocket_create_context(struct lws_context_creation_info *info)
         * to listen on port < 1023 we would have needed root, but now we are
         * listening, we don't want the power for anything else
         */
-#ifdef WIN32
+#if defined(WIN32) || defined(_WIN32)
 #else
        if (info->gid != -1)
                if (setgid(info->gid))
@@ -2381,7 +2381,7 @@ static void lwsl_emit_stderr(int level, const char *line)
        fprintf(stderr, "%s%s", buf, line);
 }
 
-#ifdef WIN32
+#if defined(WIN32) || defined(_WIN32)
 LWS_VISIBLE void lwsl_emit_syslog(int level, const char *line)
 {
        lwsl_emit_stderr(level, line);
index d5fdaeb..5db4b08 100644 (file)
@@ -27,7 +27,7 @@ extern "C" {
 #include <cstddef>
 #endif
 
-#ifdef WIN32
+#if defined(WIN32) || defined(_WIN32)
 
 #ifndef WIN32_LEAN_AND_MEAN
 #define WIN32_LEAN_AND_MEAN
index c1d6730..cae50d8 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "private-libwebsockets.h"
 
-#ifdef WIN32
+#if defined(WIN32) || defined(_WIN32)
 #include <io.h>
 #endif
 
index 6b897f0..5963db5 100644 (file)
@@ -23,7 +23,7 @@
 #ifdef CMAKE_BUILD
 #include "lws_config.h"
 #else
-#ifdef WIN32
+#if defined(WIN32) || defined(_WIN32)
 #define inline __inline
 #else
 #include "config.h"
@@ -55,7 +55,7 @@
 
 #include <sys/stat.h>
 
-#ifdef WIN32
+#if defined(WIN32) || defined(_WIN32)
 #define LWS_NO_DAEMONIZE
 #ifndef EWOULDBLOCK
 #define EWOULDBLOCK EAGAIN
index 8d12a81..44145cb 100644 (file)
@@ -22,7 +22,7 @@
 
 #include "private-libwebsockets.h"
 
-#ifdef WIN32
+#if defined(WIN32) || defined(_WIN32)
 #include <tchar.h>
 #include <io.h>
 #else
@@ -55,7 +55,7 @@ int
 interface_to_sa(const char *ifname, struct sockaddr_in *addr, size_t addrlen)
 {
        int rc = -1;
-#ifdef WIN32
+#if defined(WIN32) || defined(_WIN32)
        /* TODO */
 #else
        struct ifaddrs *ifr;
index 1491502..96b4470 100644 (file)
@@ -33,7 +33,7 @@
  */
 
 #include <sys/types.h>
-#ifdef WIN32
+#if defined(WIN32) || defined(_WIN32)
 
 #ifndef BIG_ENDIAN
 #define BIG_ENDIAN    4321  /* to show byte order (taken from gcc) */