summaryrefslogtreecommitdiff
path: root/rts/posix/GetTime.c
diff options
context:
space:
mode:
authorPaolo Capriotti <p.capriotti@gmail.com>2012-03-20 11:57:28 +0000
committerPaolo Capriotti <p.capriotti@gmail.com>2012-04-16 15:18:19 +0100
commit5ba7db93fb634ff8094f42780a14972322446a94 (patch)
tree7f460341d5e7aa16f8f6e361c5d2db74bd6c530b /rts/posix/GetTime.c
parent3377abeb6bd4623c5806936d0ee569d123c1aa59 (diff)
downloadhaskell-5ba7db93fb634ff8094f42780a14972322446a94.tar.gz
Use monotonic clock in Select.c (#5865)
Diffstat (limited to 'rts/posix/GetTime.c')
-rw-r--r--rts/posix/GetTime.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/rts/posix/GetTime.c b/rts/posix/GetTime.c
index 16511ce2e2..4abc82f6b9 100644
--- a/rts/posix/GetTime.c
+++ b/rts/posix/GetTime.c
@@ -11,23 +11,12 @@
#include "Rts.h"
#include "GetTime.h"
-
-#ifdef HAVE_TIME_H
-# include <time.h>
-#endif
-
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#endif
+#include "Clock.h"
#if HAVE_SYS_RESOURCE_H
# include <sys/resource.h>
#endif
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
#ifdef HAVE_SYS_TIMES_H
# include <sys/times.h>
#endif
@@ -77,9 +66,17 @@ Time getProcessCPUTime(void)
Time getProcessElapsedTime(void)
{
+#ifdef HAVE_CLOCK_GETTIME
+ struct timespec ts;
+
+ clock_gettime(CLOCK_ID, &ts);
+ return SecondsToTime(ts.tv_sec) + NSToTime(ts.tv_nsec);
+#else
struct timeval tv;
+
gettimeofday(&tv, (struct timezone *) NULL);
return SecondsToTime(tv.tv_sec) + USToTime(tv.tv_usec);
+#endif
}
void getProcessTimes(Time *user, Time *elapsed)