From 571b68d468ec64b8b2396bd75738c7c6113a5229 Mon Sep 17 00:00:00 2001 From: TwistedUmbrella Date: Sun, 1 Apr 2018 22:18:09 -0400 Subject: [PATCH] Fix building Windows alongside Android Studio Windows: resolve missing reference to _SC_OPEN_MAX https://lists.gnu.org/archive/html/bug-gnulib/2014-08/msg00023.html https://libwebsockets.org/lws-api-doc-master/html/libwebsockets_8h_source.html Windows: comment duplicate x86_ptr_imm definition Replaced by more explicit type definitions. Fixes x64 compile Restore secondary x86_ptr_imm for non-Windows This appears to be a necessary duplicate for other platforms. --- core/deps/libwebsocket/context.c | 8 ++++++++ core/emitter/x86_emitter.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/core/deps/libwebsocket/context.c b/core/deps/libwebsocket/context.c index bf9b6cb73..c63ab271c 100644 --- a/core/deps/libwebsocket/context.c +++ b/core/deps/libwebsocket/context.c @@ -25,6 +25,10 @@ #define LWS_BUILD_HASH "unknown-build-hash" #endif +#ifdef WIN32 +#define getdtablesize() 30000 +#endif + static const char *library_version = LWS_LIBRARY_VERSION " " LWS_BUILD_HASH; /** @@ -122,7 +126,11 @@ libwebsocket_create_context(struct lws_context_creation_info *info) context->options = info->options; context->iface = info->iface; /* to reduce this allocation, */ +#ifdef WIN32 + context->max_fds = getdtablesize (); +#else context->max_fds = sysconf(_SC_OPEN_MAX); +#endif lwsl_notice(" static allocation: %u + (%u x %u fds) = %u bytes\n", sizeof(struct libwebsocket_context), sizeof(struct libwebsocket_pollfd) + diff --git a/core/emitter/x86_emitter.h b/core/emitter/x86_emitter.h index 45727822a..ca0598beb 100644 --- a/core/emitter/x86_emitter.h +++ b/core/emitter/x86_emitter.h @@ -229,11 +229,13 @@ struct /*__declspec(dllexport)*/ x86_ptr_imm this->ptr=ptr; } +#ifndef WIN32 template x86_ptr_imm(Rv(* ptr)(Args...)) { this->ptr= reinterpret_cast(ptr); } +#endif template x86_ptr_imm(Rv(DYNACALL * ptr)(Args...))