Explorar el Código

Really check for presence of pthread_setname_np() instead of guessing

Evgeny Grin (Karlson2k) hace 12 años
padre
commit
583dc11b22
Se han modificado 2 ficheros con 10 adiciones y 4 borrados
  1. 8 0
      configure.ac
  2. 2 4
      src/microhttpd/daemon.c

+ 8 - 0
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]))
 

+ 2 - 4
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;