multithreading/ptread: gettid() is not available in all versions

gettid() is not guaranteed to be universally available
so replace this with calling the syscall directly for
building on Linux with Multithreading enabled.

Windows already use a native call for this so it should be unaffected
but other unix-like systems with pthread support will need to have
a replacement function here as well.
This is todo for later for non-linux pthread platforms.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
master
Ronnie Sahlberg 2022-02-03 17:26:26 +10:00
parent 2772c70be6
commit 4785ab7eae
1 changed files with 8 additions and 2 deletions

View File

@ -54,11 +54,17 @@
#ifdef HAVE_MULTITHREADING
#ifdef HAVE_PTHREAD
pid_t gettid(void);
#include <unistd.h>
#include <sys/syscall.h>
nfs_tid_t nfs_mt_get_tid(void)
{
return gettid();
#ifdef SYS_gettid
pid_t tid = syscall(SYS_gettid);
return tid;
#else
#error "SYS_gettid unavailable on this system"
#endif
}
static void *nfs_mt_service_thread(void *arg)