diff options
Diffstat (limited to 'rts')
-rw-r--r-- | rts/RtsUtils.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/rts/RtsUtils.c b/rts/RtsUtils.c index 3b55a7d03f..e88babcd08 100644 --- a/rts/RtsUtils.c +++ b/rts/RtsUtils.c @@ -156,10 +156,16 @@ reportHeapOverflow(void) Sleep for the given period of time. -------------------------------------------------------------------------- */ -/* Returns -1 on failure but handles EINTR internally. - * N.B. usleep has been removed from POSIX 2008 */ +/* Returns -1 on failure but handles EINTR internally. On Windows this will + * only have millisecond precision. */ int rtsSleep(Time t) { +#if defined(_WIN32) + // N.B. we can't use nanosleep on Windows as it would incur a pthreads + // dependency. See #18272. + Sleep(TimeToMS(t)); + return 0; +#else struct timespec req; req.tv_sec = TimeToSeconds(t); req.tv_nsec = TimeToNS(t - req.tv_sec * TIME_RESOLUTION); @@ -168,6 +174,7 @@ int rtsSleep(Time t) ret = nanosleep(&req, &req); } while (ret == -1 && errno == EINTR); return ret; +#endif /* _WIN32 */ } /* ----------------------------------------------------------------------------- |