~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to include/qemu/futex.h

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Wrappers around Linux futex syscall
 
3
 *
 
4
 * Copyright Red Hat, Inc. 2017
 
5
 *
 
6
 * Author:
 
7
 *  Paolo Bonzini <pbonzini@redhat.com>
 
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
 
 
14
#include <sys/syscall.h>
 
15
#include <linux/futex.h>
 
16
 
 
17
#define qemu_futex(...)              syscall(__NR_futex, __VA_ARGS__)
 
18
 
 
19
static inline void qemu_futex_wake(void *f, int n)
 
20
{
 
21
    qemu_futex(f, FUTEX_WAKE, n, NULL, NULL, 0);
 
22
}
 
23
 
 
24
static inline void qemu_futex_wait(void *f, unsigned val)
 
25
{
 
26
    while (qemu_futex(f, FUTEX_WAIT, (int) val, NULL, NULL, 0)) {
 
27
        switch (errno) {
 
28
        case EWOULDBLOCK:
 
29
            return;
 
30
        case EINTR:
 
31
            break; /* get out of switch and retry */
 
32
        default:
 
33
            abort();
 
34
        }
 
35
    }
 
36
}