[Git][ghc/ghc][wip/T18272] rts: Add Windows-specific implementation of rtsSleep
Ben Gamari
gitlab at gitlab.haskell.org
Sun May 31 17:28:18 UTC 2020
Ben Gamari pushed to branch wip/T18272 at Glasgow Haskell Compiler / GHC
Commits:
58fad7d4 by Ben Gamari at 2020-05-31T13:28:09-04:00
rts: Add Windows-specific implementation of rtsSleep
Previously we would use the POSIX path, which uses `nanosleep`. However,
it turns out that `nanosleep` is provided by `libpthread` on Windows. In
general we don't want to incur such a dependency. Avoid this by simply
using `Sleep` on Windows.
Fixes #18272.
- - - - -
1 changed file:
- rts/RtsUtils.c
Changes:
=====================================
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 */
}
/* -----------------------------------------------------------------------------
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/58fad7d43479766f3a66dd1ef9cc4edbe84ff372
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/58fad7d43479766f3a66dd1ef9cc4edbe84ff372
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20200531/80b60e2e/attachment-0001.html>
More information about the ghc-commits
mailing list