aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt21
-rw-r--r--common/threads.c4
-rw-r--r--config.h.in3
3 files changed, 26 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e503df92..9326f270 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -561,12 +561,33 @@ IF(NOT HAVE_WINDOWS_H)
CHECK_SYMBOL_EXISTS(pthread_setname_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SETNAME_NP)
IF(NOT HAVE_PTHREAD_SETNAME_NP)
CHECK_SYMBOL_EXISTS(pthread_set_name_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SET_NAME_NP)
+ ELSE()
+ CHECK_C_SOURCE_COMPILES("
+#include <pthread.h>
+#include <pthread_np.h>
+int main()
+{
+ pthread_setname_np(\"testname\");
+ return 0;
+}"
+ PTHREAD_SETNAME_NP_ONE_PARAM
+ )
ENDIF()
CHECK_SYMBOL_EXISTS(pthread_mutexattr_setkind_np "pthread.h;pthread_np.h" HAVE_PTHREAD_MUTEXATTR_SETKIND_NP)
ELSE()
CHECK_SYMBOL_EXISTS(pthread_setname_np pthread.h HAVE_PTHREAD_SETNAME_NP)
IF(NOT HAVE_PTHREAD_SETNAME_NP)
CHECK_SYMBOL_EXISTS(pthread_set_name_np pthread.h HAVE_PTHREAD_SET_NAME_NP)
+ ELSE()
+ CHECK_C_SOURCE_COMPILES("
+#include <pthread.h>
+int main()
+{
+ pthread_setname_np(\"testname\");
+ return 0;
+}"
+ PTHREAD_SETNAME_NP_ONE_PARAM
+ )
ENDIF()
CHECK_SYMBOL_EXISTS(pthread_mutexattr_setkind_np pthread.h HAVE_PTHREAD_MUTEXATTR_SETKIND_NP)
ENDIF()
diff --git a/common/threads.c b/common/threads.c
index 1f6f2223..127b9083 100644
--- a/common/threads.c
+++ b/common/threads.c
@@ -497,10 +497,10 @@ extern inline void alcall_once(alonce_flag *once, void (*callback)(void));
void althrd_setname(althrd_t thr, const char *name)
{
#if defined(HAVE_PTHREAD_SETNAME_NP)
-#if defined(__APPLE__)
+#if defined(PTHREAD_SETNAME_NP_ONE_PARAM)
if(althrd_equal(thr, althrd_current()))
pthread_setname_np(name);
-#elif defined(__GNUC__)
+#else
pthread_setname_np(thr, name);
#endif
#elif defined(HAVE_PTHREAD_SET_NAME_NP)
diff --git a/config.h.in b/config.h.in
index 3bc3eb48..dd020027 100644
--- a/config.h.in
+++ b/config.h.in
@@ -194,6 +194,9 @@
/* Define if we have pthread_setname_np() */
#cmakedefine HAVE_PTHREAD_SETNAME_NP
+/* Define if pthread_setname_np() only accepts one parameter */
+#cmakedefine PTHREAD_SETNAME_NP_ONE_PARAM
+
/* Define if we have pthread_set_name_np() */
#cmakedefine HAVE_PTHREAD_SET_NAME_NP