diff options
author | Steve Lhomme <robux4@ycbcr.xyz> | 2020-06-22 09:09:05 +0200 |
---|---|---|
committer | Steve Lhomme <robux4@ycbcr.xyz> | 2020-07-02 15:07:44 +0200 |
commit | 8dd1ebb5c3796e03b1303477b1f3e0012ea3cb40 (patch) | |
tree | a1a2a9a9d39b1706ee7efd28b15c000587ceb7fb | |
parent | 850e9b33c995dd264b9c6074ccd9081bd9b2d1da (diff) | |
download | gnutls-8dd1ebb5c3796e03b1303477b1f3e0012ea3cb40.tar.gz |
fix connectx not available on older macOS SDK
Fixes this compilation 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
The detection is the same as found in curl [1].
If HAVE_BUILTIN_AVAILABLE is not available we fallback to the code without
TCP_FASTOPEN_OSX.
The OS values match exactly the values found in
https://opensource.apple.com/source/xnu/xnu-4570.41.2/bsd/sys/socket.h
[1] https://github.com/curl/curl/commit/870d849d48a26b8eeb0d4bb1f4655367a4a191ca
Signed-off-by: Steve Lhomme <robux4@ycbcr.xyz>
-rw-r--r-- | lib/system/fastopen.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/system/fastopen.c b/lib/system/fastopen.c index 8d8409e482..bf1ee0929f 100644 --- a/lib/system/fastopen.c +++ b/lib/system/fastopen.c @@ -38,7 +38,9 @@ /* TCP Fast Open on OSX behaves differently from Linux, so define these helpers */ #if defined __APPLE__ && defined __MACH__ && defined CONNECT_DATA_IDEMPOTENT && defined CONNECT_RESUME_ON_READ_WRITE -# define TCP_FASTOPEN_OSX +# if defined __has_builtin && __has_builtin(__builtin_available) +# define TCP_FASTOPEN_OSX +# endif #elif defined TCP_FASTOPEN && defined MSG_FASTOPEN # define TCP_FASTOPEN_LINUX #endif @@ -129,9 +131,15 @@ tfo_writev(gnutls_transport_ptr_t ptr, const giovec_t * iovec, int iovec_cnt) } # elif defined(TCP_FASTOPEN_OSX) { - sa_endpoints_t endpoints = { .sae_dstaddr = (struct sockaddr*)&p->connect_addr, .sae_dstaddrlen = p->connect_addrlen }; + if(__builtin_available(macOS 10.11, iOS 9.0, tvOS 9.0, watchOS 2.0, *)) { + sa_endpoints_t endpoints = { .sae_dstaddr = (struct sockaddr*)&p->connect_addr, .sae_dstaddrlen = p->connect_addrlen }; - ret = connectx(fd, &endpoints, SAE_ASSOCID_ANY, CONNECT_RESUME_ON_READ_WRITE | CONNECT_DATA_IDEMPOTENT, NULL, 0, NULL, NULL); + ret = connectx(fd, &endpoints, SAE_ASSOCID_ANY, CONNECT_RESUME_ON_READ_WRITE | CONNECT_DATA_IDEMPOTENT, NULL, 0, NULL, NULL); + } + else + { + ret = connect(fd, (struct sockaddr*)&p->connect_addr, p->connect_addrlen); + } if (errno == ENOTCONN || errno == EINPROGRESS) { gnutls_assert(); errno = EAGAIN; |