Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #2323 from dagwieers/pthread_setname

Name threads properly on Linux, FreeBSD, OpenBSD, ...
  • Loading branch information...
commit c1aa24d42f24e5843197f348d9581ee6f85c0d44 2 parents 2c8e509 + 66d191e
@elupus elupus authored
Showing with 13 additions and 0 deletions.
  1. +6 −0 configure.in
  2. +7 −0 xbmc/threads/platform/pthreads/ThreadImpl.cpp
View
6 configure.in
@@ -974,9 +974,15 @@ AC_CHECK_LIB([jpeg], [main],, AC_MSG_ERROR($missing_library)) # check for
AC_CHECK_LIB([tiff], [main],, AC_MSG_ERROR($missing_library))
if echo "$ARCH" | grep -q freebsd; then
AC_CHECK_LIB([pthread], [main],LIBS="-pthread $LIBS", AC_MSG_ERROR($missing_library))
+AC_CHECK_LIB([pthread], [pthread_set_name_np],
+ AC_DEFINE([HAVE_PTHREAD_SET_NAME_NP],[1],["Define to 1 if pthread has pthread_set_name_np"]),
+ AC_MSG_RESULT([Could not find pthread_set_name_np in pthread]))
else
if test "$target_platform" != "target_android" ; then
AC_CHECK_LIB([pthread], [main],, AC_MSG_ERROR($missing_library))
+ AC_CHECK_LIB([pthread], [pthread_setname_np],
+ AC_DEFINE([HAVE_PTHREAD_SETNAME_NP],[1],["Define to 1 if pthread has pthread_setname_np"]),
+ AC_MSG_RESULT([Could not find pthread_setname_np in pthread]))
fi
fi
AC_CHECK_LIB([lzo2], [main],, AC_MSG_ERROR($missing_library))
View
7 xbmc/threads/platform/pthreads/ThreadImpl.cpp
@@ -18,6 +18,7 @@
*
*/
+#include "config.h"
#include <limits.h>
#if defined(TARGET_ANDROID)
#include <unistd.h>
@@ -71,10 +72,16 @@ void CThread::SetThreadInfo()
m_ThreadOpaque.LwpId = syscall(SYS_gettid);
#endif
+#if defined(HAVE_PTHREAD_SETNAME_NP)
#ifdef TARGET_DARWIN
#if(__MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 || __IPHONE_OS_VERSION_MIN_REQUIRED >= 30200)
pthread_setname_np(m_ThreadName.c_str());
#endif
+#else
+ pthread_setname_np(m_ThreadId, m_ThreadName.c_str());
+#endif
+#elif defined(HAVE_PTHREAD_SET_NAME_NP)
+ pthread_set_name_np(m_ThreadId, m_ThreadName.c_str());
#endif
#ifdef RLIMIT_NICE
Please sign in to comment.
Something went wrong with that request. Please try again.