Skip to content

Commit d44fdd9

Browse files
authored
Merge pull request #131 from jcm93/mac-threadname-fix
Account for macOS when defining pthread functions
2 parents ae5b6bd + 8d4d2fa commit d44fdd9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

util/thread_name.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#include "thread_name.hpp"
2424

25-
#ifdef __linux__
25+
#if !defined(_WIN32)
2626
#include <pthread.h>
2727
#else
2828
#define WIN32_LEAN_AND_MEAN
@@ -34,9 +34,11 @@ namespace Util
3434
{
3535
void set_current_thread_name(const char *name)
3636
{
37-
#ifdef __linux__
37+
#if defined(__linux__)
3838
pthread_setname_np(pthread_self(), name);
39-
#else
39+
#elif defined(__APPLE__)
40+
pthread_setname_np(name);
41+
#elif defined(_WIN32)
4042
using PFN_SetThreadDescription = HRESULT (WINAPI *)(HANDLE, PCWSTR);
4143
auto module = GetModuleHandleA("kernel32.dll");
4244
PFN_SetThreadDescription SetThreadDescription = module ? reinterpret_cast<PFN_SetThreadDescription>(
@@ -54,4 +56,4 @@ void set_current_thread_name(const char *name)
5456
}
5557
#endif
5658
}
57-
}
59+
}

0 commit comments

Comments
 (0)