Skip to content

build: enable thread-safe getaddrinfo() for OpenBSD, and other tidy-ups#22148

Closed
vszakats wants to merge 11 commits into
curl:masterfrom
vszakats:b-addrinfo-tsafe
Closed

build: enable thread-safe getaddrinfo() for OpenBSD, and other tidy-ups#22148
vszakats wants to merge 11 commits into
curl:masterfrom
vszakats:b-addrinfo-tsafe

Conversation

@vszakats

@vszakats vszakats commented Jun 23, 2026

Copy link
Copy Markdown
Member

Aka HAVE_GETADDRINFO_THREADSAFE.

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: #22138 (comment)


Investigation:

Mac OS X 10.5+ Leopard October 26, 2007 / Darwin 9+ (UNIX '03 certified) + all iOS and other forks
python/cpython#70112
https://en.wikipedia.org/wiki/MacOS_version_history (for macOS vs Darwin table)
MidnightBSD was forked from FreeBSD 6.1, which already had support
https://en.wikipedia.org/wiki/MidnightBSD

Sources:
freebsd/freebsd-src@9def31d 6.0.0+ Apr 4, 2005 (via NetBSD)
python/cpython#42363 wrong? 5.3+ Sep 12, 2005 [confirmed wrong]
https://github.com/freebsd/freebsd-src/blob/release/5.3.0/lib/libc/net/getaddrinfo.c (not re-entrant)
https://www.freebsd.org/releases/5.3R/announce/ 06 Nov 2004 "The network and socket subsystems are now multi-threaded and reentrant"
https://github.com/freebsd/freebsd-src/blob/release/5.4.0/lib/libc/net/getaddrinfo.c (not re-entrant)
https://www.freebsd.org/releases/5.4R/announce/ 09 May 2005 (no mention)
https://github.com/freebsd/freebsd-src/blob/release/6.0.0/lib/libc/net/getaddrinfo.c (re-entrant) initial
https://www.freebsd.org/releases/6.0R/announce/ 04 Nov 2005 (no mention)
https://github.com/freebsd/freebsd-src/blob/release/5.5.0/lib/libc/net/getaddrinfo.c (re-entrant) backported
https://www.freebsd.org/releases/5.5R/announce/ 25 May 2006 (no mention) BUT YES!
DragonFlyBSD/DragonFlyBSD@21fcee4 2.2.0+ commit Dec 28, 2008 (via FreeBSD)
DragonFlyBSD/DragonFlyBSD@21fcee4#diff-498ff649e8770eb9a94e99a399a4b473fcea41ef58b033a2a2dae3809e17bb04
https://www.dragonflybsd.org/releases/ 2.2.0 = February 17, 2009, 2.2.1 = April 26, 2009
openbsd/src@bd62015 Mar 31, 2013
http://www.openbsd.org/plus54.html 5.4+ 2013-11-01 "getaddrinfo(3) is now thread-safe."
NetBSD/src@d14c191 3.x May 21, 2004 (via Bind9)
NetBSD/src@e59232f (follow-up) May 21, 2004
NetBSD/src@6b7bf05 (became official) July 18, 2006
https://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/net/getaddrinfo.c.diff?r1=1.82&r2=1.83
NetBSD 4.0+ was released 2007-12-19.

https://bugs.python.org/issue26406
https://github.com/python/cpython/pull/20177/files guards
https://emptysqua.re/blog/getaddrinfo-cpython-mac-and-bsd/
python/cpython#70594 NetBSD/OpenBSD

Summary:

  • macOS 10.5+ / Darwin 9+ 2007-10-26 / iOS/others all versions
  • DragonFly BSD 2.2.0+ 2009-02-17
  • FreeBSD 5.5+ 2006-05-25 (or 6.0+ 2005-11-04)
  • MidnightBSD all versions 0.1 2007-08-06
  • NetBSD 4.0+ 2007-12-19 (possibly earlier, commit is from 2004-05-21)
  • OpenBSD 5.4+ 2013-11-01

Code (from CPython):

#if ((defined(__APPLE__) && \
        MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5) || \
    (defined(__FreeBSD__) && __FreeBSD_version < 503000) /* my remark: this seems inaccurate */ || \
    (defined(__OpenBSD__) && OpenBSD < 201311) || \
    (defined(__NetBSD__) && __NetBSD_Version__ < 400000000) || \
    !defined(HAVE_GETADDRINFO))
#define USE_GETADDRINFO_LOCK
#endif

@github-actions github-actions Bot added the build label Jun 23, 2026
vszakats added 4 commits June 23, 2026 19:00
stop disabling for OpenBSD, also stop listing all BSDs,
they are opted in via OtherTests.cmake anyway. We do the
same on Windows.
@vszakats vszakats changed the title build: fix thread-safe getaddrinfo() detection on some BSDs build: enable thread-safe getaddrinfo() for OpenBSD, and other tidy-ups Jun 23, 2026
@vszakats vszakats closed this in fbcce4d Jun 25, 2026
@vszakats vszakats deleted the b-addrinfo-tsafe branch June 25, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

1 participant