Andrew Morton | 0db9ae4 | 2005-10-24 23:05:58 -0700 | [diff] [blame] | 1 | #ifndef __BARRIER_H |
| 2 | #define __BARRIER_H |
| 3 | |
Ivan Kokshaysky | 63f324c | 2005-10-29 18:15:43 -0700 | [diff] [blame] | 4 | #include <asm/compiler.h> |
| 5 | |
Andrew Morton | 0db9ae4 | 2005-10-24 23:05:58 -0700 | [diff] [blame] | 6 | #define mb() \ |
| 7 | __asm__ __volatile__("mb": : :"memory") |
| 8 | |
| 9 | #define rmb() \ |
| 10 | __asm__ __volatile__("mb": : :"memory") |
| 11 | |
| 12 | #define wmb() \ |
| 13 | __asm__ __volatile__("wmb": : :"memory") |
| 14 | |
| 15 | #define read_barrier_depends() \ |
| 16 | __asm__ __volatile__("mb": : :"memory") |
| 17 | |
| 18 | #ifdef CONFIG_SMP |
Ivan Kokshaysky | 77b4cf5 | 2009-04-30 15:08:48 -0700 | [diff] [blame] | 19 | #define __ASM_SMP_MB "\tmb\n" |
Andrew Morton | 0db9ae4 | 2005-10-24 23:05:58 -0700 | [diff] [blame] | 20 | #define smp_mb() mb() |
| 21 | #define smp_rmb() rmb() |
| 22 | #define smp_wmb() wmb() |
| 23 | #define smp_read_barrier_depends() read_barrier_depends() |
| 24 | #else |
Ivan Kokshaysky | 77b4cf5 | 2009-04-30 15:08:48 -0700 | [diff] [blame] | 25 | #define __ASM_SMP_MB |
Andrew Morton | 0db9ae4 | 2005-10-24 23:05:58 -0700 | [diff] [blame] | 26 | #define smp_mb() barrier() |
| 27 | #define smp_rmb() barrier() |
| 28 | #define smp_wmb() barrier() |
Nick Piggin | 73f1028 | 2008-05-14 06:35:11 +0200 | [diff] [blame] | 29 | #define smp_read_barrier_depends() do { } while (0) |
Andrew Morton | 0db9ae4 | 2005-10-24 23:05:58 -0700 | [diff] [blame] | 30 | #endif |
| 31 | |
| 32 | #define set_mb(var, value) \ |
| 33 | do { var = value; mb(); } while (0) |
| 34 | |
Andrew Morton | 0db9ae4 | 2005-10-24 23:05:58 -0700 | [diff] [blame] | 35 | #endif /* __BARRIER_H */ |