diff options
Diffstat (limited to 'tools/include/linux')
| -rw-r--r-- | tools/include/linux/compiler.h | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h index 04e32f965ad7..1827c2f973f9 100644 --- a/tools/include/linux/compiler.h +++ b/tools/include/linux/compiler.h | |||
| @@ -151,11 +151,21 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s | |||
| 151 | * required ordering. | 151 | * required ordering. |
| 152 | */ | 152 | */ |
| 153 | 153 | ||
| 154 | #define READ_ONCE(x) \ | 154 | #define READ_ONCE(x) \ |
| 155 | ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), __u.__c, sizeof(x)); __u.__val; }) | 155 | ({ \ |
| 156 | 156 | union { typeof(x) __val; char __c[1]; } __u = \ | |
| 157 | #define WRITE_ONCE(x, val) \ | 157 | { .__c = { 0 } }; \ |
| 158 | ({ union { typeof(x) __val; char __c[1]; } __u = { .__val = (val) }; __write_once_size(&(x), __u.__c, sizeof(x)); __u.__val; }) | 158 | __read_once_size(&(x), __u.__c, sizeof(x)); \ |
| 159 | __u.__val; \ | ||
| 160 | }) | ||
| 161 | |||
| 162 | #define WRITE_ONCE(x, val) \ | ||
| 163 | ({ \ | ||
| 164 | union { typeof(x) __val; char __c[1]; } __u = \ | ||
| 165 | { .__val = (val) }; \ | ||
| 166 | __write_once_size(&(x), __u.__c, sizeof(x)); \ | ||
| 167 | __u.__val; \ | ||
| 168 | }) | ||
| 159 | 169 | ||
| 160 | 170 | ||
| 161 | #ifndef __fallthrough | 171 | #ifndef __fallthrough |
