diff options
author | Daniel Lange <DLange@git.local> | 2024-01-10 12:40:37 +0100 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2024-01-10 12:40:37 +0100 |
commit | 7271b076b82785ffca73ee9e4ae84cabb77018ee (patch) | |
tree | e8270dd60ec096bee8157dbadf029e15ed584592 /dragonflybsd/Platform.c | |
parent | f288666edc9180a2e81e6655951878124f321df6 (diff) | |
download | debian_htop-7271b076b82785ffca73ee9e4ae84cabb77018ee.tar.gz debian_htop-7271b076b82785ffca73ee9e4ae84cabb77018ee.tar.bz2 debian_htop-7271b076b82785ffca73ee9e4ae84cabb77018ee.zip |
New upstream version 3.3.0upstream/3.3.0upstream
Diffstat (limited to 'dragonflybsd/Platform.c')
-rw-r--r-- | dragonflybsd/Platform.c | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/dragonflybsd/Platform.c b/dragonflybsd/Platform.c index 8a684d8..25afa8b 100644 --- a/dragonflybsd/Platform.c +++ b/dragonflybsd/Platform.c @@ -6,6 +6,8 @@ Released under the GNU GPLv2+, see the COPYING file in the source distribution for its full text. */ +#include "config.h" // IWYU pragma: keep + #include "dragonflybsd/Platform.h" #include <math.h> @@ -20,17 +22,22 @@ in the source distribution for its full text. #include "CPUMeter.h" #include "DateMeter.h" #include "DateTimeMeter.h" +#include "FileDescriptorMeter.h" #include "HostnameMeter.h" #include "LoadAverageMeter.h" +#include "Macros.h" #include "MemoryMeter.h" #include "MemorySwapMeter.h" -#include "ProcessList.h" +#include "ProcessTable.h" #include "SwapMeter.h" #include "SysArchMeter.h" #include "TasksMeter.h" #include "UptimeMeter.h" +#include "XUtils.h" #include "dragonflybsd/DragonFlyBSDProcess.h" -#include "dragonflybsd/DragonFlyBSDProcessList.h" +#include "dragonflybsd/DragonFlyBSDProcessTable.h" +#include "generic/fdstat_sysctl.h" + const ScreenDefaults Platform_defaultScreens[] = { { @@ -108,6 +115,7 @@ const MeterClass* const Platform_meterTypes[] = { &RightCPUs4Meter_class, &LeftCPUs8Meter_class, &RightCPUs8Meter_class, + &FileDescriptorMeter_class, &BlankMeter_class, NULL }; @@ -157,7 +165,7 @@ void Platform_getLoadAverage(double* one, double* five, double* fifteen) { *fifteen = (double) loadAverage.ldavg[2] / loadAverage.fscale; } -int Platform_getMaxPid(void) { +pid_t Platform_getMaxPid(void) { int maxPid; size_t size = sizeof(maxPid); int err = sysctlbyname("kern.pid_max", &maxPid, &size, NULL, 0); @@ -168,15 +176,16 @@ int Platform_getMaxPid(void) { } double Platform_setCPUValues(Meter* this, unsigned int cpu) { - const DragonFlyBSDProcessList* fpl = (const DragonFlyBSDProcessList*) this->pl; - unsigned int cpus = this->pl->activeCPUs; + const Machine* host = this->host; + const DragonFlyBSDMachine* dhost = (const DragonFlyBSDMachine*) host; + unsigned int cpus = host->activeCPUs; const CPUData* cpuData; if (cpus == 1) { // single CPU box has everything in fpl->cpus[0] - cpuData = &(fpl->cpus[0]); + cpuData = &(dhost->cpus[0]); } else { - cpuData = &(fpl->cpus[cpu]); + cpuData = &(dhost->cpus[cpu]); } double percent; @@ -184,18 +193,17 @@ double Platform_setCPUValues(Meter* this, unsigned int cpu) { v[CPU_METER_NICE] = cpuData->nicePercent; v[CPU_METER_NORMAL] = cpuData->userPercent; - if (this->pl->settings->detailedCPUTime) { + if (super->settings->detailedCPUTime) { v[CPU_METER_KERNEL] = cpuData->systemPercent; v[CPU_METER_IRQ] = cpuData->irqPercent; this->curItems = 4; - percent = v[0] + v[1] + v[2] + v[3]; } else { - v[2] = cpuData->systemAllPercent; + v[CPU_METER_KERNEL] = cpuData->systemAllPercent; this->curItems = 3; - percent = v[0] + v[1] + v[2]; } - percent = isnan(percent) ? 0.0 : CLAMP(percent, 0.0, 100.0); + percent = sumPositiveValues(v, this->curItems); + percent = MINIMUM(percent, 100.0); v[CPU_METER_FREQUENCY] = NAN; v[CPU_METER_TEMPERATURE] = NAN; @@ -204,22 +212,23 @@ double Platform_setCPUValues(Meter* this, unsigned int cpu) { } void Platform_setMemoryValues(Meter* this) { - // TODO - const ProcessList* pl = this->pl; + const Machine* host = this->host; - this->total = pl->totalMem; - this->values[MEMORY_METER_USED] = pl->usedMem; - this->values[MEMORY_METER_BUFFERS] = pl->buffersMem; + this->total = host->totalMem; + this->values[MEMORY_METER_USED] = host->usedMem; // this->values[MEMORY_METER_SHARED] = "shared memory, like tmpfs and shm" - this->values[MEMORY_METER_CACHE] = pl->cachedMem; + // this->values[MEMORY_METER_COMPRESSED] = "compressed memory, like zswap on linux" + this->values[MEMORY_METER_BUFFERS] = host->buffersMem; + this->values[MEMORY_METER_CACHE] = host->cachedMem; // this->values[MEMORY_METER_AVAILABLE] = "available memory" } void Platform_setSwapValues(Meter* this) { - const ProcessList* pl = this->pl; - this->total = pl->totalSwap; - this->values[SWAP_METER_USED] = pl->usedSwap; - this->values[SWAP_METER_CACHE] = NAN; + const Machine* host = this->host; + this->total = host->totalSwap; + this->values[SWAP_METER_USED] = host->usedSwap; + // mtr->values[SWAP_METER_CACHE] = "pages that are both in swap and RAM, like SwapCached on linux" + // mtr->values[SWAP_METER_FRONTSWAP] = "pages that are accounted to swap but stored elsewhere, like frontswap on linux" } char* Platform_getProcessEnv(pid_t pid) { @@ -233,6 +242,10 @@ FileLocks_ProcessData* Platform_getProcessLocks(pid_t pid) { return NULL; } +void Platform_getFileDescriptors(double* used, double* max) { + Generic_getFileDescriptors_sysctl(used, max); +} + bool Platform_getDiskIO(DiskIOData* data) { // TODO (void)data; |