aboutsummaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac124
1 files changed, 117 insertions, 7 deletions
diff --git a/configure.ac b/configure.ac
index 0787464b..639c15ba 100644
--- a/configure.ac
+++ b/configure.ac
@@ -525,14 +525,124 @@ AC_CHECK_HEADERS([sys/msg.h sys/mman.h signal.h], [], [], [AC_INCLUDES_DEFAULT])
525 525
526AC_CHECK_HEADER([[search.h]], 526AC_CHECK_HEADER([[search.h]],
527 [ 527 [
528 gl_FUNC_TSEARCH 528 MHD_CHECK_LINK_RUN([[for proper tsearch(), tfind() and tdelete()]],[[mhd_cv_sys_tsearch_usable]],
529 AS_IF([[test "x$HAVE_TSEARCH" = "x1" && test "x$REPLACE_TSEARCH" != "x1"]], 529 [
530 [AC_DEFINE([[HAVE_SEARCH_H]], [[1]], 530 AS_CASE([$host_os],
531 [Define to 1 if you have the <search.h> header file and your system have properly functioning tsearch(), tfind() and tdelete() functions])]) 531 [openbsd*],
532 ], 532 [[ # Some OpenBSD versions have wrong return value for tdelete()
533 [], [AC_INCLUDES_DEFAULT]) 533 mhd_cv_sys_tsearch_usable='assuming no'
534 ]],
535 [netbsd*],
536 [[ # NetBSD had leaked root node for years
537 mhd_cv_sys_tsearch_usable='assuming no'
538 ]],
539 [[mhd_cv_sys_tsearch_usable='assuming yes']]
540 )
541 ],
542 [
543 AC_LANG_SOURCE(
544 [[
545#ifdef HAVE_STDDEF_H
546#include <stddef.h>
547#endif /* HAVE_STDDEF_H */
548#ifdef HAVE_STDLIB_H
549#include <stdlib.h>
550#endif /* HAVE_STDLIB_H */
551
552#include <stdio.h>
553#include <search.h>
534 554
535AM_CONDITIONAL([MHD_HAVE_TSEARCH], [[test "x$ac_cv_header_search_h" = xyes && test "x$HAVE_TSEARCH" = "x1" && test "x$REPLACE_TSEARCH" != "x1"]]) 555static int cmp_func(const void *p1, const void *p2)
556{
557 return (*((const int *)p1)) - (*((const int *)p2));
558}
559
560int main(void)
561{
562 int ret = 0;
563 void *root_ptr = NULL;
564 int element1 = 1;
565 int **element_ptr_ptr1;
566 int **element_ptr_ptr2;
567
568 element_ptr_ptr1 =
569 (int **) tsearch ((void*) &element1, &root_ptr, &cmp_func);
570 if (NULL == element_ptr_ptr1)
571 {
572 fprintf (stderr, "NULL pointer has been returned when tsearch() called for the first time.\n");
573 return ++ret;
574 }
575 if (*element_ptr_ptr1 != &element1)
576 {
577 fprintf (stderr, "Wrong pointer has been returned when tsearch() called for the first time.\n");
578 return ++ret;
579 }
580 if (NULL == root_ptr)
581 {
582 fprintf (stderr, "Root pointer has not been set by tsearch().\n");
583 return ++ret;
584 }
585
586 element_ptr_ptr2 =
587 (int **) tsearch ((void*) &element1, &root_ptr, &cmp_func);
588 if (NULL == element_ptr_ptr2)
589 {
590 fprintf (stderr, "NULL pointer has been returned when tsearch() called for the second time.\n");
591 return ++ret;
592 }
593 if (*element_ptr_ptr2 != &element1)
594 {
595 fprintf (stderr, "Wrong pointer has been returned when tsearch() called for the second time.\n");
596 ++ret;
597 }
598 if (element_ptr_ptr2 != element_ptr_ptr1)
599 {
600 fprintf (stderr, "Wrong element has been returned when tsearch() called for the second time.\n");
601 ++ret;
602 }
603
604 element_ptr_ptr2 =
605 (int **) tfind ((void*) &element1, &root_ptr, &cmp_func);
606 if (NULL == element_ptr_ptr2)
607 {
608 fprintf (stderr, "NULL pointer has been returned by tfind().\n");
609 ++ret;
610 }
611 if (*element_ptr_ptr2 != &element1)
612 {
613 fprintf (stderr, "Wrong pointer has been returned when by tfind().\n");
614 ++ret;
615 }
616 if (element_ptr_ptr2 != element_ptr_ptr1)
617 {
618 fprintf (stderr, "Wrong element has been returned when tsearch() called for the second time.\n");
619 ++ret;
620 }
621
622 element_ptr_ptr1 =
623 (int **) tdelete ((void*) &element1, &root_ptr, &cmp_func);
624 if (NULL == element_ptr_ptr1)
625 {
626 fprintf (stderr, "NULL pointer has been returned by tdelete().\n");
627 ++ret;
628 }
629 if (NULL != root_ptr)
630 {
631 fprintf (stderr, "Root pointer has not been set to NULL by tdelete().\n");
632 ++ret;
633 }
634
635 return ret;
636}
637 ]]
638 )
639 ],
640 [AC_DEFINE([[MHD_USE_SYS_TSEARCH]], [[1]], [Define to 1 if you have properly working tsearch(), tfind() and tdelete() functions.])]
641 )
642 ],
643 [], [AC_INCLUDES_DEFAULT]
644)
645AM_CONDITIONAL([MHD_USE_SYS_TSEARCH], [[test "x$mhd_cv_sys_tsearch_usable" = "xyes" || test "x$mhd_cv_sys_tsearch_usable" = "xassuming yes"]])
536 646
537# Optional headers used for tests 647# Optional headers used for tests
538AC_CHECK_HEADERS([sys/sysctl.h netinet/ip_icmp.h netinet/icmp_var.h], [], [], 648AC_CHECK_HEADERS([sys/sysctl.h netinet/ip_icmp.h netinet/icmp_var.h], [], [],