blob: ba34f9e96efd6bd760870150dd9cb6ba0eacbd69 [file] [log] [blame]
Rusty Russell61d0b5a42013-03-18 13:22:19 +10301#if defined(__i386__) || defined(__x86_64__)
2#define barrier() asm volatile("" ::: "memory")
Michael S. Tsirkina7c49032016-01-20 21:12:58 +02003#define virt_mb() __sync_synchronize()
4#define virt_rmb() barrier()
5#define virt_wmb() barrier()
6/* Atomic store should be enough, but gcc generates worse code in that case. */
7#define virt_store_mb(var, value) do { \
8 typeof(var) virt_store_mb_value = (value); \
9 __atomic_exchange(&(var), &virt_store_mb_value, &virt_store_mb_value, \
10 __ATOMIC_SEQ_CST); \
11 barrier(); \
12} while (0);
Rusty Russell61d0b5a42013-03-18 13:22:19 +103013/* Weak barriers should be used. If not - it's a bug */
Michael S. Tsirkina7c49032016-01-20 21:12:58 +020014# define mb() abort()
15# define rmb() abort()
16# define wmb() abort()
Rusty Russell61d0b5a42013-03-18 13:22:19 +103017#else
18#error Please fill in barrier macros
19#endif
20