Merge pull request #350 from mr-c/patch-1

add/improve atomic yields for SSE2, ARM*, PowerPC
This commit is contained in:
Daan 2021-01-28 17:29:54 -08:00 committed by GitHub
commit d9ae916a74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -281,16 +281,33 @@ static inline void mi_atomic_yield(void) {
static inline void mi_atomic_yield(void) {
YieldProcessor();
}
#elif defined(__SSE2__)
#include <emmintrin.h>
static inline void mi_atomic_yield(void) {
_mm_pause();
}
#elif (defined(__GNUC__) || defined(__clang__)) && \
(defined(__x86_64__) || defined(__i386__) || (defined(__arm__) && __ARM_ARCH__ >= 7) || defined(__aarch64__))
(defined(__x86_64__) || defined(__i386__) || (defined(__arm__) || defined(__armel__) || defined(__ARMEL__) || defined(__aarch64__) || defined(__powerpc__) || defined(__ppc__) || defined(__PPC__))
#if defined(__x86_64__) || defined(__i386__)
static inline void mi_atomic_yield(void) {
__asm__ volatile ("pause" ::: "memory");
}
#elif (defined(__arm__) && __ARM_ARCH__ >= 7) || defined(__aarch64__)
#elif defined(__aarch64__)
static inline void mi_atomic_yield(void) {
asm volatile("wfe");
}
#elif (defined(__arm__) && __ARM_ARCH__ >= 7)
static inline void mi_atomic_yield(void) {
__asm__ volatile("yield" ::: "memory");
}
#elif defined(__powerpc__) || defined(__ppc__) || defined(__PPC__)
static inline void mi_atomic_yield(void) {
__asm__ __volatile__ ("or 27,27,27" ::: "memory");
}
#elif defined(__armel__) || defined(__ARMEL__)
static inline void mi_atomic_yield(void) {
asm volatile ("nop" ::: "memory");
}
#endif
#elif defined(__sun)
// Fallback for other archs