]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
build: enable thread-safe `getaddrinfo()` for OpenBSD, and other tidy-ups
authorViktor Szakats <commit@vsz.me>
Mon, 22 Jun 2026 20:41:07 +0000 (22:41 +0200)
committerViktor Szakats <commit@vsz.me>
Thu, 25 Jun 2026 09:32:36 +0000 (11:32 +0200)
Aka `HAVE_GETADDRINFO_THREADSAFE`.

- enable it for OpenBSD 5.4+ (2013-11-01).
  Also adjust cmake pre-fill.

- explicitly opt-in DragonFly BSD, for 2.2.0+ (2009-02-17).
  Assuming this commit implemented this feature:
  https://github.com/DragonFlyBSD/DragonFlyBSD/commit/21fcee4d6e84a10a35d21e920106590570511048#diff-498ff649e8770eb9a94e99a399a4b473fcea41ef58b033a2a2dae3809e17bb04
  Prior to this patch it was enabled in autotools by accident, because
  its host ID misses `bsd` so the global BSD disable was not applied.

- autotools: fix to enable for Darwin 9+ / macOS 10.5+ (2007-10-26).
  Prior to this patch it was Darwin 6 / macOS 10.2.
  Source: https://github.com/python/cpython/issues/70112
  Ref: https://en.wikipedia.org/wiki/MacOS_version_history
  10.5 was the first one UNIX '03 certified, which requires this
  feature. iOS and others were forked from this codebase, so they also
  have support.

- cmake: add version numbers as comments.
  Sadly the OS versions are not verified. This and the autotools logic
  could possibly be implemented in `curl-setup.h` more accurately, for
  all build systems, without duplicating logic.

Also:
- cmake: `BSD` variable requires CMake 3.25+, add fallback code where
  missing.
  Ref: https://cmake.org/cmake/help/v3.25/variable/BSD.html
- unix-cache.cmake: stop listing all BSDs for `HAVE_PIPE2`,
  and fix generic BSD filter for CMake <3.25.
- unix-cache.cmake: stop listing all BSDs, since it's prefilled anyway
  for those via `OtherTests.cmake`.

Ref: https://github.com/curl/curl/pull/22138#issuecomment-4773617195

Closes #22148

CMake/OtherTests.cmake
CMake/unix-cache.cmake
CMakeLists.txt
m4/curl-functions.m4

index 6619f3ab3e880818e1a01028afddd308867a7a01..b0727d32e434c42ed47f47a72f7a47e293fd24f4 100644 (file)
@@ -77,12 +77,14 @@ if(WIN32)
   set(HAVE_GETADDRINFO_THREADSAFE ${HAVE_GETADDRINFO})
 elseif(NOT HAVE_GETADDRINFO)
   set(HAVE_GETADDRINFO_THREADSAFE FALSE)
