diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2020-11-23 21:03:52 +0100 |
---|---|---|
committer | cgzones <cgzones@googlemail.com> | 2020-11-24 17:30:21 +0100 |
commit | 42c842c190912de58ccf3f41bd58c452c595e40d (patch) | |
tree | 34bafbbe80d13ce4dc367def34d161e3f6515672 /linux | |
parent | 95f553b10c3276c731bb7e3d9a917e9d98322e85 (diff) |
LinuxProcess_adjustTime: simplify by not using double
Does not work with -ffast-math else.
Diffstat (limited to 'linux')
-rw-r--r-- | linux/LinuxProcessList.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c index 7ef32e83..1cc0a274 100644 --- a/linux/LinuxProcessList.c +++ b/linux/LinuxProcessList.c @@ -292,18 +292,16 @@ void ProcessList_delete(ProcessList* pl) { } static inline unsigned long long LinuxProcess_adjustTime(unsigned long long t) { - static double jiffy = NAN; - if (isnan(jiffy)) { + static long jiffy = -1; + if (jiffy == -1) { errno = 0; - long sc_jiffy = sysconf(_SC_CLK_TCK); - if (errno || -1 == sc_jiffy) { - jiffy = NAN; + jiffy = sysconf(_SC_CLK_TCK); + if (errno || -1 == jiffy) { + jiffy = -1; return t; // Assume 100Hz clock } - jiffy = sc_jiffy; } - double jiffytime = 1.0 / jiffy; - return t * jiffytime * 100; + return t * 100 / jiffy; } static bool LinuxProcessList_readStatFile(Process* process, const char* dirname, const char* name, char* command, int* commLen) { |