[Git][ghc/ghc][wip/rts-imports] rts: Ensure `clockid_t` is available in `rts/OSThreads.h` by explicitly...
Zubin (@wz1000)
gitlab at gitlab.haskell.org
Mon Aug 14 20:28:11 UTC 2023
Zubin pushed to branch wip/rts-imports at Glasgow Haskell Compiler / GHC
Commits:
570b2863 by Zubin Duggal at 2023-08-15T01:57:54+05:30
rts: Ensure `clockid_t` is available in `rts/OSThreads.h` by explicitly including `sys/types.h` (#23789)
- - - - -
2 changed files:
- rts/include/rts/OSThreads.h
- rts/posix/OSThreads.c
Changes:
=====================================
rts/include/rts/OSThreads.h
=====================================
@@ -27,6 +27,11 @@
#include <pthread.h>
#include <errno.h>
+#if defined(HAVE_CLOCK_GETTIME) && defined(HAVE_PTHREAD_CONDATTR_SETCLOCK) && defined(HAVE_SYS_TYPES_H)
+#define USE_TIMEOUT_CLK
+#include <sys/types.h>
+#endif
+
typedef struct {
pthread_cond_t cond;
@@ -34,7 +39,7 @@ typedef struct {
// N.B. Some older Darwin releases don't support clock_gettime. However, we
// do want to reference to CLOCK_MONOTONIC whenever possible as it is more
// robust against system time changes and is likely cheaper to query.
-#if defined(HAVE_CLOCK_GETTIME) && defined(HAVE_PTHREAD_CONDATTR_SETCLOCK)
+#if defined(USE_TIMEOUT_CLK)
clockid_t timeout_clk;
#endif
} Condition;
=====================================
rts/posix/OSThreads.c
=====================================
@@ -109,7 +109,7 @@ initCondition( Condition* pCond )
{
pthread_condattr_t attr;
CHECK(pthread_condattr_init(&attr) == 0);
-#if defined(HAVE_CLOCK_GETTIME) && defined(HAVE_PTHREAD_CONDATTR_SETCLOCK)
+#if defined(USE_TIMEOUT_CLK)
pCond->timeout_clk = CLOCK_REALTIME;
if (pthread_condattr_setclock(&attr, CLOCK_MONOTONIC) == 0) {
pCond->timeout_clk = CLOCK_MONOTONIC;
@@ -147,7 +147,7 @@ bool
timedWaitCondition ( Condition* pCond, Mutex* pMut, Time timeout) {
struct timespec ts;
-#if defined(HAVE_CLOCK_GETTIME) && defined(HAVE_PTHREAD_CONDATTR_SETCLOCK)
+#if defined(USE_TIMEOUT_CLK)
CHECK(clock_gettime(pCond->timeout_clk, &ts) == 0);
#else
struct timeval tv;
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/570b28632820d14a7c630f2f7eb9d89f2935259a
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/570b28632820d14a7c630f2f7eb9d89f2935259a
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/20230814/ba4407fe/attachment-0001.html>
More information about the ghc-commits
mailing list