Skip to content

Commit 0431a0a

Browse files
committed
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.
1 parent 6fdf797 commit 0431a0a

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

api/include/opentelemetry/common/spin_lock_mutex.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@ class SpinLockMutex
6868
# else
6969
__builtin_ia32_pause();
7070
# endif
71-
#elif defined(__arm__)
72-
__asm__ volatile("yield" ::: "memory");
71+
#elif defined(__armel__) || defined(__ARMEL__)
72+
asm volatile ("nop" ::: "memory");
73+
#elif defined(__arm__) || defined(__aarch64__) // arm big endian / arm64
74+
__asm__ __volatile__ ("yield" ::: "memory");
7375
#else
7476
// TODO: Issue PAGE/YIELD on other architectures.
7577
#endif

api/test/common/spinlock_benchmark.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,10 @@ static void BM_ProcYieldSpinLockThrashing(benchmark::State &s)
102102
# else
103103
__builtin_ia32_pause();
104104
# endif
105-
#elif defined(__arm__)
106-
__asm__ volatile("yield" ::: "memory");
105+
#elif defined(__armel__) || defined(__ARMEL__)
106+
asm volatile ("nop" ::: "memory");
107+
#elif defined(__arm__) || defined(__aarch64__) // arm big endian / arm64
108+
__asm__ __volatile__ ("yield" ::: "memory");
107109
#endif
108110
}
109111
},

0 commit comments

Comments
 (0)