Use YieldProcessor which already has the best definition for all MSVC
and MinGW supported architectures of the memory pause / yield
instruction.

Signed-off-by: Antonin Décimo <anto...@tarides.com>
---
 mingw-w64-libraries/winpthreads/src/misc.h     | 8 --------
 mingw-w64-libraries/winpthreads/src/spinlock.c | 8 +-------
 2 files changed, 1 insertion(+), 15 deletions(-)

diff --git a/mingw-w64-libraries/winpthreads/src/misc.h 
b/mingw-w64-libraries/winpthreads/src/misc.h
index 49d1ee1fb..ce278c976 100644
--- a/mingw-w64-libraries/winpthreads/src/misc.h
+++ b/mingw-w64-libraries/winpthreads/src/misc.h
@@ -101,18 +101,10 @@ static WINPTHREADS_INLINE unsigned long 
dwMilliSecs(unsigned long long ms)
   return (unsigned long) ms;
 }
 
-#ifndef _mm_pause
-#define _mm_pause() do { __asm__ __volatile__("pause"); } while (0)
-#endif
-
 #ifndef _ReadWriteBarrier
 #define _ReadWriteBarrier   __sync_synchronize
 #endif
 
-#ifndef YieldProcessor
-#define YieldProcessor      _mm_pause
-#endif
-
 unsigned long long _pthread_time_in_ms(void);
 unsigned long long _pthread_time_in_ms_from_timespec(const struct timespec 
*ts);
 unsigned long long _pthread_rel_time_in_ms(const struct timespec *ts);
diff --git a/mingw-w64-libraries/winpthreads/src/spinlock.c 
b/mingw-w64-libraries/winpthreads/src/spinlock.c
index d0e47f0b5..384c98970 100644
--- a/mingw-w64-libraries/winpthreads/src/spinlock.c
+++ b/mingw-w64-libraries/winpthreads/src/spinlock.c
@@ -52,13 +52,7 @@ pthread_spin_lock (pthread_spinlock_t *lock)
   volatile spinlock_word_t *lk = (volatile spinlock_word_t *)lock;
   while (unlikely(__sync_lock_test_and_set(lk, 0) == 0))
     do {
-#if defined(__i386__) || defined(__x86_64__)
-      asm("pause" ::: "memory");
-#elif defined(__arm__) || defined(__aarch64__)
-      asm("wfe" ::: "memory");
-#else
-#error Unsupported architecture
-#endif
+      YieldProcessor();
     } while (*lk == 0);
   return 0;
 }
-- 
2.43.0



_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to