This macro can be used in drivers imported from Linux. Signed-off-by: Julien Grall <julien.gr...@linaro.org> CC: Ian Jackson <ian.jack...@eu.citrix.com> CC: Jan Beulich <jbeul...@suse.com> CC: Keir Fraser <k...@xen.org> --- xen/include/xen/compiler.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/xen/include/xen/compiler.h b/xen/include/xen/compiler.h index 4b3472d..57eb7a6 100644 --- a/xen/include/xen/compiler.h +++ b/xen/include/xen/compiler.h @@ -90,4 +90,18 @@ __asm__ ("" : "=r"(__ptr) : "0"(ptr)); \ (typeof(ptr)) (__ptr + (off)); }) +/* + * Prevent the compiler from merging or refetching accesses. The compiler + * is also forbidden from reordering successive instances of ACCESS_ONCE(), + * but only when the compiler is aware of some particular ordering. One way + * to make the compiler aware of ordering is to put the two invocations of + * ACCESS_ONCE() in different C statements. + * + * This macro does absolutely -nothing- to prevent the CPU from reordering, + * merging, or refetching absolutely anything at any time. Its main intended + * use is to mediate communication between process-level code and irq/NMI + * handlers, all running on the same CPU. + */ +#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x)) + #endif /* __LINUX_COMPILER_H */ -- 2.1.3 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel