libmicrohttpd

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

commit 4a169d0cffaa69ed22ddd6cca721b43c7599df6c
parent 2efc013917d69a2fc60fbb3eb44fa21801fe0580
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Fri, 23 Dec 2022 17:20:54 +0300

configure: try to detect whether eventfd is enabled

eventfd is optional kernel feature, MHD can work just fine without
eventfd enabled.

Diffstat:
Mconfigure.ac | 66++++++++++++++++++++++++++++++++++++++++++------------------------
1 file changed, 42 insertions(+), 24 deletions(-)

diff --git a/configure.ac b/configure.ac @@ -1998,32 +1998,50 @@ AS_CASE([[$enable_itc]], ) AS_UNSET([[use_itc]]) -AS_IF([[test "x$enable_itc" = "xeventfd" || test "x$enable_itc" = "xauto"]], [ - AS_VAR_IF([[os_is_native_w32]], [["yes"]], [], [ - AC_CHECK_HEADERS([sys/eventfd.h], [], [], [AC_INCLUDES_DEFAULT]) - AS_VAR_IF([[ac_cv_header_sys_eventfd_h]], [["yes"]], [ - AC_CACHE_CHECK([whether eventfd(2) is usable], [[mhd_cv_eventfd_usable]], [ - AC_LINK_IFELSE([ - AC_LANG_PROGRAM([[ +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']], + [ + AC_LANG_SOURCE([[ #include <sys/eventfd.h> #include <unistd.h> - ]], [[ - int ef = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); - if (ef < 0) return 1; - close (ef); - ]]) - ], [[mhd_cv_eventfd_usable='yes']], [[mhd_cv_eventfd_usable='no']]) - ]) - ]) - ]) - AS_VAR_IF([[mhd_cv_eventfd_usable]], [["yes"]], [ - use_itc='eventfd' - enable_itc="$use_itc" - AC_DEFINE([[_MHD_ITC_EVENTFD]], [[1]], [Define to use eventFD for inter-thread communication]) - ], [ - AS_VAR_IF([[enable_itc]], [["eventfd"]], [AC_MSG_ERROR([[eventfd(2) is not usable, consider using other type of inter-thread communication]])]) - ]) -]) + +int main(void) +{ + unsigned char buf[8]; + int ret; + int efd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); + if (0 > efd) + return 2; + ret = 0; + buf[3] = 1; + if (8 != write(efd, buf, 8)) + ret = 3; + else + { + if (8 != read(efd, buf, 8)) + ret = 4; + } + close(efd); + return ret; +} + ]] + ) + ], + [ + use_itc='eventfd' + enable_itc="$use_itc" + AC_DEFINE([[_MHD_ITC_EVENTFD]], [[1]], [Define to use eventFD for inter-thread communication]) + ], + [ + AS_VAR_IF([[enable_itc]], [["eventfd"]], [AC_MSG_ERROR([[eventfd(2) is not usable, consider using other type of inter-thread communication]])]) + ] + ) + AS_VAR_IF([mhd_cv_eventfd_usable],["assuming no"], + [AC_MSG_WARN([if you have 'eventfd' support enabled on your target system consider overriding test result by "mhd_cv_eventfd_usable=yes" configure parameter])] + ) + ] +) AS_IF([[test "x$enable_itc" = "xpipe" || test "x$enable_itc" = "xauto"]], [ AS_VAR_IF([[os_is_native_w32]], [["yes"]], [], [