summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Lhomme <robux4@ycbcr.xyz>2020-06-22 09:09:05 +0200
committerDaiki Ueno <ueno@gnu.org>2020-08-31 08:12:54 +0200
commit2a1eced29438fdc4e3d26e7c73afd6639e851e68 (patch)
treea878d442afdf199cd63d3f69a8bf9d8bcfb5e5a8
parent1bb552b8d33fd361aec8229c396dd74b6170379f (diff)
downloadgnutls-2a1eced29438fdc4e3d26e7c73afd6639e851e68.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.c14
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;