summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2020-10-21 21:25:50 +0200
committercgzones <cgzones@googlemail.com>2020-10-26 19:30:38 +0100
commit72103e9613a4767a3aad2dd63c629f4a1384880c (patch)
treeec2424d702cb7009bd8d3584583659bd6b74485f
parentf757810f489b12d2a98dcb09751003f4ed002538 (diff)
Hold only a const version of the ProcessList in Meters
-rw-r--r--Meter.c2
-rw-r--r--Meter.h4
-rw-r--r--TasksMeter.c4
-rw-r--r--darwin/Platform.c18
-rw-r--r--dragonflybsd/Platform.c8
-rw-r--r--freebsd/Platform.c12
-rw-r--r--linux/Platform.c14
-rw-r--r--openbsd/Platform.c4
-rw-r--r--solaris/Platform.c12
-rw-r--r--zfs/ZfsArcMeter.c2
-rw-r--r--zfs/ZfsArcMeter.h2
-rw-r--r--zfs/ZfsCompressedArcMeter.c2
-rw-r--r--zfs/ZfsCompressedArcMeter.h2
13 files changed, 43 insertions, 43 deletions
diff --git a/Meter.c b/Meter.c
index fa1eacb4..a04a5832 100644
--- a/Meter.c
+++ b/Meter.c
@@ -31,7 +31,7 @@ const MeterClass Meter_class = {
}
};
-Meter* Meter_new(struct ProcessList_* pl, int param, const MeterClass* type) {
+Meter* Meter_new(const struct ProcessList_* pl, int param, const MeterClass* type) {
Meter* this = xCalloc(1, sizeof(Meter));
Object_setClass(this, type);
this->h = 1;
diff --git a/Meter.h b/Meter.h
index ab8ee6e4..32c167cb 100644
--- a/Meter.h
+++ b/Meter.h
@@ -74,7 +74,7 @@ struct Meter_ {
int param;
GraphData* drawData;
int h;
- ProcessList* pl;
+ const ProcessList* pl;
char curItems;
double* values;
double total;
@@ -98,7 +98,7 @@ typedef enum {
extern const MeterClass Meter_class;
-Meter* Meter_new(ProcessList* pl, int param, const MeterClass* type);
+Meter* Meter_new(const ProcessList* pl, int param, const MeterClass* type);
int Meter_humanUnit(char* buffer, unsigned long int value, int size);
diff --git a/TasksMeter.c b/TasksMeter.c
index 2116e322..562cc8fc 100644
--- a/TasksMeter.c
+++ b/TasksMeter.c
@@ -24,7 +24,7 @@ static const int TasksMeter_attributes[] = {
};
static void TasksMeter_updateValues(Meter* this, char* buffer, int len) {
- ProcessList* pl = this->pl;
+ const ProcessList* pl = this->pl;
this->values[0] = pl->kernelThreads;
this->values[1] = pl->userlandThreads;
this->values[2] = pl->totalTasks - pl->kernelThreads - pl->userlandThreads;
@@ -32,7 +32,7 @@ static void TasksMeter_updateValues(Meter* this, char* buffer, int len) {
if (pl->totalTasks > this->total) {
this->total = pl->totalTasks;
}
- if (this->pl->settings->hideKernelThreads) {
+ if (pl->settings->hideKernelThreads) {
this->values[0] = 0;
}
xSnprintf(buffer, len, "%d/%d", (int) this->values[3], (int) this->total);
diff --git a/darwin/Platform.c b/darwin/Platform.c
index 1a8b8002..965da0a1 100644
--- a/darwin/Platform.c
+++ b/darwin/Platform.c
@@ -176,8 +176,8 @@ ProcessPidColumn Process_pidColumns[] = {
};
static double Platform_setCPUAverageValues(Meter* mtr) {
- DarwinProcessList *dpl = (DarwinProcessList *)mtr->pl;
- int cpus = dpl->super.cpuCount;
+ const ProcessList *dpl = mtr->pl;
+ int cpus = dpl->cpuCount;
double sumNice = 0.0;
double sumNormal = 0.0;
double sumKernel = 0.0;
@@ -200,9 +200,9 @@ double Platform_setCPUValues(Meter* mtr, int cpu) {
return Platform_setCPUAverageValues(mtr);
}
- DarwinProcessList *dpl = (DarwinProcessList *)mtr->pl;
- processor_cpu_load_info_t prev = &dpl->prev_load[cpu-1];
- processor_cpu_load_info_t curr = &dpl->curr_load[cpu-1];
+ const DarwinProcessList *dpl = (const DarwinProcessList *)mtr->pl;
+ const processor_cpu_load_info_t prev = &dpl->prev_load[cpu-1];
+ const processor_cpu_load_info_t curr = &dpl->curr_load[cpu-1];
double total = 0;
/* Take the sums */
@@ -228,8 +228,8 @@ double Platform_setCPUValues(Meter* mtr, int cpu) {
}
void Platform_setMemoryValues(Meter* mtr) {
- DarwinProcessList *dpl = (DarwinProcessList *)mtr->pl;
- vm_statistics_t vm = &dpl->vm_stats;
+ const DarwinProcessList *dpl = (const DarwinProcessList *)mtr->pl;
+ const struct vm_statistics* vm = &dpl->vm_stats;
double page_K = (double)vm_page_size / (double)1024;
mtr->total = dpl->host_info.max_mem / 1024;
@@ -249,13 +249,13 @@ void Platform_setSwapValues(Meter* mtr) {
}
void Platform_setZfsArcValues(Meter* this) {
- DarwinProcessList* dpl = (DarwinProcessList*) this->pl;
+ const DarwinProcessList* dpl = (const DarwinProcessList*) this->pl;
ZfsArcMeter_readStats(this, &(dpl->zfs));
}
void Platform_setZfsCompressedArcValues(Meter* this) {
- DarwinProcessList* dpl = (DarwinProcessList*) this->pl;
+ const DarwinProcessList* dpl = (const DarwinProcessList*) this->pl;
ZfsCompressedArcMeter_readStats(this, &(dpl->zfs));
}
diff --git a/dragonflybsd/Platform.c b/dragonflybsd/Platform.c
index f01749b7..3eac7deb 100644
--- a/dragonflybsd/Platform.c
+++ b/dragonflybsd/Platform.c
@@ -149,9 +149,9 @@ int Platform_getMaxPid() {
}
double Platform_setCPUValues(Meter* this, int cpu) {
- DragonFlyBSDProcessList* fpl = (DragonFlyBSDProcessList*) this->pl;
+ const DragonFlyBSDProcessList* fpl = (const DragonFlyBSDProcessList*) this->pl;
int cpus = this->pl->cpuCount;
- CPUData* cpuData;
+ const CPUData* cpuData;
if (cpus == 1) {
// single CPU box has everything in fpl->cpus[0]
@@ -186,7 +186,7 @@ double Platform_setCPUValues(Meter* this, int cpu) {
void Platform_setMemoryValues(Meter* this) {
// TODO
- ProcessList* pl = (ProcessList*) this->pl;
+ const ProcessList* pl = this->pl;
this->total = pl->totalMem;
this->values[0] = pl->usedMem;
@@ -195,7 +195,7 @@ void Platform_setMemoryValues(Meter* this) {
}
void Platform_setSwapValues(Meter* this) {
- ProcessList* pl = (ProcessList*) this->pl;
+ const ProcessList* pl = this->pl;
this->total = pl->totalSwap;
this->values[0] = pl->usedSwap;
}
diff --git a/freebsd/Platform.c b/freebsd/Platform.c
index 465781a8..0a27f7c4 100644
--- a/freebsd/Platform.c
+++ b/freebsd/Platform.c
@@ -157,9 +157,9 @@ int Platform_getMaxPid() {
}
double Platform_setCPUValues(Meter* this, int cpu) {
- FreeBSDProcessList* fpl = (FreeBSDProcessList*) this->pl;
+ const FreeBSDProcessList* fpl = (const FreeBSDProcessList*) this->pl;
int cpus = this->pl->cpuCount;
- CPUData* cpuData;
+ const CPUData* cpuData;
if (cpus == 1) {
// single CPU box has everything in fpl->cpus[0]
@@ -194,7 +194,7 @@ double Platform_setCPUValues(Meter* this, int cpu) {
void Platform_setMemoryValues(Meter* this) {
// TODO
- ProcessList* pl = (ProcessList*) this->pl;
+ const ProcessList* pl = this->pl;
this->total = pl->totalMem;
this->values[0] = pl->usedMem;
@@ -203,19 +203,19 @@ void Platform_setMemoryValues(Meter* this) {
}
void Platform_setSwapValues(Meter* this) {
- ProcessList* pl = (ProcessList*) this->pl;
+ const ProcessList* pl = this->pl;
this->total = pl->totalSwap;
this->values[0] = pl->usedSwap;
}
void Platform_setZfsArcValues(Meter* this) {
- FreeBSDProcessList* fpl = (FreeBSDProcessList*) this->pl;
+ const FreeBSDProcessList* fpl = (const FreeBSDProcessList*) this->pl;
ZfsArcMeter_readStats(this, &(fpl->zfs));
}
void Platform_setZfsCompressedArcValues(Meter* this) {
- FreeBSDProcessList* fpl = (FreeBSDProcessList*) this->pl;
+ const FreeBSDProcessList* fpl = (const FreeBSDProcessList*) this->pl;
ZfsCompressedArcMeter_readStats(this, &(fpl->zfs));
}
diff --git a/linux/Platform.c b/linux/Platform.c
index d21de018..64180484 100644
--- a/linux/Platform.c
+++ b/linux/Platform.c
@@ -189,8 +189,8 @@ int Platform_getMaxPid() {
}
double Platform_setCPUValues(Meter* this, int cpu) {
- LinuxProcessList* pl = (LinuxProcessList*) this->pl;
- CPUData* cpuData = &(pl->cpus[cpu]);
+ const LinuxProcessList* pl = (const LinuxProcessList*) this->pl;
+ const CPUData* cpuData = &(pl->cpus[cpu]);
double total = (double) ( cpuData->totalPeriod == 0 ? 1 : cpuData->totalPeriod);
double percent;
double* v = this->values;
@@ -224,8 +224,8 @@ double Platform_setCPUValues(Meter* this, int cpu) {
}
void Platform_setMemoryValues(Meter* this) {
- ProcessList* pl = this->pl;
- LinuxProcessList* lpl = (LinuxProcessList*) this->pl;
+ const ProcessList* pl = this->pl;
+ const LinuxProcessList* lpl = (const LinuxProcessList*) pl;
long int usedMem = pl->usedMem;
long int buffersMem = pl->buffersMem;
@@ -243,19 +243,19 @@ void Platform_setMemoryValues(Meter* this) {
}
void Platform_setSwapValues(Meter* this) {
- ProcessList* pl = (ProcessList*) this->pl;
+ const ProcessList* pl = this->pl;
this->total = pl->totalSwap;
this->values[0] = pl->usedSwap;
}
void Platform_setZfsArcValues(Meter* this) {
- LinuxProcessList* lpl = (LinuxProcessList*) this->pl;
+ const LinuxProcessList* lpl = (const LinuxProcessList*) this->pl;
ZfsArcMeter_readStats(this, &(lpl->zfs));
}
void Platform_setZfsCompressedArcValues(Meter* this) {
- LinuxProcessList* lpl = (LinuxProcessList*) this->pl;
+ const LinuxProcessList* lpl = (const LinuxProcessList*) this->pl;
ZfsCompressedArcMeter_readStats(this, &(lpl->zfs));
}
diff --git a/openbsd/Platform.c b/openbsd/Platform.c
index eac13c96..9f7cd737 100644
--- a/openbsd/Platform.c
+++ b/openbsd/Platform.c
@@ -189,7 +189,7 @@ double Platform_setCPUValues(Meter* this, int cpu) {
}
void Platform_setMemoryValues(Meter* this) {
- ProcessList* pl = (ProcessList*) this->pl;
+ const ProcessList* pl = this->pl;
long int usedMem = pl->usedMem;
long int buffersMem = pl->buffersMem;
long int cachedMem = pl->cachedMem;
@@ -207,7 +207,7 @@ void Platform_setMemoryValues(Meter* this) {
* Taken almost directly from OpenBSD's top(1)
*/
void Platform_setSwapValues(Meter* this) {
- ProcessList* pl = (ProcessList*) this->pl;
+ const ProcessList* pl = this->pl;
struct swapent *swdev;
unsigned long long int total, used;
int nswap, rnswap, i;
diff --git a/solaris/Platform.c b/solaris/Platform.c
index 978cca08..2fa2e1de 100644
--- a/solaris/Platform.c
+++ b/solaris/Platform.c
@@ -167,9 +167,9 @@ int Platform_getMaxPid() {
}
double Platform_setCPUValues(Meter* this, int cpu) {
- SolarisProcessList* spl = (SolarisProcessList*) this->pl;
+ const SolarisProcessList* spl = (const SolarisProcessList*) this->pl;
int cpus = this->pl->cpuCount;
- CPUData* cpuData = NULL;
+ const CPUData* cpuData = NULL;
if (cpus == 1) {
// single CPU box has everything in spl->cpus[0]
@@ -203,7 +203,7 @@ double Platform_setCPUValues(Meter* this, int cpu) {
}
void Platform_setMemoryValues(Meter* this) {
- ProcessList* pl = (ProcessList*) this->pl;
+ const ProcessList* pl = this->pl;
this->total = pl->totalMem;
this->values[0] = pl->usedMem;
this->values[1] = pl->buffersMem;
@@ -211,19 +211,19 @@ void Platform_setMemoryValues(Meter* this) {
}
void Platform_setSwapValues(Meter* this) {
- ProcessList* pl = (ProcessList*) this->pl;
+ const ProcessList* pl = this->pl;
this->total = pl->totalSwap;
this->values[0] = pl->usedSwap;
}
void Platform_setZfsArcValues(Meter* this) {
- SolarisProcessList* spl = (SolarisProcessList*) this->pl;
+ const SolarisProcessList* spl = (const SolarisProcessList*) this->pl;
ZfsArcMeter_readStats(this, &(spl->zfs));
}
void Platform_setZfsCompressedArcValues(Meter* this) {
- SolarisProcessList* spl = (SolarisProcessList*) this->pl;
+ const SolarisProcessList* spl = (const SolarisProcessList*) this->pl;
ZfsCompressedArcMeter_readStats(this, &(spl->zfs));
}
diff --git a/zfs/ZfsArcMeter.c b/zfs/ZfsArcMeter.c
index 55ef2c56..72af3bc7 100644
--- a/zfs/ZfsArcMeter.c
+++ b/zfs/ZfsArcMeter.c
@@ -18,7 +18,7 @@ static const int ZfsArcMeter_attributes[] = {
ZFS_MFU, ZFS_MRU, ZFS_ANON, ZFS_HEADER, ZFS_OTHER
};
-void ZfsArcMeter_readStats(Meter* this, ZfsArcStats* stats) {
+void ZfsArcMeter_readStats(Meter* this, const ZfsArcStats* stats) {
this->total = stats->max;
this->values[0] = stats->MFU;
this->values[1] = stats->MRU;
diff --git a/zfs/ZfsArcMeter.h b/zfs/ZfsArcMeter.h
index cf552bce..52bf7842 100644
--- a/zfs/ZfsArcMeter.h
+++ b/zfs/ZfsArcMeter.h
@@ -11,7 +11,7 @@ in the source distribution for its full text.
#include "Meter.h"
-void ZfsArcMeter_readStats(Meter* this, ZfsArcStats* stats);
+void ZfsArcMeter_readStats(Meter* this, const ZfsArcStats* stats);
extern const MeterClass ZfsArcMeter_class;
diff --git a/zfs/ZfsCompressedArcMeter.c b/zfs/ZfsCompressedArcMeter.c
index 0a67c7ed..993d80e2 100644
--- a/zfs/ZfsCompressedArcMeter.c
+++ b/zfs/ZfsCompressedArcMeter.c
@@ -21,7 +21,7 @@ static const int ZfsCompressedArcMeter_attributes[] = {
ZFS_COMPRESSED
};
-void ZfsCompressedArcMeter_readStats(Meter* this, ZfsArcStats* stats) {
+void ZfsCompressedArcMeter_readStats(Meter* this, const ZfsArcStats* stats) {
if ( stats->isCompressed ) {
this->total = stats->uncompressed;
this->values[0] = stats->compressed;
diff --git a/zfs/ZfsCompressedArcMeter.h b/zfs/ZfsCompressedArcMeter.h
index 1ad6447d..025a9dd8 100644
--- a/zfs/ZfsCompressedArcMeter.h
+++ b/zfs/ZfsCompressedArcMeter.h
@@ -11,7 +11,7 @@ in the source distribution for its full text.
#include "Meter.h"
-void ZfsCompressedArcMeter_readStats(Meter* this, ZfsArcStats* stats);
+void ZfsCompressedArcMeter_readStats(Meter* this, const ZfsArcStats* stats);
extern const MeterClass ZfsCompressedArcMeter_class;

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