From 42c842c190912de58ccf3f41bd58c452c595e40d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Mon, 23 Nov 2020 21:03:52 +0100 Subject: [PATCH] LinuxProcess_adjustTime: simplify by not using double Does not work with -ffast-math else. --- linux/LinuxProcessList.c | 14 ++++++-------- 1 file 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) {