[gnutls-devel] GnuTLS | Detect the availability of connectx at runtime (!1294)

Development of GNU's TLS library gnutls-devel at lists.gnutls.org
Mon Jun 22 09:17:33 CEST 2020

Steve Lhomme created a merge request: https://gitlab.com/gnutls/gnutls/-/merge_requests/1294

Project:Branches: robUx4/gnutls:macos-connectx to gnutls/gnutls:master
Author:    Steve Lhomme

connectx is only available since macOS 10.11. So when compiling with a lower minimum SDK the compiler issues this error:

system/fastopen.c:134:9: error: 'connectx' is only available on macOS 10.11 or newer [-Werror,-Wunguarded-availability]
                ret = connectx(fd, &endpoints, SAE_ASSOCID_ANY, CONNECT_RESUME_ON_READ_WRITE | CONNECT_DATA_IDEMPOTENT, NULL, 0, NULL, NULL);
/Applications/Xcode9.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/sys/socket.h:713:5: note: 'connectx' has been marked as being introduced in macOS 10.11 here, but the deployment target is macOS 10.7.0

With macOS compilers it's possible to detect at runtime whether an API call is present or not using `__builtin_available()`. So we check at runtime for connectx and use it only when available. So the same code compiled running on 10.10 will not use it and fallback to the regular `connect()` call. The code running on 10.11+ will use `connectx` as expected.

Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/gnutls/-/merge_requests/1294
You're receiving this email because of your account on gitlab.com.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnutls-devel/attachments/20200622/504c7045/attachment.html>

More information about the Gnutls-devel mailing list