aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/compiler.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-05-10 22:51:16 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-05-10 22:51:16 -0400
commit9c3cdc1f83a6e07092392ff4aba6466517dbd1d0 (patch)
tree4dc890f607da4f85ca3a66770e4bce109879e69b /include/linux/compiler.h
parent3ed43c745d2ce0c4ca15ad406285d1cc7e8ceec3 (diff)
Move ACCESS_ONCE() to <linux/compiler.h>
It actually makes much more sense there, and we do tend to need it for non-RCU usage too. Moving it to <linux/compiler.h> will allow some other cases that have open-coded the same logic to use the same helper function that RCU has used. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/compiler.h')
-rw-r--r--include/linux/compiler.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index dcae0c8d97e6..c8bd2daf95ec 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -182,4 +182,16 @@ extern void __chk_io_ptr(const volatile void __iomem *);
182# define __section(S) __attribute__ ((__section__(#S))) 182# define __section(S) __attribute__ ((__section__(#S)))
183#endif 183#endif
184 184
185/*
186 * Prevent the compiler from merging or refetching accesses. The compiler
187 * is also forbidden from reordering successive instances of ACCESS_ONCE(),
188 * but only when the compiler is aware of some particular ordering. One way
189 * to make the compiler aware of ordering is to put the two invocations of
190 * ACCESS_ONCE() in different C statements.
191 *
192 * This macro does absolutely -nothing- to prevent the CPU from reordering,
193 * merging, or refetching absolutely anything at any time.
194 */
195#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
196
185#endif /* __LINUX_COMPILER_H */ 197#endif /* __LINUX_COMPILER_H */