gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] branch master updated (12f637aa -> dcd8ea98)


From: gnunet
Subject: [libmicrohttpd] branch master updated (12f637aa -> dcd8ea98)
Date: Tue, 14 Mar 2023 19:36:45 +0100

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from 12f637aa Corrected NEWS and ChangeLog
     new 2124a70e daemon.c: fixed heap manipulations with mutex held
     new 7b22ec1c tsearch.{h,c}: updated to the latest fixed version
     new 23b4be2f configure: reordered checks for compiler flags
     new 29311f40 mhd_check_link_run.m4: fixed typo in comment
     new 677e6e43 configure: fixed checks for tsearch() and related
     new 6b6c6db4 Makefile: fixed build with 'make' without nested vars support
     new 22686148 mhd_check_func.m4: updated
     new 41ceade7 mhd_shutdown_socket_trigger.m4: fixed compiler warning
     new 48255935 configure: fixed some compiler warnings for checks
     new da73f7ab mhd_check_func.m4: added check for function declaration
     new f53cc366 libcurl.m4: updated to the latest version
     new d088b940 libcurl.m4: patched to fix compiler warning
     new 60fa305a mhd_find_lib.m4: added new autoconf macro
     new ccf82053 configure: fixed checking for system libs, fixed .pc file
     new 17bc3279 configure: removed check for unused lib and function
     new 05905499 configure: fixed more compiler warnings in log
     new 04df6722 configure: fixed potential compiler warnings, added usage of 
cache vars
     new 8ba307c9 configure: cosmetics
     new b8089fef configure: improved compatibility with POSIX
     new 779bbfb5 configure: cosmetics: deleted extra spaces
     new dcd8ea98 mhd_check_func_gettimeofday.m4: added new autoconf macro

The 21 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 configure.ac                      | 779 ++++++++++++++++++++++++++------------
 m4/libcurl.m4                     |  11 +-
 m4/mhd_check_func.m4              | 101 +++--
 m4/mhd_check_func_gettimeofday.m4 |  53 +++
 m4/mhd_check_link_run.m4          |   8 +-
 m4/mhd_find_lib.m4                | 142 +++++++
 m4/mhd_shutdown_socket_trigger.m4 |   8 +-
 m4/search_h.m4                    |  66 ----
 m4/tsearch.m4                     |  64 ----
 src/lib/Makefile.am               |   2 +-
 src/microhttpd/Makefile.am        |  10 +-
 src/microhttpd/daemon.c           |  11 +-
 src/microhttpd/tsearch.c          |  86 ++---
 src/microhttpd/tsearch.h          |  31 +-
 14 files changed, 877 insertions(+), 495 deletions(-)
 create mode 100644 m4/mhd_check_func_gettimeofday.m4
 create mode 100644 m4/mhd_find_lib.m4
 delete mode 100644 m4/search_h.m4
 delete mode 100644 m4/tsearch.m4

