Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / packages / Python / lldbsuite / test / make / thread.h
blob053ba86dc9062a191c6c863c403b4559509ddc5b
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(_WIN32)
17 #include <windows.h>
18 #endif
20 inline uint64_t get_thread_id() {
21 #if defined(__APPLE__)
22 __uint64_t tid = 0;
23 pthread_threadid_np(pthread_self(), &tid);
24 return tid;
25 #elif defined(__linux__)
26 return syscall(__NR_gettid);
27 #elif defined(__FreeBSD__)
28 return static_cast<uint64_t>(pthread_getthreadid_np());
29 #elif defined(__NetBSD__)
30 // Technically lwpid_t is 32-bit signed integer
31 return static_cast<uint64_t>(_lwp_self());
32 #elif defined(_WIN32)
33 return static_cast<uint64_t>(::GetCurrentThreadId());
34 #else
35 return -1;
36 #endif
39 #endif // LLDB_THREAD_H