1 #ifndef __SPINLOCK_H__ 2 #define __SPINLOCK_H__ 3 4 #include "kernel/kernel.h" 5 6 typedef struct spinlock { 7 atomic_t val; 8 } spinlock_t; 9 10 #ifndef CONFIG_SMP 11 12 #define SPINLOCK_DEFINE(name) 13 #define PRIVATE_SPINLOCK_DEFINE(name) 14 #define SPINLOCK_DECLARE(name) 15 #define spinlock_init(sl) 16 #define spinlock_lock(sl) 17 #define spinlock_unlock(sl) 18 19 #else 20 21 /* SMP */ 22 #define SPINLOCK_DEFINE(name) spinlock_t name; 23 #define PRIVATE_SPINLOCK_DEFINE(name) PRIVATE SPINLOCK_DEFINE(name) 24 #define SPINLOCK_DECLARE(name) extern SPINLOCK_DEFINE(name) 25 #define spinlock_init(sl) do { (sl)->val = 0; } while (0) 26 27 #if CONFIG_MAX_CPUS == 1 28 #define spinlock_lock(sl) 29 #define spinlock_unlock(sl) 30 #else 31 void arch_spinlock_lock(atomic_t * sl); 32 void arch_spinlock_unlock(atomic_t * sl); 33 #define spinlock_lock(sl) arch_spinlock_lock((atomic_t*) sl) 34 #define spinlock_unlock(sl) arch_spinlock_unlock((atomic_t*) sl) 35 #endif 36 37 38 #endif /* CONFIG_SMP */ 39 40 #define BKL_LOCK() spinlock_lock(&big_kernel_lock) 41 #define BKL_UNLOCK() spinlock_unlock(&big_kernel_lock) 42 43 #endif /* __SPINLOCK_H__ */ 44