aboutsummaryrefslogtreecommitdiffstats
path: root/darwin
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2023-02-05 04:25:56 +0100
committerDaniel Lange <DLange@git.local>2023-02-05 04:25:56 +0100
commitf288666edc9180a2e81e6655951878124f321df6 (patch)
treeda70bf44b2423f6f8e9a070c063fed79d190b489 /darwin
parent937052b231259a47d881d539ad5748245ef55b99 (diff)
downloaddebian_htop-f288666edc9180a2e81e6655951878124f321df6.tar.gz
debian_htop-f288666edc9180a2e81e6655951878124f321df6.tar.bz2
debian_htop-f288666edc9180a2e81e6655951878124f321df6.zip
New upstream version 3.2.2upstream/3.2.2
Diffstat (limited to 'darwin')
-rw-r--r--darwin/DarwinProcess.c2
-rw-r--r--darwin/DarwinProcessList.c3
-rw-r--r--darwin/Platform.c22
-rw-r--r--darwin/Platform.h18
-rw-r--r--darwin/PlatformHelpers.c9
-rw-r--r--darwin/PlatformHelpers.h2
6 files changed, 29 insertions, 27 deletions
diff --git a/darwin/DarwinProcess.c b/darwin/DarwinProcess.c
index d0204dd..6027c25 100644
--- a/darwin/DarwinProcess.c
+++ b/darwin/DarwinProcess.c
@@ -282,7 +282,7 @@ static char* DarwinProcess_getDevname(dev_t dev) {
return NULL;
}
char buf[sizeof("/dev/") + MAXNAMLEN];
- char *name = devname_r(dev, S_IFCHR, buf, MAXNAMLEN);
+ char* name = devname_r(dev, S_IFCHR, buf, MAXNAMLEN);
if (name) {
return xStrdup(name);
}
diff --git a/darwin/DarwinProcessList.c b/darwin/DarwinProcessList.c
index bd7821b..dae588b 100644
--- a/darwin/DarwinProcessList.c
+++ b/darwin/DarwinProcessList.c
@@ -68,12 +68,13 @@ static struct kinfo_proc* ProcessList_getKInfoProcs(size_t* count) {
int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0 };
struct kinfo_proc* processes = NULL;
- for (int retry = 3; retry > 0; retry--) {
+ for (unsigned int retry = 0; retry < 4; retry++) {
size_t size = 0;
if (sysctl(mib, 4, NULL, &size, NULL, 0) < 0 || size == 0) {
CRT_fatalError("Unable to get size of kproc_infos");
}
+ size += 16 * retry * retry * sizeof(struct kinfo_proc);
processes = xRealloc(processes, size);
if (sysctl(mib, 4, processes, &size, NULL, 0) == 0) {
diff --git a/darwin/Platform.c b/darwin/Platform.c
index 4b34d88..332752b 100644
--- a/darwin/Platform.c
+++ b/darwin/Platform.c
@@ -172,7 +172,7 @@ void Platform_setBindings(Htop_Action* keys) {
(void) keys;
}
-int Platform_getUptime() {
+int Platform_getUptime(void) {
struct timeval bootTime, currTime;
int mib[2] = { CTL_KERN, KERN_BOOTTIME };
size_t size = sizeof(bootTime);
@@ -200,7 +200,7 @@ void Platform_getLoadAverage(double* one, double* five, double* fifteen) {
}
}
-int Platform_getMaxPid() {
+int Platform_getMaxPid(void) {
/* http://opensource.apple.com/source/xnu/xnu-2782.1.97/bsd/sys/proc_internal.hh */
return 99999;
}
@@ -264,11 +264,11 @@ void Platform_setMemoryValues(Meter* mtr) {
double page_K = (double)vm_page_size / (double)1024;
mtr->total = dpl->host_info.max_mem / 1024;
- mtr->values[0] = (double)(vm->active_count + vm->wire_count) * page_K;
- mtr->values[1] = (double)vm->purgeable_count * page_K;
- // mtr->values[2] = "shared memory, like tmpfs and shm"
- mtr->values[3] = (double)vm->inactive_count * page_K;
- // mtr->values[4] = "available memory"
+ mtr->values[MEMORY_METER_USED] = (double)(vm->active_count + vm->wire_count) * page_K;
+ mtr->values[MEMORY_METER_BUFFERS] = (double)vm->purgeable_count * page_K;
+ // mtr->values[MEMORY_METER_SHARED] = "shared memory, like tmpfs and shm"
+ mtr->values[MEMORY_METER_CACHE] = (double)vm->inactive_count * page_K;
+ // mtr->values[MEMORY_METER_AVAILABLE] = "available memory"
}
void Platform_setSwapValues(Meter* mtr) {
@@ -278,7 +278,7 @@ void Platform_setSwapValues(Meter* mtr) {
sysctl(mib, 2, &swapused, &swlen, NULL, 0);
mtr->total = swapused.xsu_total / 1024;
- mtr->values[0] = swapused.xsu_used / 1024;
+ mtr->values[SWAP_METER_USED] = swapused.xsu_used / 1024;
}
void Platform_setZfsArcValues(Meter* this) {
@@ -344,12 +344,6 @@ char* Platform_getProcessEnv(pid_t pid) {
return env;
}
-char* Platform_getInodeFilename(pid_t pid, ino_t inode) {
- (void)pid;
- (void)inode;
- return NULL;
-}
-
FileLocks_ProcessData* Platform_getProcessLocks(pid_t pid) {
(void)pid;
return NULL;
diff --git a/darwin/Platform.h b/darwin/Platform.h
index 4f8e7c9..6636207 100644
--- a/darwin/Platform.h
+++ b/darwin/Platform.h
@@ -68,8 +68,6 @@ void Platform_setZfsCompressedArcValues(Meter* this);
char* Platform_getProcessEnv(pid_t pid);
-char* Platform_getInodeFilename(pid_t pid, ino_t inode);
-
FileLocks_ProcessData* Platform_getProcessLocks(pid_t pid);
bool Platform_getDiskIO(DiskIOData* data);
@@ -100,7 +98,9 @@ static inline void Platform_gettime_realtime(struct timeval* tv, uint64_t* msec)
void Platform_gettime_monotonic(uint64_t* msec);
-static inline Hashtable* Platform_dynamicMeters(void) { return NULL; }
+static inline Hashtable* Platform_dynamicMeters(void) {
+ return NULL;
+}
static inline void Platform_dynamicMetersDone(ATTR_UNUSED Hashtable* table) { }
@@ -110,12 +110,18 @@ static inline void Platform_dynamicMeterUpdateValues(ATTR_UNUSED Meter* meter) {
static inline void Platform_dynamicMeterDisplay(ATTR_UNUSED const Meter* meter, ATTR_UNUSED RichString* out) { }
-static inline Hashtable* Platform_dynamicColumns(void) { return NULL; }
+static inline Hashtable* Platform_dynamicColumns(void) {
+ return NULL;
+}
static inline void Platform_dynamicColumnsDone(ATTR_UNUSED Hashtable* table) { }
-static inline const char* Platform_dynamicColumnInit(ATTR_UNUSED unsigned int key) { return NULL; }
+static inline const char* Platform_dynamicColumnInit(ATTR_UNUSED unsigned int key) {
+ return NULL;
+}
-static inline bool Platform_dynamicColumnWriteField(ATTR_UNUSED const Process* proc, ATTR_UNUSED RichString* str, ATTR_UNUSED unsigned int key) { return false; }
+static inline bool Platform_dynamicColumnWriteField(ATTR_UNUSED const Process* proc, ATTR_UNUSED RichString* str, ATTR_UNUSED unsigned int key) {
+ return false;
+}
#endif
diff --git a/darwin/PlatformHelpers.c b/darwin/PlatformHelpers.c
index bde9068..97f0741 100644
--- a/darwin/PlatformHelpers.c
+++ b/darwin/PlatformHelpers.c
@@ -58,7 +58,7 @@ bool Platform_KernelVersionIsBetween(KernelVersion lowerBound, KernelVersion upp
&& Platform_CompareKernelVersion(upperBound) < 0;
}
-void Platform_getCPUBrandString(char *cpuBrandString, size_t cpuBrandStringSize) {
+void Platform_getCPUBrandString(char* cpuBrandString, size_t cpuBrandStringSize) {
if (sysctlbyname("machdep.cpu.brand_string", cpuBrandString, &cpuBrandStringSize, NULL, 0) == -1) {
fprintf(stderr,
"WARN: Unable to determine the CPU brand string.\n"
@@ -69,12 +69,13 @@ void Platform_getCPUBrandString(char *cpuBrandString, size_t cpuBrandStringSize)
}
// Adapted from https://developer.apple.com/documentation/apple-silicon/about-the-rosetta-translation-environment
-bool Platform_isRunningTranslated() {
+bool Platform_isRunningTranslated(void) {
int ret = 0;
size_t size = sizeof(ret);
errno = 0;
if (sysctlbyname("sysctl.proc_translated", &ret, &size, NULL, 0) == -1) {
- if (errno == ENOENT) return false;
+ if (errno == ENOENT)
+ return false;
fprintf(stderr,
"WARN: Could not determine if this process was running in a translation environment like Rosetta 2.\n"
@@ -86,7 +87,7 @@ bool Platform_isRunningTranslated() {
return ret;
}
-double Platform_calculateNanosecondsPerMachTick() {
+double Platform_calculateNanosecondsPerMachTick(void) {
// Check if we can determine the timebase used on this system.
// If the API is unavailable assume we get our timebase in nanoseconds.
#ifndef HAVE_MACH_TIMEBASE_INFO
diff --git a/darwin/PlatformHelpers.h b/darwin/PlatformHelpers.h
index 07f3fe2..45aea1a 100644
--- a/darwin/PlatformHelpers.h
+++ b/darwin/PlatformHelpers.h
@@ -31,7 +31,7 @@ bool Platform_KernelVersionIsBetween(KernelVersion lowerBound, KernelVersion upp
double Platform_calculateNanosecondsPerMachTick(void);
-void Platform_getCPUBrandString(char *cpuBrandString, size_t cpuBrandStringSize);
+void Platform_getCPUBrandString(char* cpuBrandString, size_t cpuBrandStringSize);
bool Platform_isRunningTranslated(void);

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