Skip to content
This repository
Browse code

Merge pull request #2323 from dagwieers/pthread_setname

Name threads properly on Linux, FreeBSD, OpenBSD, ...
  • Loading branch information...
commit c1aa24d42f24e5843197f348d9581ee6f85c0d44 2 parents 2c8e509 + 66d191e
Joakim Plate authored March 01, 2013
6  configure.in
@@ -974,9 +974,15 @@ AC_CHECK_LIB([jpeg],        [main],, AC_MSG_ERROR($missing_library)) # check for
974 974
 AC_CHECK_LIB([tiff],        [main],, AC_MSG_ERROR($missing_library))
975 975
 if echo "$ARCH" | grep -q freebsd; then
976 976
 AC_CHECK_LIB([pthread],     [main],LIBS="-pthread $LIBS", AC_MSG_ERROR($missing_library))
  977
+AC_CHECK_LIB([pthread],     [pthread_set_name_np],
  978
+  AC_DEFINE([HAVE_PTHREAD_SET_NAME_NP],[1],["Define to 1 if pthread has pthread_set_name_np"]),
  979
+  AC_MSG_RESULT([Could not find pthread_set_name_np in pthread]))
977 980
 else
978 981
 if test "$target_platform" != "target_android" ; then
979 982
   AC_CHECK_LIB([pthread],     [main],, AC_MSG_ERROR($missing_library))
  983
+  AC_CHECK_LIB([pthread],     [pthread_setname_np],
  984
+    AC_DEFINE([HAVE_PTHREAD_SETNAME_NP],[1],["Define to 1 if pthread has pthread_setname_np"]),
  985
+    AC_MSG_RESULT([Could not find pthread_setname_np in pthread]))
980 986
 fi
981 987
 fi
982 988
 AC_CHECK_LIB([lzo2],        [main],, AC_MSG_ERROR($missing_library))
7  xbmc/threads/platform/pthreads/ThreadImpl.cpp
@@ -18,6 +18,7 @@
18 18
  *
19 19
  */
20 20
 
  21
+#include "config.h"
21 22
 #include <limits.h>
22 23
 #if defined(TARGET_ANDROID)
23 24
 #include <unistd.h>
@@ -71,10 +72,16 @@ void CThread::SetThreadInfo()
71 72
   m_ThreadOpaque.LwpId = syscall(SYS_gettid);
72 73
 #endif
73 74
 
  75
+#if defined(HAVE_PTHREAD_SETNAME_NP)
74 76
 #ifdef TARGET_DARWIN
75 77
 #if(__MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 || __IPHONE_OS_VERSION_MIN_REQUIRED >= 30200)
76 78
   pthread_setname_np(m_ThreadName.c_str());
77 79
 #endif
  80
+#else
  81
+  pthread_setname_np(m_ThreadId, m_ThreadName.c_str());
  82
+#endif
  83
+#elif defined(HAVE_PTHREAD_SET_NAME_NP)
  84
+  pthread_set_name_np(m_ThreadId, m_ThreadName.c_str());
78 85
 #endif
79 86
     
80 87
 #ifdef RLIMIT_NICE

0 notes on commit c1aa24d

Please sign in to comment.
Something went wrong with that request. Please try again.