dnl check for sys/prctl for setting thread name on Linux
AC_CHECK_HEADERS([sys/prctl.h], [], [], [AC_INCLUDES_DEFAULT])
+dnl check for pthread_setname_np(const char*)
+dnl which is present on OS X 10.6, iOS 3.2 and above
+AC_MSG_CHECKING(for pthread_setname_np(const char*))
+AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM(
+ [#include <pthread.h>],
+ [pthread_setname_np("example")])],
+ [AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID,1,
+ [Have function pthread_setname_np(const char*)])],
+ [AC_MSG_RESULT(no)])
+
dnl check for sys/uio.h for writev()
AC_CHECK_HEADERS([sys/uio.h], [], [], [AC_INCLUDES_DEFAULT])
#include <sys/prctl.h>
#endif
+#ifdef HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID
+#include <pthread.h>
+#endif
+
GST_DEBUG_CATEGORY_STATIC (task_debug);
#define GST_CAT_DEFAULT (task_debug)
GST_DEBUG_OBJECT (task, "Failed to set thread name");
}
GST_OBJECT_UNLOCK (task);
-#endif
-#ifdef _MSC_VER
+#elif defined(HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID)
+ const gchar *name;
+
+ GST_OBJECT_LOCK (task);
+ name = GST_OBJECT_NAME (task);
+
+ /* set the thread name to something easily identifiable */
+ GST_DEBUG_OBJECT (task, "Setting thread name to '%s'", name);
+ if (pthread_setname_np (name))
+ GST_DEBUG_OBJECT (task, "Failed to set thread name");
+
+ GST_OBJECT_UNLOCK (task);
+#elif _MSC_VER
const gchar *name;
name = GST_OBJECT_NAME (task);