diff --git a/CMakeLists.txt b/CMakeLists.txt index 49ff1854b..f62245ae4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -807,6 +807,7 @@ CHECK_INCLUDE_FILE(vfork.h LWS_HAVE_VFORK_H) CHECK_INCLUDE_FILE(sys/capability.h LWS_HAVE_SYS_CAPABILITY_H) CHECK_INCLUDE_FILE(malloc.h LWS_HAVE_MALLOC_H) CHECK_INCLUDE_FILE(pthread.h LWS_HAVE_PTHREAD_H) +CHECK_INCLUDE_FILE(inttypes.h LWS_HAVE_INTTYPES_H) CHECK_LIBRARY_EXISTS(cap cap_set_flag "" LWS_HAVE_LIBCAP) diff --git a/cmake/lws_config_private.h.in b/cmake/lws_config_private.h.in index 22afd64e0..8ac12bf7e 100644 --- a/cmake/lws_config_private.h.in +++ b/cmake/lws_config_private.h.in @@ -119,3 +119,8 @@ #cmakedefine LWS_WITH_ZLIB #cmakedefine LWS_HAS_PTHREAD_SETNAME_NP +/* Defined if you have the header file. */ +#cmakedefine LWS_HAVE_INTTYPES_H + +#cmakedefine LWS_HAVE_SNPRINTF +#cmakedefine LWS_HAVE__SNPRINTF diff --git a/lib/core/private.h b/lib/core/private.h index 1da5e209b..3a7b7a45e 100644 --- a/lib/core/private.h +++ b/lib/core/private.h @@ -40,7 +40,21 @@ #include #include #include + +#ifdef LWS_HAVE_INTTYPES_H #include +#endif + +#if defined(WIN32) || defined(_WIN32) +#ifndef LWS_HAVE_SNPRINTF // no snprintf +#ifdef LWS_HAVE__SNPRINTF // has _snprintf +#define snprintf _snprintf +#else +#error "no snprintf to use" +#endif +#endif +#endif + #include #ifdef LWS_HAVE_SYS_TYPES_H diff --git a/lib/plat/windows/windows-service.c b/lib/plat/windows/windows-service.c index f4344a1ea..c95ff0fa0 100644 --- a/lib/plat/windows/windows-service.c +++ b/lib/plat/windows/windows-service.c @@ -35,6 +35,8 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi) unsigned int i; DWORD ev; int n; + unsigned int eIdx; + int interrupt_requested; /* stay dead once we are dead */ if (context == NULL || !context->vhost_list) @@ -138,7 +140,7 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi) ev = WSAWaitForMultipleEvents(1, &pt->events, FALSE, timeout_ms, FALSE); if (ev == WSA_WAIT_EVENT_0) { EnterCriticalSection(&pt->interrupt_lock); - const int interrupt_requested = pt->interrupt_requested; + interrupt_requested = pt->interrupt_requested; pt->interrupt_requested = 0; LeaveCriticalSection(&pt->interrupt_lock); if(interrupt_requested) { @@ -146,8 +148,6 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi) return 0; } - unsigned int eIdx; - #if defined(LWS_WITH_TLS) if (pt->context->tls_ops && pt->context->tls_ops->fake_POLLIN_for_buffered)