From 54b291187b6af46c815c74f7e2c28e4bd5b95fc6 Mon Sep 17 00:00:00 2001 From: Bryan Roe Date: Thu, 23 Apr 2020 16:47:57 -0700 Subject: [PATCH] 1. Fixed compiler warning when NO_IFADDR is defined 2. Added pthread_timedjoin_np() workaround for older glibc/gcc --- microscript/ILibDuktape_ScriptContainer.c | 4 +++- microstack/ILibParsers.c | 15 +++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/microscript/ILibDuktape_ScriptContainer.c b/microscript/ILibDuktape_ScriptContainer.c index 4a4e602..ab3fc7b 100644 --- a/microscript/ILibDuktape_ScriptContainer.c +++ b/microscript/ILibDuktape_ScriptContainer.c @@ -1564,7 +1564,9 @@ duk_ret_t ILibDuktape_ScriptContainer_OS_networkInterfaces(duk_context *ctx) { #if !defined(WIN32) duk_eval_string(ctx, "require('os').getDefaultGateways();"); - void *gwTable = duk_get_heapptr(ctx, -1); + #ifndef NO_IFADDR + void *gwTable = duk_get_heapptr(ctx, -1); + #endif #endif duk_push_object(ctx); // [retVal] diff --git a/microstack/ILibParsers.c b/microstack/ILibParsers.c index 8aa5443..f165ec3 100644 --- a/microstack/ILibParsers.c +++ b/microstack/ILibParsers.c @@ -71,6 +71,13 @@ limitations under the License. #if defined(__APPLE__) || defined (_FREEBSD) #include #include +#else + #if defined(_POSIX) + // On Linux Platforms, we need to check glibc version of the compiler + #if (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3) || (__GLIBC__ < 2) + #define ILIB_NO_TIMEDJOIN + #endif + #endif #endif #if defined(WIN32) && !defined(WSA_FLAG_NO_HANDLE_INHERIT) @@ -9424,7 +9431,7 @@ void ILIBLOGMESSAGEX(char *format, ...) ILIBLOGMESSSAGE(dest); } -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(ILIB_NO_TIMEDJOIN) typedef struct ILibThread_AppleThread { pthread_t tid; @@ -9461,7 +9468,7 @@ void* ILibSpawnNormalThreadEx(voidfp1 method, void* arg, int detached) void* (*fptr) (void* a); pthread_t newThread; fptr = (void*(*)(void*))method; -#if defined(__APPLE__) +#if defined(__APPLE__) || defined(ILIB_NO_TIMEDJOIN) ILibThread_AppleThread *ret = (ILibThread_AppleThread*)ILibMemory_SmartAllocate(sizeof(ILibThread_AppleThread)); ret->method = method; ret->arg = arg; if (detached != 0) { sem_init(&(ret->s), 0, 0); ret->joinable = 1; } @@ -9488,7 +9495,7 @@ void* ILibSpawnNormalThreadEx(voidfp1 method, void* arg, int detached) #ifndef WIN32 int ILibThread_TimedJoinEx(void *thr, struct timespec* timeout) { -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(ILIB_NO_TIMEDJOIN) int ret = 1; if (ILibMemory_CanaryOK(thr) && ((ILibThread_AppleThread*)thr)->joinable != 0) { @@ -9537,7 +9544,7 @@ void ILibThread_Join(void *thr) #ifdef WIN32 WaitForSingleObject((HANDLE)thr, INFINITE); #else - #ifdef __APPLE__ + #if defined(__APPLE__) || defined(ILIB_NO_TIMEDJOIN) if (ILibMemory_CanaryOK(thr) && ((ILibThread_AppleThread*)thr)->joinable!=0) { pthread_join(((ILibThread_AppleThread*)thr)->tid, NULL);