Wed Apr 19 16:24:51 2023 UTC ()
Pull up following revision(s) (requested by hannken in ticket #140):

	external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_mutex.h: revision 1.3

Fix StaticSpinMutex::CheckLocked() on sparc32.

The lock gets set with atomic_exchange() -> __sync_lock_test_and_set()
which sets the value to 255 instead of 1.  Check for a taken lock
with "!= 0" instead of "== 1".  This should work on all architectures.

Ok: Matthew Green


(martin)
diff -r1.2 -r1.2.6.1 src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_mutex.h

cvs diff -r1.2 -r1.2.6.1 src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_mutex.h (expand / switch to unified diff)

--- src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_mutex.h 2021/04/11 23:54:27 1.2
+++ src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_mutex.h 2023/04/19 16:24:51 1.2.6.1
@@ -29,27 +29,27 @@ class StaticSpinMutex { @@ -29,27 +29,27 @@ class StaticSpinMutex {
29 return; 29 return;
30 LockSlow(); 30 LockSlow();
31 } 31 }
32 32
33 bool TryLock() { 33 bool TryLock() {
34 return atomic_exchange(&state_, 1, memory_order_acquire) == 0; 34 return atomic_exchange(&state_, 1, memory_order_acquire) == 0;
35 } 35 }
36 36
37 void Unlock() { 37 void Unlock() {
38 atomic_store(&state_, 0, memory_order_release); 38 atomic_store(&state_, 0, memory_order_release);
39 } 39 }
40 40
41 void CheckLocked() { 41 void CheckLocked() {
42 CHECK_EQ(atomic_load(&state_, memory_order_relaxed), 1); 42 CHECK_NE(atomic_load(&state_, memory_order_relaxed), 0);
43 } 43 }
44 44
45 private: 45 private:
46 atomic_uint8_t state_; 46 atomic_uint8_t state_;
47 47
48 void NOINLINE LockSlow() { 48 void NOINLINE LockSlow() {
49 for (int i = 0;; i++) { 49 for (int i = 0;; i++) {
50 if (i < 10) 50 if (i < 10)
51 proc_yield(10); 51 proc_yield(10);
52 else 52 else
53 internal_sched_yield(); 53 internal_sched_yield();
54 if (atomic_load(&state_, memory_order_relaxed) == 0 54 if (atomic_load(&state_, memory_order_relaxed) == 0
55 && atomic_exchange(&state_, 1, memory_order_acquire) == 0) 55 && atomic_exchange(&state_, 1, memory_order_acquire) == 0)