[AGPGART] Replace kmalloc+memset's with kzalloc's
[linux-2.6.22.y-op.git] / include / linux / spinlock_up.h
blob31accf2f0b137645910b230bc7a4028a93115b2d
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"
6 #endif
8 /*
9 * include/linux/spinlock_up.h - UP-debug version of spinlocks.
11 * portions Copyright 2005, Red Hat, Inc., Ingo Molnar
12 * Released under the General Public License (GPL).
14 * In the debug case, 1 means unlocked, 0 means locked. (the values
15 * are inverted, to catch initialization bugs)
17 * No atomicity anywhere, we are on UP.
20 #ifdef CONFIG_DEBUG_SPINLOCK
22 #define __raw_spin_is_locked(x) ((x)->slock == 0)
24 static inline void __raw_spin_lock(raw_spinlock_t *lock)
26 lock->slock = 0;
29 static inline void
30 __raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long flags)
32 local_irq_save(flags);
33 lock->slock = 0;
36 static inline int __raw_spin_trylock(raw_spinlock_t *lock)
38 char oldval = lock->slock;
40 lock->slock = 0;
42 return oldval > 0;
45 static inline void __raw_spin_unlock(raw_spinlock_t *lock)
47 lock->slock = 1;
51 * Read-write spinlocks. No debug version.
53 #define __raw_read_lock(lock) do { (void)(lock); } while (0)
54 #define __raw_write_lock(lock) do { (void)(lock); } while (0)
55 #define __raw_read_trylock(lock) ({ (void)(lock); 1; })
56 #define __raw_write_trylock(lock) ({ (void)(lock); 1; })
57 #define __raw_read_unlock(lock) do { (void)(lock); } while (0)
58 #define __raw_write_unlock(lock) do { (void)(lock); } while (0)
60 #else /* DEBUG_SPINLOCK */
61 #define __raw_spin_is_locked(lock) ((void)(lock), 0)
62 /* for sched.c and kernel_lock.c: */
63 # define __raw_spin_lock(lock) do { (void)(lock); } while (0)
64 # define __raw_spin_unlock(lock) do { (void)(lock); } while (0)
65 # define __raw_spin_trylock(lock) ({ (void)(lock); 1; })
66 #endif /* DEBUG_SPINLOCK */
68 #define __raw_read_can_lock(lock) (((void)(lock), 1))
69 #define __raw_write_can_lock(lock) (((void)(lock), 1))
71 #define __raw_spin_unlock_wait(lock) \
72 do { cpu_relax(); } while (__raw_spin_is_locked(lock))
74 #endif /* __LINUX_SPINLOCK_UP_H */