Created
February 2, 2014 17:47
-
-
Save smirn0v/8772052 to your computer and use it in GitHub Desktop.
OSSpinLockTry
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
/* | |
* void | |
* OSSpinLockUnlock(p) | |
* int *p; | |
* | |
* Unlock the lock pointed to by p. | |
*/ | |
LEAF(_OSSpinLockUnlock, 0) | |
LEAF(_IOSpinUnlock, 0) | |
LEAF(_ev_unlock, 0) | |
movl $0, (%rdi) | |
END(_OSSpinLockUnlock) | |
/* | |
* int | |
* OSSpinLockTry(p) | |
* int *p; | |
* | |
* Try to lock p. Return zero if not successful. | |
*/ | |
LEAF(_OSSpinLockTry, 0) | |
LEAF(_IOTrySpinLock, 0) | |
LEAF(_ev_try_lock, 0) | |
xorl %eax, %eax | |
orl $-1, %edx | |
lock | |
cmpxchgl %edx, (%rdi) | |
setz %dl | |
movzbl %dl, %eax | |
END(_OSSpinLockTry) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment