From d27afa928c442e5ea58e7aa42fe342c5d26ab837 Mon Sep 17 00:00:00 2001 From: Roland Jax Date: Fri, 14 Nov 2014 16:41:05 +0100 Subject: [PATCH] check for pthread function 'pthread_setname_np' added. --- Makefile.am | 2 +- configure.ac | 6 +++++- src/lib/utils/thread.cpp | 5 +++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index 2bf1f2d5..ef6ef5c0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = src/lib/ebus src/lib/ebus/test src/lib/utils src/ebusd src/ebusctl +SUBDIRS = src/lib/utils src/lib/ebus src/lib/ebus/test src/ebusd src/ebusctl distclean-local: -rm -rf autom4te.cache diff --git a/configure.ac b/configure.ac index a5cebf73..589f43f5 100644 --- a/configure.ac +++ b/configure.ac @@ -12,13 +12,17 @@ AC_CHECK_HEADERS([arpa/inet.h \ sys/ioctl.h \ termios.h]) +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])) + AC_CONFIG_AUX_DIR([build]) AC_CONFIG_SRCDIR([src/ebusd/ebusd.cpp]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_FILES([Makefile + src/lib/utils/Makefile src/lib/ebus/Makefile src/lib/ebus/test/Makefile - src/lib/utils/Makefile src/ebusd/Makefile src/ebusctl/Makefile]) diff --git a/src/lib/utils/thread.cpp b/src/lib/utils/thread.cpp index 48dbc250..7393587b 100644 --- a/src/lib/utils/thread.cpp +++ b/src/lib/utils/thread.cpp @@ -17,6 +17,7 @@ * along with ebusd. If not, see http://www.gnu.org/licenses/. */ +#include "config.h" #include "thread.h" static void* runThread(void* arg) @@ -39,7 +40,11 @@ int Thread::start(const char* name) int result = pthread_create(&m_threadid, NULL, runThread, this); if (result == 0) { + +#ifdef HAVE_PTHREAD_SETNAME_NP pthread_setname_np(m_threadid, name); +#endif + m_running = true; }