From 2eeb39298e81fefb28ec6545cedb20915eb1657e Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Sun, 14 Jul 2024 17:20:26 +0200 Subject: [PATCH] pthread: timespec.tv_nsec must be less then 1000000000 ns --- src/thread/pthread/SDL_syscond.c | 2 +- src/thread/pthread/SDL_syssem.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/thread/pthread/SDL_syscond.c b/src/thread/pthread/SDL_syscond.c index a1a2e63b90..c7583dcfef 100644 --- a/src/thread/pthread/SDL_syscond.c +++ b/src/thread/pthread/SDL_syscond.c @@ -114,7 +114,7 @@ int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms) abstime.tv_sec = delta.tv_sec + (ms / 1000); abstime.tv_nsec = (long)(delta.tv_usec + (ms % 1000) * 1000) * 1000; #endif - if (abstime.tv_nsec > 1000000000) { + if (abstime.tv_nsec >= 1000000000) { abstime.tv_sec += 1; abstime.tv_nsec -= 1000000000; } diff --git a/src/thread/pthread/SDL_syssem.c b/src/thread/pthread/SDL_syssem.c index 6d0cdd5c2a..9894bab4dd 100644 --- a/src/thread/pthread/SDL_syssem.c +++ b/src/thread/pthread/SDL_syssem.c @@ -141,7 +141,7 @@ int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) #endif /* Wrap the second if needed */ - if (ts_timeout.tv_nsec > 1000000000) { + if (ts_timeout.tv_nsec >= 1000000000) { ts_timeout.tv_sec += 1; ts_timeout.tv_nsec -= 1000000000; }