blob: af1f47229e70292ec2ec63556c4a484f41d4bc18 [file] [log] [blame]
Ingo Molnarfb1c8f92005-09-10 00:25:56 -07001#ifndef __LINUX_SPINLOCK_API_UP_H
2#define __LINUX_SPINLOCK_API_UP_H
3
4#ifndef __LINUX_SPINLOCK_H
5# error "please don't include this file directly"
6#endif
7
8/*
9 * include/linux/spinlock_api_up.h
10 *
11 * spinlock API implementation on UP-nondebug (inlined implementation)
12 *
13 * portions Copyright 2005, Red Hat, Inc., Ingo Molnar
14 * Released under the General Public License (GPL).
15 */
16
17#define in_lock_functions(ADDR) 0
18
Thomas Gleixnerc2f21ce2009-12-02 20:02:59 +010019#define assert_raw_spin_locked(lock) do { (void)(lock); } while (0)
Ingo Molnarfb1c8f92005-09-10 00:25:56 -070020
21/*
22 * In the UP-nondebug case there's no real locking going on, so the
23 * only thing we have to do is to keep the preempt counts and irq
Joe Perchesfd3f8982008-02-03 17:45:46 +020024 * flags straight, to suppress compiler warnings of unused lock
Ingo Molnarfb1c8f92005-09-10 00:25:56 -070025 * variables, and to add the proper checker annotations:
26 */
27#define __LOCK(lock) \
28 do { preempt_disable(); __acquire(lock); (void)(lock); } while (0)
29
30#define __LOCK_BH(lock) \
31 do { local_bh_disable(); __LOCK(lock); } while (0)
32
33#define __LOCK_IRQ(lock) \
34 do { local_irq_disable(); __LOCK(lock); } while (0)
35
36#define __LOCK_IRQSAVE(lock, flags) \
37 do { local_irq_save(flags); __LOCK(lock); } while (0)
38
39#define __UNLOCK(lock) \
40 do { preempt_enable(); __release(lock); (void)(lock); } while (0)
41
42#define __UNLOCK_BH(lock) \
Thomas Gleixner9c1721a2009-12-03 21:52:18 +010043 do { preempt_enable_no_resched(); local_bh_enable(); \
44 __release(lock); (void)(lock); } while (0)
Ingo Molnarfb1c8f92005-09-10 00:25:56 -070045
46#define __UNLOCK_IRQ(lock) \
47 do { local_irq_enable(); __UNLOCK(lock); } while (0)
48
49#define __UNLOCK_IRQRESTORE(lock, flags) \
50 do { local_irq_restore(flags); __UNLOCK(lock); } while (0)
51
Thomas Gleixner9c1721a2009-12-03 21:52:18 +010052#define _raw_spin_lock(lock) __LOCK(lock)
53#define _raw_spin_lock_nested(lock, subclass) __LOCK(lock)
54#define _raw_read_lock(lock) __LOCK(lock)
55#define _raw_write_lock(lock) __LOCK(lock)
56#define _raw_spin_lock_bh(lock) __LOCK_BH(lock)
57#define _raw_read_lock_bh(lock) __LOCK_BH(lock)
58#define _raw_write_lock_bh(lock) __LOCK_BH(lock)
59#define _raw_spin_lock_irq(lock) __LOCK_IRQ(lock)
60#define _raw_read_lock_irq(lock) __LOCK_IRQ(lock)
61#define _raw_write_lock_irq(lock) __LOCK_IRQ(lock)
62#define _raw_spin_lock_irqsave(lock, flags) __LOCK_IRQSAVE(lock, flags)
63#define _raw_read_lock_irqsave(lock, flags) __LOCK_IRQSAVE(lock, flags)
64#define _raw_write_lock_irqsave(lock, flags) __LOCK_IRQSAVE(lock, flags)
65#define _raw_spin_trylock(lock) ({ __LOCK(lock); 1; })
66#define _raw_read_trylock(lock) ({ __LOCK(lock); 1; })
67#define _raw_write_trylock(lock) ({ __LOCK(lock); 1; })
68#define _raw_spin_trylock_bh(lock) ({ __LOCK_BH(lock); 1; })
69#define _raw_spin_unlock(lock) __UNLOCK(lock)
70#define _raw_read_unlock(lock) __UNLOCK(lock)
71#define _raw_write_unlock(lock) __UNLOCK(lock)
72#define _raw_spin_unlock_bh(lock) __UNLOCK_BH(lock)
73#define _raw_write_unlock_bh(lock) __UNLOCK_BH(lock)
74#define _raw_read_unlock_bh(lock) __UNLOCK_BH(lock)
75#define _raw_spin_unlock_irq(lock) __UNLOCK_IRQ(lock)
76#define _raw_read_unlock_irq(lock) __UNLOCK_IRQ(lock)
77#define _raw_write_unlock_irq(lock) __UNLOCK_IRQ(lock)
78#define _raw_spin_unlock_irqrestore(lock, flags) \
79 __UNLOCK_IRQRESTORE(lock, flags)
80#define _raw_read_unlock_irqrestore(lock, flags) \
81 __UNLOCK_IRQRESTORE(lock, flags)
82#define _raw_write_unlock_irqrestore(lock, flags) \
83 __UNLOCK_IRQRESTORE(lock, flags)
Ingo Molnarfb1c8f92005-09-10 00:25:56 -070084
85#endif /* __LINUX_SPINLOCK_API_UP_H */