diff --git a/configure.ac b/configure.ac
index e224cd88..9396240e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -102,7 +102,7 @@ AS_VAR_IF([enable_build_type], ["debugger"],
   [ # Build only static version unless something else is specified by the user
     AS_IF([test -z "${enable_static}" || test "x${enable_static}" = "xyes"],
       [
-        AS_IF([test -z "${enable_shared}"], 
+        AS_IF([test -z "${enable_shared}"],
           [
             enable_shared="no"
             enable_static="yes"
@@ -191,7 +191,7 @@ AS_CASE([${enable_compact_code}], [auto],
       ],[],[/* no includes */]
     )
 
-    AS_VAR_IF([enable_compact_code], ["auto"], 
+    AS_VAR_IF([enable_compact_code], ["auto"],
       [
         # No preference by preprocessor macros
         AC_CACHE_CHECK([whether compiler is configured to optimize for size],
@@ -220,7 +220,7 @@ choke me now
       ]
     )
 
-    AS_VAR_IF([enable_compact_code], ["auto"], 
+    AS_VAR_IF([enable_compact_code], ["auto"],
       [
         # No preference by preprocessor macros and compiler flags
         AS_CASE([${enable_build_type}],[*-compact],
@@ -233,7 +233,7 @@ choke me now
       ]
     )
 
-    AS_VAR_IF([enable_compact_code], ["auto"], 
+    AS_VAR_IF([enable_compact_code], ["auto"],
       [
         # No preference
         enable_compact_code="no"
@@ -281,6 +281,7 @@ MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-fno-strict-aliasing], 
[-qnoansialias])
 # '-qlonglong' is XLC option for C89, not used with C99 or later
 MHD_CHECK_ADD_CC_CFLAG([-qlonglong], [CFLAGS_ac])
 
+# Set basic optimisation flags
 AS_VAR_IF([enable_build_type],["neutral"],[],
   [ # Any non-neutral build types
     AC_CACHE_CHECK([whether workarounds for clang or clang-based compiler are 
required],
@@ -298,14 +299,6 @@ choke me now
         )
       ]
     )
-    MHD_CHECK_ADD_CC_CFLAGS([-Wall -fdelete-null-pointer-checks 
-Wnull-dereference], [CFLAGS_ac])
-    MHD_CHECK_ADD_CC_CFLAGS([-Wdeclaration-after-statement -Wimplicit 
-Wnested-externs], [CFLAGS_ac])
-    MHD_CHECK_ADD_CC_CFLAGS([-Wredundant-decls -Wtrampolines 
-Wunsafe-loop-optimizations], [CFLAGS_ac])
-    MHD_CHECK_ADD_CC_CFLAGS([-Wpoison-system-directories], [CFLAGS_ac])
-    CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
-    LDFLAGS="${user_LDFLAGS}"
-    MHD_CHECK_ADD_CC_LDFLAG([-Wl,--warn-common], [LDFLAGS_ac])
-    LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
   ]
 )
 AS_CASE([${enable_build_type}],[debug|debugger],
@@ -321,6 +314,53 @@ AS_CASE([${enable_build_type}],[debug|debugger],
       ],
       [MHD_CHECK_ADD_CC_CFLAG([-O0], [CFLAGS_ac])]
     )
+    CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
+  ]
+)
+AS_CASE([${enable_build_type}],[release|release-*],
+  [ # All release types
+    AS_VAR_IF([enable_build_type],["release-compact"],
+      [
+        CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
+        AC_CHECK_DECL([MHD_FAVOR_SMALL_CODE],[],
+          [AC_CHECK_DECL([MHD_FAVOR_FAST_CODE],[],
+            [MHD_APPEND_FLAG_TO_VAR([CPPFLAGS_ac],[-DMHD_FAVOR_SMALL_CODE=1])],
+            [/* no includes */])],[/* no includes */])
+        CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
+        CFLAGS="${user_CFLAGS}"
+        MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-Oz], [-Os], [-O])
+           CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
+      ],
+      [ # All non-compact release types
+        CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
+        AC_CHECK_DECL([MHD_FAVOR_SMALL_CODE],[],
+          [AC_CHECK_DECL([MHD_FAVOR_FAST_CODE],[],
+            [MHD_APPEND_FLAG_TO_VAR([CPPFLAGS_ac],[-DMHD_FAVOR_FAST_CODE=1])],
+            [/* no includes */])],[/* no includes */])
+        CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
+        CFLAGS="${user_CFLAGS}"
+        MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-O2], [-O])
+           CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
+      ]
+    )
+  ]
+)
+
+AS_VAR_IF([enable_build_type],["neutral"],[],
+  [ # Any non-neutral build types
+    MHD_CHECK_ADD_CC_CFLAGS([-Wall -Wnull-dereference], [CFLAGS_ac])
+    MHD_CHECK_ADD_CC_CFLAGS([-Wdeclaration-after-statement -Wimplicit 
-Wnested-externs], [CFLAGS_ac])
+    MHD_CHECK_ADD_CC_CFLAGS([-Wredundant-decls -Wtrampolines 
-Wunsafe-loop-optimizations], [CFLAGS_ac])
+    MHD_CHECK_ADD_CC_CFLAGS([-Wpoison-system-directories], [CFLAGS_ac])
+    CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
+    LDFLAGS="${user_LDFLAGS}"
+    MHD_CHECK_ADD_CC_LDFLAG([-Wl,--warn-common], [LDFLAGS_ac])
+    LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
+  ]
+)
+AS_CASE([${enable_build_type}],[debug|debugger],
+  [ # Debug build or build for walking with debugger
+    CFLAGS="${user_CFLAGS}"
     MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-ggdb3], [-g3], [-ggdb], [-g])
     MHD_CHECK_ADD_CC_CFLAGS([-Wextra -Wdouble-promotion], [CFLAGS_ac])
     MHD_FIND_ADD_CC_CFLAG_IFELSE(
@@ -407,21 +447,8 @@ AS_CASE([${enable_build_type}],[release|release-*],
   [ # All release types
     CFLAGS="${user_CFLAGS}"
     AS_VAR_IF([enable_build_type],["release-compact"],
-      [
-        AC_CHECK_DECL([MHD_FAVOR_SMALL_CODE],[],
-          [AC_CHECK_DECL([MHD_FAVOR_FAST_CODE],[],
-            [MHD_APPEND_FLAG_TO_VAR([CPPFLAGS_ac],[-DMHD_FAVOR_SMALL_CODE=1])],
-            [/* no includes */])],[/* no includes */])
-        CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
-        MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-Oz], [-Os], [-O])
-      ],
+      [],
       [ # All non-compact release types
-        AC_CHECK_DECL([MHD_FAVOR_SMALL_CODE],[],
-          [AC_CHECK_DECL([MHD_FAVOR_FAST_CODE],[],
-            [MHD_APPEND_FLAG_TO_VAR([CPPFLAGS_ac],[-DMHD_FAVOR_FAST_CODE=1])],
-            [/* no includes */])],[/* no includes */])
-        CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
-        MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-O2], [-O])
         MHD_CHECK_ADD_CC_CFLAGS([-fsched-pressure -fira-loop-pressure 
-fmerge-all-constants], [CFLAGS_ac]) # These flags may improve size, recheck 
with LTO and linker garbage collection
         MHD_CHECK_ADD_CC_CFLAGS([-ftree-partial-pre -fgcse-after-reload 
-fipa-pta], [CFLAGS_ac])
         MHD_CHECK_ADD_CC_CFLAGS([-fisolate-erroneous-paths-attribute 
-ffinite-loops -floop-nest-optimize], [CFLAGS_ac])
@@ -456,7 +483,8 @@ AC_CHECK_HEADERS_ONCE([stdio.h string.h stdint.h errno.h 
limits.h fcntl.h], [],
   [AC_MSG_ERROR([Compiling libmicrohttpd requires standard POSIX headers 
files])], [AC_INCLUDES_DEFAULT])
 
 # Check for basic optional headers
-AC_CHECK_HEADERS([stddef.h stdlib.h inttypes.h sys/types.h sys/stat.h 
unistd.h], [], [], [AC_INCLUDES_DEFAULT])
+AC_CHECK_HEADERS([stddef.h stdlib.h inttypes.h sys/types.h sys/stat.h unistd.h 
\
+                  sys/uio.h], [], [], [AC_INCLUDES_DEFAULT])
 
 # Check for clock-specific optional headers
 AC_CHECK_HEADERS([sys/time.h time.h], [], [], [AC_INCLUDES_DEFAULT])
@@ -498,14 +526,124 @@ AC_CHECK_HEADERS([sys/msg.h sys/mman.h signal.h], [], 
[], [AC_INCLUDES_DEFAULT])
 
 AC_CHECK_HEADER([[search.h]],
   [
-   gl_FUNC_TSEARCH
-   AS_IF([[test "x$HAVE_TSEARCH" = "x1" && test "x$REPLACE_TSEARCH" != "x1"]],
-     [AC_DEFINE([[HAVE_SEARCH_H]], [[1]],
-       [Define to 1 if you have the <search.h> header file and your system 
have properly functioning tsearch(), tfind() and tdelete() functions])])
-  ],
-  [], [AC_INCLUDES_DEFAULT])
+    MHD_CHECK_LINK_RUN([[for proper tsearch(), tfind() and 
tdelete()]],[[mhd_cv_sys_tsearch_usable]],
+         [
+           AS_CASE([$host_os],
+             [openbsd*],
+             [[ # Some OpenBSD versions have wrong return value for tdelete()
+               mhd_cv_sys_tsearch_usable='assuming no'
+             ]],
+             [netbsd*],
+             [[ # NetBSD had leaked root node for years
+               mhd_cv_sys_tsearch_usable='assuming no'
+             ]],
+             [[mhd_cv_sys_tsearch_usable='assuming yes']]
+           )
+         ],
+         [
+           AC_LANG_SOURCE(
+             [[
+#ifdef HAVE_STDDEF_H
+#include <stddef.h>
+#endif /* HAVE_STDDEF_H */
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif /* HAVE_STDLIB_H */
+
+#include <stdio.h>
+#include <search.h>
+
+static int cmp_func(const void *p1, const void *p2)
+{
+  return (*((const int *)p1)) - (*((const int *)p2));
+}
+
+int main(void)
+{
+  int ret = 0;
+  void *root_ptr = NULL;
+  int element1 = 1;
+  int **element_ptr_ptr1;
+  int **element_ptr_ptr2;
+
+  element_ptr_ptr1 =
+    (int **) tsearch ((void*) &element1, &root_ptr, &cmp_func);
+  if (NULL == element_ptr_ptr1)
+  {
+    fprintf (stderr, "NULL pointer has been returned when tsearch() called for 
the first time.\n");
+    return ++ret;
+  }
+  if (*element_ptr_ptr1 != &element1)
+  {
+    fprintf (stderr, "Wrong pointer has been returned when tsearch() called 
for the first time.\n");
+    return ++ret;
+  }
+  if (NULL == root_ptr)
+  {
+    fprintf (stderr, "Root pointer has not been set by tsearch().\n");
+    return ++ret;
+  }
+
+  element_ptr_ptr2 =
+    (int **) tsearch ((void*) &element1, &root_ptr, &cmp_func);
+  if (NULL == element_ptr_ptr2)
+  {
+    fprintf (stderr, "NULL pointer has been returned when tsearch() called for 
the second time.\n");
+    return ++ret;
+  }
+  if (*element_ptr_ptr2 != &element1)
+  {
+    fprintf (stderr, "Wrong pointer has been returned when tsearch() called 
for the second time.\n");
+    ++ret;
+  }
+  if (element_ptr_ptr2 != element_ptr_ptr1)
+  {
+    fprintf (stderr, "Wrong element has been returned when tsearch() called 
for the second time.\n");
+    ++ret;
+  }
 
-AM_CONDITIONAL([MHD_HAVE_TSEARCH], [[test "x$ac_cv_header_search_h" = xyes && 
test "x$HAVE_TSEARCH" = "x1" && test "x$REPLACE_TSEARCH" != "x1"]])
+  element_ptr_ptr2 =
+    (int **) tfind ((void*) &element1, &root_ptr, &cmp_func);
+  if (NULL == element_ptr_ptr2)
+  {
+    fprintf (stderr, "NULL pointer has been returned by tfind().\n");
+    ++ret;
+  }
+  if (*element_ptr_ptr2 != &element1)
+  {
+    fprintf (stderr, "Wrong pointer has been returned when by tfind().\n");
+    ++ret;
+  }
+  if (element_ptr_ptr2 != element_ptr_ptr1)
+  {
+    fprintf (stderr, "Wrong element has been returned when tsearch() called 
for the second time.\n");
+    ++ret;
+  }
+
+  element_ptr_ptr1 =
+    (int **) tdelete ((void*) &element1, &root_ptr, &cmp_func);
+  if (NULL == element_ptr_ptr1)
+  {
+    fprintf (stderr, "NULL pointer has been returned by tdelete().\n");
+    ++ret;
+  }
+  if (NULL != root_ptr)
+  {
+    fprintf (stderr, "Root pointer has not been set to NULL by tdelete().\n");
+    ++ret;
+  }
+
+  return ret;
+}
+             ]]
+           )
+         ],
+         [AC_DEFINE([[MHD_USE_SYS_TSEARCH]], [[1]], [Define to 1 if you have 
properly working tsearch(), tfind() and tdelete() functions.])]
+       )
+  ],
+  [], [AC_INCLUDES_DEFAULT]
+)
+AM_CONDITIONAL([MHD_USE_SYS_TSEARCH], [[test "x$mhd_cv_sys_tsearch_usable" = 
"xyes" || test "x$mhd_cv_sys_tsearch_usable" = "xassuming yes"]])
 
 # Optional headers used for tests
 AC_CHECK_HEADERS([sys/sysctl.h netinet/ip_icmp.h netinet/icmp_var.h], [], [],
@@ -706,7 +844,8 @@ AX_CHECK_COMPILE_FLAG([[-Werror=attributes]],
    AC_MSG_CHECKING([[whether -Werror=attributes actually works]])
    CFLAGS="${CFLAGS_ac} ${user_CFLAGS} -Werror=attributes"
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
-       [[__attribute__((non_existing_attrb_dummy)) int SimpleFunc(void) 
{return 3;}]], [[int r = SimpleFunc(); if (r) return r;]])],
+       [[__attribute__((non_existing_attrb_dummy)) static int SimpleFunc(void) 
{return 3;}]],
+       [[int r = SimpleFunc(); if (r) return r;]])],
      [
        AC_MSG_RESULT([[no]])
        errattr_CFLAGS=""
@@ -844,9 +983,7 @@ AS_CASE(["$host_os"],
  [AC_DEFINE([SOLARIS],[1],[This is a Solaris system])
      AC_DEFINE([_REENTRANT],[1],[Need with solaris or errno does not work])
      mhd_host_os='Solaris'
-     AC_MSG_RESULT([[$mhd_host_os]])
-     AC_SEARCH_LIBS([gethostbyname], [nsl])
-     AC_SEARCH_LIBS([socket], [socket])],
+     AC_MSG_RESULT([[$mhd_host_os]])],
   [*linux*],
   [AC_DEFINE([LINUX],[1],[This is a Linux kernel])
      mhd_host_os='Linux'
@@ -862,7 +999,6 @@ AS_CASE(["$host_os"],
      AC_DEFINE([WINDOWS],[1],[This is a Windows system])
      mhd_host_os='Windows/MinGW'
      AC_MSG_RESULT([[$mhd_host_os]])
-     LIBS="-lws2_32 ${LIBS}"
      AC_CHECK_HEADERS([winsock2.h ws2tcpip.h], [], [AC_MSG_ERROR([[Winsock2 
headers are required for W32]])], [AC_INCLUDES_DEFAULT])
      AC_CACHE_CHECK([for MS lib utility], [ac_cv_use_ms_lib_tool],
        [mslibcheck=`lib 2>&1`
@@ -1448,13 +1584,94 @@ AM_CONDITIONAL([W32_SHARED_LIB_EXP], [test 
"x$w32_shared_lib_exp" = "xyes"])
 AM_CONDITIONAL([USE_MS_LIB_TOOL], [test "x$ac_cv_use_ms_lib_tool" = "xyes"])
 AM_CONDITIONAL([USE_EXPORT_FILE], [test "x$use_expfile" = "xyes"])
 
+dnl gethostbyname() is not really needed
+dnl AC_SEARCH_LIBS([gethostbyname], [nsl])
+MHD_FIND_LIB([socket],
+  [[
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#ifdef HAVE_SOCKLIB_H
+#include <sockLib.h>
+#endif
+#if defined(_WIN32) && ! defined(__CYGWIN__)
+#include <winsock2.h>
+#endif
+  ]],
+  [(void)socket(0, 0, 0);],
+  [socket ws2_32 xnet],
+  [
+    AS_VAR_IF([[mhd_cv_find_lib_socket]],[["none required"]], [],
+      [
+       MHD_LIBDEPS_PKGCFG="${mhd_cv_find_lib_socket} $MHD_LIBDEPS_PKGCFG"
+      ]
+    )
+  ],
+  [AC_MSG_ERROR([[cannot find header or library required for function 
socket()]])]
+)
+
 MHD_CHECK_SOCKET_SHUTDOWN_TRIGGER([AC_DEFINE([HAVE_LISTEN_SHUTDOWN],[1],[can 
use shutdown on listen sockets])])
 AM_CONDITIONAL([HAVE_LISTEN_SHUTDOWN], [test 
"x$mhd_cv_host_shtdwn_trgr_select" = "xyes"])
 
-# SENDMSG. Should we check for SCM_RIGHTS instead?
-# https://lists.x.org/archives/xorg-devel/2013-November/038687.html
-AC_SEARCH_LIBS([sendmsg], [socket], [AC_DEFINE([HAVE_SENDMSG],[1],[Define if 
your platform supports sendmsg])])
-AC_CHECK_FUNCS([writev])
+MHD_CHECK_FUNC([writev],
+  [[#include <sys/uio.h>]],
+  [[
+    struct iovec iov[2];
+    char some_str[4] = "OK\n";
+    iov[0].iov_base = (void *) some_str;
+    iov[0].iov_len = 3;
+    i][f (0 > writev(1, iov, 1))
+      return 2;
+  ]]
+)
+MHD_FIND_LIB([sendmsg],
+  [[
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#ifdef HAVE_SOCKLIB_H
+#include <sockLib.h>
+#endif
+#ifdef HAVE_SYS_UIO_H
+#include <sys/uio.h>
+#endif
+  ]],
+  [[
+    struct msghdr msg;
+    struct iovec iov;
+    unsigned int i;
+    char some_str[5] = "test";
+
+    iov.iov_base = (void*)some_str;
+    iov.iov_len = 4;
+
+    for (i = 0; i < (unsigned int) sizeof(msg); i++)
+    {
+      *(((unsigned char *)&msg) + i) = 0;
+    }
+    msg.msg_iov = &iov;
+    msg.msg_iovlen = 1;
+
+    i][f (0 > sendmsg(1, &msg, 0))
+      return -1;
+  ]],
+  [socket],
+  [
+    AC_DEFINE([HAVE_SENDMSG],[1],[Define to '1' if your have sendmsg() 
function])
+    AS_VAR_IF([[mhd_cv_find_lib_sendmsg]],[["none required"]], [],
+      [
+        MHD_LIBDEPS_PKGCFG="${mhd_cv_find_lib_sendmsg} $MHD_LIBDEPS_PKGCFG"
+      ]
+    )
+  ],[],
+  [MHD_LIBDEPS]
+)
 
 AC_C_BIGENDIAN
 AC_C_VARARRAYS
@@ -1477,14 +1694,14 @@ AS_VAR_IF([mhd_cv_macro___func___avail], ["yes"],
 )
 AC_CACHE_CHECK([[whether __builtin_bswap32() is available]],
   [[mhd_cv_func___builtin_bswap32_avail]], [dnl
-  AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include<stdint.h>]], [[uint32_t a = 1; 
uint32_t b = __builtin_bswap32(a); a = b;]])],
+  AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include<stdint.h>]], [[uint32_t a = 1; 
uint32_t b = __builtin_bswap32(a); a = b; (void) a;]])],
     
[[mhd_cv_func___builtin_bswap32_avail="yes"]],[[mhd_cv_func___builtin_bswap32_avail="no"]])
 ])
 AS_IF([[test "x$mhd_cv_func___builtin_bswap32_avail" = "xyes"]],
   [AC_DEFINE([[MHD_HAVE___BUILTIN_BSWAP32]], [[1]], [Define to 1 if you have 
__builtin_bswap32() builtin function])])
 AC_CACHE_CHECK([[whether __builtin_bswap64() is available]],
   [[mhd_cv_func___builtin_bswap64_avail]], [dnl
-  AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include<stdint.h>]], [[uint64_t a = 1; 
uint32_t b = __builtin_bswap64(a); a = b;]])],
+  AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include<stdint.h>]], [[uint64_t a = 1; 
uint64_t b = __builtin_bswap64(a); a = b; (void) a;]])],
     [[mhd_cv_func___builtin_bswap64_avail="yes"]], 
