Created
March 22, 2018 17:28
-
-
Save arichardson/2d8c45d03c2c56bdc4c0c9d4f5b51932 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class QReadWriteLockPrivate; | |
typedef __uintcap_t quintptr; | |
namespace { | |
enum { | |
StateMask = 0x3, | |
StateLockedForRead = 0x1, | |
StateLockedForWrite = 0x2, | |
}; | |
const auto dummyLockedForRead = reinterpret_cast<QReadWriteLockPrivate *>(quintptr(StateLockedForRead)); | |
const auto dummyLockedForWrite = reinterpret_cast<QReadWriteLockPrivate *>(quintptr(StateLockedForWrite)); | |
} | |
bool testAndSetAcquire(void* expected, void* newValue); | |
void lockSlowPath(); | |
void lock() { | |
// This previously stored a $ddc derived value instead of a null-derived one | |
if (testAndSetAcquire(nullptr, dummyLockedForRead)) | |
return; | |
lockSlowPath(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment