summaryrefslogtreecommitdiffstats
path: root/unsupported
diff options
context:
space:
mode:
authorNathan Scott <nathans@redhat.com>2023-05-02 16:56:18 +1000
committerNathan Scott <nathans@redhat.com>2023-05-08 13:06:38 +1000
commit72235d8e098d9d79029dca65122605741e1aafad (patch)
tree96593b8bd9dc95dc5ab321bd363d36351cbd0a99 /unsupported
parent0bdade1b6cb40c5bd374a93ac0489058a7421bb5 (diff)
Adapt platform code for the new Machine base class
Move host-centric data to new derived <Platform>Machine classes, separate from process-list-centric data.
Diffstat (limited to 'unsupported')
-rw-r--r--unsupported/UnsupportedMachine.c56
-rw-r--r--unsupported/UnsupportedMachine.h17
-rw-r--r--unsupported/UnsupportedProcessList.c35
-rw-r--r--unsupported/UnsupportedProcessList.h14
4 files changed, 81 insertions, 41 deletions
diff --git a/unsupported/UnsupportedMachine.c b/unsupported/UnsupportedMachine.c
new file mode 100644
index 00000000..a6635acc
--- /dev/null
+++ b/unsupported/UnsupportedMachine.c
@@ -0,0 +1,56 @@
+/*
+htop - UnsupportedMachine.c
+(C) 2014 Hisham H. Muhammad
+Released under the GNU GPLv2+, see the COPYING file
+in the source distribution for its full text.
+*/
+
+#include "UnsupportedMachine.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "Machine.h"
+
+
+Machine* Machine_new(UsersTable* usersTable, uid_t userId) {
+ UnsupportedMachine* this = xCalloc(1, sizeof(UnsupportedMachine));
+ Machine* super = &this->super;
+
+ Machine_init(super, usersTable, userId);
+
+ super->existingCPUs = 1;
+ super->activeCPUs = 1;
+
+ return super;
+}
+
+void Machine_delete(Machine* super) {
+ UnsupportedMachine* this = (UnsupportedMachine*) super;
+ Machine_done(super);
+ free(this);
+}
+
+bool Machine_isCPUonline(const Machine* host, unsigned int id) {
+ assert(id < host->existingCPUs);
+
+ (void) host; (void) id;
+
+ return true;
+}
+
+void Machine_scan(Machine* super) {
+ super->existingCPUs = 1;
+ super->activeCPUs = 1;
+
+ super->totalMem = 0;
+ super->usedMem = 0;
+ super->buffersMem = 0;
+ super->cachedMem = 0;
+ super->sharedMem = 0;
+ super->availableMem = 0;
+
+ super->totalSwap = 0;
+ super->usedSwap = 0;
+ super->cachedSwap = 0;
+}
diff --git a/unsupported/UnsupportedMachine.h b/unsupported/UnsupportedMachine.h
new file mode 100644
index 00000000..4ec760f1
--- /dev/null
+++ b/unsupported/UnsupportedMachine.h
@@ -0,0 +1,17 @@
+#ifndef HEADER_UnsupportedMachine
+#define HEADER_UnsupportedMachine
+/*
+htop - UnsupportedMachine.h
+(C) 2014 Hisham H. Muhammad
+Released under the GNU GPLv2+, see the COPYING file
+in the source distribution for its full text.
+*/
+
+#include "Machine.h"
+
+
+typedef struct UnsupportedMachine_ {
+ Machine super;
+} UnsupportedMachine;
+
+#endif
diff --git a/unsupported/UnsupportedProcessList.c b/unsupported/UnsupportedProcessList.c
index e5b7af6d..e56f4978 100644
--- a/unsupported/UnsupportedProcessList.c
+++ b/unsupported/UnsupportedProcessList.c
@@ -16,10 +16,8 @@ in the source distribution for its full text.
ProcessList* ProcessList_new(Machine* host, Hashtable* pidMatchList) {
ProcessList* this = xCalloc(1, sizeof(ProcessList));
- ProcessList_init(this, Class(Process), host, pidMatchList);
- host->existingCPUs = 1;
- host->activeCPUs = 1;
+ ProcessList_init(this, Class(Process), host, pidMatchList);
return this;
}
@@ -29,13 +27,7 @@ void ProcessList_delete(ProcessList* this) {
free(this);
}
-void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
-
- // in pause mode only gather global data for meters (CPU/memory/...)
- if (pauseProcessUpdate) {
- return;
- }
-
+void ProcessList_goThroughEntries(ProcessList* super) {
bool preExisting = true;
Process* proc;
@@ -51,7 +43,8 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
Process_updateCmdline(proc, "<unsupported architecture>", 0, 0);
Process_updateExe(proc, "/path/to/executable");
- if (proc->settings->ss->flags & PROCESS_FLAG_CWD) {
+ const Settings* settings = proc->host->settings;
+ if (settings->ss->flags & PROCESS_FLAG_CWD) {
free_and_xStrdup(&proc->procCwd, "/current/working/directory");
}
@@ -60,7 +53,7 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
proc->state = RUNNING;
proc->isKernelThread = false;
proc->isUserlandThread = false;
- proc->show = true; /* Reflected in proc->settings-> "hideXXX" really */
+ proc->show = true; /* Reflected in settings-> "hideXXX" really */
proc->pgrp = 0;
proc->session = 0;
proc->tty_nr = 0;
@@ -90,21 +83,3 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
if (!preExisting)
ProcessList_add(super, proc);
}
-
-Machine* Machine_new(UsersTable* usersTable, uid_t userId) {
- Machine* this = xCalloc(1, sizeof(Machine));
- Machine_init(this, usersTable, userId);
- return this;
-}
-
-void Machine_delete(Machine* host) {
- free(host);
-}
-
-bool Machine_isCPUonline(const Machine* host, unsigned int id) {
- assert(id < host->existingCPUs);
-
- (void) host; (void) id;
-
- return true;
-}
diff --git a/unsupported/UnsupportedProcessList.h b/unsupported/UnsupportedProcessList.h
index cdb0b601..96efdcd2 100644
--- a/unsupported/UnsupportedProcessList.h
+++ b/unsupported/UnsupportedProcessList.h
@@ -10,16 +10,8 @@ in the source distribution for its full text.
#include "ProcessList.h"
-ProcessList* ProcessList_new(Machine* host, Hashtable* pidMatchList);
-
-void ProcessList_delete(ProcessList* this);
-
-void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
-
-Machine* Machine_new(UsersTable* usersTable, uid_t userId);
-
-bool Machine_isCPUonline(const Machine* host, unsigned int id);
-
-void Machine_delete(Machine* host);
+typedef struct UnsupportedProcessList_ {
+ ProcessList super;
+} UnsupportedProcessList;
#endif

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