diff options
author | David Chisnall <theraven@theravensnest.org> | 2012-02-28 15:56:07 +0000 |
---|---|---|
committer | David Chisnall <theraven@theravensnest.org> | 2012-02-28 15:56:07 +0000 |
commit | 69c4c6f192271918d1bf64a84d3f8a41d1e943ac (patch) | |
tree | 5418ab2db8a969582b1b8d0a0c072922a3cc5ffb | |
parent | 937302fd7a69c962d86b63f2032614ee128f2950 (diff) | |
download | libcxxrt-69c4c6f192271918d1bf64a84d3f8a41d1e943ac.tar.gz libcxxrt-69c4c6f192271918d1bf64a84d3f8a41d1e943ac.tar.bz2 libcxxrt-69c4c6f192271918d1bf64a84d3f8a41d1e943ac.tar.xz |
Fix a potential race in guard logic.
-rw-r--r-- | src/guard.cc | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/guard.cc b/src/guard.cc index f236053..1cbeb58 100644 --- a/src/guard.cc +++ b/src/guard.cc @@ -103,6 +103,10 @@ extern "C" int __cxa_guard_acquire(volatile int64_t *guard_object) // the lock at the same time. while (!__sync_bool_compare_and_swap_4(lock, 0, 1)) { + if (1 == ((*guard_object) >> 56)) + { + break; + } sched_yield(); } // We have to test the guard again, in case another thread has performed |