util: Fix the integer addition in os_time_get_absolute_timeout()

This should fix glClientWaitSync() timing out too early with a INT64_MAX
timeout on radeonsi

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11615
Fixes: 7316cc92f3 ("gallium/os: add conversion and wait functions for absolute timeouts")
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30476>
This commit is contained in:
Echo J 2024-08-01 20:42:36 +03:00 committed by Marge Bot
parent dafc4476f7
commit e14d1f5bc0

View file

@ -97,7 +97,9 @@ os_time_get_absolute_timeout(uint64_t timeout)
return OS_TIMEOUT_INFINITE;
time = os_time_get_nano();
abs_timeout = time + (int64_t)timeout;
/* Do the addition in unsigned, because signed overflow is UB, then convert to signed again. */
abs_timeout = (uint64_t)time + (uint64_t)timeout;
/* Check for overflow. */
if (abs_timeout < time)