blob: 6be3c59f245aa66cf37d31c47db9910956e0a3f4 [file] [log] [blame]
John Park33858a32018-09-28 23:05:48 -07001#ifndef AOS_UTIL_COMPILER_MEMORY_BARRIER_H_
2#define AOS_UTIL_COMPILER_MEMORY_BARRIER_H_
Brian Silverman3d37a5f2014-09-05 18:42:20 -04003
4// Prevents the compiler from reordering memory operations around this.
5// Using this function makes it clearer what you're doing and easier to be
6// portable.
7static inline void aos_compiler_memory_barrier(void) {
Brian Silvermanc93c0782019-12-18 21:38:21 -08008 __asm__ __volatile__("" ::: "memory", "cc");
Brian Silverman3d37a5f2014-09-05 18:42:20 -04009}
10
John Park33858a32018-09-28 23:05:48 -070011#endif // AOS_UTIL_COMPILER_MEMORY_BARRIER_H_