summaryrefslogtreecommitdiffstats
path: root/Compat.c
diff options
context:
space:
mode:
authorNathan Scott <nathans@redhat.com>2021-03-30 15:55:48 +1100
committerSohaib <sohaib.amhmd@gmail.com>2021-04-05 23:41:07 +0200
commit356488aa53e8c0bedeb7641685d931c8900098c5 (patch)
treec09f2df8264cc4075b72a55409ae261c021cda55 /Compat.c
parent421bdeec603b4fb1a4edec0e802c437fbe47fca0 (diff)
Request the realtime and monotonic clock times once per sample
Refactor the sample time code to make one call to gettimeofday (aka the realtime clock in clock_gettime, when available) and one to the monotonic clock. Stores each in more appropriately named ProcessList fields for ready access when needed. Every platform gets the opportunity to provide their own clock code, and the existing Mac OS X specific code is moved below darwin instead of in Compat. A couple of leftover time(2) calls are converted to use these ProcessList fields as well, instead of yet again sampling the system clock. Related to https://github.com/htop-dev/htop/pull/574
Diffstat (limited to 'Compat.c')
-rw-r--r--Compat.c34
1 files changed, 0 insertions, 34 deletions
diff --git a/Compat.c b/Compat.c
index 55be1b1d..43d02ec7 100644
--- a/Compat.c
+++ b/Compat.c
@@ -11,18 +11,12 @@ in the source distribution for its full text.
#include <errno.h>
#include <fcntl.h> // IWYU pragma: keep
-#include <time.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h> // IWYU pragma: keep
#include "XUtils.h" // IWYU pragma: keep
-#ifdef HAVE_HOST_GET_CLOCK_SERVICE
-#include <mach/clock.h>
-#include <mach/mach.h>
-#endif
-
int Compat_faccessat(int dirfd,
const char* pathname,
@@ -123,31 +117,3 @@ ssize_t Compat_readlinkat(int dirfd,
#endif
}
-
-int Compat_clock_monotonic_gettime(struct timespec *tp) {
-
-#if defined(HAVE_CLOCK_GETTIME)
-
- return clock_gettime(CLOCK_MONOTONIC, tp);
-
-#elif defined(HAVE_HOST_GET_CLOCK_SERVICE)
-
- clock_serv_t cclock;
- mach_timespec_t mts;
-
- host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cclock);
- clock_get_time(cclock, &mts);
- mach_port_deallocate(mach_task_self(), cclock);
-
- tp->tv_sec = mts.tv_sec;
- tp->tv_nsec = mts.tv_nsec;
-
- return 0;
-
-#else
-
-#error No Compat_clock_monotonic_gettime() implementation!
-
-#endif
-
-}

© 2014-2024 Faster IT GmbH | imprint | privacy policy