Skip to content

Commit

Permalink
Implement set_thread_name() on FreeBSD
Browse files Browse the repository at this point in the history
  • Loading branch information
AMDmi3 committed Mar 14, 2022
1 parent 1fb34f9 commit 4d01c4f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions include/osmium/thread/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ DEALINGS IN THE SOFTWARE.
#include <thread>
#include <utility>

#ifdef __linux__
#if defined(__linux__)
# include <sys/prctl.h>
#elif defined(__FreeBSD__)
# include <pthread.h>
#endif

namespace osmium {
Expand Down Expand Up @@ -72,10 +74,14 @@ namespace osmium {
/**
* Set name of current thread for debugging. This only works on Linux.
*/
#ifdef __linux__
#if defined(__linux__)
inline void set_thread_name(const char* name) noexcept {
prctl(PR_SET_NAME, name, 0, 0, 0);
}
#elif defined(__FreeBSD__)
inline void set_thread_name(const char* name) noexcept {
pthread_setname_np(pthread_self(), name);
}
#else
inline void set_thread_name(const char*) noexcept {
// intentionally left blank
Expand Down

0 comments on commit 4d01c4f

Please sign in to comment.