diff options
author | Nicolai Hähnle <[email protected]> | 2017-10-22 17:38:46 +0200 |
---|---|---|
committer | Nicolai Hähnle <[email protected]> | 2017-11-09 13:58:10 +0100 |
commit | e3a8013de8ca854d21225be00f123ccf63f9060f (patch) | |
tree | b0163adc1cbfe8ac52e7c98987ebd30d1d4e8f25 /src/util/futex.h | |
parent | f1a364878431c8c5f4fd38b40b9766449e49f552 (diff) |
util/u_queue: add util_queue_fence_wait_timeout
v2:
- style fixes
- fix missing timeout handling in futex path
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/util/futex.h')
-rw-r--r-- | src/util/futex.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/util/futex.h b/src/util/futex.h index 722cdd35f67..4402893069d 100644 --- a/src/util/futex.h +++ b/src/util/futex.h @@ -33,7 +33,7 @@ #include <sys/syscall.h> #include <sys/time.h> -static inline long sys_futex(void *addr1, int op, int val1, struct timespec *timeout, void *addr2, int val3) +static inline long sys_futex(void *addr1, int op, int val1, const struct timespec *timeout, void *addr2, int val3) { return syscall(SYS_futex, addr1, op, val1, timeout, addr2, val3); } @@ -43,9 +43,12 @@ static inline int futex_wake(uint32_t *addr, int count) return sys_futex(addr, FUTEX_WAKE, count, NULL, NULL, 0); } -static inline int futex_wait(uint32_t *addr, int32_t value) +static inline int futex_wait(uint32_t *addr, int32_t value, const struct timespec *timeout) { - return sys_futex(addr, FUTEX_WAIT, value, NULL, NULL, 0); + /* FUTEX_WAIT_BITSET with FUTEX_BITSET_MATCH_ANY is equivalent to + * FUTEX_WAIT, except that it treats the timeout as absolute. */ + return sys_futex(addr, FUTEX_WAIT_BITSET, value, timeout, NULL, + FUTEX_BITSET_MATCH_ANY); } #endif |