From e7372d18a1a661d8c3dba9f51e1f17b5f94171a7 Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Wed, 10 Jan 2024 11:17:08 +0100 Subject: New upstream version 3.3.0 --- SwapMeter.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'SwapMeter.c') diff --git a/SwapMeter.c b/SwapMeter.c index 081967f..1055a6e 100644 --- a/SwapMeter.c +++ b/SwapMeter.c @@ -13,6 +13,7 @@ in the source distribution for its full text. #include #include "CRT.h" +#include "Macros.h" #include "Object.h" #include "Platform.h" #include "RichString.h" @@ -20,7 +21,8 @@ in the source distribution for its full text. static const int SwapMeter_attributes[] = { SWAP, - SWAP_CACHE + SWAP_CACHE, + SWAP_FRONTSWAP, }; static void SwapMeter_updateValues(Meter* this) { @@ -28,10 +30,11 @@ static void SwapMeter_updateValues(Meter* this) { size_t size = sizeof(this->txtBuffer); int written; - this->values[1] = NAN; /* 'cached' not present on all platforms */ + this->values[SWAP_METER_CACHE] = NAN; /* 'cached' not present on all platforms */ + this->values[SWAP_METER_FRONTSWAP] = NAN; /* 'frontswap' not present on all platforms */ Platform_setSwapValues(this); - written = Meter_humanUnit(buffer, this->values[0], size); + written = Meter_humanUnit(buffer, this->values[SWAP_METER_USED], size); METER_BUFFER_CHECK(buffer, size, written); METER_BUFFER_APPEND_CHR(buffer, size, '/'); @@ -45,15 +48,21 @@ static void SwapMeter_display(const Object* cast, RichString* out) { RichString_writeAscii(out, CRT_colors[METER_TEXT], ":"); Meter_humanUnit(buffer, this->total, sizeof(buffer)); RichString_appendAscii(out, CRT_colors[METER_VALUE], buffer); - Meter_humanUnit(buffer, this->values[0], sizeof(buffer)); + Meter_humanUnit(buffer, this->values[SWAP_METER_USED], sizeof(buffer)); RichString_appendAscii(out, CRT_colors[METER_TEXT], " used:"); RichString_appendAscii(out, CRT_colors[METER_VALUE], buffer); - if (!isnan(this->values[1])) { - Meter_humanUnit(buffer, this->values[1], sizeof(buffer)); + if (isNonnegative(this->values[SWAP_METER_CACHE])) { + Meter_humanUnit(buffer, this->values[SWAP_METER_CACHE], sizeof(buffer)); RichString_appendAscii(out, CRT_colors[METER_TEXT], " cache:"); RichString_appendAscii(out, CRT_colors[SWAP_CACHE], buffer); } + + if (isNonnegative(this->values[SWAP_METER_FRONTSWAP])) { + Meter_humanUnit(buffer, this->values[SWAP_METER_FRONTSWAP], sizeof(buffer)); + RichString_appendAscii(out, CRT_colors[METER_TEXT], " frontswap:"); + RichString_appendAscii(out, CRT_colors[SWAP_FRONTSWAP], buffer); + } } const MeterClass SwapMeter_class = { @@ -64,7 +73,7 @@ const MeterClass SwapMeter_class = { }, .updateValues = SwapMeter_updateValues, .defaultMode = BAR_METERMODE, - .maxItems = 2, + .maxItems = SWAP_METER_ITEMCOUNT, .total = 100.0, .attributes = SwapMeter_attributes, .name = "Swap", -- cgit v1.2.3