Skip to content

Commit 4d01c4f

Browse files
committed
Implement set_thread_name() on FreeBSD
1 parent 1fb34f9 commit 4d01c4f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

include/osmium/thread/util.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ DEALINGS IN THE SOFTWARE.
3838
#include <thread>
3939
#include <utility>
4040

41-
#ifdef __linux__
41+
#if defined(__linux__)
4242
# include <sys/prctl.h>
43+
#elif defined(__FreeBSD__)
44+
# include <pthread.h>
4345
#endif
4446

4547
namespace osmium {
@@ -72,10 +74,14 @@ namespace osmium {
7274
/**
7375
* Set name of current thread for debugging. This only works on Linux.
7476
*/
75-
#ifdef __linux__
77+
#if defined(__linux__)
7678
inline void set_thread_name(const char* name) noexcept {
7779
prctl(PR_SET_NAME, name, 0, 0, 0);
7880
}
81+
#elif defined(__FreeBSD__)
82+
inline void set_thread_name(const char* name) noexcept {
83+
pthread_setname_np(pthread_self(), name);
84+
}
7985
#else
8086
inline void set_thread_name(const char*) noexcept {
8187
// intentionally left blank

0 commit comments

Comments
 (0)