]>
Commit | Line | Data |
---|---|---|
fbcc3e50 PB |
1 | /* |
2 | * Wrappers around Linux futex syscall | |
3 | * | |
4 | * Copyright Red Hat, Inc. 2017 | |
5 | * | |
6 | * Author: | |
7 | * Paolo Bonzini <[email protected]> | |
8 | * | |
9 | * This work is licensed under the terms of the GNU GPL, version 2 or later. | |
10 | * See the COPYING file in the top-level directory. | |
11 | * | |
12 | */ | |
13 | ||
f3245d63 EC |
14 | #ifndef QEMU_FUTEX_H |
15 | #define QEMU_FUTEX_H | |
16 | ||
fbcc3e50 PB |
17 | #include <sys/syscall.h> |
18 | #include <linux/futex.h> | |
19 | ||
20 | #define qemu_futex(...) syscall(__NR_futex, __VA_ARGS__) | |
21 | ||
22 | static inline void qemu_futex_wake(void *f, int n) | |
23 | { | |
24 | qemu_futex(f, FUTEX_WAKE, n, NULL, NULL, 0); | |
25 | } | |
26 | ||
27 | static inline void qemu_futex_wait(void *f, unsigned val) | |
28 | { | |
29 | while (qemu_futex(f, FUTEX_WAIT, (int) val, NULL, NULL, 0)) { | |
30 | switch (errno) { | |
31 | case EWOULDBLOCK: | |
32 | return; | |
33 | case EINTR: | |
34 | break; /* get out of switch and retry */ | |
35 | default: | |
36 | abort(); | |
37 | } | |
38 | } | |
39 | } | |
f3245d63 EC |
40 | |
41 | #endif /* QEMU_FUTEX_H */ |