diff options
Diffstat (limited to 'include/linux/compiler.h')
| -rw-r--r-- | include/linux/compiler.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/include/linux/compiler.h b/include/linux/compiler.h index a1c81f80978e..33063f872ee3 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h | |||
| @@ -215,7 +215,7 @@ static __always_inline void __read_once_size(volatile void *p, void *res, int si | |||
| 215 | } | 215 | } |
| 216 | } | 216 | } |
| 217 | 217 | ||
| 218 | static __always_inline void __assign_once_size(volatile void *p, void *res, int size) | 218 | static __always_inline void __write_once_size(volatile void *p, void *res, int size) |
| 219 | { | 219 | { |
| 220 | switch (size) { | 220 | switch (size) { |
| 221 | case 1: *(volatile __u8 *)p = *(__u8 *)res; break; | 221 | case 1: *(volatile __u8 *)p = *(__u8 *)res; break; |
| @@ -235,15 +235,15 @@ static __always_inline void __assign_once_size(volatile void *p, void *res, int | |||
| 235 | /* | 235 | /* |
| 236 | * Prevent the compiler from merging or refetching reads or writes. The | 236 | * Prevent the compiler from merging or refetching reads or writes. The |
| 237 | * compiler is also forbidden from reordering successive instances of | 237 | * compiler is also forbidden from reordering successive instances of |
| 238 | * READ_ONCE, ASSIGN_ONCE and ACCESS_ONCE (see below), but only when the | 238 | * READ_ONCE, WRITE_ONCE and ACCESS_ONCE (see below), but only when the |
| 239 | * compiler is aware of some particular ordering. One way to make the | 239 | * compiler is aware of some particular ordering. One way to make the |
| 240 | * compiler aware of ordering is to put the two invocations of READ_ONCE, | 240 | * compiler aware of ordering is to put the two invocations of READ_ONCE, |
| 241 | * ASSIGN_ONCE or ACCESS_ONCE() in different C statements. | 241 | * WRITE_ONCE or ACCESS_ONCE() in different C statements. |
| 242 | * | 242 | * |
| 243 | * In contrast to ACCESS_ONCE these two macros will also work on aggregate | 243 | * In contrast to ACCESS_ONCE these two macros will also work on aggregate |
| 244 | * data types like structs or unions. If the size of the accessed data | 244 | * data types like structs or unions. If the size of the accessed data |
| 245 | * type exceeds the word size of the machine (e.g., 32 bits or 64 bits) | 245 | * type exceeds the word size of the machine (e.g., 32 bits or 64 bits) |
| 246 | * READ_ONCE() and ASSIGN_ONCE() will fall back to memcpy and print a | 246 | * READ_ONCE() and WRITE_ONCE() will fall back to memcpy and print a |
| 247 | * compile-time warning. | 247 | * compile-time warning. |
| 248 | * | 248 | * |
| 249 | * Their two major use cases are: (1) Mediating communication between | 249 | * Their two major use cases are: (1) Mediating communication between |
| @@ -257,8 +257,8 @@ static __always_inline void __assign_once_size(volatile void *p, void *res, int | |||
| 257 | #define READ_ONCE(x) \ | 257 | #define READ_ONCE(x) \ |
| 258 | ({ typeof(x) __val; __read_once_size(&x, &__val, sizeof(__val)); __val; }) | 258 | ({ typeof(x) __val; __read_once_size(&x, &__val, sizeof(__val)); __val; }) |
| 259 | 259 | ||
| 260 | #define ASSIGN_ONCE(val, x) \ | 260 | #define WRITE_ONCE(x, val) \ |
| 261 | ({ typeof(x) __val; __val = val; __assign_once_size(&x, &__val, sizeof(__val)); __val; }) | 261 | ({ typeof(x) __val; __val = val; __write_once_size(&x, &__val, sizeof(__val)); __val; }) |
| 262 | 262 | ||
| 263 | #endif /* __KERNEL__ */ | 263 | #endif /* __KERNEL__ */ |
| 264 | 264 | ||
