[llvm] Add check for SYS_gettid support (PR #119742)
Alexander Peskov via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 12 10:51:37 PST 2024
https://github.com/apeskov created https://github.com/llvm/llvm-project/pull/119742
To improve compatibility with old glibc version which lack `syscall(SYS_gettid)` will use `pthread_self()` as a fallback.
>From 93fc6b80885e68468111cc368b8b92d610cafba1 Mon Sep 17 00:00:00 2001
From: Alexander Peskov <apeskov at nvidia.com>
Date: Mon, 9 Dec 2024 16:09:40 +0400
Subject: [PATCH] Add check for support of SYS_gettid
To improve compatibility with old glibc version which lack SYS_gettid
will use pthread_self() as a fallback.
---
llvm/lib/Support/Unix/Threading.inc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/lib/Support/Unix/Threading.inc b/llvm/lib/Support/Unix/Threading.inc
index c7b4c7af3b9f33..368e3cf1c5bd8f 100644
--- a/llvm/lib/Support/Unix/Threading.inc
+++ b/llvm/lib/Support/Unix/Threading.inc
@@ -140,7 +140,7 @@ uint64_t llvm::get_threadid() {
return uint64_t(getthrid());
#elif defined(__ANDROID__)
return uint64_t(gettid());
-#elif defined(__linux__)
+#elif defined(__linux__) && defined(SYS_gettid)
return uint64_t(syscall(SYS_gettid));
#else
return uint64_t(pthread_self());
More information about the llvm-commits
mailing list