summaryrefslogtreecommitdiffstats
path: root/SwapMeter.c
diff options
context:
space:
mode:
authorNathan Scott <nathans@redhat.com>2021-07-07 14:24:32 +1000
committerNathan Scott <nathans@redhat.com>2021-07-07 14:24:32 +1000
commit149774209be588fb0da001e5d9cac224862cc5da (patch)
tree1f96fb860bcc3fbe1de7827bf0d236949c20e77f /SwapMeter.c
parent15a71f32fe1636d24bc8c2ae5e1eb689d2e28c7e (diff)
Remove Linux-specific cpp conditional in SwapMeter.c
Instead use the common NAN pattern to use of the swap cached value on platforms that do not support it.
Diffstat (limited to 'SwapMeter.c')
-rw-r--r--SwapMeter.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/SwapMeter.c b/SwapMeter.c
index e428102a..63f58c5a 100644
--- a/SwapMeter.c
+++ b/SwapMeter.c
@@ -9,6 +9,7 @@ in the source distribution for its full text.
#include "SwapMeter.h"
+#include <math.h>
#include <stddef.h>
#include "CRT.h"
@@ -26,6 +27,8 @@ static void SwapMeter_updateValues(Meter* this) {
char* buffer = this->txtBuffer;
size_t size = sizeof(this->txtBuffer);
int written;
+
+ this->values[1] = NAN; /* 'cached' not present on all platforms */
Platform_setSwapValues(this);
written = Meter_humanUnit(buffer, this->values[0], size);
@@ -46,11 +49,11 @@ static void SwapMeter_display(const Object* cast, RichString* out) {
RichString_appendAscii(out, CRT_colors[METER_TEXT], " used:");
RichString_appendAscii(out, CRT_colors[METER_VALUE], buffer);
-#ifdef HTOP_LINUX
- Meter_humanUnit(buffer, this->values[1], sizeof(buffer));
- RichString_appendAscii(out, CRT_colors[METER_TEXT], " cache:");
- RichString_appendAscii(out, CRT_colors[SWAP_CACHE], buffer);
-#endif
+ if (!isnan(this->values[1])) {
+ Meter_humanUnit(buffer, this->values[1], sizeof(buffer));
+ RichString_appendAscii(out, CRT_colors[METER_TEXT], " cache:");
+ RichString_appendAscii(out, CRT_colors[SWAP_CACHE], buffer);
+ }
}
const MeterClass SwapMeter_class = {

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