aboutsummaryrefslogtreecommitdiffstats
path: root/common/threads.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-07-29 09:29:35 -0700
committerChris Robinson <[email protected]>2019-07-29 09:29:35 -0700
commitf0408809d6b2012aca0f1e8a344e087cb504a231 (patch)
tree3cecaa9827519ce5419febe9f584881ad286c97e /common/threads.cpp
parent40e937c63a2a74ef2ff94ba8a056cce0a07832ed (diff)
Cleanup common sources' includes
Diffstat (limited to 'common/threads.cpp')
-rw-r--r--common/threads.cpp20
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)