1 #ifndef __LINUX_SPINLOCK_UP_H
2 #define __LINUX_SPINLOCK_UP_H
4 #ifndef __LINUX_SPINLOCK_H
5 # error "please don't include this file directly"
8 #include <asm/processor.h> /* for cpu_relax() */
11 * include/linux/spinlock_up.h - UP-debug version of spinlocks.
13 * portions Copyright 2005, Red Hat, Inc., Ingo Molnar
14 * Released under the General Public License (GPL).
16 * In the debug case, 1 means unlocked, 0 means locked. (the values
17 * are inverted, to catch initialization bugs)
19 * No atomicity anywhere, we are on UP.
22 #ifdef CONFIG_DEBUG_SPINLOCK
23 #define arch_spin_is_locked(x) ((x)->slock == 0)
25 static inline void arch_spin_lock(arch_spinlock_t
*lock
)
31 arch_spin_lock_flags(arch_spinlock_t
*lock
, unsigned long flags
)
33 local_irq_save(flags
);
37 static inline int arch_spin_trylock(arch_spinlock_t
*lock
)
39 char oldval
= lock
->slock
;
46 static inline void arch_spin_unlock(arch_spinlock_t
*lock
)
52 * Read-write spinlocks. No debug version.
54 #define arch_read_lock(lock) do { (void)(lock); } while (0)
55 #define arch_write_lock(lock) do { (void)(lock); } while (0)
56 #define arch_read_trylock(lock) ({ (void)(lock); 1; })
57 #define arch_write_trylock(lock) ({ (void)(lock); 1; })
58 #define arch_read_unlock(lock) do { (void)(lock); } while (0)
59 #define arch_write_unlock(lock) do { (void)(lock); } while (0)
61 #else /* DEBUG_SPINLOCK */
62 #define arch_spin_is_locked(lock) ((void)(lock), 0)
63 /* for sched.c and kernel_lock.c: */
64 # define arch_spin_lock(lock) do { (void)(lock); } while (0)
65 # define arch_spin_lock_flags(lock, flags) do { (void)(lock); } while (0)
66 # define arch_spin_unlock(lock) do { (void)(lock); } while (0)
67 # define arch_spin_trylock(lock) ({ (void)(lock); 1; })
68 #endif /* DEBUG_SPINLOCK */
70 #define arch_spin_is_contended(lock) (((void)(lock), 0))
72 #define arch_read_can_lock(lock) (((void)(lock), 1))
73 #define arch_write_can_lock(lock) (((void)(lock), 1))
75 #define arch_spin_unlock_wait(lock) \
76 do { cpu_relax(); } while (arch_spin_is_locked(lock))
78 #endif /* __LINUX_SPINLOCK_UP_H */
This page took 0.031489 seconds and 5 git commands to generate.