mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 09:38:07 +02:00
util: futex fixes for OpenBSD
Fix absolute to relative timeout computation. Add sanity checks to futex_wait() - handle the NULL timeout pointer case - avoid negative cases. From Matthieu Herrb and Scott Cheloha. Fixes:c91997b6c4("util/futex: use futex syscall on OpenBSD") Signed-off-by: Jonathan Gray <jsg@jsg.id.au> Acked-by: Eric Engestrom <eric@engestrom.ch> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5630> (cherry picked from commitc66c5b38e0)
This commit is contained in:
parent
9b41f98803
commit
591853c796
2 changed files with 11 additions and 4 deletions
|
|
@ -1264,7 +1264,7 @@
|
|||
"description": "util: futex fixes for OpenBSD",
|
||||
"nominated": true,
|
||||
"nomination_type": 1,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"master_sha": null,
|
||||
"because_sha": "c91997b6c4395831a8de2b84e6ea2ff981a00e4b"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -100,9 +100,16 @@ static inline int futex_wake(uint32_t *addr, int count)
|
|||
|
||||
static inline int futex_wait(uint32_t *addr, int32_t value, const struct timespec *timeout)
|
||||
{
|
||||
struct timespec tsrel, tsnow;
|
||||
clock_gettime(CLOCK_MONOTONIC, &tsnow);
|
||||
timespecsub(timeout, &tsrel, &tsrel);
|
||||
struct timespec tsnow, tsrel;
|
||||
|
||||
if (timeout == NULL)
|
||||
return futex(addr, FUTEX_WAIT, value, NULL, NULL);
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &tsnow);
|
||||
if (timespeccmp(&tsnow, timeout, <))
|
||||
timespecsub(timeout, &tsnow, &tsrel);
|
||||
else
|
||||
timespecclear(&tsrel);
|
||||
return futex(addr, FUTEX_WAIT, value, &tsrel, NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue