[Git][ghc/ghc][wip/T18272] rts: Add Windows-specific implementation of rtsSleep
Ben Gamari
gitlab at gitlab.haskell.org
Sun May 31 17:27:28 UTC 2020
Ben Gamari pushed to branch wip/T18272 at Glasgow Haskell Compiler / GHC
Commits:
19f21f44 by Ben Gamari at 2020-05-31T13:27:19-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(mingw32_HOST_OS)
+ // 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 /* mingw32_HOST_OS */
}
/* -----------------------------------------------------------------------------
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/19f21f444d7f34ff8d6caba20fd2d0712d380cc3
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/19f21f444d7f34ff8d6caba20fd2d0712d380cc3
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/4c447a67/attachment-0001.html>
More information about the ghc-commits
mailing list