libuv win32 fixes

Signed-off-by: Andy Green <andy@warmcat.com>
This commit is contained in:
Andy Green 2016-04-05 07:31:11 +08:00
parent 8b83266301
commit 934cc80d95
3 changed files with 19 additions and 4 deletions

View file

@ -864,7 +864,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"
@ -874,7 +874,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"

View 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;
@ -221,8 +225,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))
@ -343,8 +352,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);

View file

@ -232,6 +232,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>