From 0431a0a677b0458f783c0ea3b05a2bba460182e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Ruano=20Rinc=C3=B3n?= Date: Wed, 6 Nov 2024 10:49:07 -0300 Subject: [PATCH] Improve how to handle yield() in ARM. The yield instruction was introduced in ARM processors more recent than armel. So building in armel ends up in "Error: selected processor does not support `yield' in ARM mode". Also, the __yield() intrinsic instruction is not understood for armel by g++. So let's do nothing for armel. --- 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..4cc95ba33f 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..bd186b3272 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 } },