diff options
Diffstat (limited to 'common/threads.cpp')
-rw-r--r-- | common/threads.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/common/threads.cpp b/common/threads.cpp index 45f73243..fe34f5b0 100644 --- a/common/threads.cpp +++ b/common/threads.cpp @@ -22,12 +22,13 @@ #include "threads.h" -#include <limits> #include <system_error> #ifdef _WIN32 +#include <limits> + void althrd_setname(const char *name) { #if defined(_MSC_VER) @@ -86,7 +87,7 @@ bool semaphore::try_wait() noexcept #else -#include <cerrno> +#if defined(HAVE_PTHREAD_SETNAME_NP) || defined(HAVE_PTHREAD_SET_NAME_NP) #include <pthread.h> #ifdef HAVE_PTHREAD_NP_H #include <pthread_np.h> @@ -94,20 +95,21 @@ bool semaphore::try_wait() noexcept void althrd_setname(const char *name) { -#if defined(HAVE_PTHREAD_SETNAME_NP) -#if defined(PTHREAD_SETNAME_NP_ONE_PARAM) +#if defined(HAVE_PTHREAD_SET_NAME_NP) + pthread_set_name_np(pthread_self(), name); +#elif defined(PTHREAD_SETNAME_NP_ONE_PARAM) pthread_setname_np(name); #elif defined(PTHREAD_SETNAME_NP_THREE_PARAMS) pthread_setname_np(pthread_self(), "%s", (void*)name); #else pthread_setname_np(pthread_self(), name); #endif -#elif defined(HAVE_PTHREAD_SET_NAME_NP) - pthread_set_name_np(pthread_self(), name); +} + #else - (void)name; + +void althrd_setname(const char*) { } #endif -} namespace al { @@ -134,6 +136,8 @@ bool semaphore::try_wait() noexcept #else /* !__APPLE__ */ +#include <cerrno> + semaphore::semaphore(unsigned int initial) { if(sem_init(&mSem, 0, initial) != 0) |