2 #if defined(__OpenBSD__)
3 #include <pthread_np.h>
7 void set_thread_name(const char *name
) {
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
);
20 set_thread_name("hello world");
22 set_thread_name("goodbye world");