summaryrefslogtreecommitdiff
path: root/lib/connect.c
diff options
context:
space:
mode:
authorNick Zitzmann <nickzman@gmail.com>2017-08-16 12:24:39 -0500
committerGitHub <noreply@github.com>2017-08-16 12:24:39 -0500
commit870d849d48a26b8eeb0d4bb1f4655367a4a191ca (patch)
tree48415a008b75a845d0dc8f03c71b66fa4e59d299 /lib/connect.c
parentca9630f12843f0bb0baa3ae78491e07431ccf5de (diff)
downloadcurl-870d849d48a26b8eeb0d4bb1f4655367a4a191ca.tar.gz
configure: check for __builtin_available() availability (#1788)
This change does two things: 1. It un-breaks the build in Xcode 9.0. (Xcode 9.0 is currently failing trying to compile connectx() in lib/connect.c.) 2. It finally weak-links the connectx() function, and falls back on connect() when run on older operating systems.
Diffstat (limited to 'lib/connect.c')
-rwxr-xr-x[-rw-r--r--]lib/connect.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/lib/connect.c b/lib/connect.c
index 8d5d32ba6..927ff7cec 100644..100755
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -1059,16 +1059,25 @@ static CURLcode singleipconnect(struct connectdata *conn,
if(!isconnected && (conn->socktype == SOCK_STREAM)) {
if(conn->bits.tcp_fastopen) {
#if defined(CONNECT_DATA_IDEMPOTENT) /* OS X */
- sa_endpoints_t endpoints;
- endpoints.sae_srcif = 0;
- endpoints.sae_srcaddr = NULL;
- endpoints.sae_srcaddrlen = 0;
- endpoints.sae_dstaddr = &addr.sa_addr;
- endpoints.sae_dstaddrlen = addr.addrlen;
-
- rc = connectx(sockfd, &endpoints, SAE_ASSOCID_ANY,
- CONNECT_RESUME_ON_READ_WRITE | CONNECT_DATA_IDEMPOTENT,
- NULL, 0, NULL, NULL);
+#ifdef HAVE_BUILTIN_AVAILABLE
+ if(__builtin_available(macOS 10.11, iOS 9.0, tvOS 9.0, watchOS 2.0, *)) {
+#endif /* HAVE_BUILTIN_AVAILABLE */
+ sa_endpoints_t endpoints;
+ endpoints.sae_srcif = 0;
+ endpoints.sae_srcaddr = NULL;
+ endpoints.sae_srcaddrlen = 0;
+ endpoints.sae_dstaddr = &addr.sa_addr;
+ endpoints.sae_dstaddrlen = addr.addrlen;
+
+ rc = connectx(sockfd, &endpoints, SAE_ASSOCID_ANY,
+ CONNECT_RESUME_ON_READ_WRITE | CONNECT_DATA_IDEMPOTENT,
+ NULL, 0, NULL, NULL);
+#ifdef HAVE_BUILTIN_AVAILABLE
+ }
+ else {
+ rc = connect(sockfd, &addr.sa_addr, addr.addrlen);
+ }
+#endif /* HAVE_BUILTIN_AVAILABLE */
#elif defined(MSG_FASTOPEN) /* Linux */
if(conn->given->flags & PROTOPT_SSL)
rc = connect(sockfd, &addr.sa_addr, addr.addrlen);