From 4420652549c1e8d4ec75507c8867872298c46a13 Mon Sep 17 00:00:00 2001 From: Jim McGee Date: Fri, 6 May 2011 22:30:33 -0700 Subject: [PATCH] Add standalone memory barrier function to project. --- memory_barrier.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 memory_barrier.h diff --git a/memory_barrier.h b/memory_barrier.h new file mode 100644 index 0000000..662f2de --- /dev/null +++ b/memory_barrier.h @@ -0,0 +1,18 @@ +#ifndef _MEMORY_BARRIER_H_ +#define _MEMORY_BARRIER_H_ + +#include +#include + +// Provide a memory barrier to the compiler. This informs +// the compiler that is should write any cached values that +// are destined for a global variable and discard any other +// cached values from global variables. +// +// Note that this behavior does apply to all global variables, +// not just volatile ones. However, cached local variables +// are not affected as they are not externally visible. + +#define MEMORY_BARRIER() __asm volatile( "" ::: "memory" ) + +#endif \ No newline at end of file