-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error: use of unknown builtin '__builtin_ia32_pause' #9058
Labels
Comments
Does this work: diff --git a/lib/easy_lock.h b/lib/easy_lock.h
index 07c85c5..15c6c07 100644
--- a/lib/easy_lock.h
+++ b/lib/easy_lock.h
@@ -52,7 +52,11 @@ static inline void curl_simple_lock_lock(curl_simple_lock *lock)
while(atomic_load_explicit(lock, memory_order_relaxed)) {
/* Reduce load (not mandatory) */
#if defined(__i386__) || defined(__x86_64__)
+#if defined(__GNUC__) && !defined(__llvm__)
__builtin_ia32_pause();
+#else
+ __asm__ volatile("pause");
+#endif
#elif defined(__aarch64__)
__asm__ volatile("yield" ::: "memory");
#elif defined(HAVE_SCHED_YIELD) |
You could keep using the builtin with clang versions that support it by checking for it with |
Then perhaps (also available as #9062) diff --git a/lib/easy_lock.h b/lib/easy_lock.h
index 07c85c5ff..18d90a4dc 100644
--- a/lib/easy_lock.h
+++ b/lib/easy_lock.h
@@ -41,19 +41,29 @@
#endif
#define curl_simple_lock atomic_bool
#define CURL_SIMPLE_LOCK_INIT false
+/* a clang-thing */
+#ifndef __has_builtin
+#define __has_builtin(x) 0
+#endif
+
+#if (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) || \
+ __has_builtin(__builtin_ia32_pause)
+#define HAVE_BUILTIN_IA32_PAUSE
+#endif
+
static inline void curl_simple_lock_lock(curl_simple_lock *lock)
{
for(;;) {
if(!atomic_exchange_explicit(lock, true, memory_order_acquire))
break;
/* Reduce cache coherency traffic */
while(atomic_load_explicit(lock, memory_order_relaxed)) {
/* Reduce load (not mandatory) */
-#if defined(__i386__) || defined(__x86_64__)
+#ifdef HAVE_BUILTIN_IA32_PAUSE
__builtin_ia32_pause();
#elif defined(__aarch64__)
__asm__ volatile("yield" ::: "memory");
#elif defined(HAVE_SCHED_YIELD)
sched_yield(); |
bagder
added a commit
that referenced
this issue
Jun 28, 2022
Reported-by: Ryan Schmidt Assisted-by: Joshua Root Fixes #9058
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I did this
Compile curl
I expected the following
Successful compile
curl/libcurl version
7.84.0
operating system
OS X 10.10
Xcode 7.2.1
Apple LLVM version 7.0.2 (clang-700.1.81)
https://build.macports.org/builders/ports-10.10_x86_64-builder/builds/188168/steps/install-port/logs/stdio
This problem does not occur on later system such as:
OS X 10.11
Xcode 8.2.1
Apple LLVM version 8.0.0 (clang-800.0.42.1)
The text was updated successfully, but these errors were encountered: