commit 583dc11b22fd086a389399a019363be7f44c70fe
parent b5d8ccf533db180e659425fa775dedf0eab1df85
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date: Tue, 1 Apr 2014 06:22:45 +0000
Really check for presence of pthread_setname_np() instead of guessing
Diffstat:
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/configure.ac b/configure.ac
@@ -212,6 +212,14 @@ if test "$enable_epoll" != "no"; then
fi
fi
+# Check for pthread_setname_np()
+AC_MSG_CHECKING([[for pthread_setname_np]])
+AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM([[#include <pthread.h>]], [[ pthread_setname_np(pthread_self(), "name")]])],
+ [AC_DEFINE([[HAVE_PTHREAD_SETNAME_NP]], [[1]], [Define if you have pthread_setname_np function.])
+ AC_MSG_RESULT([[yes]])],
+ [AC_MSG_RESULT([[no]])] )
+
# Check for headers that are ALWAYS required
AC_CHECK_HEADERS([fcntl.h math.h errno.h limits.h stdio.h locale.h sys/stat.h sys/types.h pthread.h],,AC_MSG_ERROR([Compiling libmicrohttpd requires standard UNIX headers files]))
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
@@ -1073,11 +1073,9 @@ create_thread (pthread_t *thread,
}
ret = pthread_create (thread, pattr,
start_routine, arg);
-#if (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 12)
-#if LINUX
+#ifdef HAVE_PTHREAD_SETNAME_NP
(void) pthread_setname_np (*thread, "libmicrohttpd");
-#endif
-#endif
+#endif /* HAVE_PTHREAD_SETNAME_NP */
if (0 != daemon->thread_stack_size)
pthread_attr_destroy (&attr);
return ret;