From 4c6365af02b4ea7422fed929dea4453d6d848912 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 2 Oct 2023 11:24:14 +0000 Subject: [PATCH] autotools: restore `HAVE_IOCTL_*` detections This restores `CURL_CHECK_FUNC_IOCTL` detection. I deleted it in 4d73854462f30948acab12984b611e9e33ee41e6 and c3456652a0c72d1845d08df9769667db7e159949 (2022-08), because the `HAVE_IOCTL` result it generated was unused in the source. But, I did miss the fact that this had two dependent checks: `CURL_CHECK_FUNC_IOCTL_FIONBIO`, `CURL_CHECK_FUNC_IOCTL_SIOCGIFADDR` that we do actually need: `HAVE_IOCTL_FIONBIO`, `HAVE_IOCTL_SIOCGIFADDR`. Regression from 4d73854462f30948acab12984b611e9e33ee41e6 Ref: #11964 (effort to sync cmake detections with autotools) Closes #12008 --- configure.ac | 1 + m4/curl-functions.m4 | 87 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) diff --git a/configure.ac b/configure.ac index b308f518f6..2d71c838f8 100644 --- a/configure.ac +++ b/configure.ac @@ -3550,6 +3550,7 @@ CURL_CHECK_FUNC_GETIFADDRS CURL_CHECK_FUNC_GMTIME_R CURL_CHECK_FUNC_INET_NTOP CURL_CHECK_FUNC_INET_PTON +CURL_CHECK_FUNC_IOCTL CURL_CHECK_FUNC_IOCTLSOCKET CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL CURL_CHECK_FUNC_MEMRCHR diff --git a/m4/curl-functions.m4 b/m4/curl-functions.m4 index b0848d0b29..7fefa39670 100644 --- a/m4/curl-functions.m4 +++ b/m4/curl-functions.m4 @@ -3323,6 +3323,93 @@ AC_DEFUN([CURL_CHECK_FUNC_INET_PTON], [ ]) +dnl CURL_CHECK_FUNC_IOCTL +dnl ------------------------------------------------- +dnl Verify if ioctl is available, prototyped, and +dnl can be compiled. If all of these are true, and +dnl usage has not been previously disallowed with +dnl shell variable curl_disallow_ioctl, then +dnl HAVE_IOCTL will be defined. + +AC_DEFUN([CURL_CHECK_FUNC_IOCTL], [ + AC_REQUIRE([CURL_INCLUDES_STROPTS])dnl + # + tst_links_ioctl="unknown" + tst_proto_ioctl="unknown" + tst_compi_ioctl="unknown" + tst_allow_ioctl="unknown" + # + AC_MSG_CHECKING([if ioctl can be linked]) + AC_LINK_IFELSE([ + AC_LANG_FUNC_LINK_TRY([ioctl]) + ],[ + AC_MSG_RESULT([yes]) + tst_links_ioctl="yes" + ],[ + AC_MSG_RESULT([no]) + tst_links_ioctl="no" + ]) + # + if test "$tst_links_ioctl" = "yes"; then + AC_MSG_CHECKING([if ioctl is prototyped]) + AC_EGREP_CPP([ioctl],[ + $curl_includes_stropts + ],[ + AC_MSG_RESULT([yes]) + tst_proto_ioctl="yes" + ],[ + AC_MSG_RESULT([no]) + tst_proto_ioctl="no" + ]) + fi + # + if test "$tst_proto_ioctl" = "yes"; then + AC_MSG_CHECKING([if ioctl is compilable]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + $curl_includes_stropts + ]],[[ + if(0 != ioctl(0, 0, 0)) + return 1; + ]]) + ],[ + AC_MSG_RESULT([yes]) + tst_compi_ioctl="yes" + ],[ + AC_MSG_RESULT([no]) + tst_compi_ioctl="no" + ]) + fi + # + if test "$tst_compi_ioctl" = "yes"; then + AC_MSG_CHECKING([if ioctl usage allowed]) + if test "x$curl_disallow_ioctl" != "xyes"; then + AC_MSG_RESULT([yes]) + tst_allow_ioctl="yes" + else + AC_MSG_RESULT([no]) + tst_allow_ioctl="no" + fi + fi + # + AC_MSG_CHECKING([if ioctl might be used]) + if test "$tst_links_ioctl" = "yes" && + test "$tst_proto_ioctl" = "yes" && + test "$tst_compi_ioctl" = "yes" && + test "$tst_allow_ioctl" = "yes"; then + AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(HAVE_IOCTL, 1, + [Define to 1 if you have the ioctl function.]) + curl_cv_func_ioctl="yes" + CURL_CHECK_FUNC_IOCTL_FIONBIO + CURL_CHECK_FUNC_IOCTL_SIOCGIFADDR + else + AC_MSG_RESULT([no]) + curl_cv_func_ioctl="no" + fi +]) + + dnl CURL_CHECK_FUNC_IOCTL_FIONBIO dnl ------------------------------------------------- dnl Verify if ioctl with the FIONBIO command is