aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-08-18 11:22:08 +0200
committerChristian Grothoff <christian@grothoff.org>2018-08-18 11:22:08 +0200
commitdca675afab5776e17f9a37b891a70cd0d97d76f1 (patch)
tree2274c7e3e7e399ace0858541fd7a16e6e2382689
parent27a95aa100313190eaca1a5018180e731e17b5c8 (diff)
downloadlibmicrohttpd-dca675afab5776e17f9a37b891a70cd0d97d76f1.tar.gz
libmicrohttpd-dca675afab5776e17f9a37b891a70cd0d97d76f1.zip
polish configure.ac, use AS_IF where appropriate
-rw-r--r--configure.ac108
-rw-r--r--src/microhttpd/daemon.c11
2 files changed, 50 insertions, 69 deletions
diff --git a/configure.ac b/configure.ac
index e503a5da..09da0ad4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -35,28 +35,22 @@ AC_SUBST(LIB_VERSION_REVISION)
35AC_SUBST(LIB_VERSION_AGE) 35AC_SUBST(LIB_VERSION_AGE)
36 36
37AC_MSG_CHECKING([[whether z/OS special settings are required]]) 37AC_MSG_CHECKING([[whether z/OS special settings are required]])
38if test `uname -s` = "OS/390" 38AS_IF([test `uname -s` = "OS/390"],
39then 39[
40# configure binaries for z/OS 40# configure binaries for z/OS
41 if test -z "$CC" 41 AS_IF([test -z "$CC"],
42 then 42 [CC=`pwd`"/contrib/xcc"
43 CC=`pwd`"/contrib/xcc" 43 chmod +x $CC || true])
44 chmod +x $CC || true 44 AS_IF([test -z "$CPP"],
45 fi 45 CPP="c89 -E")
46 if test -z "$CPP" 46 AS_IF([test -z "$CXXCPP"],
47 then 47 CXXCPP="c++ -E -+")
48 CPP="c89 -E"
49 fi
50 if test -z "$CXXCPP"
51 then
52 CXXCPP="c++ -E -+"
53 fi
54 AC_MSG_RESULT([[yes]]) 48 AC_MSG_RESULT([[yes]])
55# _CCC_CCMODE=1 49# _CCC_CCMODE=1
56# _C89_CCMODE=1 50# _C89_CCMODE=1
57else 51],
58 AC_MSG_RESULT([[no]]) 52 AC_MSG_RESULT([[no]])
59fi 53)
60 54
61# Checks for programs. 55# Checks for programs.
62AC_PROG_AWK 56AC_PROG_AWK
@@ -427,15 +421,14 @@ AS_IF([[test "x$with_threads" = "xposix"]],
427 ) 421 )
428 ] 422 ]
429 ) 423 )
430if test "x$USE_THREADS" = "xposix"; then 424AS_IF([test "x$USE_THREADS" = "xposix"],
431 CC="$PTHREAD_CC" 425 [CC="$PTHREAD_CC"
432 AC_DEFINE([MHD_USE_POSIX_THREADS],[1],[define to use pthreads]) 426 AC_DEFINE([MHD_USE_POSIX_THREADS],[1],[define to use pthreads])
433 MHD_LIB_CFLAGS="$MHD_LIB_CFLAGS $PTHREAD_CFLAGS" 427 MHD_LIB_CFLAGS="$MHD_LIB_CFLAGS $PTHREAD_CFLAGS"
434 MHD_LIBDEPS="$PTHREAD_LIBS $MHD_LIBDEPS" 428 MHD_LIBDEPS="$PTHREAD_LIBS $MHD_LIBDEPS"
435 MHD_LIBDEPS_PKGCFG="$PTHREAD_LIBS $MHD_LIBDEPS_PKGCFG" 429 MHD_LIBDEPS_PKGCFG="$PTHREAD_LIBS $MHD_LIBDEPS_PKGCFG"
436elif test "x$USE_THREADS" = "xw32"; then 430elif test "x$USE_THREADS" = "xw32"; then
437 AC_DEFINE([MHD_USE_W32_THREADS],[1],[define to use W32 threads]) 431 AC_DEFINE([MHD_USE_W32_THREADS],[1],[define to use W32 threads])])
438fi
439AM_CONDITIONAL([USE_POSIX_THREADS], [test "x$USE_THREADS" = "xposix"]) 432AM_CONDITIONAL([USE_POSIX_THREADS], [test "x$USE_THREADS" = "xposix"])
440AM_CONDITIONAL([USE_W32_THREADS], [test "x$USE_THREADS" = "xw32"]) 433AM_CONDITIONAL([USE_W32_THREADS], [test "x$USE_THREADS" = "xw32"])
441AC_MSG_RESULT([[$USE_THREADS]]) 434AC_MSG_RESULT([[$USE_THREADS]])
@@ -444,7 +437,7 @@ AC_ARG_ENABLE([[thread-names]],
444 [AS_HELP_STRING([--disable-thread-names [auto] ],[do not set names on MHD generated threads])], 437 [AS_HELP_STRING([--disable-thread-names [auto] ],[do not set names on MHD generated threads])],
445 [], [enable_thread_names='auto']) 438 [], [enable_thread_names='auto'])
446 439
447if test "x$enable_thread_names" != "xno" && test "x$USE_THREADS" = "xposix"; then 440AS_IF([test "x$enable_thread_names" != "xno" && test "x$USE_THREADS" = "xposix"],[
448 # Check for thread name function 441 # Check for thread name function
449 HAVE_THREAD_NAME_FUNC="no" 442 HAVE_THREAD_NAME_FUNC="no"
450 SAVE_LIBS="$LIBS" 443 SAVE_LIBS="$LIBS"
@@ -600,10 +593,9 @@ AC_INCLUDES_DEFAULT
600 593
601 LIBS="$SAVE_LIBS" 594 LIBS="$SAVE_LIBS"
602 CFLAGS="$SAVE_CFLAGS" 595 CFLAGS="$SAVE_CFLAGS"
603fi 596])
604 597
605AS_IF( 598AS_IF([[test "x$enable_thread_names" != "xno"]],
606 [[test "x$enable_thread_names" != "xno"]],
607 [ 599 [
608 AC_MSG_CHECKING([[whether to enable thread names]]) 600 AC_MSG_CHECKING([[whether to enable thread names]])
609 AC_COMPILE_IFELSE( 601 AC_COMPILE_IFELSE(
@@ -690,31 +682,25 @@ AC_ARG_ENABLE([[poll]],
690 [enable_poll='auto'] 682 [enable_poll='auto']
691 ) 683 )
692 684
693if test "$enable_poll" != "no"; then 685AS_IF([test "$enable_poll" != "no"],
694 if test "$os_is_native_w32" != "yes"; then 686 [AS_IF([test "$os_is_native_w32" != "yes"],
695 AC_CHECK_HEADERS([poll.h], 687 AC_CHECK_HEADERS([poll.h],
696 [ 688 [AC_CHECK_FUNCS([poll], [have_poll='yes'], [have_poll='no'])],
697 AC_CHECK_FUNCS([poll], [have_poll='yes'], [have_poll='no']) 689 [],
698 ], [], [AC_INCLUDES_DEFAULT]) 690 [AC_INCLUDES_DEFAULT]),
699 else 691 [AC_MSG_CHECKING([for WSAPoll()])
700 AC_MSG_CHECKING([for WSAPoll()]) 692 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
701 AC_LINK_IFELSE([
702 AC_LANG_PROGRAM([[
703#include <winsock2.h> 693#include <winsock2.h>
704 ]], [[ 694 ]],[[
705WSAPOLLFD fda[2]; 695WSAPOLLFD fda[2];
706WSAPoll(fda, 2, 0);]])], 696WSAPoll(fda, 2, 0);]])],
707 [ 697 [have_poll='yes'
708 have_poll='yes' 698 AC_DEFINE([HAVE_POLL],[1])
709 AC_DEFINE([HAVE_POLL],[1]) 699 ],[have_poll='no'])
710 ], [have_poll='no']) 700 AC_MSG_RESULT([$have_poll])])
711 AC_MSG_RESULT([$have_poll]) 701 AS_IF([test "$enable_poll" = "yes" && test "$have_poll" != "yes"],
712 fi 702 AC_MSG_ERROR([[Support for poll was explicitly requested but cannot be enabled on this platform.]]))
713 if test "$enable_poll" = "yes" && test "$have_poll" != "yes"; then 703 enable_poll="$have_poll"])
714 AC_MSG_ERROR([[Support for poll was explicitly requested but cannot be enabled on this platform.]])
715 fi
716 enable_poll="$have_poll"
717fi
718 704
719AC_ARG_ENABLE([[epoll]], 705AC_ARG_ENABLE([[epoll]],
720 [AS_HELP_STRING([[--enable-epoll[=ARG]]], [enable epoll support (yes, no, auto) [auto]])], 706 [AS_HELP_STRING([[--enable-epoll[=ARG]]], [enable epoll support (yes, no, auto) [auto]])],
@@ -722,23 +708,20 @@ AC_ARG_ENABLE([[epoll]],
722 [enable_epoll='auto'] 708 [enable_epoll='auto']
723 ) 709 )
724 710
725if test "$enable_epoll" != "no"; then 711AS_IF([test "$enable_epoll" != "no"],
726 AX_HAVE_EPOLL 712 [AX_HAVE_EPOLL
727 if test "${ax_cv_have_epoll}" = "yes"; then 713 AS_IF([test "${ax_cv_have_epoll}" = "yes"],
728 AC_DEFINE([[EPOLL_SUPPORT]],[[1]],[Define to 1 to enable epoll support]) 714 [AC_DEFINE([[EPOLL_SUPPORT]],[[1]],[Define to 1 to enable epoll support])
729 enable_epoll='yes' 715 enable_epoll='yes'],
730 else 716 [AS_IF([test "$enable_epoll" = "yes"],
731 if test "$enable_epoll" = "yes"; then 717 AC_MSG_ERROR([[Support for epoll was explicitly requested but cannot be enabled on this platform.]]))
732 AC_MSG_ERROR([[Support for epoll was explicitly requested but cannot be enabled on this platform.]]) 718 enable_epoll='no'])])
733 fi
734 enable_epoll='no'
735 fi
736fi
737 719
738AM_CONDITIONAL([MHD_HAVE_EPOLL], [[test "x$enable_epoll" = xyes]]) 720AM_CONDITIONAL([MHD_HAVE_EPOLL], [[test "x$enable_epoll" = xyes]])
739 721
740if test "x$enable_epoll" = "xyes"; then 722AS_IF([test "x$enable_epoll" = "xyes"],
741 AC_CACHE_CHECK([for epoll_create1()], [mhd_cv_have_epoll_create1], [ 723 AC_CACHE_CHECK([for epoll_create1()],
724 [mhd_cv_have_epoll_create1], [
742 AC_LINK_IFELSE([ 725 AC_LINK_IFELSE([
743 AC_LANG_PROGRAM([[ 726 AC_LANG_PROGRAM([[
744#include <sys/epoll.h> 727#include <sys/epoll.h>
@@ -748,8 +731,7 @@ fd = epoll_create1(EPOLL_CLOEXEC);]])],
748 [mhd_cv_have_epoll_create1=yes], 731 [mhd_cv_have_epoll_create1=yes],
749 [mhd_cv_have_epoll_create1=no])]) 732 [mhd_cv_have_epoll_create1=no])])
750 AS_IF([test "x$mhd_cv_have_epoll_create1" = "xyes"],[ 733 AS_IF([test "x$mhd_cv_have_epoll_create1" = "xyes"],[
751 AC_DEFINE([[HAVE_EPOLL_CREATE1]], [[1]], [Define if you have epoll_create1 function.])]) 734 AC_DEFINE([[HAVE_EPOLL_CREATE1]], [[1]], [Define if you have epoll_create1 function.])]))
752fi
753 735
754# Check for headers that are ALWAYS required 736# Check for headers that are ALWAYS required
755AC_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]) 737AC_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])
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 721763dd..c70a405a 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -3923,6 +3923,8 @@ MHD_poll (struct MHD_Daemon *daemon,
3923 return MHD_poll_listen_socket (daemon, 3923 return MHD_poll_listen_socket (daemon,
3924 may_block); 3924 may_block);
3925#else 3925#else
3926 (void) daemon;
3927 (void) may_block;
3926 return MHD_NO; 3928 return MHD_NO;
3927#endif 3929#endif
3928} 3930}
@@ -3960,30 +3962,25 @@ is_urh_ready(struct MHD_UpgradeResponseHandle * const urh)
3960 (0 == urh->in_buffer_used) && 3962 (0 == urh->in_buffer_used) &&
3961 (0 == urh->out_buffer_used) ) 3963 (0 == urh->out_buffer_used) )
3962 return false; 3964 return false;
3963
3964 if (connection->daemon->shutdown) 3965 if (connection->daemon->shutdown)
3965 return true; 3966 return true;
3966
3967 if ( ( (0 != (MHD_EPOLL_STATE_READ_READY & urh->app.celi)) || 3967 if ( ( (0 != (MHD_EPOLL_STATE_READ_READY & urh->app.celi)) ||
3968 (connection->tls_read_ready) ) && 3968 (connection->tls_read_ready) ) &&
3969 (urh->in_buffer_used < urh->in_buffer_size) ) 3969 (urh->in_buffer_used < urh->in_buffer_size) )
3970 return true; 3970 return true;
3971
3972 if ( (0 != (MHD_EPOLL_STATE_READ_READY & urh->mhd.celi)) && 3971 if ( (0 != (MHD_EPOLL_STATE_READ_READY & urh->mhd.celi)) &&
3973 (urh->out_buffer_used < urh->out_buffer_size) ) 3972 (urh->out_buffer_used < urh->out_buffer_size) )
3974 return true; 3973 return true;
3975
3976 if ( (0 != (MHD_EPOLL_STATE_WRITE_READY & urh->app.celi)) && 3974 if ( (0 != (MHD_EPOLL_STATE_WRITE_READY & urh->app.celi)) &&
3977 (urh->out_buffer_used > 0) ) 3975 (urh->out_buffer_used > 0) )
3978 return true; 3976 return true;
3979
3980 if ( (0 != (MHD_EPOLL_STATE_WRITE_READY & urh->mhd.celi)) && 3977 if ( (0 != (MHD_EPOLL_STATE_WRITE_READY & urh->mhd.celi)) &&
3981 (urh->in_buffer_used > 0) ) 3978 (urh->in_buffer_used > 0) )
3982 return true; 3979 return true;
3983
3984 return false; 3980 return false;
3985} 3981}
3986 3982
3983
3987/** 3984/**
3988 * Do epoll()-based processing for TLS connections that have been 3985 * Do epoll()-based processing for TLS connections that have been
3989 * upgraded. This requires a separate epoll() invocation as we 3986 * upgraded. This requires a separate epoll() invocation as we
@@ -4093,11 +4090,13 @@ run_epoll_for_upgrade (struct MHD_Daemon *daemon)
4093} 4090}
4094#endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ 4091#endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */
4095 4092
4093
4096/** 4094/**
4097 * Pointer-marker to distinguish ITC slot in epoll sets. 4095 * Pointer-marker to distinguish ITC slot in epoll sets.
4098 */ 4096 */
4099static const char * const epoll_itc_marker = "itc_marker"; 4097static const char * const epoll_itc_marker = "itc_marker";
4100 4098
4099
4101/** 4100/**
4102 * Do epoll()-based processing (this function is allowed to 4101 * Do epoll()-based processing (this function is allowed to
4103 * block if @a may_block is set to #MHD_YES). 4102 * block if @a may_block is set to #MHD_YES).