diff options
author | PHO <pho@cielonegro.org> | 2021-05-05 15:51:22 +0900 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-05-06 02:32:44 -0400 |
commit | e57783654ed9a5d16afddddbaa555778993e81b8 (patch) | |
tree | 19653f0d287651d5e63abafe39f0bedcaf7ca2af /rts | |
parent | 1635d5c229a3ea0bc8e0ee862948cda2c435221a (diff) | |
download | haskell-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')
-rw-r--r-- | rts/posix/GetTime.c | 10 |
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) |