Created
November 18, 2011 10:50
-
-
Save piscisaureus/1376139 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
/* The low-order bit of lock->Ptr is set when the lock is held. If _only_ */ | |
/* the low-order bit is set, the lock is held in exclusive mode. */ | |
BOOLEAN TryAcquireSRWLockExclusive(SRWLOCK* lock) { | |
if (sizeof lock->Ptr == sizeof LONG) { | |
return InterlockedBitTestAndSet((LONG*) lock->Ptr, 0); | |
} else if (sizeof lock->Ptr == sizeof LONG64) { | |
return InterlockedBitTestAndSet64((LONG64*) lock->Ptr, 0); | |
} else { | |
abort(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment