From 508d9ce5dcda45a33bd31d49cab19566c9cdcc89 Mon Sep 17 00:00:00 2001 From: Ximalas Date: Tue, 9 May 2023 12:48:49 +0200 Subject: Build fixes for FreeBSD Part of a series of changes to get rid of errors and warnings. --- freebsd/FreeBSDMachine.c | 6 +++--- freebsd/FreeBSDMachine.h | 4 ++-- freebsd/FreeBSDProcessList.c | 11 ++++++----- freebsd/Platform.c | 8 ++++---- 4 files changed, 15 insertions(+), 14 deletions(-) (limited to 'freebsd') diff --git a/freebsd/FreeBSDMachine.c b/freebsd/FreeBSDMachine.c index b8d5d87f..26da667a 100644 --- a/freebsd/FreeBSDMachine.c +++ b/freebsd/FreeBSDMachine.c @@ -59,7 +59,7 @@ Machine* Machine_new(UsersTable* usersTable, uid_t userId) { char errbuf[_POSIX2_LINE_MAX]; size_t len; - Machine_init(this, usersTable, userId); + Machine_init(super, usersTable, userId); // physical memory in system: hw.physmem // physical page size: hw.pagesize @@ -146,13 +146,13 @@ Machine* Machine_new(UsersTable* usersTable, uid_t userId) { CRT_fatalError("kvm_openfiles() failed"); } - return this; + return super; } void Machine_delete(Machine* super) { FreeBSDMachine* this = (FreeBSDMachine*) super; - ProcessList_done(this); + Machine_done(super); if (this->kd) { kvm_close(this->kd); diff --git a/freebsd/FreeBSDMachine.h b/freebsd/FreeBSDMachine.h index 1a90534e..f34b568e 100644 --- a/freebsd/FreeBSDMachine.h +++ b/freebsd/FreeBSDMachine.h @@ -28,7 +28,7 @@ typedef struct CPUData_ { double temperature; } CPUData; -typedef struct FreeBSDProcessList_ { +typedef struct FreeBSDMachine_ { Machine super; kvm_t* kd; @@ -49,6 +49,6 @@ typedef struct FreeBSDProcessList_ { unsigned long* cp_times_o; unsigned long* cp_times_n; -} FreeBSDProcessList; +} FreeBSDMachine; #endif diff --git a/freebsd/FreeBSDProcessList.c b/freebsd/FreeBSDProcessList.c index 1cf32502..d8d4bbe0 100644 --- a/freebsd/FreeBSDProcessList.c +++ b/freebsd/FreeBSDProcessList.c @@ -29,7 +29,6 @@ in the source distribution for its full text. #include "CRT.h" #include "Compat.h" -#include "FreeBSDProcess.h" #include "Macros.h" #include "Object.h" #include "Process.h" @@ -38,6 +37,9 @@ in the source distribution for its full text. #include "Settings.h" #include "XUtils.h" +#include "freebsd/FreeBSDMachine.h" +#include "freebsd/FreeBSDProcess.h" + ProcessList* ProcessList_new(Machine* host, Hashtable* pidMatchList) { FreeBSDProcessList* this = xCalloc(1, sizeof(FreeBSDProcessList)); @@ -45,7 +47,7 @@ ProcessList* ProcessList_new(Machine* host, Hashtable* pidMatchList) { ProcessList_init(super, Class(FreeBSDProcess), host, pidMatchList); - return this; + return super; } void ProcessList_delete(ProcessList* super) { @@ -156,14 +158,13 @@ IGNORE_WCASTQUAL_END void ProcessList_goThroughEntries(ProcessList* super) { const Machine* host = super->host; - const FreeBSDMachine* fhost = (FreeBSDMachine*) host; - FreeBSDProcessList* fpl = (FreeBSDProcessList*) super; + const FreeBSDMachine* fhost = (const FreeBSDMachine*) host; const Settings* settings = host->settings; bool hideKernelThreads = settings->hideKernelThreads; bool hideUserlandThreads = settings->hideUserlandThreads; int count = 0; - const struct kinfo_proc* kprocs = kvm_getprocs(fpl->kd, KERN_PROC_PROC, 0, &count); + const struct kinfo_proc* kprocs = kvm_getprocs(fhost->kd, KERN_PROC_PROC, 0, &count); for (int i = 0; i < count; i++) { const struct kinfo_proc* kproc = &kprocs[i]; diff --git a/freebsd/Platform.c b/freebsd/Platform.c index 0588b0fa..a2dc072c 100644 --- a/freebsd/Platform.c +++ b/freebsd/Platform.c @@ -209,7 +209,7 @@ double Platform_setCPUValues(Meter* this, unsigned int cpu) { v[CPU_METER_NICE] = cpuData->nicePercent; v[CPU_METER_NORMAL] = cpuData->userPercent; - if (super->settings->detailedCPUTime) { + if (host->settings->detailedCPUTime) { v[CPU_METER_KERNEL] = cpuData->systemPercent; v[CPU_METER_IRQ] = cpuData->irqPercent; this->curItems = 4; @@ -240,11 +240,11 @@ void Platform_setMemoryValues(Meter* this) { this->values[MEMORY_METER_CACHE] = host->cachedMem; // this->values[MEMORY_METER_AVAILABLE] = "available memory" - if (dhost->zfs.enabled) { + if (fhost->zfs.enabled) { // ZFS does not shrink below the value of zfs_arc_min. unsigned long long int shrinkableSize = 0; - if (dhost->zfs.size > dhost->zfs.min) - shrinkableSize = dhost->zfs.size - dhost->zfs.min; + if (fhost->zfs.size > fhost->zfs.min) + shrinkableSize = fhost->zfs.size - fhost->zfs.min; this->values[MEMORY_METER_USED] -= shrinkableSize; this->values[MEMORY_METER_CACHE] += shrinkableSize; // this->values[MEMORY_METER_AVAILABLE] += shrinkableSize; -- cgit v1.2.3