From 933f2fc239bcfa7104dd42cb41b1b56880f6189e Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Sun, 14 Jul 2024 17:04:27 +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 7583abbd40..fbfca4ac77 100644 --- a/src/thread/pthread/SDL_syscond.c +++ b/src/thread/pthread/SDL_syscond.c @@ -120,7 +120,7 @@ int SDL_WaitConditionTimeoutNS(SDL_Condition *cond, SDL_Mutex *mutex, Sint64 tim abstime.tv_sec = delta.tv_sec + (timeoutNS / SDL_NS_PER_SECOND); abstime.tv_nsec = SDL_US_TO_NS(delta.tv_usec) + (timeoutNS % SDL_NS_PER_SECOND); #endif - while (abstime.tv_nsec > 1000000000) { + while (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 738bb866f6..fcc287e800 100644 --- a/src/thread/pthread/SDL_syssem.c +++ b/src/thread/pthread/SDL_syssem.c @@ -115,7 +115,7 @@ int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS) #endif /* Wrap the second if needed */ - while (ts_timeout.tv_nsec > 1000000000) { + while (ts_timeout.tv_nsec >= 1000000000) { ts_timeout.tv_sec += 1; ts_timeout.tv_nsec -= 1000000000; }