[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnurl] 17/256: configure: check for __builtin_available()
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnurl] 17/256: configure: check for __builtin_available() availability (#1788) |
Date: |
Fri, 06 Oct 2017 19:41:48 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnurl.
commit 870d849d48a26b8eeb0d4bb1f4655367a4a191ca
Author: Nick Zitzmann <address@hidden>
AuthorDate: Wed Aug 16 12:24:39 2017 -0500
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.
---
acinclude.m4 | 26 ++++++++++++++++++++++++++
configure.ac | 1 +
lib/connect.c | 29 +++++++++++++++++++----------
3 files changed, 46 insertions(+), 10 deletions(-)
diff --git a/acinclude.m4 b/acinclude.m4
old mode 100644
new mode 100755
index 539322870..dd5d896bc
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -3243,3 +3243,29 @@ AC_DEFUN([CURL_MAC_CFLAGS], [
fi
])
+
+
+dnl CURL_SUPPORTS_BUILTIN_AVAILABLE
+dnl
+dnl Check to see if the compiler supports __builtin_available. This built-in
+dnl compiler function first appeared in Apple LLVM 9.0.0. It's so new that, at
+dnl the time this macro was written, the function was not yet documented. Its
+dnl purpose is to return true if the code is running under a certain OS version
+dnl or later.
+
+AC_DEFUN([CURL_SUPPORTS_BUILTIN_AVAILABLE], [
+ AC_MSG_CHECKING([to see if the compiler supports __builtin_available()])
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([[
+#include <stdlib.h>
+ ]],[[
+ if (__builtin_available(macOS 10.8, iOS 5.0, *)) {}
+ ]])
+ ],[
+ AC_MSG_RESULT([yes])
+ AC_DEFINE_UNQUOTED(HAVE_BUILTIN_AVAILABLE, 1,
+ [Define to 1 if you have the __builtin_available function.])
+ ],[
+ AC_MSG_RESULT([no])
+ ])
+])
diff --git a/configure.ac b/configure.ac
old mode 100644
new mode 100755
index edebfc77b..605abc3fd
--- a/configure.ac
+++ b/configure.ac
@@ -354,6 +354,7 @@ esac
CURL_CHECK_WIN32_LARGEFILE
CURL_MAC_CFLAGS
+CURL_SUPPORTS_BUILTIN_AVAILABLE
dnl ************************************************************
dnl switch off particular protocols
diff --git a/lib/connect.c b/lib/connect.c
old mode 100644
new mode 100755
index 8d5d32ba6..927ff7cec
--- 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);
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnurl] 09/256: cmake: remove dead code for CURL_DISABLE_RTMP, (continued)
- [GNUnet-SVN] [gnurl] 09/256: cmake: remove dead code for CURL_DISABLE_RTMP, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 02/256: runtests: match keywords case insensitively, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 05/256: test1449: FTP download range with an too large size, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 03/256: travis: build the examples too, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 13/256: m4/curl-compilers.m4: use proper quotes around string, not backticks, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 01/256: examples/ftpuploadresume.c: use portable code, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 12/256: cmake: remove dead code for DISABLED_THREADSAFE, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 06/256: RELEASE-NOTES: synced with 91c46dc44, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 08/256: zsh.pl: produce a working completion script again, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 07/256: curlver: toward 7.56.0?, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 17/256: configure: check for __builtin_available() availability (#1788),
gnunet <=
- [GNUnet-SVN] [gnurl] 18/256: http_proxy: fix build error for CURL_DOES_CONVERSIONS, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 11/256: curl-confopts.m4: fix --disable-threaded-resolver, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 14/256: darwinssi: fix error: variable length array used, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 21/256: curl/system.h: checksrc compliance, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 19/256: examples/ftpuploadresume: checksrc compliance, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 04/256: strtoofft: reduce integer overflow risks globally, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 47/256: curl: shorten and clean up CA cert verification error message, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 40/256: tftp: fix memory leak on too long filename, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 50/256: config-tpf: define SIZEOF_LONG, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 23/256: CURLOPT_SSH_COMPRESSION.3: enable with 1L, gnunet, 2017/10/06