libuv win32 fixes
authorAndy Green <andy@warmcat.com>
Thu, 31 Mar 2016 12:11:53 +0000 (20:11 +0800)
committerAndy Green <andy@warmcat.com>
Thu, 31 Mar 2016 12:12:14 +0000 (20:12 +0800)
Signed-off-by: Andy Green <andy@warmcat.com>
CMakeLists.txt
lib/libuv.c
lib/private-libwebsockets.h

index 91eba67..f45a70e 100644 (file)
@@ -955,7 +955,7 @@ if (NOT LWS_WITHOUT_TESTAPPS)
                                        "test-server/test-server-status.c"
                                        "test-server/test-server-echogen.c")
                        endif()
-                       if (UNIX AND NOT ((CMAKE_C_COMPILER_ID MATCHES "Clang") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
+                       if (NOT ((CMAKE_C_COMPILER_ID MATCHES "Clang") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
                                AND LWS_WITH_LIBEV)
                                create_test_app(test-server-libev
                                        "test-server/test-server-libev.c"
@@ -965,7 +965,7 @@ if (NOT LWS_WITHOUT_TESTAPPS)
                                        "test-server/test-server-status.c"
                                        "test-server/test-server-echogen.c")
                        endif()
-                       if (UNIX AND NOT ((CMAKE_C_COMPILER_ID MATCHES "Clang") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
+                       if (NOT ((CMAKE_C_COMPILER_ID MATCHES "Clang") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
                                AND LWS_WITH_LIBUV)
                                create_test_app(test-server-libuv
                                        "test-server/test-server-libuv.c"
index e74e81d..dfd4c52 100644 (file)
@@ -38,7 +38,11 @@ lws_io_cb(uv_poll_t *watcher, int status, int revents)
        struct lws_context *context = lws_io->context;
        struct lws_pollfd eventfd;
 
+#if defined(WIN32) || defined(_WIN32)
+       eventfd.fd = watcher->sock;
+#else
        eventfd.fd = watcher->io_watcher.fd;
+#endif
        eventfd.events = 0;
        eventfd.revents = 0;
 
@@ -207,8 +211,13 @@ lws_libuv_io(struct lws *wsi, int flags)
 {
        struct lws_context *context = lws_get_context(wsi);
        struct lws_context_per_thread *pt = &wsi->context->pt[(int)wsi->tsi];
+#if defined(WIN32) || defined(_WIN32)
+       int current_events = wsi->w_read.uv_watcher.io.events &
+                            (UV_READABLE | UV_WRITABLE);
+#else
        int current_events = wsi->w_read.uv_watcher.io_watcher.pevents &
                             (UV_READABLE | UV_WRITABLE);
+#endif
        struct lws_io_watcher *w = &wsi->w_read;
 
        if (!LWS_LIBUV_ENABLED(context))
@@ -329,8 +338,8 @@ lws_uv_getloop(struct lws_context *context, int tsi)
 static void
 lws_libuv_closewsi(uv_handle_t* handle)
 {
-       struct lws *n = NULL, *wsi = (struct lws *)(((void *)handle) -
-                         (void *)(&n->w_read.uv_watcher));
+       struct lws *n = NULL, *wsi = (struct lws *)(((char *)handle) -
+                         (char *)(&n->w_read.uv_watcher));
        struct lws_context *context = lws_get_context(wsi);
 
        lws_close_free_wsi_final(wsi);
index 580e1e7..04d1a89 100644 (file)
@@ -261,6 +261,12 @@ typedef unsigned __int64 u_int64_t;
 #endif
 #endif
 
+#include <stddef.h>
+
+#ifndef container_of
+#define container_of(P,T,M)    ((T *)((char *)(P) - offsetof(T, M)))
+#endif
+
 #else
 
 #include <sys/stat.h>