提交 a7c49033 编写于 作者: M Michael S. Tsirkin

tools/virtio: use virt_xxx barriers

Fix build after API changes.
Reported-by: NKamal Mostafa <kamal@canonical.com>
Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
上级 2989be09
#if defined(__i386__) || defined(__x86_64__) #if defined(__i386__) || defined(__x86_64__)
#define barrier() asm volatile("" ::: "memory") #define barrier() asm volatile("" ::: "memory")
#define mb() __sync_synchronize() #define virt_mb() __sync_synchronize()
#define virt_rmb() barrier()
#define smp_mb() mb() #define virt_wmb() barrier()
# define dma_rmb() barrier() /* Atomic store should be enough, but gcc generates worse code in that case. */
# define dma_wmb() barrier() #define virt_store_mb(var, value) do { \
# define smp_rmb() barrier() typeof(var) virt_store_mb_value = (value); \
# define smp_wmb() barrier() __atomic_exchange(&(var), &virt_store_mb_value, &virt_store_mb_value, \
__ATOMIC_SEQ_CST); \
barrier(); \
} while (0);
/* Weak barriers should be used. If not - it's a bug */ /* Weak barriers should be used. If not - it's a bug */
# define mb() abort()
# define rmb() abort() # define rmb() abort()
# define wmb() abort() # define wmb() abort()
#else #else
......
#ifndef LINUX_COMPILER_H
#define LINUX_COMPILER_H
#define WRITE_ONCE(var, val) \
(*((volatile typeof(val) *)(&(var))) = (val))
#define READ_ONCE(var) (*((volatile typeof(val) *)(&(var))))
#endif
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <assert.h> #include <assert.h>
#include <stdarg.h> #include <stdarg.h>
#include <linux/compiler.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/printk.h> #include <linux/printk.h>
#include <linux/bug.h> #include <linux/bug.h>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册