forked from cms-sw/cmsdist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
classlib-3.1.3-fix-obsolete-CLK_TCK.patch
49 lines (48 loc) · 2.06 KB
/
classlib-3.1.3-fix-obsolete-CLK_TCK.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
diff --git a/src/utils/TimeInfo.cpp b/src/utils/TimeInfo.cpp
index 1c29859..92ed42a 100644
--- a/src/utils/TimeInfo.cpp
+++ b/src/utils/TimeInfo.cpp
@@ -1,3 +1,4 @@
+#include <bits/types.h>
#include "classlib/utils/TimeInfo.h"
#include "classlib/utils/DebugAids.h"
@@ -295,7 +296,7 @@ TimeInfo::init (void)
if (pstat_getprocessor (&psp, sizeof(psp), 1, 0) != -1)
{
s_features |= FEATURE_EXACT_MHZ;
- s_ghz = psp.psp_iticksperclktick * sysconf(_SC_CLK_TCK) * 1e-9;
+ s_ghz = psp.psp_iticksperclktick * (__clock_t)sysconf(_SC_CLK_TCK) * 1e-9;
s_hiResFactor = 1e9 / s_ghz;
}
}
@@ -378,7 +379,7 @@ TimeInfo::time (void)
struct timespec now; clock_gettime (CLOCK_MONOTONIC, &now);
return (now.tv_sec * 1e9) + now.tv_nsec;
#elif _POSIX_VERSION > 0
- struct tms now; return times (&now) * (1e9 / CLK_TCK);
+ struct tms now; return times (&now) * (1e9 / (__clock_t)sysconf(_SC_CLK_TCK));
#else
// Do not use process-relative time: we probably can't measure real
// time anyway (only user + system), and even if we can, we'll end
@@ -426,7 +427,7 @@ TimeInfo::resolution (void)
struct timespec res; clock_getres (CLOCK_MONOTONIC, &res);
return (res.tv_sec * 1e9) + res.tv_nsec;
#elif _POSIX_VERSION > 0
- return 1e9 / CLK_TCK;
+ return 1e9 / (__clock_t)sysconf(_SC_CLK_TCK);
#else
return 1e9 / CLOCKS_PER_SEC;
#endif
@@ -843,9 +844,9 @@ TimeInfo::processTimes (NanoSecs &user, NanoSecs &system, NanoSecs &real)
//
// Note that on linux and hp-ux s_clockBase is precise. Other
// systems resort to estimated real time based on call to init.
- struct tms now; real = times (&now) * (1e9 / CLK_TCK);
- user = now.tms_utime * (1e9/CLK_TCK);
- system = now.tms_stime * (1e9/CLK_TCK);
+ struct tms now; real = times (&now) * (1e9 / (__clock_t)sysconf(_SC_CLK_TCK));
+ user = now.tms_utime * (1e9/(__clock_t)sysconf(_SC_CLK_TCK));
+ system = now.tms_stime * (1e9/(__clock_t)sysconf(_SC_CLK_TCK));
real -= s_clockBase;
#elif _WIN32
// Real time will be based on an estimate from call to init; the