mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 15:08:21 +00:00
spinlocks
This commit is contained in:
@@ -0,0 +1,12 @@
|
|||||||
|
#ifndef _SPINLOCK_H_INCLUDE
|
||||||
|
#define _SPINLOCK_H_INCLUDE
|
||||||
|
|
||||||
|
static inline void spinlock_acquire(int *lock){
|
||||||
|
while(!__sync_bool_compare_and_swap(lock, 0, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void spinlock_release(int *lock){
|
||||||
|
*lock = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user