Lines Matching refs:ev
283 static inline void futex_wake(QemuEvent *ev, int n) in futex_wake() argument
285 futex(ev, FUTEX_WAKE, n, NULL, NULL, 0); in futex_wake()
288 static inline void futex_wait(QemuEvent *ev, unsigned val) in futex_wait() argument
290 futex(ev, FUTEX_WAIT, (int) val, NULL, NULL, 0); in futex_wait()
293 static inline void futex_wake(QemuEvent *ev, int n) in futex_wake() argument
296 pthread_cond_signal(&ev->cond); in futex_wake()
298 pthread_cond_broadcast(&ev->cond); in futex_wake()
302 static inline void futex_wait(QemuEvent *ev, unsigned val) in futex_wait() argument
304 pthread_mutex_lock(&ev->lock); in futex_wait()
305 if (ev->value == val) { in futex_wait()
306 pthread_cond_wait(&ev->cond, &ev->lock); in futex_wait()
308 pthread_mutex_unlock(&ev->lock); in futex_wait()
330 void qemu_event_init(QemuEvent *ev, bool init) in qemu_event_init() argument
333 pthread_mutex_init(&ev->lock, NULL); in qemu_event_init()
334 pthread_cond_init(&ev->cond, NULL); in qemu_event_init()
337 ev->value = (init ? EV_SET : EV_FREE); in qemu_event_init()
340 void qemu_event_destroy(QemuEvent *ev) in qemu_event_destroy() argument
343 pthread_mutex_destroy(&ev->lock); in qemu_event_destroy()
344 pthread_cond_destroy(&ev->cond); in qemu_event_destroy()
348 void qemu_event_set(QemuEvent *ev) in qemu_event_set() argument
350 if (atomic_mb_read(&ev->value) != EV_SET) { in qemu_event_set()
351 if (atomic_xchg(&ev->value, EV_SET) == EV_BUSY) { in qemu_event_set()
353 futex_wake(ev, INT_MAX); in qemu_event_set()
358 void qemu_event_reset(QemuEvent *ev) in qemu_event_reset() argument
360 if (atomic_mb_read(&ev->value) == EV_SET) { in qemu_event_reset()
365 atomic_or(&ev->value, EV_FREE); in qemu_event_reset()
369 void qemu_event_wait(QemuEvent *ev) in qemu_event_wait() argument
373 value = atomic_mb_read(&ev->value); in qemu_event_wait()
382 if (atomic_cmpxchg(&ev->value, EV_FREE, EV_BUSY) == EV_SET) { in qemu_event_wait()
386 futex_wait(ev, EV_BUSY); in qemu_event_wait()