summaryrefslogtreecommitdiff
path: root/rts/posix
diff options
context:
space:
mode:
authorDuncan Coutts <duncan@well-typed.com>2011-10-25 18:41:46 +0100
committerDuncan Coutts <duncan@well-typed.com>2011-10-26 12:00:42 +0100
commitece21ea00b8681b09c9eedbebbac1af764864367 (patch)
treec46d45e42baf9cad94ed2eb40e34865830ef7d60 /rts/posix
parent17c166232cf2a547a9b0a4fce5f38307ae64f157 (diff)
downloadhaskell-ece21ea00b8681b09c9eedbebbac1af764864367.tar.gz
Add rts time util getUnixEpochTime
The other existing time utilities give us time elapsed since process or thread start. This is for wall clock time, using the common Unix epoch interpretation.
Diffstat (limited to 'rts/posix')
-rw-r--r--rts/posix/GetTime.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/rts/posix/GetTime.c b/rts/posix/GetTime.c
index 15643b8319..eab7177fe5 100644
--- a/rts/posix/GetTime.c
+++ b/rts/posix/GetTime.c
@@ -181,6 +181,22 @@ Ticks getThreadCPUTime(void)
return getProcessCPUTime();
}
+void getUnixEpochTime(StgWord64 *sec, StgWord32 *nsec)
+{
+#if defined(HAVE_GETTIMEOFDAY)
+ struct timeval tv;
+ gettimeofday(&tv, (struct timezone *) NULL);
+ *sec = tv.tv_sec;
+ *nsec = tv.tv_usec * 1000;
+#else
+ /* Sigh, fall back to second resolution. */
+ time_t t;
+ time(&t);
+ *sec = t;
+ *nsec = 0;
+#endif
+}
+
nat
getPageFaults(void)
{