Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 1 | #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 Gleixner | c2f21ce | 2009-12-02 20:02:59 +0100 | [diff] [blame] | 19 | #define assert_raw_spin_locked(lock) do { (void)(lock); } while (0) |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 20 | |
| 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 Perches | fd3f898 | 2008-02-03 17:45:46 +0200 | [diff] [blame] | 24 | * flags straight, to suppress compiler warnings of unused lock |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 25 | * variables, and to add the proper checker annotations: |
| 26 | */ |
Peter Zijlstra | 9ea4c38 | 2013-11-19 16:13:38 +0100 | [diff] [blame] | 27 | #define ___LOCK(lock) \ |
| 28 | do { __acquire(lock); (void)(lock); } while (0) |
| 29 | |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 30 | #define __LOCK(lock) \ |
Peter Zijlstra | 9ea4c38 | 2013-11-19 16:13:38 +0100 | [diff] [blame] | 31 | do { preempt_disable(); ___LOCK(lock); } while (0) |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 32 | |
| 33 | #define __LOCK_BH(lock) \ |
Peter Zijlstra | 9ea4c38 | 2013-11-19 16:13:38 +0100 | [diff] [blame] | 34 | do { __local_bh_disable_ip(_THIS_IP_, SOFTIRQ_LOCK_OFFSET); ___LOCK(lock); } while (0) |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 35 | |
| 36 | #define __LOCK_IRQ(lock) \ |
| 37 | do { local_irq_disable(); __LOCK(lock); } while (0) |
| 38 | |
| 39 | #define __LOCK_IRQSAVE(lock, flags) \ |
| 40 | do { local_irq_save(flags); __LOCK(lock); } while (0) |
| 41 | |
Peter Zijlstra | 9ea4c38 | 2013-11-19 16:13:38 +0100 | [diff] [blame] | 42 | #define ___UNLOCK(lock) \ |
| 43 | do { __release(lock); (void)(lock); } while (0) |
| 44 | |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 45 | #define __UNLOCK(lock) \ |
Peter Zijlstra | 9ea4c38 | 2013-11-19 16:13:38 +0100 | [diff] [blame] | 46 | do { preempt_enable(); ___UNLOCK(lock); } while (0) |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 47 | |
| 48 | #define __UNLOCK_BH(lock) \ |
Peter Zijlstra | 9ea4c38 | 2013-11-19 16:13:38 +0100 | [diff] [blame] | 49 | do { __local_bh_enable_ip(_THIS_IP_, SOFTIRQ_LOCK_OFFSET); \ |
| 50 | ___UNLOCK(lock); } while (0) |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 51 | |
| 52 | #define __UNLOCK_IRQ(lock) \ |
| 53 | do { local_irq_enable(); __UNLOCK(lock); } while (0) |
| 54 | |
| 55 | #define __UNLOCK_IRQRESTORE(lock, flags) \ |
| 56 | do { local_irq_restore(flags); __UNLOCK(lock); } while (0) |
| 57 | |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 58 | #define _raw_spin_lock(lock) __LOCK(lock) |
| 59 | #define _raw_spin_lock_nested(lock, subclass) __LOCK(lock) |
Thomas Graf | 113948d | 2015-01-02 23:00:19 +0100 | [diff] [blame] | 60 | #define _raw_spin_lock_bh_nested(lock, subclass) __LOCK(lock) |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 61 | #define _raw_read_lock(lock) __LOCK(lock) |
| 62 | #define _raw_write_lock(lock) __LOCK(lock) |
| 63 | #define _raw_spin_lock_bh(lock) __LOCK_BH(lock) |
| 64 | #define _raw_read_lock_bh(lock) __LOCK_BH(lock) |
| 65 | #define _raw_write_lock_bh(lock) __LOCK_BH(lock) |
| 66 | #define _raw_spin_lock_irq(lock) __LOCK_IRQ(lock) |
| 67 | #define _raw_read_lock_irq(lock) __LOCK_IRQ(lock) |
| 68 | #define _raw_write_lock_irq(lock) __LOCK_IRQ(lock) |
| 69 | #define _raw_spin_lock_irqsave(lock, flags) __LOCK_IRQSAVE(lock, flags) |
| 70 | #define _raw_read_lock_irqsave(lock, flags) __LOCK_IRQSAVE(lock, flags) |
| 71 | #define _raw_write_lock_irqsave(lock, flags) __LOCK_IRQSAVE(lock, flags) |
| 72 | #define _raw_spin_trylock(lock) ({ __LOCK(lock); 1; }) |
| 73 | #define _raw_read_trylock(lock) ({ __LOCK(lock); 1; }) |
| 74 | #define _raw_write_trylock(lock) ({ __LOCK(lock); 1; }) |
| 75 | #define _raw_spin_trylock_bh(lock) ({ __LOCK_BH(lock); 1; }) |
| 76 | #define _raw_spin_unlock(lock) __UNLOCK(lock) |
| 77 | #define _raw_read_unlock(lock) __UNLOCK(lock) |
| 78 | #define _raw_write_unlock(lock) __UNLOCK(lock) |
| 79 | #define _raw_spin_unlock_bh(lock) __UNLOCK_BH(lock) |
| 80 | #define _raw_write_unlock_bh(lock) __UNLOCK_BH(lock) |
| 81 | #define _raw_read_unlock_bh(lock) __UNLOCK_BH(lock) |
| 82 | #define _raw_spin_unlock_irq(lock) __UNLOCK_IRQ(lock) |
| 83 | #define _raw_read_unlock_irq(lock) __UNLOCK_IRQ(lock) |
| 84 | #define _raw_write_unlock_irq(lock) __UNLOCK_IRQ(lock) |
| 85 | #define _raw_spin_unlock_irqrestore(lock, flags) \ |
| 86 | __UNLOCK_IRQRESTORE(lock, flags) |
| 87 | #define _raw_read_unlock_irqrestore(lock, flags) \ |
| 88 | __UNLOCK_IRQRESTORE(lock, flags) |
| 89 | #define _raw_write_unlock_irqrestore(lock, flags) \ |
| 90 | __UNLOCK_IRQRESTORE(lock, flags) |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 91 | |
| 92 | #endif /* __LINUX_SPINLOCK_API_UP_H */ |