projects
/
ghc-hetmet.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
cf570a3
)
Handle clock_gettime failing
author
Ian Lynagh
<igloo@earth.li>
Wed, 27 Sep 2006 23:46:30 +0000
(23:46 +0000)
committer
Ian Lynagh
<igloo@earth.li>
Wed, 27 Sep 2006 23:46:30 +0000
(23:46 +0000)
rts/posix/GetTime.c
patch
|
blob
|
history
diff --git
a/rts/posix/GetTime.c
b/rts/posix/GetTime.c
index
0e591ef
..
a2d9a31
100644
(file)
--- a/
rts/posix/GetTime.c
+++ b/
rts/posix/GetTime.c
@@
-44,7
+44,7
@@
Ticks getProcessCPUTime(void)
{
struct rusage t;
getrusage(RUSAGE_SELF, &t);
{
struct rusage t;
getrusage(RUSAGE_SELF, &t);
- return ((Ticks)t.ru_utime.tv_sec * TICKS_PER_SECOND +
+ return ((Ticks)t.ru_utime.tv_sec * TICKS_PER_SECOND +
((Ticks)t.ru_utime.tv_usec * TICKS_PER_SECOND)/1000000);
}
((Ticks)t.ru_utime.tv_usec * TICKS_PER_SECOND)/1000000);
}
@@
-119,12
+119,14
@@
Ticks getThreadCPUTime(void)
// clock_gettime() gives us per-thread CPU time. It isn't
// reliable on Linux, but it's the best we have.
struct timespec ts;
// clock_gettime() gives us per-thread CPU time. It isn't
// reliable on Linux, but it's the best we have.
struct timespec ts;
- clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts);
- return ((Ticks)ts.tv_sec * TICKS_PER_SECOND +
- ((Ticks)ts.tv_nsec * TICKS_PER_SECOND) / 1000000000);
-#else
- return getProcessCPUTime();
+ int res;
+ res = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts);
+ if (res == 0) {
+ return ((Ticks)ts.tv_sec * TICKS_PER_SECOND +
+ ((Ticks)ts.tv_nsec * TICKS_PER_SECOND) / 1000000000);
+ }
#endif
#endif
+ return getProcessCPUTime();
}
nat
}
nat