From 4785ab7eae980ec3922cb1000d56aa22b752217d Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Thu, 3 Feb 2022 17:26:26 +1000 Subject: [PATCH] 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 --- lib/multithreading.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/multithreading.c b/lib/multithreading.c index 82cd743..71926dc 100644 --- a/lib/multithreading.c +++ b/lib/multithreading.c @@ -54,11 +54,17 @@ #ifdef HAVE_MULTITHREADING #ifdef HAVE_PTHREAD -pid_t gettid(void); +#include +#include 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)