-elseif(APPLE OR
-       AIX OR CMAKE_SYSTEM_NAME STREQUAL "AIX" OR
-       CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR
-       CMAKE_SYSTEM_NAME STREQUAL "HP-UX" OR
-       CMAKE_SYSTEM_NAME STREQUAL "MidnightBSD" OR
-       CMAKE_SYSTEM_NAME STREQUAL "NetBSD" OR
+elseif(APPLE OR  # Darwin 9+ / macOS 10.5+
+       AIX OR CMAKE_SYSTEM_NAME STREQUAL "AIX" OR  # 5.2+
+       CMAKE_SYSTEM_NAME STREQUAL "DragonFlyBSD" OR  # 2.2.0+
+       CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR  # 5.5+
+       CMAKE_SYSTEM_NAME STREQUAL "HP-UX" OR  # 11.11+
+       CMAKE_SYSTEM_NAME STREQUAL "MidnightBSD" OR  # all versions
+       CMAKE_SYSTEM_NAME STREQUAL "NetBSD" OR  # 4+
+       CMAKE_SYSTEM_NAME STREQUAL "OpenBSD" OR  # 5.4+
        CMAKE_SYSTEM_NAME STREQUAL "SunOS")
   set(HAVE_GETADDRINFO_THREADSAFE TRUE)
 elseif(BSD OR CMAKE_SYSTEM_NAME MATCHES "BSD")
index 78816499ca011c2ad3de9854e253d9587ccbb0a0..44dc6472b22ead7201b23d2d094e03c16ea8e242 100644 (file)
@@ -106,14 +106,7 @@ elseif(CYGWIN OR
   set(HAVE_FSETXATTR_6 0)
 endif()
 set(HAVE_GETADDRINFO 1)
-if(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
-  set(HAVE_GETADDRINFO_THREADSAFE 0)
-elseif(CYGWIN OR
-       CMAKE_SYSTEM_NAME STREQUAL "Linux" OR
-       CMAKE_SYSTEM_NAME STREQUAL "DragonFlyBSD" OR
-       CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR
-       CMAKE_SYSTEM_NAME STREQUAL "MidnightBSD" OR
-       CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
+if(CYGWIN)
   set(HAVE_GETADDRINFO_THREADSAFE 1)
 endif()
 set(HAVE_GETEUID 1)
@@ -219,12 +212,7 @@ if(APPLE OR
    CYGWIN)
   set(HAVE_PIPE2 0)
 elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR
-       BSD OR
-       CMAKE_SYSTEM_NAME STREQUAL "DragonFlyBSD" OR
-       CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR
-       CMAKE_SYSTEM_NAME STREQUAL "MidnightBSD" OR
-       CMAKE_SYSTEM_NAME STREQUAL "NetBSD" OR
-       CMAKE_SYSTEM_NAME STREQUAL "OpenBSD" OR
+       BSD OR CMAKE_SYSTEM_NAME MATCHES "BSD" OR
        CMAKE_SYSTEM_NAME STREQUAL "SunOS")
   set(HAVE_PIPE2 1)
 endif()
index e459b3d0761a6db30e893d53fb6e2ee125452566..c956dc411578e362bd71bfff6614b2ce78ddd657 100644 (file)
@@ -89,7 +89,7 @@ endif()
 if(UNIX)
   string(APPEND _target_flags " UNIX")
 endif()
-if(BSD)
+if(BSD OR CMAKE_SYSTEM_NAME MATCHES "BSD")
   string(APPEND _target_flags " BSD")
 endif()
 if(ANDROID)
index debd76d1d53440f549c80dbfc6cf9b0c123fe678..8b81d736cbdaf9b4605172636e52d9f295233d41 100644 (file)
@@ -1330,7 +1330,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETADDRINFO], [
   if test "$curl_cv_func_getaddrinfo" = "yes"; then
     AC_MSG_CHECKING([if getaddrinfo is thread-safe])
     if test "$curl_cv_apple" = "yes"; then
-      dnl Darwin 6.0 and macOS 10.2.X and newer
+      dnl Darwin 9+ and macOS 10.5+
       tst_tsafe_getaddrinfo="yes"
     fi
     case $host_os in
@@ -1342,10 +1342,18 @@ AC_DEFUN([CURL_CHECK_FUNC_GETADDRINFO], [
         dnl AIX 5.2 and newer
         tst_tsafe_getaddrinfo="yes"
         ;;
-      darwin[[12345]].*)
-        dnl Darwin 5.0 and macOS 10.1.X and older
+      darwin[[12345678]].*)
+        dnl Darwin <=8.0 and macOS <=10.4
         tst_tsafe_getaddrinfo="no"
         ;;
+      dragonfly1.* | dragonfly2.[[01]])
+        dnl DragonFly BSD <=2.1.0
+        tst_tsafe_getaddrinfo="no"
+        ;;
+      dragonfly*)
+        dnl DragonFly BSD 2.2.0+
+        tst_tsafe_getaddrinfo="yes"
+        ;;
       freebsd[[1234]].* | freebsd5.[[1234]]*)
         dnl FreeBSD 5.4 and older
         tst_tsafe_getaddrinfo="no"
@@ -1374,6 +1382,14 @@ AC_DEFUN([CURL_CHECK_FUNC_GETADDRINFO], [
         dnl NetBSD 4.X and newer
         tst_tsafe_getaddrinfo="yes"
         ;;
+      openbsd[[1234]].* | openbsd5.[[0123]])
+        dnl OpenBSD <=5.3
+        tst_tsafe_getaddrinfo="no"
+        ;;
+      openbsd*)
+        dnl OpenBSD 5.4+
+        tst_tsafe_getaddrinfo="yes"
+        ;;
       *bsd*)
         dnl All other BSD's
         tst_tsafe_getaddrinfo="no"