lemoncake

rbtree based memory allocator
git clone git://git.2f30.org/lemoncake
Log | Files | Refs | README | LICENSE

spinlock.h (194B)


      1 typedef int spinlock_t;
      2 
      3 static inline void
      4 lock(spinlock_t *sl)
      5 {
      6 	while (__sync_lock_test_and_set(sl, 1))
      7 		;
      8 }
      9 
     10 static inline void
     11 unlock(spinlock_t *sl)
     12 {
     13 	__sync_synchronize();
     14 	*sl = 0;
     15 }