All other spinlock functions which writes to spinlock storage already mark
spinlock storage as volatile, so do it also in pthread_spin_init.

This should ensure that compiler does not reorder initialization of
spinlock with other code.
---
 mingw-w64-libraries/winpthreads/src/spinlock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mingw-w64-libraries/winpthreads/src/spinlock.c 
b/mingw-w64-libraries/winpthreads/src/spinlock.c
index eb21509d607f..27ad7627fd25 100644
--- a/mingw-w64-libraries/winpthreads/src/spinlock.c
+++ b/mingw-w64-libraries/winpthreads/src/spinlock.c
@@ -42,7 +42,7 @@ typedef intptr_t spinlock_word_t;
 int
 pthread_spin_init (pthread_spinlock_t *lock, int pshared)
 {
-  spinlock_word_t *lk = (spinlock_word_t *)lock;
+  volatile spinlock_word_t *lk = (spinlock_word_t *)lock;
   *lk = -1;
   return 0;
 }
-- 
2.20.1



_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to