migration/rdma: Plug memory leaks in qemu_rdma_registration_stop()
[qemu/armbru.git] / util / sys_membarrier.c
blob1362c0c4c5959d6a24e7af520b3f7913bc6791bb
1 /*
2 * Process-global memory barriers
4 * Copyright (c) 2018 Red Hat, Inc.
6 * Author: Paolo Bonzini <pbonzini@redhat.com>
7 */
9 #include "qemu/osdep.h"
10 #include "qemu/sys_membarrier.h"
11 #include "qemu/error-report.h"
13 #ifdef CONFIG_LINUX
14 #include <linux/membarrier.h>
15 #include <sys/syscall.h>
17 static int
18 membarrier(int cmd, int flags)
20 return syscall(__NR_membarrier, cmd, flags);
22 #endif
24 void smp_mb_global(void)
26 #if defined CONFIG_WIN32
27 FlushProcessWriteBuffers();
28 #elif defined CONFIG_LINUX
29 membarrier(MEMBARRIER_CMD_SHARED, 0);
30 #else
31 #error --enable-membarrier is not supported on this operating system.
32 #endif
35 void smp_mb_global_init(void)
37 #ifdef CONFIG_LINUX
38 int ret = membarrier(MEMBARRIER_CMD_QUERY, 0);
39 if (ret < 0) {
40 error_report("This QEMU binary requires the membarrier system call.");
41 error_report("Please upgrade your system to a newer version of Linux");
42 exit(1);
44 if (!(ret & MEMBARRIER_CMD_SHARED)) {
45 error_report("This QEMU binary requires MEMBARRIER_CMD_SHARED support.");
46 error_report("Please upgrade your system to a newer version of Linux");
47 exit(1);
49 #endif