Created
November 2, 2018 07:00
-
-
Save leiless/cfff539426e7d9f4f2f3e73f22902d6b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| /* | |
| * Created 181102 | |
| */ | |
| #include <libkern/OSAtomicDeprecated.h> | |
| static volatile int __spin; | |
| #define spin_lock() while (!OSAtomicCompareAndSwapInt(0, 1, &__spin)) continue | |
| #define spin_unlock() do { \ | |
| bool ok = OSAtomicCompareAndSwapInt(1, 0, &__spin); \ | |
| NSCAssert(ok == 1, @"spin_unlock() failure"); \ | |
| } while (0) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment