John Park | 33858a3 | 2018-09-28 23:05:48 -0700 | [diff] [blame] | 1 | #ifndef AOS_UTIL_COMPILER_MEMORY_BARRIER_H_ |
| 2 | #define AOS_UTIL_COMPILER_MEMORY_BARRIER_H_ |
Brian Silverman | 3d37a5f | 2014-09-05 18:42:20 -0400 | [diff] [blame] | 3 | |
| 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. |
| 7 | static inline void aos_compiler_memory_barrier(void) { |
Brian Silverman | c93c078 | 2019-12-18 21:38:21 -0800 | [diff] [blame] | 8 | __asm__ __volatile__("" ::: "memory", "cc"); |
Brian Silverman | 3d37a5f | 2014-09-05 18:42:20 -0400 | [diff] [blame] | 9 | } |
| 10 | |
John Park | 33858a3 | 2018-09-28 23:05:48 -0700 | [diff] [blame] | 11 | #endif // AOS_UTIL_COMPILER_MEMORY_BARRIER_H_ |