1 #ifndef __LUNAIX_SPIN_H
2 #define __LUNAIX_SPIN_H
4 #include <lunaix/types.h>
11 typedef struct spinlock spinlock_t;
14 TODO we might use our own construct for atomic ops
15 But we will do itlater, currently this whole
16 kernel is on a single long thread of fate,
17 there won't be any hardware concurrent access
22 spinlock_init(spinlock_t* lock)
27 static inline bool spinlock_try_acquire(spinlock_t* lock)
33 return (lock->flag = true);
36 static inline void spinlock_acquire(spinlock_t* lock)
42 static inline void spinlock_release(spinlock_t* lock)
47 #define DEFINE_SPINLOCK_OPS(type, lock_accessor) \
48 static inline void lock(type obj) { spinlock_acquire(&obj->lock_accessor); } \
49 static inline void unlock(type obj) { spinlock_release(&obj->lock_accessor); }
51 #endif /* __LUNAIX_SPIN_H */