The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 1 | /**************************************************************************** |
| 2 | **************************************************************************** |
| 3 | *** |
| 4 | *** This header was automatically generated from a Linux kernel header |
| 5 | *** of the same name, to make information necessary for userspace to |
| 6 | *** call into the kernel available to libc. It contains only constants, |
| 7 | *** structures, and macros generated from the original header, and thus, |
| 8 | *** contains no copyrightable information. |
| 9 | *** |
| 10 | **************************************************************************** |
| 11 | ****************************************************************************/ |
| 12 | #ifndef __LINUX_SEQLOCK_H |
| 13 | #define __LINUX_SEQLOCK_H |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 14 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 15 | #include <linux/spinlock.h> |
| 16 | #include <linux/preempt.h> |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 17 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 18 | typedef struct { |
| 19 | unsigned sequence; |
| 20 | spinlock_t lock; |
| 21 | } seqlock_t; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 22 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 23 | #define __SEQLOCK_UNLOCKED(lockname) { 0, __SPIN_LOCK_UNLOCKED(lockname) } |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 24 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 25 | #define SEQLOCK_UNLOCKED __SEQLOCK_UNLOCKED(old_style_seqlock_init) |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 26 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 27 | #define seqlock_init(x) do { *(x) = (seqlock_t) __SEQLOCK_UNLOCKED(x); } while (0) |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 28 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 29 | #define DEFINE_SEQLOCK(x) seqlock_t x = __SEQLOCK_UNLOCKED(x) |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 30 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 31 | #define SEQCNT_ZERO { 0 } |
| 32 | #define seqcount_init(x) do { *(x) = (seqcount_t) SEQCNT_ZERO; } while (0) |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 33 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 34 | #define write_seqlock_irqsave(lock, flags) do { local_irq_save(flags); write_seqlock(lock); } while (0) |
| 35 | #define write_seqlock_irq(lock) do { local_irq_disable(); write_seqlock(lock); } while (0) |
| 36 | #define write_seqlock_bh(lock) do { local_bh_disable(); write_seqlock(lock); } while (0) |
| 37 | #define write_sequnlock_irqrestore(lock, flags) do { write_sequnlock(lock); local_irq_restore(flags); } while(0) |
| 38 | #define write_sequnlock_irq(lock) do { write_sequnlock(lock); local_irq_enable(); } while(0) |
| 39 | #define write_sequnlock_bh(lock) do { write_sequnlock(lock); local_bh_enable(); } while(0) |
| 40 | #define read_seqbegin_irqsave(lock, flags) ({ local_irq_save(flags); read_seqbegin(lock); }) |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 41 | #define read_seqretry_irqrestore(lock, iv, flags) ({ int ret = read_seqretry(lock, iv); local_irq_restore(flags); ret; }) |
| 42 | #endif |