[[mhd_cv_func___builtin_bswap64_avail="no"]])
 ])
 AS_IF([[test "x$mhd_cv_func___builtin_bswap64_avail" = "xyes"]],
@@ -1561,24 +1778,50 @@ AC_ARG_ENABLE([[poll]],
   )
 
 AS_IF([test "$enable_poll" != "no"],
-       [AS_IF([test "$os_is_native_w32" != "yes"],
-             AC_CHECK_HEADERS([poll.h],
-                [AC_CHECK_FUNCS([poll], [have_poll='yes'], [have_poll='no'])],
-               [],
-               [AC_INCLUDES_DEFAULT]),
-             [AC_MSG_CHECKING([for WSAPoll()])
-              AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+  [
+    AS_IF([test "$os_is_native_w32" != "yes"],
+      [
+        AC_CHECK_HEADERS([poll.h],
+          [
+            MHD_CHECK_FUNC([poll],
+              [[
+#include <poll.h>
+              ]],
+              [[
+  struct pollfd fds[2];
+
+  fds[0].fd = 0;
+  fds[0].events = POLLIN;
+  if (0 > poll(fds, 1, 0))
+    return 2;
+              ]],
+              [have_poll='yes'], [have_poll='no']
+            )
+          ], [], [AC_INCLUDES_DEFAULT]
+        )
+      ],
+      [
+        MHD_CHECK_FUNC([WSAPoll],
+          [[
 #include <winsock2.h>
-              ]],[[
-WSAPOLLFD fda[2];
-WSAPoll(fda, 2, 0);]])],
-              [have_poll='yes'
-              AC_DEFINE([HAVE_POLL],[1])
-              ],[have_poll='no'])
-              AC_MSG_RESULT([$have_poll])])
-       AS_IF([test "$enable_poll" = "yes" && test "$have_poll" != "yes"],
-             [AC_MSG_ERROR([[Support for poll was explicitly requested but 
cannot be enabled on this platform.]])])
-       enable_poll="$have_poll"])
+          ]],
+          [[
+  WSAPOLLFD fda[2];
+  WSAPoll(fda, 2, 0);
+          ]],
+          [
+            have_poll='yes'
+            AC_DEFINE([HAVE_POLL],[1])
+          ],
+          [have_poll='no']
+        )
+      ]
+    )
+    AS_IF([test "$enable_poll" = "yes" && test "$have_poll" != "yes"],
+      [AC_MSG_ERROR([[Support for poll was explicitly requested but cannot be 
enabled on this platform.]])])
+    enable_poll="$have_poll"
+  ]
+)
 
 AC_ARG_ENABLE([[epoll]],
   [AS_HELP_STRING([[--enable-epoll[=ARG]]], [enable epoll support (yes, no, 
auto) [auto]])],
@@ -1607,18 +1850,18 @@ AS_IF([test "$enable_epoll" != "no"],
 AM_CONDITIONAL([MHD_HAVE_EPOLL], [[test "x$enable_epoll" = xyes]])
 
 AS_IF([test "x$enable_epoll" = "xyes"],
-  AC_CACHE_CHECK([for epoll_create1()],
-                 [mhd_cv_have_epoll_create1], [
-    AC_LINK_IFELSE([
-      AC_LANG_PROGRAM([[
+  [
+    MHD_CHECK_FUNC([epoll_create1],
+      [[
 #include <sys/epoll.h>
-        ]], [[
-int fd;
-fd = epoll_create1(EPOLL_CLOEXEC);]])],
-      [mhd_cv_have_epoll_create1=yes],
-      [mhd_cv_have_epoll_create1=no])])
-  AS_IF([test "x$mhd_cv_have_epoll_create1" = "xyes"],[
-    AC_DEFINE([[HAVE_EPOLL_CREATE1]], [[1]], [Define if you have epoll_create1 
function.])]))
+      ]],
+      [[
+  i][f (0 > epoll_create1(EPOLL_CLOEXEC))
+    return 3;
+      ]]
+    )
+  ]
+)
 
 AC_CACHE_CHECK([for supported 'noreturn' keyword], [mhd_cv_decl_noreturn],
   [
@@ -1632,7 +1875,7 @@ AC_CACHE_CHECK([for supported 'noreturn' keyword], 
[mhd_cv_decl_noreturn],
 #include <stdlib.h>
 #endif
 
-${decl_noret} void myexitfunc(int code)
+${decl_noret} static void myexitfunc(int code)
 {
 #ifdef HAVE_STDLIB_H
   exit (code);
@@ -1750,7 +1993,7 @@ AC_CHECK_MEMBERS([struct sockaddr_in.sin_len, struct 
sockaddr_in6.sin6_len,
 #endif
    ])
 
-MHD_CHECK_LINK_RUN([[for working getsockname()]],[[mhd_cv_getsockname_usable]],
+MHD_CHECK_LINK_RUN([[f][or working 
getsockname()]],[[mhd_cv_getsockname_usable]],
   [[mhd_cv_getsockname_usable='assuming yes']],
   [
     AC_LANG_SOURCE(
@@ -2000,7 +2243,7 @@ AS_UNSET([[use_itc]])
 
 AS_IF([[test "x$enable_itc" = "xeventfd" || test "x$enable_itc" = "xauto"]],
   [
-    MHD_CHECK_LINK_RUN([[for working 
eventfd(2)]],[[mhd_cv_eventfd_usable]],[[mhd_cv_eventfd_usable='assuming no']],
+    MHD_CHECK_LINK_RUN([[f][or working 
eventfd(2)]],[[mhd_cv_eventfd_usable]],[[mhd_cv_eventfd_usable='assuming no']],
       [
         AC_LANG_SOURCE([[
 #include <sys/eventfd.h>
@@ -2139,7 +2382,68 @@ AC_INCLUDES_DEFAULT
 AS_IF([[test -z "$use_itc"]], [AC_MSG_ERROR([[cannot find usable type of 
inter-thread communication]])])
 
 
-AC_CHECK_FUNCS_ONCE([accept4 gmtime_r memmem snprintf])
+MHD_CHECK_FUNC([accept4],
+  [[
+#if defined(HAVE_SYS_TYPES_H)
+#  include <sys/types.h>
+#endif
+#include <sys/socket.h>
+  ]],
+  [[
+  struct sockaddr sk_addr;
+  socklen_t addr_size;
+  i][f (0 > accept4(0, &sk_addr, &addr_size, 0))
+    return 3;
+  ]]
+)
+MHD_CHECK_FUNC([gmtime_r],
+  [[
+#if defined(HAVE_SYS_TYPES_H)
+#  include <sys/types.h>
+#endif
+#include <time.h>
+  ]],
+  [[
+  time_t timer = (time_t) 0;
+  struct tm res;
+
+  i][f (&res != gmtime_r(&timer, &res))
+    return 3;
+  ]]
+)
+MHD_CHECK_FUNC([memmem],
+  [[
+#if defined(HAVE_STDDEF_H)
+#  include <stddef.h>
+#elif defined(HAVE_STDLIB_H)
+#  include <stdlib.h>
+#endif /* HAVE_STDLIB_H */
+#include <string.h>
+  ]],
+  [[
+  const char *haystack = "abc";
+  size_t hslen = 3;
+  const char *needle = "b";
+  size_t needlelen = 1;
+
+  i][f ((haystack + 1) != memmem(haystack, hslen, needle, needlelen))
+    return 3;
+  ]]
+)
+MHD_CHECK_FUNC([snprintf],
+  [[
+#include <stdio.h>
+  ]],
+  [[
+  char buf[2];
+
+  i][f (1 != snprintf(buf, 2, "a"))
+    return 3;
+  /* Do not use the next check to avoid compiler warning */
+  /* i][f (4 != snprintf(buf, 2, "abcd"))
+    return 4; */
+  ]]
+)
 AC_CHECK_DECL([gmtime_s],
   [
     AC_MSG_CHECKING([[whether gmtime_s is in C11 form]])
@@ -2204,50 +2508,40 @@ AC_CHECK_DECL([SOCK_NONBLOCK], 
[AC_DEFINE([HAVE_SOCK_NONBLOCK], [1], [SOCK_NONBL
   ]]
 )
 
-
-AC_CHECK_DECL([[clock_gettime]],
+MHD_FIND_LIB([clock_gettime],[[#include <time.h>]],
+  [[
+    struct timespec tp;
+    i][f (0 > clock_gettime(CLOCK_REALTIME, &tp))
+      return 3;
+  ]],
+  [rt],
   [
-   SAVE_LIBS="$LIBS"
-   AC_SEARCH_LIBS([clock_gettime], [rt],
-     [
-      AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [Have clock_gettime])
-      AS_VAR_IF([[ac_cv_search_clock_gettime]],[["none required"]], [],
-        [
-         MHD_LIBDEPS="$ac_cv_search_clock_gettime $MHD_LIBDEPS"
-         MHD_LIBDEPS_PKGCFG="$ac_cv_search_clock_gettime $MHD_LIBDEPS_PKGCFG"
-        ])
-     ], [], [$MHD_LIBDEPS])
-   LIBS="$SAVE_LIBS"
-  ], [], [[
-#include <time.h>
-  ]])
+    AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [Define to '1' if you have 
clock_gettime() function])
+    AS_VAR_IF([[mhd_cv_find_lib_clock_gettime]],[["none required"]], [],
+      [
+        MHD_LIBDEPS_PKGCFG="${mhd_cv_find_lib_clock_gettime} 
$MHD_LIBDEPS_PKGCFG"
+      ]
+    )
+  ],[],
+  [MHD_LIBDEPS]
+)
 
-AC_MSG_CHECKING([[for clock_get_time]])
-AC_LINK_IFELSE(
-  [AC_LANG_PROGRAM(
-    [[
+MHD_CHECK_FUNC([clock_get_time],
+  [[
 #include <mach/clock.h>
 #include <mach/mach.h>
-    ]],
-    [[
-      clock_serv_t cs;
-      mach_timespec_t mt;
-      host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cs);
-      clock_get_time(cs, &mt);
-      mach_port_deallocate(mach_task_self(), cs);
-    ]])
-  ],
-  [
-    AC_DEFINE([HAVE_CLOCK_GET_TIME], [1], [Define to 1 if you have 
`clock_get_time', `host_get_clock_service' and `mach_port_deallocate' 
functions.])
-    AC_MSG_RESULT([[yes]])
-  ],
-  [AC_MSG_RESULT([[no]])
-  ])
+  ]],
+  [[
+    clock_serv_t cs;
+    mach_timespec_t mt;
+    host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cs);
+    clock_get_time(cs, &mt);
+    mach_port_deallocate(mach_task_self(), cs);
+  ]]
+)
 
-AC_MSG_CHECKING([[for gethrtime]])
-AC_LINK_IFELSE(
-  [AC_LANG_PROGRAM(
-    [[
+MHD_CHECK_FUNC([gethrtime],
+  [[
 #ifdef HAVE_SYS_TIME_H
 /* Solaris define gethrtime() in sys/time.h */
 #include <sys/time.h>
@@ -2256,100 +2550,69 @@ AC_LINK_IFELSE(
 /* HP-UX define gethrtime() in time.h */
 #include <time.h>
 #endif /* HAVE_TIME_H */
-    ]], [[hrtime_t hrt = gethrtime(); ]])
-  ],
-  [
-    AC_DEFINE([HAVE_GETHRTIME], [1], [Define to 1 if you have `gethrtime' 
function.])
-    AC_MSG_RESULT([[yes]])
-  ],
-  [AC_MSG_RESULT([[no]])
-  ])
+  ]],
+  [[
+    hrtime_t hrt = gethrtime();
+    i][f (0 == hrt)
+      return 3;
+  ]]
+)
 
 AS_VAR_IF([ac_cv_header_time_h], ["yes"],
   [
-    AC_CACHE_CHECK([[for C11 timespec_get()]], [mhd_cv_func_timespec_get],
-      [
-        AC_LINK_IFELSE(
-          [
-            AC_LANG_PROGRAM(
-              [[
+    MHD_CHECK_FUNC([timespec_get],
+      [[
 #include <time.h>
 
 #ifndef TIME_UTC
 #error TIME_UTC must be defined to use timespec_get()
 choke me now
 #endif
-              ]],
-              [[
+      ]],
+      [[
   struct timespec ts;
-  if (TIME_UTC != timespec_get (&ts, TIME_UTC))
-    return 1;
-              ]]
-            )
-          ], [[mhd_cv_func_timespec_get="yes"]], 
[[mhd_cv_func_timespec_get="no"]]
-        )
-      ]
-    )
-    AS_VAR_IF([mhd_cv_func_timespec_get], ["yes"],
-      [AC_DEFINE([HAVE_TIMESPEC_GET], [1], [Define to 1 if you have C11 
`mhd_cv_func_timespec_get' function and TIME_UTC macro.])]
+  i][f (TIME_UTC != timespec_get (&ts, TIME_UTC))
+    return 3;
+      ]]
     )
   ]
 )
 
-AS_VAR_SET_IF([ac_cv_func_gettimeofday], 
[mhd_cv_func_gettimeofday="${ac_cv_func_gettimeofday}"])
-AC_CACHE_CHECK([[for gettimeofday(2)]], [mhd_cv_func_gettimeofday], [
-  AC_LINK_IFELSE(
-    [
-      AC_LANG_PROGRAM(
-        [[
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif /* HAVE_SYS_TIME_H */
-#ifdef HAVE_TIME_H
-#include <time.h>
-#endif /* HAVE_TIME_H */
-        ]],
-        [[
-  struct timeval tv;
-  if (0 != gettimeofday (&tv, (void*) 0))
-    return 1;
-        ]]
-      )
-    ], [[mhd_cv_func_gettimeofday="yes"]], [[mhd_cv_func_gettimeofday="no"]]
-  )
-])
-AS_VAR_IF([mhd_cv_func_gettimeofday], ["yes"],
-  [AC_DEFINE([HAVE_GETTIMEOFDAY], [1], [Define to 1 if you have `gettimeofday' 
function.])]
-)
+MHD_CHECK_FUNC_GETTIMEOFDAY
 
 # IPv6
-AC_MSG_CHECKING(for IPv6)
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+AC_CACHE_CHECK([for IPv6],[mhd_cv_have_inet6],
+  [
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 #include <stdio.h>
-#if HAVE_NETINET_IN_H
+#ifdef HAVE_NETINET_IN_H
 #include <netinet/in.h>
 #endif
-#if HAVE_SYS_SOCKET_H
+#ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
 #endif
-#if HAVE_WINSOCK2_H
+#ifdef HAVE_WINSOCK2_H
 #include <winsock2.h>
 #endif
-#if HAVE_WS2TCPIP_H
+#ifdef HAVE_WS2TCPIP_H
 #include <ws2tcpip.h>
 #endif
-]], [[
-int af=AF_INET6;
-int pf=PF_INET6;
-struct sockaddr_in6 sa;
-printf("%d %d %p\n", af, pf, &sa);
-]])],[
-have_inet6=yes;
-AC_DEFINE([HAVE_INET6], [1], [Provides IPv6 headers])
-],[
-have_inet6=no
-])
-AC_MSG_RESULT($have_inet6)
+          ]], [[
+  int af=AF_INET6;
+  int pf=PF_INET6;
+  struct sockaddr_in6 sa;
+  printf("%d %d %p\n", af, pf, (void*) &sa);
+          ]]
+        )
+      ],
+      [AS_VAR_SET([mhd_cv_have_inet6],["yes"])],
+      [AS_VAR_SET([mhd_cv_have_inet6],["no"])]
+    )
+  ]
+)
+AS_VAR_IF([mhd_cv_have_inet6],["yes"],
+  [AC_DEFINE([HAVE_INET6], [1], [Define to '1' if you have IPv6 headers])]
+)
 
 MHD_CHECK_FUNC([[sysconf]], [[#include <unistd.h>]], [[long a = sysconf(0); if 
(a) return 1;]])
 
@@ -2438,42 +2701,67 @@ AS_IF([test "x$enable_curl" = "xyes"],
   [MSG_CURL="no, many unit tests will not run"]
 )
 
-mhd_have_libmagic="no"
-SAVE_LIBS="$LIBS"
-LIBS="-lmagic $LIBS"
-AC_MSG_CHECKING([[for suitable libmagic]])
-AC_LINK_IFELSE(
-  [AC_LANG_PROGRAM(
-    [AC_INCLUDES_DEFAULT
-     [
+MHD_CHECK_FUNC([magic_open],
+  [[
 #include <magic.h>
-    ]],
-    [[
-      char var_data[256];
-      const char *var_mime;
-      magic_t var_magic = magic_open (MAGIC_MIME_TYPE);
-      (void)magic_load (var_magic, NULL);
-      var_data[0] = 0;
-      var_mime = magic_buffer (var_magic, var_data, 1);
-      magic_close (var_magic);
-    ]]
-   )
-  ],
-  [
-    AC_DEFINE([MHD_HAVE_LIBMAGIC], [1], [Define to 1 if you have suitable 
libmagic.])
-    mhd_have_libmagic="yes"
-    AC_MSG_RESULT([[yes]])
-  ],
-  [AC_MSG_RESULT([[no]])
-  ]
+  ]],
+  [[
+    char var_data[256];
+    const char *var_mime;
+    magic_t var_magic = magic_open (MAGIC_MIME_TYPE);
+    (void)magic_load (var_magic, NULL);
+    var_data[0] = 0;
+    var_mime = magic_buffer (var_magic, var_data, 1);
+    magic_close (var_magic);
+  ]],
+  [AC_DEFINE([MHD_HAVE_LIBMAGIC], [1], [Define to 1 if you have suitable 
libmagic.])],
+  [],
+  [-lmagic]
 )
-LIBS="$SAVE_LIBS"
-AM_CONDITIONAL([MHD_HAVE_LIBMAGIC], [[test "x$mhd_have_libmagic" = "xyes"]])
+AM_CONDITIONAL([MHD_HAVE_LIBMAGIC], [[test "x$mhd_cv_func_magic_open" = 
"xyes"]])
 
 # large file support (> 4 GB)
 AC_SYS_LARGEFILE
 AC_FUNC_FSEEKO
-AC_CHECK_FUNCS([lseek64 pread64 pread])
+MHD_CHECK_FUNC([lseek64],
+  [[
+#if defined(HAVE_SYS_TYPES_H)
+#  include <sys/types.h>
+#endif
+#include <unistd.h>
+  ]],
+  [[
+  i][f (((off64_t) -1) == lseek64(0, (off64_t) 0, SEEK_SET))
+    return 3;
+  ]]
+)
+MHD_CHECK_FUNC([pread64],
+  [[
+#if defined(HAVE_SYS_TYPES_H)
+#  include <sys/types.h>
+#endif
+#include <unistd.h>
+  ]],
+  [[
+  char buf[5];
+  i][f (0 > pread64(0, (void *) buf, 1, (off64_t) 0))
+    return 3;
+  ]]
+)
+MHD_CHECK_FUNC([pread],
+  [[
+#if defined(HAVE_SYS_TYPES_H)
+#  include <sys/types.h>
+#endif
+#include <unistd.h>
+  ]],
+  [[
+  char buf[5];
+  i][f (0 > pread(0, (void *) buf, 1, 0))
+    return 3;
+  ]]
+)
+
 
 # check for various sendfile functions
 AC_ARG_ENABLE([sendfile],
@@ -2517,7 +2805,16 @@ ssize_t sendfile(int, int, off_t*, size_t);
         AC_DEFINE([HAVE_LINUX_SENDFILE], [1], [Define to 1 if you have 
linux-style sendfile(2).])
         found_sendfile="yes, Linux-style"
         AC_MSG_RESULT([[yes]])
-        AC_CHECK_FUNCS([sendfile64])
+        MHD_CHECK_FUNC([sendfile64],
+          [[
+#include <sys/sendfile.h>
+          ]],
+          [[
+  off64_t f_offset = (off64_t) 0;
+  if (0 > sendfile64 (0, 1, &f_offset, 1))
+    return 3;
+          ]]
+        )
       ],
       [AC_MSG_RESULT([[no]])
       ]
@@ -2644,7 +2941,18 @@ ssize_t sendfile(int out_fd, int in_fd,
        MHD_LIBDEPS="-lsendfile $MHD_LIBDEPS"
        MHD_LIBDEPS_PKGCFG="-lsendfile $MHD_LIBDEPS_PKGCFG"
        AC_MSG_RESULT([[yes]])
-       AC_CHECK_FUNCS([sendfile64])
+       MHD_CHECK_FUNC([sendfile64],
+         [[
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/sendfile.h>
+         ]],
+         [[
+  off64_t f_offset = (off64_t) 0;
+  if (0 > sendfile64 (0, 1, &f_offset, 1))
+    return 3;
+         ]]
+       )
      ],
      [AC_MSG_RESULT([[no]])
      ]
@@ -2762,15 +3070,20 @@ AC_ARG_WITH([[gnutls]],
         LDFLAGS="${LDFLAGS_ac} -L$with_gnutls/lib ${user_LDFLAGS}"
         CPPFLAGS="${CPPFLAGS_ac} -I$with_gnutls/include ${user_CPPFLAGS}"
         have_gnutls_pkgcfg=no
-          AC_CHECK_HEADERS([gnutls/gnutls.h],
-            [AC_CHECK_LIB([gnutls], [gnutls_priority_set],
-              [
-                GNUTLS_CPPFLAGS="-I$with_gnutls/include"
-                GNUTLS_LDFLAGS="-L$with_gnutls/lib"
-                GNUTLS_LIBS="-lgnutls"
-                have_gnutls=yes
-              ])], [], [AC_INCLUDES_DEFAULT])
-        AS_IF([test "x$have_gnutls" != "xyes"], [AC_MSG_ERROR([can't find 
usable libgnutls at specified prefix $with_gnutls])])
+        MHD_CHECK_FUNC([gnutls_check_version],[[#include <gnutls/gnutls.h>]],
+          [
+           if(!gnutls_check_version("2.0.0"))
+             return 3;
+          ],
+          [
+            GNUTLS_CPPFLAGS="-I$with_gnutls/include"
+            GNUTLS_LDFLAGS="-L$with_gnutls/lib"
+            GNUTLS_LIBS="-lgnutls"
+            have_gnutls=yes
+          ],
+          [AC_MSG_ERROR([can't find usable libgnutls at specified prefix 
$with_gnutls])],
+          [-lgnutls]
+        )
         CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
         CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
         LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
@@ -3469,7 +3782,7 @@ AS_VAR_IF([[mhd_cv_have_func_calloc]], [["yes"]],
   [AC_DEFINE([[HAVE_CALLOC]], [[1]], [Define to 1 if you have the usable 
`calloc' function.])])
 
 # Some systems have IPv6 disabled in kernel at run-time
-AS_IF([[test "x${have_inet6}" = "xyes" && test "x${cross_compiling}" = "xno"]],
+AS_IF([[test "x${mhd_cv_have_inet6}" = "xyes" && test "x${cross_compiling}" = 
"xno"]],
  [
    AC_CACHE_CHECK([whether IPv6 could be used for 
testing],[mhd_cv_ipv6_for_testing],
      [
@@ -3888,7 +4201,7 @@ AS_IF([test "x${enable_sanitizers}" = "xno"],
     enable_san_undef="no"
     enable_san_leak="no"
     enable_san_upoison="no"
-    for san in `AS_ECHO([${enable_sanitizers}]) | tr ',' ' '`
+    f][or san in `AS_ECHO([${enable_sanitizers}]) | tr ',' ' '`
     do
       AS_CASE([$san],
         [address], [enable_san_address="yes"],
@@ -4273,22 +4586,22 @@ int main(int argc, char *argv[])
             test_undf_prog='
 #include <stdio.h>
 
-void func_out_b(char *arr)
+static void func_out_b(char *arr)
 {
   arr[0] = 0;
   arr[16] = 2;
 }
 
-unsigned int int_deref(void *ptr)
+static unsigned int int_deref(void *ptr)
 {
-  return (*((int*)ptr)) + 2;
+  return (*((unsigned int*)ptr)) + 2;
 }
 
-int func1(void)
+static int func1(void)
 {
   char chr[16];
   func_out_b (chr);
-  return int_deref(chr + 1) + int_deref(chr + 2);
+  return (int) (int_deref(chr + 1) + int_deref(chr + 2));
 }
 
 int main(void)
diff --git a/m4/libcurl.m4 b/m4/libcurl.m4
index ad53a444..d0209207 100644
--- a/m4/libcurl.m4
+++ b/m4/libcurl.m4
@@ -5,7 +5,7 @@
 #                            | (__| |_| |  _ <| |___
 #                             \___|\___/|_| \_\_____|
 #
-# Copyright (C) 2006 - 2020, David Shaw <dshaw@jabberwocky.com>
+# Copyright (C) David Shaw <dshaw@jabberwocky.com>
 #
 # This software is licensed as described in the file COPYING, which
 # you should have received as part of this distribution. The terms
@@ -18,6 +18,8 @@
 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 # KIND, either express or implied.
 #
+# SPDX-License-Identifier: curl
+#
 ###########################################################################
 # LIBCURL_CHECK_CONFIG ([DEFAULT-ACTION], [MINIMUM-VERSION],
 #                       [ACTION-IF-YES], [ACTION-IF-NO])
@@ -197,9 +199,10 @@ if (x) {;}
            _libcurl_save_libs=$LIBS
            LIBS="$LIBS $LIBCURL"
 
-           AC_CHECK_FUNC(curl_free,,
-              AC_DEFINE(curl_free,free,
-                [Define curl_free() as free() if our version of curl lacks 
curl_free.]))
+           AC_CHECK_DECL([curl_free],[],
+              [AC_DEFINE([curl_free],[free],
+                [Define curl_free() as free() if our version of curl lacks 
curl_free.])],
+              [[#include <curl/curl.h>]])
 
            CPPFLAGS=$_libcurl_save_cppflags
            LIBS=$_libcurl_save_libs
diff --git a/m4/mhd_check_func.m4 b/m4/mhd_check_func.m4
index 342c12f9..77e6baca 100644
--- a/m4/mhd_check_func.m4
+++ b/m4/mhd_check_func.m4
@@ -9,13 +9,15 @@
 #
 #   This macro checks for presence of specific function by including
 #   specified headers and compiling and linking CHECK_CODE.
-#   This check both declaration and presence in library.
+#   This checks both declaration and presence in library.
+#   If function is available then macro HAVE_function_name (the name
+#   of the function convetedd to all uppercase characters) is defined
+#   automatically.
 #   Unlike AC_CHECK_FUNCS macro, this macro do not produce false
 #   negative result if function is declared with specific calling
 #   conventions like __stdcall' or attribute like
-#   __attribute__((__dllimport__)) and linker failed to build test
-#   program if library contains function with calling conventions
-#   different from declared. 
+#   __attribute__((__dllimport__)) and linker failing to build test
+#   program due to the different calling conventions. 
 #   By using definition from provided headers, this macro ensures that
 #   correct calling convention is used for detection.
 #
@@ -26,54 +28,77 @@
 #                    [const void *ptr = memmem("aa", 2, "a", 1); (void)ptr;],
 #                    [var_use_memmem='yes'], [var_use_memmem='no'])
 #
-#   Defined cache variable used in check so if any test will not work
+#   The cache variable used in check so if any test will not work
 #   correctly on some platform, user may simply fix it by giving cache
 #   variable in configure parameters, for example:
 #
 #     ./configure mhd_cv_func_memmem_have=no
 #
-#   This simplify building from source on exotic platforms as patching
+#   This simplifies building from source on exotic platforms as patching
 #   of configure.ac is not required to change results of tests.
 #
 # LICENSE
 #
-#   Copyright (c) 2019-2022 Karlson2k (Evgeny Grin) <k2k@narod.ru>
+#   Copyright (c) 2019-2023 Karlson2k (Evgeny Grin) <k2k@narod.ru>
 #
 #   Copying and distribution of this file, with or without modification, are
 #   permitted in any medium without royalty provided the copyright notice
 #   and this notice are preserved. This file is offered as-is, without any
 #   warranty.
 
-#serial 3
+#serial 5
 
 AC_DEFUN([MHD_CHECK_FUNC],[dnl
-  AC_PREREQ([2.64])dnl for AS_VAR_IF, m4_ifblank, m4_ifnblank
-  m4_ifblank(m4_translit([$1],[()],[  ]), [m4_fatal([First macro argument must 
not be empty])])dnl
-  m4_ifblank([$3], [m4_fatal([Third macro argument must not be empty])])dnl
-  m4_bmatch(m4_normalize([$1]), [\s],dnl
-            [m4_fatal([First macro argument must not contain whitespaces])])dnl
-  m4_if(m4_index([$3], m4_normalize(m4_translit([$1],[()],[  ]))), [-1], dnl
-        [m4_fatal([CHECK_CODE parameter (third macro argument) does not 
contain ']m4_normalize([$1])[' token])])dnl
-  AS_VAR_PUSHDEF([cv_Var], 
[mhd_cv_func_]m4_bpatsubst(_mhd_norm_expd(m4_translit([$1],[()],[  
])),[[^a-zA-Z0-9]],[_]))dnl
-  dnl
-  AC_CACHE_CHECK([for function $1], cv_Var,
-    [dnl
-      m4_ifnblank([$6],[dnl
-        mhd_check_func_SAVE_LIBS="$LIBS"
-        LIBS="$LIBS _mhd_norm_expd([$6])"
-      ])dnl
-      AC_LINK_IFELSE(
-        [AC_LANG_PROGRAM([m4_default_nblank([$2],[AC_INCLUDES_DEFAULT])], 
[$3]) ],
-        [AS_VAR_SET([cv_Var],["yes"])], [AS_VAR_SET([cv_Var],["no"])] ) 
-      m4_ifnblank([$6],[dnl
-        LIBS="${mhd_check_func_SAVE_LIBS}"
-        AS_UNSET([mhd_check_func_SAVE_LIBS])
-      ])dnl
-    ])
-  AS_VAR_IF([cv_Var], ["yes"],
-            
[AC_DEFINE([[HAVE_]]m4_bpatsubst(m4_toupper(_mhd_norm_expd(m4_translit([$1],[()],[
  ]))),[[^A-Z0-9]],[_]),
-                       [1], [Define to 1 if you have the 
']_mhd_norm_expd(m4_translit([$1],[()],[  ]))[' function.])
-            m4_n([$4])dnl
-            ], [$5])
-  AS_VAR_POPDEF([cv_Var])dnl
-])
+AC_PREREQ([2.64])dnl for AS_VAR_IF, m4_ifblank, m4_ifnblank
+m4_newline([[# Expansion of $0 macro starts here]])
+AC_LANG_ASSERT([C])dnl
+m4_ifblank(m4_translit([$1],[()],[  ]), [m4_fatal([First macro argument must 
not be empty])])dnl
+m4_ifblank([$3], [m4_fatal([Third macro argument must not be empty])])dnl
+m4_bmatch(m4_normalize([$1]), [\s],dnl
+          [m4_fatal([First macro argument must not contain whitespaces])])dnl
+m4_if(m4_index([$3], m4_normalize(m4_translit([$1],[()],[  ]))), [-1], dnl
+      [m4_fatal([CHECK_CODE parameter (third macro argument) does not contain 
']m4_normalize([$1])[' token])])dnl
+AS_VAR_PUSHDEF([decl_cv_Var],[ac_cv_have_decl_]m4_bpatsubst(_mhd_norm_expd(m4_translit([$1],[()],[
  ])),[[^a-zA-Z0-9]],[_]))dnl
+AS_VAR_PUSHDEF([cv_Var],[mhd_cv_func_]m4_bpatsubst(_mhd_norm_expd(m4_translit([$1],[()],[
  ])),[[^a-zA-Z0-9]],[_]))dnl
+AS_VAR_SET_IF([cv_Var],[],[AC_CHECK_DECL(_mhd_norm_expd([$1]),[],[],[$2])])
+AC_CACHE_CHECK([for function $1], [cv_Var],dnl
+  [dnl
+    AS_VAR_IF([decl_cv_Var],["yes"],dnl
+      [dnl
+        m4_ifnblank([$6],[dnl
+          mhd_check_func_SAVE_LIBS="$LIBS"
+          LIBS="_mhd_norm_expd([$6]) $LIBS"
+        ])dnl
+        AC_LINK_IFELSE(
+          [AC_LANG_SOURCE([
+m4_default_nblank([$2],[AC_INCLUDES_DEFAULT])
+
+[int main(void)
+{
+
+  ]$3[
+
+  return 0;
+}
+            ]])
+          ],
+          [AS_VAR_SET([cv_Var],["yes"])],
+          [AS_VAR_SET([cv_Var],["no"])]dnl
+        )
+        m4_ifnblank([$6],[dnl
+          LIBS="${mhd_check_func_SAVE_LIBS}"
+          AS_UNSET([mhd_check_func_SAVE_LIBS])
+        ])dnl
+      ],[AS_VAR_SET([cv_Var],["no"])]dnl
+    )dnl
+  ]dnl
+)
+AS_VAR_IF([cv_Var], ["yes"],
+          
[AC_DEFINE([[HAVE_]]m4_bpatsubst(m4_toupper(_mhd_norm_expd(m4_translit([$1],[()],[
  ]))),[[^A-Z0-9]],[_]),
+                     [1], [Define to 1 if you have the 
']_mhd_norm_expd(m4_translit([$1],[()],[  ]))[' function.])
+          m4_n([$4])dnl
+          ],[$5])
+AS_VAR_POPDEF([cv_Var])dnl
+AS_VAR_POPDEF([decl_cv_Var])dnl
+m4_newline([[# Expansion of $0 macro ends here]])
+])dnl AC_DEFUN MHD_CHECK_FUNC
diff --git a/m4/mhd_check_func_gettimeofday.m4 
b/m4/mhd_check_func_gettimeofday.m4
new file mode 100644
index 00000000..8ef69ccb
--- /dev/null
+++ b/m4/mhd_check_func_gettimeofday.m4
@@ -0,0 +1,53 @@
+# SYNOPSIS
+#
+#   MHD_CHECK_FUNC_GETTIMEOFDAY([ACTION-IF-AVAILABLE],
+#                               [ACTION-IF-NOT-AVAILABLE])
+#
+# DESCRIPTION
+#
+#   This macro checks for presence of gettimeofday() function.
+#   If function is available macro HAVE_GETTIMEOFDAY is defined
+#   automatically.
+#
+#   Example usage:
+#
+#     MHD_CHECK_FUNC_GETTIMEOFDAY([var_use_gettimeofday='yes'])
+#
+#   The cache variable used in check so if any test will not work
+#   correctly on some platform, user may simply fix it by giving cache
+#   variable in configure parameters, for example:
+#
+#     ./configure mhd_cv_func_memmem_have=no
+#
+#   This simplifies building from source on exotic platforms as patching
+#   of configure.ac is not required to change results of tests.
+#
+# LICENSE
+#
+#   Copyright (c) 2019-2023 Karlson2k (Evgeny Grin) <k2k@narod.ru>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 1
+
+AC_DEFUN([MHD_CHECK_FUNC_GETTIMEOFDAY],[dnl
+AC_CHECK_HEADERS([sys/time.h time.h])dnl
+MHD_CHECK_FUNC([[gettimeofday]],
+  [[
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif /* HAVE_SYS_TIME_H */
+#ifdef HAVE_TIME_H
+#include <time.h>
+#endif /* HAVE_TIME_H */
+  ]],
+  [[
+  struct timeval tv;
+  if (0 != gettimeofday (&tv, (void*) 0))
+    return 1;
+  ]],[$1],[$2]
+)
+])dnl AC_DEFUN MHD_CHECK_FUNC_GETTIMEOFDAY
diff --git a/m4/mhd_check_link_run.m4 b/m4/mhd_check_link_run.m4
index 0f28bd74..25ff1290 100644
--- a/m4/mhd_check_link_run.m4
+++ b/m4/mhd_check_link_run.m4
@@ -17,9 +17,9 @@
 #   Example usage:
 #
 #     MHD_CHECK_LINK_RUN([for valid snprintf()], [mhd_cv_snprintf_valid],
-#                        AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
-#                                        [if (4 != snprintf(NULL, 0, "test"))
-#                                           return 2;])],
+#                        [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
+#                                         [if (4 != snprintf(NULL, 0, "test"))
+#                                            return 2;])],
 #                        [mhd_cv_snprintf_valid='assuming no'])
 #
 #
@@ -32,7 +32,7 @@
 #   and this notice are preserved. This file is offered as-is, without any
 #   warranty.
 
-#serial 1
+#serial 2
 
 AC_DEFUN([MHD_CHECK_LINK_RUN],[dnl
 m4_ifblank([$1],[m4_fatal([$0: The first macro argument ("MESSAGE") must not 
be empty])])dnl
diff --git a/m4/mhd_find_lib.m4 b/m4/mhd_find_lib.m4
new file mode 100644
index 00000000..8e6a5e9a
--- /dev/null
+++ b/m4/mhd_find_lib.m4
@@ -0,0 +1,142 @@
+# SYNOPSIS
+#
+#   MHD_FIND_LIB([FUNCTION_NAME],
+#                [INCLUDES=AC_INCLUDES_DEFAULT], [CHECK_CODE],
+#                [LIBS_TO_CHECK],
+#                [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
+#                [VAR_TO_PREPEND_LIB=LIBS], [ADDITIONAL_LIBS])
+#
+# DESCRIPTION
+#
+#   This macro checks for presence of specific function by including
+#   specified headers and compiling and linking CHECK_CODE.
+#   This checks both the declaration and the presence in library.
+#   If declaration is not found in headers then libraries are not
+#   checked.
+#   LIBS_TO_CHECK is whitespace-separated list of libraries to check.
+#   The macro first tries to link without any library, and if it fails
+#   the libraries are checked one by one. 
+#   The required library (if any) prepended to VAR_TO_PREPEND_LIB (or
+#   to the LIBS variable if VAR_TO_APPEND_LIB is not specified).
+#   By using definition from provided headers, this macro ensures that
+#   correct calling convention is used for detection.
+#
+#   Example usage:
+#
+#     MHD_FIND_LIB([clock_gettime],
+#                  [[#include <time.h>]],
+#                  [[struct timespec tp;
+#                    if (0 > clock_gettime(CLOCK_REALTIME, &tp)) return 3;]],
+#                  [rt],
+#                  [var_use_gettime='yes'],[var_use_gettime='no'])
+#
+#   Defined cache variable used in the check so if any test will not
+#   work correctly on some platform, a user may simply fix it by giving
+#   cache variable in configure parameters, for example:
+#
+#     ./configure mhd_cv_find_clock_gettime=no
+#
+#   This simplifies building from source on exotic platforms as patching
+#   of configure.ac is not required to change results of tests.
+#
+# LICENSE
+#
+#   Copyright (c) 2023 Karlson2k (Evgeny Grin) <k2k@narod.ru>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 1
+
+AC_DEFUN([MHD_FIND_LIB],[dnl
+AC_PREREQ([2.64])dnl for AS_VAR_IF, m4_ifblank, m4_ifnblank
+m4_newline([[# Expansion of $0 macro starts here]])
+AC_LANG_ASSERT([C])dnl
+m4_ifblank(m4_translit([$1],[()],[  ]), [m4_fatal([First macro argument 
FUNCTION_NAME must not be empty])])dnl
+m4_ifblank([$3], [m4_fatal([Third macro argument CHECK_CODE must not be 
empty])])dnl
+m4_bmatch(m4_normalize([$1]), [\s],dnl
+          [m4_fatal([First macro argument FUNCTION_NAME must not contain 
whitespaces])])dnl
+m4_if(m4_index([$3], m4_normalize(m4_translit([$1],[()],[  ]))), [-1], dnl
+      [m4_fatal([CHECK_CODE parameter (third macro argument) does not contain 
']m4_normalize([$1])[' token])])dnl
+m4_bmatch([$7], [\$], [m4_fatal([$0: Seventh macro argument VAR_TO_PREPEND_LIB 
must not contain '$'])])dnl
+_MHD_FIND_LIB_BODY([$1],[$2],[$3],[$4],[$5],[$6],m4_default_nblank(_mhd_norm_expd([$7]),[LIBS]),[$8])dnl
+])dnl AC_DEFUN MHD_FIND_LIB
+
+# SYNOPSIS
+#
+#   _MHD_FIND_LIB_BODY([1_FUNCTION_NAME],
+#                      [2_INCLUDES=AC_INCLUDES_DEFAULT], [3_CHECK_CODE],
+#                      [4_LIBS_TO_CHECK],
+#                      [5_ACTION-IF-FOUND], [6_ACTION-IF-NOT-FOUND],
+#                      [7_VAR_TO_PREPEND_LIB=LIBS], [8_ADDITIONAL_LIBS])
+
+AC_DEFUN([_MHD_FIND_LIB_BODY],[dnl
+AS_VAR_PUSHDEF([decl_cv_Var],[ac_cv_have_decl_]m4_bpatsubst(_mhd_norm_expd(m4_translit([$1],[()],[
  ])),[[^a-zA-Z0-9]],[_]))dnl
+AS_VAR_PUSHDEF([cv_Var], 
[mhd_cv_find_lib_]m4_bpatsubst(_mhd_norm_expd(m4_translit([$1],[()],[  
])),[[^a-zA-Z0-9]],[_]))dnl
+AS_VAR_SET_IF([cv_Var],[],[AC_CHECK_DECL(_mhd_norm_expd([$1]),[],[],[$2])])
+AC_CACHE_CHECK([for library containing function $1], [cv_Var],
+  [
+    AS_VAR_IF([decl_cv_Var],["yes"],dnl
+      [dnl
+        mhd_find_lib_SAVE_LIBS="$LIBS"
+        m4_if([$7],LIBS,[dnl
+            mhd_find_lib_CHECK_LIBS="_mhd_norm_expd([$8]) $LIBS"
+          ],[dnl
+            mhd_find_lib_CHECK_LIBS="[$]$7 _mhd_norm_expd([$8]) $LIBS"
+          ]
+        )
+        # Reuse the same source file
+        AC_LANG_CONFTEST(
+          [AC_LANG_SOURCE([
+m4_default_nblank([$2],[AC_INCLUDES_DEFAULT])
+
+[int main(void)
+{
+
+  ]$3[
+
+  return 0;
+}
+             ]])
+          ]
+        )
+        for mhd_find_lib_LIB in '' $4
+        do
+          AS_IF([test -z "${mhd_find_lib_LIB}"],
+            [LIBS="${mhd_find_lib_CHECK_LIBS}"],
+            [LIBS="-l${mhd_find_lib_LIB} ${mhd_find_lib_CHECK_LIBS}"]
+          )
+          AC_LINK_IFELSE([],
+            [
+              AS_IF([test -z "${mhd_find_lib_LIB}"],
+                [AS_VAR_SET([cv_Var],["none required"])],
+                [AS_VAR_SET([cv_Var],["-l${mhd_find_lib_LIB}"])]
+              )
+            ]
+          )
+          AS_VAR_SET_IF([cv_Var],[break])
+        done
+        AS_UNSET([mhd_find_lib_LIB])
+        rm -f conftest.$ac_ext
+        LIBS="${mhd_find_lib_SAVE_LIBS}"
+        AS_UNSET([mhd_find_lib_SAVE_LIBS])
+      ]
+    )
+    AS_VAR_SET_IF([cv_Var],[:],[AS_VAR_SET([cv_Var],["no"])])
+  ]
+)
+AS_IF([test "x${cv_Var}" != "xno"],
+[dnl
+  AS_VAR_IF([cv_Var],["none required"],[:],
+    [
+      AS_IF([test -z "[$]$7"],[$7="${cv_Var}"],[$7="${cv_Var} [$]$7"])
+    ]
+  )
+  m4_n([$5])dnl
+],[m4_n([$6])])dnl AS_VAR_SET_IF cv_Var
+AS_VAR_POPDEF([cv_Var])dnl
+AS_VAR_POPDEF([decl_cv_Var])dnl
+m4_newline([[# Expansion of $0 macro ends here]])
+])dnl AC_DEFUN MHD_CHECK_FUNC
diff --git a/m4/mhd_shutdown_socket_trigger.m4 
b/m4/mhd_shutdown_socket_trigger.m4
index 469271b7..d33c4b18 100644
--- a/m4/mhd_shutdown_socket_trigger.m4
+++ b/m4/mhd_shutdown_socket_trigger.m4
@@ -11,24 +11,22 @@
 #
 # LICENSE
 #
-#   Copyright (c) 2017 Karlson2k (Evgeny Grin) <k2k@narod.ru>
+#   Copyright (c) 2017-2023 Karlson2k (Evgeny Grin) <k2k@narod.ru>
 #
 #   Copying and distribution of this file, with or without modification, are
 #   permitted in any medium without royalty provided the copyright notice
 #   and this notice are preserved. This file is offered as-is, without any
 #   warranty.
 
-#serial 3
+#serial 5
 
 AC_DEFUN([MHD_CHECK_SOCKET_SHUTDOWN_TRIGGER],[dnl
   AC_PREREQ([2.64])dnl
   AC_REQUIRE([AC_CANONICAL_HOST])dnl
   AC_REQUIRE([AC_PROG_CC])dnl
   AC_REQUIRE([AX_PTHREAD])dnl
-  AC_CHECK_HEADERS([sys/time.h],[AC_CHECK_FUNCS([gettimeofday])],[], 
[AC_INCLUDES_DEFAULT])
-  dnl AC_CHECK_HEADERS([time.h],[AC_CHECK_FUNCS([nanosleep])],[], 
[AC_INCLUDES_DEFAULT])
+  AC_REQUIRE([MHD_CHECK_FUNC_GETTIMEOFDAY])dnl
   MHD_CHECK_FUNC([[usleep]], [[#include <unistd.h>]], [[usleep(100000);]])
-  dnl AC_CHECK_HEADERS([unistd.h],[AC_CHECK_FUNCS([usleep])],[], 
[AC_INCLUDES_DEFAULT])
   MHD_CHECK_FUNC([[nanosleep]], [[#include <time.h>]], [[struct timespec ts2, 
ts1 = {0, 0}; nanosleep(&ts1, &ts2);]])
   AC_CHECK_HEADERS([string.h sys/types.h sys/socket.h netinet/in.h time.h 
sys/select.h netinet/tcp.h],[],[], [AC_INCLUDES_DEFAULT])
   AC_CACHE_CHECK([[whether shutdown of listen socket triggers select()]],
diff --git a/m4/search_h.m4 b/m4/search_h.m4
deleted file mode 100644
index 9fafc716..00000000
--- a/m4/search_h.m4
+++ /dev/null
@@ -1,66 +0,0 @@
-# search_h.m4 serial 12
-dnl Copyright (C) 2007-2021 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_REQUIRE([AC_C_RESTRICT])
-])
-
-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 Support Microsoft deprecated alias function names by default.
-  GNULIB_MDA_LFIND=1;   AC_SUBST([GNULIB_MDA_LFIND])
-  GNULIB_MDA_LSEARCH=1; AC_SUBST([GNULIB_MDA_LSEARCH])
-  dnl Assume proper GNU behavior unless another module says otherwise.
-  HAVE_TSEARCH=1;    AC_SUBST([HAVE_TSEARCH])
-  HAVE_TWALK=1;      AC_SUBST([HAVE_TWALK])
-  REPLACE_TSEARCH=0; AC_SUBST([REPLACE_TSEARCH])
-])
diff --git a/m4/tsearch.m4 b/m4/tsearch.m4
deleted file mode 100644
index 9f8782e4..00000000
--- a/m4/tsearch.m4
+++ /dev/null
@@ -1,64 +0,0 @@
-# tsearch.m4 serial 8
-dnl Copyright (C) 2006-2021 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 twalk])
-  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" ;;
-                         # Guess yes on native Windows.
-               mingw*)   gl_cv_func_tdelete_works="guessing yes" ;;
-               *)        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
-  if test $ac_cv_func_twalk != yes; then
-    HAVE_TWALK=0
-  fi
-])
-
-# Prerequisites of lib/tsearch.c.
-AC_DEFUN([gl_PREREQ_TSEARCH], [
-  :
-])
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index a0f71779..33bfd034 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -156,7 +156,7 @@ if USE_COVERAGE
   AM_CFLAGS += --coverage
 endif
 
-if !MHD_HAVE_TSEARCH
+if !MHD_USE_SYS_TSEARCH
 libmicrohttpd2_la_SOURCES += \
   tsearch.c tsearch.h
 endif
diff --git a/src/microhttpd/Makefile.am b/src/microhttpd/Makefile.am
index 8e6e623a..325c20fd 100644
--- a/src/microhttpd/Makefile.am
+++ b/src/microhttpd/Makefile.am
@@ -16,14 +16,14 @@ lib_LTLIBRARIES = \
 noinst_DATA =
 MOSTLYCLEANFILES =
 
-AM_V_LIB = $(am__v_LIB_$(V))
-am__v_LIB_ = $(am__v_LIB_$(AM_DEFAULT_VERBOSITY))
+AM_V_LIB = $(am__v_LIB_@AM_V@)
+am__v_LIB_ = $(am__v_LIB_@AM_DEFAULT_V@)
 am__v_LIB_0 = @echo "  LIB     " $@;
 am__v_LIB_1 = 
 
 if W32_SHARED_LIB_EXP
-AM_V_DLLTOOL = $(am__v_DLLTOOL_$(V))
-am__v_DLLTOOL_ = $(am__v_DLLTOOL_$(AM_DEFAULT_VERBOSITY))
+AM_V_DLLTOOL = $(am__v_DLLTOOL_@AM_V@)
+am__v_DLLTOOL_ = $(am__v_DLLTOOL_@AM_DEFAULT_V@)
 am__v_DLLTOOL_0 = @echo "  DLLTOOL " $@;
 am__v_DLLTOOL_1 = 
 
@@ -153,7 +153,7 @@ if USE_COVERAGE
   AM_CFLAGS += --coverage
 endif
 
-if !MHD_HAVE_TSEARCH
+if !MHD_USE_SYS_TSEARCH
 libmicrohttpd_la_SOURCES += \
   tsearch.c tsearch.h
 endif
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 97054e59..5e9be378 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -47,11 +47,11 @@
 #include "mhd_align.h"
 #include "mhd_str.h"
 
-#ifdef HAVE_SEARCH_H
+#ifdef MHD_USE_SYS_TSEARCH
 #include <search.h>
-#else
+#else  /* ! MHD_USE_SYS_TSEARCH */
 #include "tsearch.h"
-#endif
+#endif /* ! MHD_USE_SYS_TSEARCH */
 
 #ifdef HTTPS_SUPPORT
 #include "connection_https.h"
@@ -483,10 +483,11 @@ MHD_ip_limit_del (struct MHD_Daemon *daemon,
     tdelete (found_key,
              &daemon->per_ip_connection_count,
              &MHD_ip_addr_compare);
+    MHD_ip_count_unlock (daemon);
     free (found_key);
   }
-
-  MHD_ip_count_unlock (daemon);
+  else
+    MHD_ip_count_unlock (daemon);
 }
 
 
diff --git a/src/microhttpd/tsearch.c b/src/microhttpd/tsearch.c
index ba550b7d..af373fc3 100644
--- a/src/microhttpd/tsearch.c
+++ b/src/microhttpd/tsearch.c
@@ -21,119 +21,105 @@
 
 typedef struct node
 {
-  const void   *key;
-  struct node  *llink;
-  struct node  *rlink;
+  const void *key;
+  struct node  *llink, *rlink;
 } node_t;
 
 
-/*     $NetBSD: tsearch.c,v 1.5 2005/11/29 03:12:00 christos Exp $     */
+/*  $NetBSD: tsearch.c,v 1.7 2012/06/25 22:32:45 abs Exp $  */
 /* find or insert datum into search tree */
 void *
-tsearch (const void *vkey,  /* key to be located */
-         void **vrootp,     /* address of tree root */
+tsearch (const void *vkey, void **vrootp,
          int (*compar)(const void *, const void *))
 {
   node_t *q;
   node_t **rootp = (node_t **) vrootp;
 
-  if (NULL == rootp)
+  if (rootp == NULL)
     return NULL;
 
-  while (*rootp != NULL)
-  {   /* Knuth's T1: */
+  while (*rootp != NULL)        /* Knuth's T1: */
+  {
     int r;
 
     if ((r = (*compar)(vkey, (*rootp)->key)) == 0) /* T2: */
       return *rootp;                               /* we found it! */
 
     rootp = (r < 0) ?
-            &(*rootp)->llink : /* T3: follow left branch */
-            &(*rootp)->rlink; /* T4: follow right branch */
+            &(*rootp)->llink :      /* T3: follow left branch */
+            &(*rootp)->rlink;       /* T4: follow right branch */
   }
 
   q = malloc (sizeof(node_t)); /* T5: key not found */
-  if (q)
-  {                            /* make new node */
+  if (q != NULL)               /* make new node */
+  {
     *rootp = q;                /* link new node to old */
-    q->key = vkey;             /* initialize new node */
+    q->key = vkey; /* initialize new node */
     q->llink = q->rlink = NULL;
   }
   return q;
 }
 
 
-/*     $NetBSD: tfind.c,v 1.5 2005/03/23 08:16:53 kleink Exp $ */
-/* find a node, or return NULL */
+/*  $NetBSD: tfind.c,v 1.7 2012/06/25 22:32:45 abs Exp $    */
+/* find a node by key "vkey" in tree "vrootp", or return 0 */
 void *
-tfind (const void *vkey,         /* key to be found */
-       void *const *vrootp,      /* address of the tree root */
+tfind (const void *vkey, void * const *vrootp,
        int (*compar)(const void *, const void *))
 {
-  node_t *const *rootp = (node_t *const*) vrootp;
+  node_t * const *rootp = (node_t * const *) vrootp;
 
-  if (NULL == rootp)
+  if (rootp == NULL)
     return NULL;
 
-  while (*rootp != NULL)
-  {     /* T1: */
+  while (*rootp != NULL)            /* T1: */
+  {
     int r;
 
     if ((r = (*compar)(vkey, (*rootp)->key)) == 0) /* T2: */
       return *rootp;                               /* key found */
     rootp = (r < 0) ?
-            &(*rootp)->llink : /* T3: follow left branch */
-            &(*rootp)->rlink; /* T4: follow right branch */
+            &(*rootp)->llink :                     /* T3: follow left branch */
+            &(*rootp)->rlink;                      /* T4: follow right branch 
*/
   }
   return NULL;
 }
 
 
-/*     $NetBSD: tdelete.c,v 1.2 1999/09/16 11:45:37 lukem Exp $        */
-/*
- * delete node with given key
- *
- * vkey:   key to be deleted
- * vrootp: address of the root of the tree
- * compar: function to carry out node comparisons
- */
+/*  $NetBSD: tdelete.c,v 1.8 2016/01/20 20:47:41 christos Exp $ */
+/* find a node with key "vkey" in tree "vrootp" */
 void *
-tdelete (const void *__restrict vkey,
-         void **__restrict vrootp,
+tdelete (const void *vkey, void **vrootp,
          int (*compar)(const void *, const void *))
 {
   node_t **rootp = (node_t **) vrootp;
-  node_t *p;
-  node_t *q;
-  node_t *r;
+  node_t *p, *q, *r;
   int cmp;
 
-  if ((rootp == NULL) || ((p = *rootp) == NULL))
+  if ((rootp == NULL) || ((p = *rootp) == NULL) )
     return NULL;
 
   while ((cmp = (*compar)(vkey, (*rootp)->key)) != 0)
   {
     p = *rootp;
     rootp = (cmp < 0) ?
-            &(*rootp)->llink : /* follow llink branch */
-            &(*rootp)->rlink; /* follow rlink branch */
+            &(*rootp)->llink :       /* follow llink branch */
+            &(*rootp)->rlink;        /* follow rlink branch */
     if (*rootp == NULL)
       return NULL;                   /* key not found */
   }
   r = (*rootp)->rlink;               /* D1: */
   if ((q = (*rootp)->llink) == NULL) /* Left NULL? */
-  {
     q = r;
-  }
-  else if (r != NULL)
-  {       /* Right link is NULL? */
-    if (r->llink == NULL)
-    {     /* D2: Find successor */
+  else if (r != NULL)                /* Right link is NULL? */
+  {
+    if (r->llink == NULL)            /* D2: Find successor */
+    {
       r->llink = q;
       q = r;
     }
-    else
-    {         /* D3: Find NULL link */
+    else                    /* D3: Find NULL link */
+    {
       for (q = r->llink; q->llink != NULL; q = r->llink)
         r = q;
       r->llink = q->rlink;
@@ -141,8 +127,8 @@ tdelete (const void *__restrict vkey,
       q->rlink = (*rootp)->rlink;
     }
   }
-  free (*rootp);    /* D4: Free node */
-  *rootp = q;       /* link parent to new node */
+  free (*rootp);            /* D4: Free node */
+  *rootp = q;               /* link parent to new node */
   return p;
 }
 
diff --git a/src/microhttpd/tsearch.h b/src/microhttpd/tsearch.h
index 0cfe16a7..c6d873b4 100644
--- a/src/microhttpd/tsearch.h
+++ b/src/microhttpd/tsearch.h
@@ -3,36 +3,27 @@
  * Public domain.
  *
  *     $NetBSD: search.h,v 1.12 1999/02/22 10:34:28 christos Exp $
- * $FreeBSD: release/9.0.0/include/search.h 105250 2002-10-16 14:29:23Z robert 
$
  */
 
 #ifndef _TSEARCH_H_
 #define _TSEARCH_H_
 
-#if defined(__cplusplus)
-extern "C" {
+#ifdef __cplusplus
+extern "C"
+{
 #endif /* __cplusplus */
 
+void    *tdelete (const void *, void **,
+                  int (*)(const void *, const void *));
 
-void  *
-  tdelete (const void *__restrict,
-           void **__restrict,
-           int (*)(const void *, const void *));
+void    *tfind (const void *, void * const *,
+                int (*)(const void *, const void *));
 
+void    *tsearch (const void *, void **,
+                  int (*)(const void *, const void *));
 
-void  *
-  tfind (const void *,
-         void *const *,
-         int (*)(const void *, const void *));
-
-
-void  *
-  tsearch (const void *,
-           void **,
-           int (*)(const void *, const void *));
-
-#if defined(__cplusplus)
-};
+#ifdef __cplusplus
+}
 #endif /* __cplusplus */
 
 #endif /* !_TSEARCH_H_ */

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]