[Openmp-commits] [openmp] [OpenMP] Use pthread_self for __kmp_gettid on Solaris (PR #138510)

Rainer Orth via Openmp-commits openmp-commits at lists.llvm.org
Mon May 5 04:44:55 PDT 2025


https://github.com/rorth created https://github.com/llvm/llvm-project/pull/138510

Building `openmp` on Solaris/amd64, I get

```
In file included from openmp/runtime/src/kmp_utility.cpp:16:
openmp/runtime/src/kmp_wrapper_getpid.h:47:2: warning: No gettid found, use getpid instead [-W#warnings]
   47 | #warning No gettid found, use getpid instead
      |  ^

```

There's no reason to do this: Solaris can use `pthread_self` just as AIX does.

Tested on `amd64-pc-solaris2.11` and `x86_64-pc-linux-gnu`.

>From 7e5bd2b4ff6185d1d6a227d46cc786d08a6a3d24 Mon Sep 17 00:00:00 2001
From: Rainer Orth <ro at gcc.gnu.org>
Date: Mon, 5 May 2025 13:43:29 +0200
Subject: [PATCH] [OpenMP] Use pthread_self for __kmp_gettid on Solaris

Building `openmp` on Solaris/amd64, I get

```
In file included from openmp/runtime/src/kmp_utility.cpp:16:
openmp/runtime/src/kmp_wrapper_getpid.h:47:2: warning: No gettid found, use getpid instead [-W#warnings]
   47 | #warning No gettid found, use getpid instead
      |  ^

```

There's no reason to do this: Solaris can use `pthread_self` just as AIX
does.

Tested on `amd64-pc-solaris2.11` and `x86_64-pc-linux-gnu`.
---
 openmp/runtime/src/kmp_wrapper_getpid.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/openmp/runtime/src/kmp_wrapper_getpid.h b/openmp/runtime/src/kmp_wrapper_getpid.h
index 6b41dfcc20880..6d99b17702b2a 100644
--- a/openmp/runtime/src/kmp_wrapper_getpid.h
+++ b/openmp/runtime/src/kmp_wrapper_getpid.h
@@ -33,7 +33,7 @@
 #define __kmp_gettid() _lwp_self()
 #elif KMP_OS_OPENBSD
 #define __kmp_gettid() getthrid()
-#elif KMP_OS_AIX
+#elif KMP_OS_AIX || KMP_OS_SOLARIS
 #include <pthread.h>
 #define __kmp_gettid() pthread_self()
 #elif KMP_OS_HAIKU



More information about the Openmp-commits mailing list