Skip to content

Commit

Permalink
time_sleep(): WIN32-specific implementation without nanosleep()
Browse files Browse the repository at this point in the history
Patch by linfk.
  • Loading branch information
pasky committed Jan 22, 2012
1 parent 07721b9 commit fe05ad1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions timeinfo.c
Expand Up @@ -208,11 +208,16 @@ time_now(void)
void
time_sleep(double interval)
{
#ifdef _WIN32
unsigned int t = interval * 1000.0;
Sleep(t);
#else
struct timespec ts;
double sec;
ts.tv_nsec = (int)(modf(interval, &sec)*1000000000.0);
ts.tv_sec = (int)sec;
nanosleep(&ts, NULL); /* ignore error if interval was < 0 */
#endif
}


Expand Down

0 comments on commit fe05ad1

Please sign in to comment.