[NFC][LLVM][CodeGen] Move LiveDebugVariables.h into llvm/include/llvm/CodeGen (#88374)
[llvm-project.git] / lldb / packages / Python / lldbsuite / test / make / thread.h
blobba1f381c7e40a147d51de35059efb46e45285816
1 #ifndef LLDB_THREAD_H
2 #define LLDB_THREAD_H
4 #include <stdint.h>
6 #if defined(__APPLE__)
7 __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)
8 int pthread_threadid_np(pthread_t, __uint64_t *);
9 #elif defined(__linux__)
10 #include <sys/syscall.h>
11 #include <unistd.h>
12 #elif defined(__FreeBSD__)
13 #include <pthread_np.h>
14 #elif defined(__NetBSD__)
15 #include <lwp.h>
16 #elif defined(__OpenBSD__)
17 #include <unistd.h>
18 #elif defined(_WIN32)
19 #include <windows.h>
20 #endif
22 inline uint64_t get_thread_id() {
23 #if defined(__APPLE__)
24 __uint64_t tid = 0;
25 pthread_threadid_np(pthread_self(), &tid);
26 return tid;
27 #elif defined(__linux__)
28 return syscall(__NR_gettid);
29 #elif defined(__FreeBSD__)
30 return static_cast<uint64_t>(pthread_getthreadid_np());
31 #elif defined(__NetBSD__)
32 // Technically lwpid_t is 32-bit signed integer
33 return static_cast<uint64_t>(_lwp_self());
34 #elif defined(__OpenBSD__)
35 return static_cast<uint64_t>(getthrid());
36 #elif defined(_WIN32)
37 return static_cast<uint64_t>(::GetCurrentThreadId());
38 #else
39 return -1;
40 #endif
43 #endif // LLDB_THREAD_H