]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
autotools: restore `HAVE_IOCTL_*` detections
authorViktor Szakats <commit@vsz.me>
Mon, 2 Oct 2023 11:24:14 +0000 (11:24 +0000)
committerViktor Szakats <commit@vsz.me>
Mon, 2 Oct 2023 21:19:23 +0000 (21:19 +0000)
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
m4/curl-functions.m4

index b308f518f603a38484f32675b48414cc7a812aab..2d71c838f86b63053b3b5fde85f75b407f3e6700 100644 (file)
@@ -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
index b0848d0b29f0c2d211b2ecd88efefa7452603bf7..7fefa39670d29d3750f928825d307bf1fb244a7e 100644 (file)
@@ -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