aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/compiler.h
diff options
context:
space:
mode:
authorChristian Borntraeger <borntraeger@de.ibm.com>2015-01-13 04:46:42 -0500
committerChristian Borntraeger <borntraeger@de.ibm.com>2015-01-13 14:39:09 -0500
commit43239cbe79fc369f5d2160bd7f69e28b5c50a58c (patch)
tree6048604d62a170c8ff8df7e5ba307cf64479fc77 /include/linux/compiler.h
parenteaa27f34e91a14cdceed26ed6c6793ec1d186115 (diff)
kernel: Change ASSIGN_ONCE(val, x) to WRITE_ONCE(x, val)
Feedback has shown that WRITE_ONCE(x, val) is easier to use than ASSIGN_ONCE(val,x). There are no in-tree users yet, so lets change it for 3.19. Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com> Acked-by: Peter Zijlstra <peterz@infradead.org> Acked-by: Davidlohr Bueso <dave@stgolabs.net> Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Diffstat (limited to 'include/linux/compiler.h')
-rw-r--r--include/linux/compiler.h12
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
218static __always_inline void __assign_once_size(volatile void *p, void *res, int size) 218static __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