Skip to content

Commit

Permalink
Support older glibc
Browse files Browse the repository at this point in the history
Replace gettid() with syscall(SYS_gettid)

See #6
  • Loading branch information
tidwall committed Apr 14, 2024
1 parent 5364a33 commit f772897
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions neco.c
Original file line number Diff line number Diff line change
Expand Up @@ -2831,9 +2831,11 @@ bool worker_submit(struct worker *worker, int64_t pin, void(*work)(void *udata),
#include <netinet/in.h>
#include <sys/un.h>
#include <dlfcn.h>
#include <sys/syscall.h>
#endif
#include <pthread.h>


#include "neco.h"

#if defined(__FreeBSD__) || defined(__APPLE__)
Expand Down Expand Up @@ -3657,9 +3659,8 @@ static int is_main_thread(void) {
return IsGUIThread(false);
}
#elif defined(__linux__) || defined(__EMSCRIPTEN__)
int gettid(void);
static int is_main_thread(void) {
return getpid() == gettid();
return getpid() == (pid_t)syscall(SYS_gettid);
}
#else
int pthread_main_np(void);
Expand Down

0 comments on commit f772897

Please sign in to comment.