[Openmp-commits] [openmp] [OpenMP][Wasm][Emscripten] Fixed 'No gettid found, use getpid instead' warning (PR #117038)

Christian Oliveros via Openmp-commits openmp-commits at lists.llvm.org
Wed Nov 20 11:54:50 PST 2024


https://github.com/maniatic0 created https://github.com/llvm/llvm-project/pull/117038

Fixed 'No gettid found, use getpid instead' compilation warning as Emscripten defines ```gettid``` without defining ```SYS_gettid``` [[1](https://github.com/emscripten-core/emsdk/issues/908#issuecomment-940090540), [2](https://github.com/emscripten-core/emscripten/pull/15189)]

Note that for Emscripten ```gettid``` is just (from [[3](https://github.com/emscripten-core/emscripten/blob/f56ee36bc635341f3d538513c57558e6e302a444/system/lib/libc/musl/src/linux/gettid.c#L7)])
```
pid_t gettid(void)
{
	return __pthread_self()->tid;
}
```



[1] https://github.com/emscripten-core/emsdk/issues/908#issuecomment-940090540
[2] https://github.com/emscripten-core/emscripten/pull/15189
[3] https://github.com/emscripten-core/emscripten/blob/f56ee36bc635341f3d538513c57558e6e302a444/system/lib/libc/musl/src/linux/gettid.c#L7

>From b9699ada1ca91f968d3db9d011f52364c578c194 Mon Sep 17 00:00:00 2001
From: Christian Oliveros <christianol_01 at hotmail.com>
Date: Wed, 20 Nov 2024 20:40:35 +0100
Subject: [PATCH] [OpenMP][Wasm][Emscripten] Fixed 'No gettid found, use getpid
 instead' warning

---
 openmp/runtime/src/kmp_wrapper_getpid.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/openmp/runtime/src/kmp_wrapper_getpid.h b/openmp/runtime/src/kmp_wrapper_getpid.h
index d31c6e80f75df3..791d01a5c25de7 100644
--- a/openmp/runtime/src/kmp_wrapper_getpid.h
+++ b/openmp/runtime/src/kmp_wrapper_getpid.h
@@ -36,6 +36,9 @@
 #elif KMP_OS_AIX
 #include <pthread.h>
 #define __kmp_gettid() pthread_self()
+#elif KMP_OS_EMSCRIPTEN
+// Emscripten defines gettid without defining SYS_gettid
+#define __kmp_gettid() gettid()
 #elif defined(SYS_gettid)
 // Hopefully other Unix systems define SYS_gettid syscall for getting os thread
 // id



More information about the Openmp-commits mailing list