summaryrefslogtreecommitdiff
path: root/rts/posix
diff options
context:
space:
mode:
authorPHO <pho@cielonegro.org>2021-05-05 15:51:22 +0900
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-05-06 02:32:44 -0400
commite57783654ed9a5d16afddddbaa555778993e81b8 (patch)
tree19653f0d287651d5e63abafe39f0bedcaf7ca2af /rts/posix
parent1635d5c229a3ea0bc8e0ee862948cda2c435221a (diff)
downloadhaskell-e57783654ed9a5d16afddddbaa555778993e81b8.tar.gz
rts/posix/GetTime.c: Use Solaris-specific gethrvtime(3) on OpenSolaris derivatives
The constant CLOCK_THREAD_CPUTIME_ID is defined in a system header but it isn't acutally usable. clock_gettime(2) always returns EINVAL.
Diffstat (limited to 'rts/posix')
-rw-r--r--rts/posix/GetTime.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/rts/posix/GetTime.c b/rts/posix/GetTime.c
index 7d53f95401..fa6f70f73c 100644
--- a/rts/posix/GetTime.c
+++ b/rts/posix/GetTime.c
@@ -32,6 +32,10 @@
#include <mach/mach_port.h>
#endif
+#if defined(solaris2_HOST_OS)
+#include <sys/time.h>
+#endif
+
#if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_GETRUSAGE)
// we'll implement getProcessCPUTime() and getProcessElapsedTime()
// separately, using getrusage() and gettimeofday() respectively
@@ -81,6 +85,12 @@ Time getCurrentThreadCPUTime(void)
sysErrorBelch("getThreadCPUTime");
stg_exit(EXIT_FAILURE);
}
+#elif defined(solaris2_HOST_OS)
+ // On OpenSolaris derivatives, the constant CLOCK_THREAD_CPUTIME_ID is
+ // defined in a system header but it isn't actually usable. clock_gettime(2)
+ // always returns EINVAL. Use solaris-specific gethrvtime(3) as an
+ // alternative.
+ return NSToTime(gethrvtime());
#elif defined(HAVE_CLOCK_GETTIME) && \
defined(CLOCK_PROCESS_CPUTIME_ID) && \
defined(HAVE_SYSCONF)