Add standalone memory barrier function to project.
This commit is contained in:
parent
1059f27592
commit
4420652549
|
|
@ -0,0 +1,18 @@
|
||||||
|
#ifndef _MEMORY_BARRIER_H_
|
||||||
|
#define _MEMORY_BARRIER_H_
|
||||||
|
|
||||||
|
#include <util/atomic.h>
|
||||||
|
#include <avr/version.h>
|
||||||
|
|
||||||
|
// 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
|
||||||
Loading…
Reference in New Issue