xserver: Branch 'master'

Adam Jackson ajax at kemper.freedesktop.org
Tue Sep 13 20:57:38 UTC 2016


 configure.ac            |   20 ++++++++++++++++++++
 include/dix-config.h.in |    6 ++++++
 os/inputthread.c        |   12 ++++++++++++
 3 files changed, 38 insertions(+)

New commits:
commit c4799f186b31e579721f5874c897f3f46db6ad0a
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Sat Sep 10 21:14:19 2016 -0700

    os: Use pthread_setname_np to set thread names if available
    
    Autoconf logic borrowed from glib
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
    Tested-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/configure.ac b/configure.ac
index e206e0f..4ff317f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -870,6 +870,26 @@ if test "x$INPUTTHREAD" = "xyes" ; then
     SYS_LIBS="$SYS_LIBS $PTHREAD_LIBS"
     CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
     AC_DEFINE(INPUTTHREAD, 1, [Use a separate input thread])
+
+    save_LIBS="$LIBS"
+    LIBS="$LIBS $SYS_LIBS"
+    dnl MacOS X 10.6 & higher
+    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 GNU libc 2.12 & higher, Solaris 11.3 & higher
+    AC_MSG_CHECKING(for pthread_setname_np(pthread_t, const char*))
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
+                             [pthread_setname_np(pthread_self(), "example")])],
+                   [AC_MSG_RESULT(yes)
+		    AC_DEFINE(HAVE_PTHREAD_SETNAME_NP_WITH_TID,1,
+	                      [Have function pthread_setname_np(pthread_t, const char*)])],
+		   [AC_MSG_RESULT(no)])
+    LIBS="$save_LIBS"
 fi
 
 REQUIRED_MODULES="$FIXESPROTO $DAMAGEPROTO $XCMISCPROTO $XTRANS $BIGREQSPROTO $SDK_REQUIRED_MODULES"
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index d49af92..4f020e5 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -143,6 +143,12 @@
 /* Define to 1 if you have the `mmap' function. */
 #undef HAVE_MMAP
 
+/* Define to 1 if you have the function pthread_setname_np(const char*) */
+#undef HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID
+
+/* Define to 1 if you have the function pthread_setname_np(pthread_t, const char*) */
+#undef HAVE_PTHREAD_SETNAME_NP_WITH_TID
+
 /* Define to 1 if you have the <ndbm.h> header file. */
 #undef HAVE_NDBM_H
 
diff --git a/os/inputthread.c b/os/inputthread.c
index 6b379f5..6aa0a9c 100644
--- a/os/inputthread.c
+++ b/os/inputthread.c
@@ -310,6 +310,12 @@ InputThreadDoWork(void *arg)
 
     inputThreadInfo->running = TRUE;
 
+#if defined(HAVE_PTHREAD_SETNAME_NP_WITH_TID)
+    pthread_setname_np (pthread_self(), "InputThread");
+#elif defined(HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID)
+    pthread_setname_np ("InputThread");
+#endif
+
     ospoll_add(inputThreadInfo->fds, hotplugPipeRead,
                ospoll_trigger_level,
                InputThreadPipeNotify,
@@ -422,6 +428,12 @@ InputThreadPreInit(void)
     }
     hotplugPipeWrite = hotplugPipe[1];
 
+#if defined(HAVE_PTHREAD_SETNAME_NP_WITH_TID)
+    pthread_setname_np (pthread_self(), "MainThread");
+#elif defined(HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID)
+    pthread_setname_np ("MainThread");
+#endif
+
 }
 
 /**


More information about the xorg-commit mailing list