Skip to content

Commit

Permalink
Build fixes for FreeBSD
Browse files Browse the repository at this point in the history
Part of a series of changes to get rid of errors and warnings.
  • Loading branch information
Ximalas authored and BenBE committed May 9, 2023
1 parent e40daf9 commit 508d9ce
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
6 changes: 3 additions & 3 deletions freebsd/FreeBSDMachine.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions freebsd/FreeBSDMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ typedef struct CPUData_ {
double temperature;
} CPUData;

typedef struct FreeBSDProcessList_ {
typedef struct FreeBSDMachine_ {
Machine super;
kvm_t* kd;

Expand All @@ -49,6 +49,6 @@ typedef struct FreeBSDProcessList_ {
unsigned long* cp_times_o;
unsigned long* cp_times_n;

} FreeBSDProcessList;
} FreeBSDMachine;

#endif
11 changes: 6 additions & 5 deletions freebsd/FreeBSDProcessList.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -38,14 +37,17 @@ 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));
ProcessList* super = &this->super;

ProcessList_init(super, Class(FreeBSDProcess), host, pidMatchList);

return this;
return super;
}

void ProcessList_delete(ProcessList* super) {
Expand Down Expand Up @@ -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];
Expand Down
8 changes: 4 additions & 4 deletions freebsd/Platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 508d9ce

Please sign in to comment.