diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2016-08-10 13:52:47 +0000 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2016-08-10 13:52:47 +0000 |
commit | a7029c10cccdf2b0d4597eb79fb58d2f11d167f1 (patch) | |
tree | d11d1941b64fd11f3e4d3b9f462facaa011af520 | |
parent | f1316455d7f9abbf68cb227d4df1124e6a979454 (diff) |
configure.ac: added --disable-thread-names parameter
-rw-r--r-- | configure.ac | 43 | ||||
-rw-r--r-- | src/include/microhttpd.h | 10 | ||||
-rw-r--r-- | src/microhttpd/daemon.c | 6 |
3 files changed, 56 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac index 53c67de6..54a516e7 100644 --- a/configure.ac +++ b/configure.ac @@ -302,7 +302,11 @@ AM_CONDITIONAL([USE_POSIX_THREADS], [test "x$USE_THREADS" = "xposix"]) AM_CONDITIONAL([USE_W32_THREADS], [test "x$USE_THREADS" = "xw32"]) AC_MSG_RESULT([[$USE_THREADS]]) -if test "x$HAVE_POSIX_THREADS" = "xyes"; then +AC_ARG_ENABLE([[thread-names]], + [AS_HELP_STRING([--disable-thread-names [auto] ],[do not set names on MHD generated threads])], + [], [enable_thread_names='auto']) + +if test "x$enable_thread_names" != "xno" && test "x$USE_THREADS" = "xposix"; then # Check for pthread_setname_np() SAVE_LIBS="$LIBS" SAVE_CFLAGS="$CFLAGS" @@ -362,6 +366,42 @@ if test "x$HAVE_POSIX_THREADS" = "xyes"; then CFLAGS="$SAVE_CFLAGS" fi +AS_IF( + [[test "x$enable_thread_names" != "xno"]], + [ + AC_MSG_CHECKING([[whether to enable thread names]]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([], [[ +#ifdef MHD_NO_THREAD_NAMES +#error Thread names are disabled. +choke me +#endif + +/* Keep in sync with mhd_threads.h */ +#if defined(MHD_USE_POSIX_THREADS) && (defined(HAVE_PTHREAD_SETNAME_NP_GNU) || defined(HAVE_PTHREAD_SET_NAME_NP_FREEBSD) || defined(HAVE_PTHREAD_SETNAME_NP_DARWIN) || defined(HAVE_PTHREAD_SETNAME_NP_NETBSD) ) +int a = 1; +#elif defined(MHD_USE_W32_THREADS) && defined(_MSC_FULL_VER) +int b = 2; +#else +#error No thread name function is available. +choke me +#endif + ]]) + ], [ + enable_thread_names='yes' + ], [ + AS_IF([[test "x$enable_thread_names" = "xyes"]], + [ + AC_MSG_RESULT([[no]]) + AC_MSG_ERROR([[thread names was explicitly requested, but thread name function is not available]]) + ]) + enable_thread_names='no' + ]) + AC_MSG_RESULT([[$enable_thread_names]]) + ]) + +AS_IF([[test "x$enable_thread_names" = "xno"]], + [AC_DEFINE([[MHD_NO_THREAD_NAMES]], [[1]], [Define to 1 to disable setting name on generated threads])]) AM_CONDITIONAL(HAVE_W32, [test "x$os_is_native_w32" = "xyes"]) w32_shared_lib_exp=no @@ -1007,6 +1047,7 @@ AC_MSG_NOTICE([libmicrohttpd ${PACKAGE_VERSION} Configuration Summary: Cross-compiling: ${cross_compiling} Operating System: ${host_os} Threading lib: ${USE_THREADS} + Use thread names: ${enable_thread_names} libcurl (testing): ${MSG_CURL} Target directory: ${prefix} Messages: ${enable_messages} diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h index 878897ec..39a0703e 100644 --- a/src/include/microhttpd.h +++ b/src/include/microhttpd.h @@ -21,6 +21,7 @@ * @file microhttpd.h * @brief public interface to libmicrohttpd * @author Christian Grothoff + * @author Karlson2k (Evgeny Grin) * @author Chris GauthierDickey * * All symbols defined in this header start with MHD. MHD is a small @@ -130,7 +131,7 @@ typedef intptr_t ssize_t; * Current version of the library. * 0x01093001 = 1.9.30-1. */ -#define MHD_VERSION 0x00095002 +#define MHD_VERSION 0x00095003 /** * MHD-internal return code for "YES". @@ -2817,7 +2818,12 @@ enum MHD_FEATURE * offsets larger than 2 GiB. If not supported value of size+offset is * limited to 2 GiB. */ - MHD_FEATURE_LARGE_FILE = 15 + MHD_FEATURE_LARGE_FILE = 15, + + /** + * Get whether MHD set names on generated threads. + */ + MHD_THREAD_NAMES = 16 }; diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index f493d19d..4845d60a 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c @@ -4905,6 +4905,12 @@ MHD_is_feature_supported(enum MHD_FEATURE feature) #else return (sizeof(uint64_t) > sizeof(off_t)) ? MHD_NO : MHD_YES; #endif + case MHD_THREAD_NAMES: +#if defined(MHD_USE_THREAD_NAME_) + return MHD_YES; +#else + return MHD_NO; +#endif } return MHD_NO; } |