Open uraimo opened 5 years ago
clrex
is available on ARMv6k/v7+ as confirmed here:
Architectures
This ARM instruction is available in ARMv6K and above.
This 32-bit Thumb-2 instruction is available in ARMv7 and above.
There is no 16-bit Thumb CLREX instruction
The Raspberry Pi Zero is identified as an armv6l
(I don't know enough about the armv6 variants but it's possible that the basic armv6l does not support clrex
and other related instructions like LDREX and STREX).
A quick search leads to another issue addressed by William, two years ago (armv6l variant added to the armv6 family).
This issue is the result of this:
#if defined(__arm__) || defined(__arm64__)
int spins = DISPATCH_WAIT_SPINS_WFE;
void *value;
while (unlikely(spins-- > 0)) {
if (likely(value = __builtin_arm_ldrex(ptr))) {
__builtin_arm_clrex();
return value;
}
__builtin_arm_wfe();
}
#else
That generic #if defined(__arm__)
makes no difference between the various arm32 variants.
Will look into it.
Note: Could we just use dispatch_hardware_pause
defined here?
Temporary workaround: 7903180c4cc6e7f3b099b49cc7291ca3166076c4
CLREX
should be a thumb2 instruction, so a proper fix would check for (defined(__arm__) && defined(_ARM_ARCH_7))
or defined(__thumb2__)
if it's available.
On a Raspberry Pi Zero, while compiling libdispatch: