Restricts cpu yield instructions a little.

adding clobber for ARM and preventing older 32 bits chips not supporting this instruction.
This commit is contained in:
David Carlier 2020-12-12 12:06:24 +00:00
parent 745cf1e2f5
commit 33a10b4860

View File

@ -282,16 +282,22 @@ static inline void mi_atomic_yield(void) {
YieldProcessor();
}
#elif (defined(__GNUC__) || defined(__clang__)) && \
(defined(__x86_64__) || defined(__i386__) || defined(__arm__) || defined(__aarch64__))
(defined(__x86_64__) || defined(__i386__) || (defined(__arm__) && __ARM_ARCH__ >= 7) || defined(__aarch64__))
#if defined(__x86_64__) || defined(__i386__)
static inline void mi_atomic_yield(void) {
__asm__ volatile ("pause" ::: "memory");
}
#elif defined(__arm__) || defined(__aarch64__)
#elif (defined(__arm__) && __ARM_ARCH__ >= 7) || defined(__aarch64__)
static inline void mi_atomic_yield(void) {
__asm__ volatile("yield");
__asm__ volatile("yield" ::: "memory");
}
#endif
#elif defined(__sun)
// Fallback for other archs
#include <synch.h>
static inline void mi_atomic_yield(void) {
smt_pause();
}
#elif defined(__wasi__)
#include <sched.h>
static inline void mi_atomic_yield(void) {
@ -305,4 +311,4 @@ static inline void mi_atomic_yield(void) {
#endif
#endif // __MIMALLOC_ATOMIC_H
#endif // __MIMALLOC_ATOMIC_H