libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 82d65c48edbccca45bd6851879aa69c629a024b7
parent f154b0ef8894185fd6c01888d10280049bed10c6
Author: Christian Grothoff <christian@grothoff.org>
Date:   Thu, 16 Feb 2017 11:20:50 +0100

replace tsearch test with code from gnulib, to hopefully address silviprog's android problems

Diffstat:
MChangeLog | 3+++
Mconfigure.ac | 8+++++---
Am4/search_h.m4 | 60++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Am4/tsearch.m4 | 59+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 127 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,6 @@ +Thu Feb 16 11:20:05 CET 2017 + Replace tsearch configure check with code from gnulib. -CG + Wed Feb 15 13:35:36 CET 2017 Fixing a few very rare race conditions for thread-pool or thread-per-connection operations during shutdown. diff --git a/configure.ac b/configure.ac @@ -1,5 +1,5 @@ # This file is part of libmicrohttpd. -# (C) 2006-2015 Christian Grothoff (and other contributing authors) +# (C) 2006-2017 Christian Grothoff (and other contributing authors) # # libmicrohttpd is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published @@ -695,12 +695,14 @@ fi AC_CHECK_HEADERS([fcntl.h math.h errno.h limits.h stdio.h locale.h sys/stat.h sys/types.h], [], [AC_MSG_ERROR([Compiling libmicrohttpd requires standard UNIX headers files])], [AC_INCLUDES_DEFAULT]) # Check for optional headers -AC_CHECK_HEADERS([sys/types.h sys/time.h sys/msg.h time.h sys/mman.h search.h sys/ioctl.h \ +AC_CHECK_HEADERS([sys/types.h sys/time.h sys/msg.h time.h sys/mman.h sys/ioctl.h \ sys/socket.h sys/select.h netdb.h netinet/in.h netinet/ip.h netinet/tcp.h arpa/inet.h \ endian.h machine/endian.h sys/endian.h sys/param.h sys/machine.h sys/byteorder.h machine/param.h sys/isa_defs.h \ inttypes.h stddef.h unistd.h \ sockLib.h inetLib.h net/if.h], [], [], [AC_INCLUDES_DEFAULT]) -AM_CONDITIONAL([HAVE_TSEARCH], [test "x$ac_cv_header_search_h" = "xyes"]) + +gl_FUNC_TSEARCH +AM_CONDITIONAL([HAVE_TSEARCH], [test "x$HAVE_TSEARCH" = "x1"]) # Check for generic functions AC_CHECK_FUNCS([rand random]) diff --git a/m4/search_h.m4 b/m4/search_h.m4 @@ -0,0 +1,60 @@ +# search_h.m4 serial 9 +dnl Copyright (C) 2007-2017 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_SEARCH_H], +[ + AC_REQUIRE([gl_SEARCH_H_DEFAULTS]) + gl_CHECK_NEXT_HEADERS([search.h]) + if test $ac_cv_header_search_h = yes; then + HAVE_SEARCH_H=1 + else + HAVE_SEARCH_H=0 + fi + AC_SUBST([HAVE_SEARCH_H]) + + if test $HAVE_SEARCH_H = 1; then + AC_CACHE_CHECK([for type VISIT], [gl_cv_type_VISIT], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#if HAVE_SEARCH_H + #include <search.h> + #endif + ]], + [[static VISIT x; x = postorder;]])], + [gl_cv_type_VISIT=yes], + [gl_cv_type_VISIT=no])]) + else + gl_cv_type_VISIT=no + fi + if test $gl_cv_type_VISIT = yes; then + HAVE_TYPE_VISIT=1 + else + HAVE_TYPE_VISIT=0 + fi + AC_SUBST([HAVE_TYPE_VISIT]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[#include <search.h> + ]], [tdelete tfind tsearch twalk]) +]) + +AC_DEFUN([gl_SEARCH_MODULE_INDICATOR], +[ + dnl Use AC_REQUIRE here, so that the default settings are expanded once only. + AC_REQUIRE([gl_SEARCH_H_DEFAULTS]) + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +AC_DEFUN([gl_SEARCH_H_DEFAULTS], +[ + GNULIB_TSEARCH=0; AC_SUBST([GNULIB_TSEARCH]) + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_TSEARCH=1; AC_SUBST([HAVE_TSEARCH]) + REPLACE_TSEARCH=0; AC_SUBST([REPLACE_TSEARCH]) +]) diff --git a/m4/tsearch.m4 b/m4/tsearch.m4 @@ -0,0 +1,59 @@ +# tsearch.m4 serial 6 +dnl Copyright (C) 2006-2017 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_TSEARCH], +[ + AC_REQUIRE([gl_SEARCH_H_DEFAULTS]) + AC_CHECK_FUNCS([tsearch]) + if test $ac_cv_func_tsearch = yes; then + dnl On OpenBSD 4.0, the return value of tdelete() is incorrect. + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether tdelete works], [gl_cv_func_tdelete_works], + [ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include <stddef.h> +#include <search.h> +static int +cmp_fn (const void *a, const void *b) +{ + return *(const int *) a - *(const int *) b; +} +int +main () +{ + int result = 0; + int x = 0; + void *root = NULL; + if (!(tfind (&x, &root, cmp_fn) == NULL)) + result |= 1; + tsearch (&x, &root, cmp_fn); + if (!(tfind (&x, &root, cmp_fn) != NULL)) + result |= 2; + if (!(tdelete (&x, &root, cmp_fn) != NULL)) + result |= 4; + return result; +}]])], [gl_cv_func_tdelete_works=yes], [gl_cv_func_tdelete_works=no], + [case "$host_os" in + openbsd*) gl_cv_func_tdelete_works="guessing no";; + *) gl_cv_func_tdelete_works="guessing yes";; + esac + ]) + ]) + case "$gl_cv_func_tdelete_works" in + *no) + REPLACE_TSEARCH=1 + ;; + esac + else + HAVE_TSEARCH=0 + fi +]) + +# Prerequisites of lib/tsearch.c. +AC_DEFUN([gl_PREREQ_TSEARCH], [ + : +])