File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,17 @@ class rw_lock
38
38
39
39
/* * Start waiting for an exclusive lock. */
40
40
void write_lock_wait_start ()
41
- { lock.fetch_or (WRITER_WAITING, std::memory_order_relaxed); }
41
+ {
42
+ #if defined __GNUC__ && (defined __i386__ || defined __x86_64__)
43
+ static_assert (WRITER_WAITING == 1U << 30 , " compatibility" );
44
+ __asm__ __volatile__ (" lock btsl $30, %0" : " +m" (lock));
45
+ #elif defined _MSC_VER && (defined _M_IX86 || defined _M_IX64)
46
+ static_assert (WRITER_WAITING == 1U << 30 , " compatibility" );
47
+ _interlockedbittestandset (reinterpret_cast <volatile long *>(&lock), 30 );
48
+ #else
49
+ lock.fetch_or (WRITER_WAITING, std::memory_order_relaxed);
50
+ #endif
51
+ }
42
52
/* * Try to acquire a shared lock.
43
53
@param l the value of the lock word
44
54
@return whether the lock was acquired */
You can’t perform that action at this time.
0 commit comments