diff options
author | Jason Ekstrand <jason@jlekstrand.net> | 2021-10-27 16:32:24 -0500 |
---|---|---|
committer | Jason Ekstrand <jason@jlekstrand.net> | 2021-11-16 10:02:08 -0600 |
commit | f3843b11c9127a16b7381c9d6d0091ca59a1d029 (patch) | |
tree | 5475a29a56152a065ee21d3896aea8e252736203 /include | |
parent | 13ab3757bbe0e7af7a7bc29d2a00b7f1f2400aa9 (diff) |
c11/threads: Re-align return values for timed waits
They're supposed to return thrd_timedout (which we mistakenly named
thrd_timeout), not thrd_busy.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13427>
Diffstat (limited to 'include')
-rw-r--r-- | include/c11/threads.h | 2 | ||||
-rw-r--r-- | include/c11/threads_posix.h | 6 | ||||
-rw-r--r-- | include/c11/threads_win32.h | 4 |
3 files changed, 6 insertions, 6 deletions
diff --git a/include/c11/threads.h b/include/c11/threads.h index 3c3f23a8ab8..790f52cb49f 100644 --- a/include/c11/threads.h +++ b/include/c11/threads.h @@ -52,7 +52,7 @@ enum { enum { thrd_success = 0, // succeeded - thrd_timeout, // timeout + thrd_timedout, // timed out thrd_error, // failed thrd_busy, // resource busy thrd_nomem // out of memory diff --git a/include/c11/threads_posix.h b/include/c11/threads_posix.h index 45cb6075e6e..802526a77c8 100644 --- a/include/c11/threads_posix.h +++ b/include/c11/threads_posix.h @@ -142,7 +142,7 @@ cnd_timedwait(cnd_t *cond, mtx_t *mtx, const struct timespec *abs_time) rt = pthread_cond_timedwait(cond, mtx, abs_time); if (rt == ETIMEDOUT) - return thrd_busy; + return thrd_timedout; return (rt == 0) ? thrd_success : thrd_error; } @@ -242,14 +242,14 @@ mtx_timedlock(mtx_t *mtx, const struct timespec *ts) rt = pthread_mutex_timedlock(mtx, ts); if (rt == 0) return thrd_success; - return (rt == ETIMEDOUT) ? thrd_busy : thrd_error; + return (rt == ETIMEDOUT) ? thrd_timedout : thrd_error; #else time_t expire = time(NULL); expire += ts->tv_sec; while (mtx_trylock(mtx) != thrd_success) { time_t now = time(NULL); if (expire < now) - return thrd_busy; + return thrd_timedout; // busy loop! thrd_yield(); } diff --git a/include/c11/threads_win32.h b/include/c11/threads_win32.h index 02c2a73dda1..8c014fab45c 100644 --- a/include/c11/threads_win32.h +++ b/include/c11/threads_win32.h @@ -259,7 +259,7 @@ cnd_timedwait(cnd_t *cond, mtx_t *mtx, const struct timespec *abs_time) const DWORD timeout = impl_abs2relmsec(abs_time); if (SleepConditionVariableCS(cond, mtx, timeout)) return thrd_success; - return (GetLastError() == ERROR_TIMEOUT) ? thrd_busy : thrd_error; + return (GetLastError() == ERROR_TIMEOUT) ? thrd_timedout : thrd_error; #else return thrd_error; #endif @@ -317,7 +317,7 @@ mtx_timedlock(mtx_t *mtx, const struct timespec *ts) #ifdef HAVE_TIMESPEC_GET while (mtx_trylock(mtx) != thrd_success) { if (impl_abs2relmsec(ts) == 0) - return thrd_busy; + return thrd_timedout; // busy loop! thrd_yield(); } |