From 8b0a67a2538d7c79b74086caab07735fa97aa047 Mon Sep 17 00:00:00 2001 From: Jon Lund Steffensen Date: Sun, 22 Feb 2015 11:51:20 -0500 Subject: Fix #174: Use nanosleep() instead of usleep() usleep() cannot sleep for more than 1000000 microseconds on certain platforms. nanosleep() does not have this limitation. --- src/systemtime.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/systemtime.c b/src/systemtime.c index 0d0cb85..9a971fa 100644 --- a/src/systemtime.c +++ b/src/systemtime.c @@ -24,6 +24,7 @@ # if _POSIX_TIMERS > 0 # include # else +# include # include # endif #else @@ -74,7 +75,10 @@ void systemtime_msleep(unsigned int msecs) { #ifndef _WIN32 - usleep(msecs*1000); + struct timespec sleep; + sleep.tv_sec = msecs / 1000; + sleep.tv_nsec = (msecs % 1000)*1000000; + nanosleep(&sleep, NULL); #else Sleep(msecs); #endif -- cgit v1.2.3-70-g09d2