From 5b71aac2eddd5a53e31adecdd4406b37653a778b Mon Sep 17 00:00:00 2001 From: Patrick Gansterer Date: Fri, 28 Feb 2014 01:31:39 +0100 Subject: [PATCH] Enable compilation on Windows CE Add a few ifdefs to support this additional platform. --- CMakeLists.txt | 4 +++- lib/libwebsockets.c | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bb9ec3a..12f7e1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -454,7 +454,9 @@ endif(LWS_WITH_SSL) # # Platform specific libs. # -if (WIN32) +if (WINCE) + list(APPEND LIB_LIST ws2.lib) +elseif (WIN32) list(APPEND LIB_LIST ws2_32.lib) endif() diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index 8ce6074..f0a09fd 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -24,6 +24,9 @@ #if defined(WIN32) || defined(_WIN32) #include #include +#ifdef _WIN32_WCE +#define vsnprintf _vsnprintf +#endif #else #ifdef LWS_BUILTIN_GETIFADDRS #include @@ -140,6 +143,15 @@ static unsigned long long time_in_microseconds() #endif } +#ifdef _WIN32_WCE +static inline time_t time(time_t *t) +{ + time_t ret = time_in_microseconds() / 1000000; + *t = ret; + return ret; +} +#endif + int insert_wsi_socket_into_fds(struct libwebsocket_context *context, struct libwebsocket *wsi) @@ -1974,6 +1986,7 @@ libwebsocket_create_context(struct lws_context_creation_info *info) /* default to a poll() made out of select() */ poll = emulated_poll; +#ifndef _WIN32_WCE /* if windows socket lib available, use his WSAPoll */ wsdll = GetModuleHandle(_T("Ws2_32.dll")); if (wsdll) @@ -1982,6 +1995,7 @@ libwebsocket_create_context(struct lws_context_creation_info *info) /* Finally fall back to emulated poll if all else fails */ if (!poll) poll = emulated_poll; +#endif } #endif -- 2.7.4