cpu: enforce a memory barrier inside cpu_relax()
Put a memory barrier inside cpu_relax() to make sure the compiler
doesn't cache variables used outside cpu_relax() in registers.
Suppose to have the following case (used in many device drivers):
static int done = false;
void irq_handler(void)
{
done = true;
}
void wait_for_completion(void)
{
while (done == false)
cpu_relax();
}
If cpu_relax() is just considered a nop the compiler may decide to not
reload the value in the variable "done" from memory, causing a
neverending loop.
The presence of an explicit memory barrier fixes this case.
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4344
38d2e660-2303-0410-9eaa-
f027e97ec537