scripts

misc scripts and tools
git clone git://git.2f30.org/scripts
Log | Files | Refs

commit 859527cd00e6cb2e44b434b8c8db0a64f2ba8b4f
parent aaf93b722c979ac2227eb3a72c36e456661e7016
Author: sin <sin@2f30.org>
Date:   Thu,  1 Aug 2013 17:07:42 +0100

Add spinlock.h

Diffstat:
Arandom/spinlock.h | 15+++++++++++++++
1 file changed, 15 insertions(+), 0 deletions(-)

diff --git a/random/spinlock.h b/random/spinlock.h @@ -0,0 +1,15 @@ +typedef int spinlock_t; + +static inline void +lock(spinlock_t *sl) +{ + while (__sync_lock_test_and_set(sl, 1)) + ; +} + +static inline void +unlock(spinlock_t *sl) +{ + __sync_synchronize(); + *sl = 0; +}