[llvm] Add check for SYS_gettid support (PR #119742)

via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 12 10:52:34 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-support

Author: Alexander Peskov (apeskov)

<details>
<summary>Changes</summary>

To improve compatibility with old glibc version which lack `syscall(SYS_gettid)` will use `pthread_self()` as a fallback.

---
Full diff: https://github.com/llvm/llvm-project/pull/119742.diff


1 Files Affected:

- (modified) llvm/lib/Support/Unix/Threading.inc (+1-1) 


``````````diff
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());

``````````

</details>


https://github.com/llvm/llvm-project/pull/119742


More information about the llvm-commits mailing list