Revert "Remove dependence on <ciso646>" (#126399)
[llvm-project.git] / lldb / test / API / tools / lldb-server / thread-name / main.cpp
blob17756ed7943b76df1156896b823310e31ff92b65
1 #include <pthread.h>
2 #if defined(__OpenBSD__)
3 #include <pthread_np.h>
4 #endif
5 #include <signal.h>
7 void set_thread_name(const char *name) {
8 #if defined(__APPLE__)
9 ::pthread_setname_np(name);
10 #elif defined(__FreeBSD__) || defined(__linux__)
11 ::pthread_setname_np(::pthread_self(), name);
12 #elif defined(__NetBSD__)
13 ::pthread_setname_np(::pthread_self(), "%s", const_cast<char *>(name));
14 #elif defined(__OpenBSD__)
15 ::pthread_set_name_np(::pthread_self(), name);
16 #endif
19 int main() {
20 set_thread_name("hello world");
21 raise(SIGINT);
22 set_thread_name("goodbye world");
23 raise(SIGINT);
24 return 0;