From ff2447df6360378105a79618cba9e5dacf9e3bce Mon Sep 17 00:00:00 2001 From: Santiago Date: Thu, 7 Nov 2024 19:01:59 -0300 Subject: [PATCH] [BUILD] Improve how to handle yield() in ARM. (#3129) --- api/include/opentelemetry/common/spin_lock_mutex.h | 6 ++++-- api/test/common/spinlock_benchmark.cc | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/api/include/opentelemetry/common/spin_lock_mutex.h b/api/include/opentelemetry/common/spin_lock_mutex.h index 369183b953..7031fa4d23 100644 --- a/api/include/opentelemetry/common/spin_lock_mutex.h +++ b/api/include/opentelemetry/common/spin_lock_mutex.h @@ -68,8 +68,10 @@ class SpinLockMutex # else __builtin_ia32_pause(); # endif -#elif defined(__arm__) - __asm__ volatile("yield" ::: "memory"); +#elif defined(__armel__) || defined(__ARMEL__) + asm volatile("nop" ::: "memory"); +#elif defined(__arm__) || defined(__aarch64__) // arm big endian / arm64 + __asm__ __volatile__("yield" ::: "memory"); #else // TODO: Issue PAGE/YIELD on other architectures. #endif diff --git a/api/test/common/spinlock_benchmark.cc b/api/test/common/spinlock_benchmark.cc index b5e98a2108..da588b7e30 100644 --- a/api/test/common/spinlock_benchmark.cc +++ b/api/test/common/spinlock_benchmark.cc @@ -102,8 +102,10 @@ static void BM_ProcYieldSpinLockThrashing(benchmark::State &s) # else __builtin_ia32_pause(); # endif -#elif defined(__arm__) - __asm__ volatile("yield" ::: "memory"); +#elif defined(__armel__) || defined(__ARMEL__) + asm volatile("nop" ::: "memory"); +#elif defined(__arm__) || defined(__aarch64__) // arm big endian / arm64 + __asm__ __volatile__("yield" ::: "memory"); #endif } },