1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-16 16:23:25 +00:00

1. Fixed compiler warning when NO_IFADDR is defined

2. Added pthread_timedjoin_np() workaround for older glibc/gcc
This commit is contained in:
Bryan Roe
2020-04-23 16:47:57 -07:00
parent a6fe772422
commit 54b291187b
2 changed files with 14 additions and 5 deletions

View File

@@ -1564,7 +1564,9 @@ duk_ret_t ILibDuktape_ScriptContainer_OS_networkInterfaces(duk_context *ctx)
{ {
#if !defined(WIN32) #if !defined(WIN32)
duk_eval_string(ctx, "require('os').getDefaultGateways();"); duk_eval_string(ctx, "require('os').getDefaultGateways();");
#ifndef NO_IFADDR
void *gwTable = duk_get_heapptr(ctx, -1); void *gwTable = duk_get_heapptr(ctx, -1);
#endif
#endif #endif
duk_push_object(ctx); // [retVal] duk_push_object(ctx); // [retVal]

View File

@@ -71,6 +71,13 @@ limitations under the License.
#if defined(__APPLE__) || defined (_FREEBSD) #if defined(__APPLE__) || defined (_FREEBSD)
#include <ifaddrs.h> #include <ifaddrs.h>
#include <sys/sysctl.h> #include <sys/sysctl.h>
#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 #endif
#if defined(WIN32) && !defined(WSA_FLAG_NO_HANDLE_INHERIT) #if defined(WIN32) && !defined(WSA_FLAG_NO_HANDLE_INHERIT)
@@ -9424,7 +9431,7 @@ void ILIBLOGMESSAGEX(char *format, ...)
ILIBLOGMESSSAGE(dest); ILIBLOGMESSSAGE(dest);
} }
#ifdef __APPLE__ #if defined(__APPLE__) || defined(ILIB_NO_TIMEDJOIN)
typedef struct ILibThread_AppleThread typedef struct ILibThread_AppleThread
{ {
pthread_t tid; pthread_t tid;
@@ -9461,7 +9468,7 @@ void* ILibSpawnNormalThreadEx(voidfp1 method, void* arg, int detached)
void* (*fptr) (void* a); void* (*fptr) (void* a);
pthread_t newThread; pthread_t newThread;
fptr = (void*(*)(void*))method; fptr = (void*(*)(void*))method;
#if defined(__APPLE__) #if defined(__APPLE__) || defined(ILIB_NO_TIMEDJOIN)
ILibThread_AppleThread *ret = (ILibThread_AppleThread*)ILibMemory_SmartAllocate(sizeof(ILibThread_AppleThread)); ILibThread_AppleThread *ret = (ILibThread_AppleThread*)ILibMemory_SmartAllocate(sizeof(ILibThread_AppleThread));
ret->method = method; ret->arg = arg; ret->method = method; ret->arg = arg;
if (detached != 0) { sem_init(&(ret->s), 0, 0); ret->joinable = 1; } 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 #ifndef WIN32
int ILibThread_TimedJoinEx(void *thr, struct timespec* timeout) int ILibThread_TimedJoinEx(void *thr, struct timespec* timeout)
{ {
#ifdef __APPLE__ #if defined(__APPLE__) || defined(ILIB_NO_TIMEDJOIN)
int ret = 1; int ret = 1;
if (ILibMemory_CanaryOK(thr) && ((ILibThread_AppleThread*)thr)->joinable != 0) if (ILibMemory_CanaryOK(thr) && ((ILibThread_AppleThread*)thr)->joinable != 0)
{ {
@@ -9537,7 +9544,7 @@ void ILibThread_Join(void *thr)
#ifdef WIN32 #ifdef WIN32
WaitForSingleObject((HANDLE)thr, INFINITE); WaitForSingleObject((HANDLE)thr, INFINITE);
#else #else
#ifdef __APPLE__ #if defined(__APPLE__) || defined(ILIB_NO_TIMEDJOIN)
if (ILibMemory_CanaryOK(thr) && ((ILibThread_AppleThread*)thr)->joinable!=0) if (ILibMemory_CanaryOK(thr) && ((ILibThread_AppleThread*)thr)->joinable!=0)
{ {
pthread_join(((ILibThread_AppleThread*)thr)->tid, NULL); pthread_join(((ILibThread_AppleThread*)thr)->tid, NULL);