summaryrefslogtreecommitdiffstats
path: root/unsupported
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:00:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:00:29 +0000
commit52e25213825024b8bb446eb26b03bedc9d5c2103 (patch)
treeda70bf44b2423f6f8e9a070c063fed79d190b489 /unsupported
parentInitial commit. (diff)
downloadhtop-upstream.tar.xz
htop-upstream.zip
Adding upstream version 3.2.2.upstream/3.2.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'unsupported')
-rw-r--r--unsupported/Platform.c158
-rw-r--r--unsupported/Platform.h107
-rw-r--r--unsupported/ProcessField.h15
-rw-r--r--unsupported/UnsupportedProcess.c104
-rw-r--r--unsupported/UnsupportedProcess.h28
-rw-r--r--unsupported/UnsupportedProcessList.c100
-rw-r--r--unsupported/UnsupportedProcessList.h21
7 files changed, 533 insertions, 0 deletions
diff --git a/unsupported/Platform.c b/unsupported/Platform.c
new file mode 100644
index 0000000..27bc560
--- /dev/null
+++ b/unsupported/Platform.c
@@ -0,0 +1,158 @@
+/*
+htop - unsupported/Platform.c
+(C) 2014 Hisham H. Muhammad
+(C) 2015 David C. Hunt
+Released under the GNU GPLv2+, see the COPYING file
+in the source distribution for its full text.
+*/
+
+#include "config.h" // IWYU pragma: keep
+
+#include "unsupported/Platform.h"
+
+#include <math.h>
+
+#include "CPUMeter.h"
+#include "ClockMeter.h"
+#include "DateMeter.h"
+#include "DateTimeMeter.h"
+#include "HostnameMeter.h"
+#include "LoadAverageMeter.h"
+#include "Macros.h"
+#include "MemoryMeter.h"
+#include "MemorySwapMeter.h"
+#include "SwapMeter.h"
+#include "SysArchMeter.h"
+#include "TasksMeter.h"
+#include "UptimeMeter.h"
+
+
+const ScreenDefaults Platform_defaultScreens[] = {
+ {
+ .name = "Main",
+ .columns = "PID USER PRIORITY NICE M_VIRT M_RESIDENT STATE PERCENT_CPU PERCENT_MEM TIME Command",
+ .sortKey = "PERCENT_CPU",
+ },
+};
+
+const unsigned int Platform_numberOfDefaultScreens = ARRAYSIZE(Platform_defaultScreens);
+
+const SignalItem Platform_signals[] = {
+ { .name = " 0 Cancel", .number = 0 },
+};
+
+const unsigned int Platform_numberOfSignals = ARRAYSIZE(Platform_signals);
+
+const MeterClass* const Platform_meterTypes[] = {
+ &CPUMeter_class,
+ &ClockMeter_class,
+ &DateMeter_class,
+ &DateTimeMeter_class,
+ &LoadAverageMeter_class,
+ &LoadMeter_class,
+ &MemoryMeter_class,
+ &SwapMeter_class,
+ &MemorySwapMeter_class,
+ &TasksMeter_class,
+ &BatteryMeter_class,
+ &HostnameMeter_class,
+ &SysArchMeter_class,
+ &UptimeMeter_class,
+ &AllCPUsMeter_class,
+ &AllCPUs2Meter_class,
+ &AllCPUs4Meter_class,
+ &AllCPUs8Meter_class,
+ &LeftCPUsMeter_class,
+ &RightCPUsMeter_class,
+ &LeftCPUs2Meter_class,
+ &RightCPUs2Meter_class,
+ &LeftCPUs4Meter_class,
+ &RightCPUs4Meter_class,
+ &LeftCPUs8Meter_class,
+ &RightCPUs8Meter_class,
+ &BlankMeter_class,
+ NULL
+};
+
+static const char Platform_unsupported[] = "unsupported";
+
+bool Platform_init(void) {
+ /* no platform-specific setup needed */
+ return true;
+}
+
+void Platform_done(void) {
+ /* no platform-specific cleanup needed */
+}
+
+void Platform_setBindings(Htop_Action* keys) {
+ /* no platform-specific key bindings */
+ (void) keys;
+}
+
+int Platform_getUptime(void) {
+ return 0;
+}
+
+void Platform_getLoadAverage(double* one, double* five, double* fifteen) {
+ *one = 0;
+ *five = 0;
+ *fifteen = 0;
+}
+
+int Platform_getMaxPid(void) {
+ return 1;
+}
+
+double Platform_setCPUValues(Meter* this, unsigned int cpu) {
+ (void) cpu;
+
+ double* v = this->values;
+ v[CPU_METER_FREQUENCY] = NAN;
+ v[CPU_METER_TEMPERATURE] = NAN;
+
+ this->curItems = 1;
+
+ return 0.0;
+}
+
+void Platform_setMemoryValues(Meter* this) {
+ (void) this;
+}
+
+void Platform_setSwapValues(Meter* this) {
+ (void) this;
+}
+
+char* Platform_getProcessEnv(pid_t pid) {
+ (void) pid;
+ return NULL;
+}
+
+FileLocks_ProcessData* Platform_getProcessLocks(pid_t pid) {
+ (void)pid;
+ return NULL;
+}
+
+bool Platform_getDiskIO(DiskIOData* data) {
+ (void)data;
+ return false;
+}
+
+bool Platform_getNetworkIO(NetworkIOData* data) {
+ (void)data;
+ return false;
+}
+
+void Platform_getBattery(double* percent, ACPresence* isOnAC) {
+ *percent = NAN;
+ *isOnAC = AC_ERROR;
+}
+
+void Platform_getHostname(char* buffer, size_t size) {
+ String_safeStrncpy(buffer, Platform_unsupported, size);
+}
+
+void Platform_getRelease(char** string) {
+ *string = xStrdup(Platform_unsupported);
+}
diff --git a/unsupported/Platform.h b/unsupported/Platform.h
new file mode 100644
index 0000000..f475dda
--- /dev/null
+++ b/unsupported/Platform.h
@@ -0,0 +1,107 @@
+#ifndef HEADER_Platform
+#define HEADER_Platform
+/*
+htop - unsupported/Platform.h
+(C) 2014 Hisham H. Muhammad
+(C) 2015 David C. Hunt
+Released under the GNU GPLv2+, see the COPYING file
+in the source distribution for its full text.
+*/
+
+#include "Action.h"
+#include "BatteryMeter.h"
+#include "DiskIOMeter.h"
+#include "Hashtable.h"
+#include "NetworkIOMeter.h"
+#include "ProcessLocksScreen.h"
+#include "SignalsPanel.h"
+#include "CommandLine.h"
+#include "generic/gettime.h"
+#include "unsupported/UnsupportedProcess.h"
+
+
+extern const ScreenDefaults Platform_defaultScreens[];
+
+extern const unsigned int Platform_numberOfDefaultScreens;
+
+extern const SignalItem Platform_signals[];
+
+extern const unsigned int Platform_numberOfSignals;
+
+extern const MeterClass* const Platform_meterTypes[];
+
+bool Platform_init(void);
+
+void Platform_done(void);
+
+void Platform_setBindings(Htop_Action* keys);
+
+int Platform_getUptime(void);
+
+void Platform_getLoadAverage(double* one, double* five, double* fifteen);
+
+int Platform_getMaxPid(void);
+
+double Platform_setCPUValues(Meter* this, unsigned int cpu);
+
+void Platform_setMemoryValues(Meter* this);
+
+void Platform_setSwapValues(Meter* this);
+
+char* Platform_getProcessEnv(pid_t pid);
+
+FileLocks_ProcessData* Platform_getProcessLocks(pid_t pid);
+
+bool Platform_getDiskIO(DiskIOData* data);
+
+bool Platform_getNetworkIO(NetworkIOData* data);
+
+void Platform_getBattery(double* percent, ACPresence* isOnAC);
+
+void Platform_getHostname(char* buffer, size_t size);
+
+void Platform_getRelease(char** string);
+
+#define PLATFORM_LONG_OPTIONS
+
+static inline void Platform_longOptionsUsage(ATTR_UNUSED const char* name) { }
+
+static inline CommandLineStatus Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) {
+ return STATUS_ERROR_EXIT;
+}
+
+static inline void Platform_gettime_realtime(struct timeval* tv, uint64_t* msec) {
+ Generic_gettime_realtime(tv, msec);
+}
+
+static inline void Platform_gettime_monotonic(uint64_t* msec) {
+ Generic_gettime_monotonic(msec);
+}
+
+static inline Hashtable* Platform_dynamicMeters(void) {
+ return NULL;
+}
+
+static inline void Platform_dynamicMetersDone(ATTR_UNUSED Hashtable* table) { }
+
+static inline void Platform_dynamicMeterInit(ATTR_UNUSED Meter* meter) { }
+
+static inline void Platform_dynamicMeterUpdateValues(ATTR_UNUSED Meter* meter) { }
+
+static inline void Platform_dynamicMeterDisplay(ATTR_UNUSED const Meter* meter, ATTR_UNUSED RichString* out) { }
+
+static inline Hashtable* Platform_dynamicColumns(void) {
+ return NULL;
+}
+
+static inline void Platform_dynamicColumnsDone(ATTR_UNUSED Hashtable* table) { }
+
+static inline const char* Platform_dynamicColumnInit(ATTR_UNUSED unsigned int key) {
+ return NULL;
+}
+
+static inline bool Platform_dynamicColumnWriteField(ATTR_UNUSED const Process* proc, ATTR_UNUSED RichString* str, ATTR_UNUSED unsigned int key) {
+ return false;
+}
+
+#endif
diff --git a/unsupported/ProcessField.h b/unsupported/ProcessField.h
new file mode 100644
index 0000000..0c908ea
--- /dev/null
+++ b/unsupported/ProcessField.h
@@ -0,0 +1,15 @@
+#ifndef HEADER_UnsupportedProcessField
+#define HEADER_UnsupportedProcessField
+/*
+htop - unsupported/ProcessField.h
+(C) 2020 htop dev team
+Released under the GNU GPLv2+, see the COPYING file
+in the source distribution for its full text.
+*/
+
+
+#define PLATFORM_PROCESS_FIELDS \
+ // End of list
+
+
+#endif /* HEADER_UnsupportedProcessField */
diff --git a/unsupported/UnsupportedProcess.c b/unsupported/UnsupportedProcess.c
new file mode 100644
index 0000000..2aca048
--- /dev/null
+++ b/unsupported/UnsupportedProcess.c
@@ -0,0 +1,104 @@
+/*
+htop - UnsupportedProcess.c
+(C) 2015 Hisham H. Muhammad
+Released under the GNU GPLv2+, see the COPYING file
+in the source distribution for its full text.
+*/
+
+#include "config.h" // IWYU pragma: keep
+
+#include "unsupported/UnsupportedProcess.h"
+
+#include <stdlib.h>
+
+#include "CRT.h"
+#include "Process.h"
+
+
+const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
+ [0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },
+ [PID] = { .name = "PID", .title = "PID", .description = "Process/thread ID", .flags = 0, .pidColumn = true, },
+ [COMM] = { .name = "Command", .title = "Command ", .description = "Command line", .flags = 0, },
+ [STATE] = { .name = "STATE", .title = "S ", .description = "Process state (S sleeping, R running, D disk, Z zombie, T traced, W paging)", .flags = 0, },
+ [PPID] = { .name = "PPID", .title = "PPID", .description = "Parent process ID", .flags = 0, .pidColumn = true, },
+ [PGRP] = { .name = "PGRP", .title = "PGRP", .description = "Process group ID", .flags = 0, .pidColumn = true, },
+ [SESSION] = { .name = "SESSION", .title = "SID", .description = "Process's session ID", .flags = 0, .pidColumn = true, },
+ [TTY] = { .name = "TTY", .title = "TTY ", .description = "Controlling terminal", .flags = 0, },
+ [TPGID] = { .name = "TPGID", .title = "TPGID", .description = "Process ID of the fg process group of the controlling terminal", .flags = 0, .pidColumn = true, },
+ [MINFLT] = { .name = "MINFLT", .title = " MINFLT ", .description = "Number of minor faults which have not required loading a memory page from disk", .flags = 0, .defaultSortDesc = true,},
+ [MAJFLT] = { .name = "MAJFLT", .title = " MAJFLT ", .description = "Number of major faults which have required loading a memory page from disk", .flags = 0, .defaultSortDesc = true, },
+ [PRIORITY] = { .name = "PRIORITY", .title = "PRI ", .description = "Kernel's internal priority for the process", .flags = 0, },
+ [NICE] = { .name = "NICE", .title = " NI ", .description = "Nice value (the higher the value, the more it lets other processes take priority)", .flags = 0, },
+ [STARTTIME] = { .name = "STARTTIME", .title = "START ", .description = "Time the process was started", .flags = 0, },
+ [ELAPSED] = { .name = "ELAPSED", .title = "ELAPSED ", .description = "Time since the process was started", .flags = 0, },
+ [PROCESSOR] = { .name = "PROCESSOR", .title = "CPU ", .description = "Id of the CPU the process last executed on", .flags = 0, },
+ [M_VIRT] = { .name = "M_VIRT", .title = " VIRT ", .description = "Total program size in virtual memory", .flags = 0, .defaultSortDesc = true, },
+ [M_RESIDENT] = { .name = "M_RESIDENT", .title = " RES ", .description = "Resident set size, size of the text and data sections, plus stack usage", .flags = 0, .defaultSortDesc = true, },
+ [ST_UID] = { .name = "ST_UID", .title = "UID", .description = "User ID of the process owner", .flags = 0, },
+ [PERCENT_CPU] = { .name = "PERCENT_CPU", .title = " CPU%", .description = "Percentage of the CPU time the process used in the last sampling", .flags = 0, .defaultSortDesc = true, .autoWidth = true, },
+ [PERCENT_NORM_CPU] = { .name = "PERCENT_NORM_CPU", .title = "NCPU%", .description = "Normalized percentage of the CPU time the process used in the last sampling (normalized by cpu count)", .flags = 0, .defaultSortDesc = true, .autoWidth = true, },
+ [PERCENT_MEM] = { .name = "PERCENT_MEM", .title = "MEM% ", .description = "Percentage of the memory the process is using, based on resident memory size", .flags = 0, .defaultSortDesc = true, },
+ [USER] = { .name = "USER", .title = "USER ", .description = "Username of the process owner (or user ID if name cannot be determined)", .flags = 0, },
+ [TIME] = { .name = "TIME", .title = " TIME+ ", .description = "Total time the process has spent in user and system time", .flags = 0, .defaultSortDesc = true, },
+ [NLWP] = { .name = "NLWP", .title = "NLWP ", .description = "Number of threads in the process", .flags = 0, },
+ [TGID] = { .name = "TGID", .title = "TGID", .description = "Thread group ID (i.e. process ID)", .flags = 0, .pidColumn = true, },
+};
+
+Process* UnsupportedProcess_new(const Settings* settings) {
+ Process* this = xCalloc(1, sizeof(UnsupportedProcess));
+ Object_setClass(this, Class(UnsupportedProcess));
+ Process_init(this, settings);
+ return this;
+}
+
+void Process_delete(Object* cast) {
+ Process* super = (Process*) cast;
+ Process_done(super);
+ // free platform-specific fields here
+ free(cast);
+}
+
+static void UnsupportedProcess_writeField(const Process* this, RichString* str, ProcessField field) {
+ const UnsupportedProcess* up = (const UnsupportedProcess*) this;
+ bool coloring = this->settings->highlightMegabytes;
+ char buffer[256]; buffer[255] = '\0';
+ int attr = CRT_colors[DEFAULT_COLOR];
+ size_t n = sizeof(buffer) - 1;
+
+ (void) up;
+ (void) coloring;
+ (void) n;
+
+ switch (field) {
+ /* Add platform specific fields */
+ default:
+ Process_writeField(this, str, field);
+ return;
+ }
+ RichString_appendWide(str, attr, buffer);
+}
+
+static int UnsupportedProcess_compareByKey(const Process* v1, const Process* v2, ProcessField key) {
+ const UnsupportedProcess* p1 = (const UnsupportedProcess*)v1;
+ const UnsupportedProcess* p2 = (const UnsupportedProcess*)v2;
+
+ (void) p1;
+ (void) p2;
+
+ switch (key) {
+ /* Add platform specific fields */
+ default:
+ return Process_compareByKey_Base(v1, v2, key);
+ }
+}
+
+const ProcessClass UnsupportedProcess_class = {
+ .super = {
+ .extends = Class(Process),
+ .display = Process_display,
+ .delete = Process_delete,
+ .compare = Process_compare
+ },
+ .writeField = UnsupportedProcess_writeField,
+ .compareByKey = UnsupportedProcess_compareByKey
+};
diff --git a/unsupported/UnsupportedProcess.h b/unsupported/UnsupportedProcess.h
new file mode 100644
index 0000000..e30169c
--- /dev/null
+++ b/unsupported/UnsupportedProcess.h
@@ -0,0 +1,28 @@
+#ifndef HEADER_UnsupportedProcess
+#define HEADER_UnsupportedProcess
+/*
+htop - UnsupportedProcess.h
+(C) 2015 Hisham H. Muhammad
+Released under the GNU GPLv2+, see the COPYING file
+in the source distribution for its full text.
+*/
+
+#include "Settings.h"
+
+
+typedef struct UnsupportedProcess_ {
+ Process super;
+
+ /* Add platform specific fields */
+} UnsupportedProcess;
+
+
+extern const ProcessFieldData Process_fields[LAST_PROCESSFIELD];
+
+Process* UnsupportedProcess_new(const Settings* settings);
+
+void Process_delete(Object* cast);
+
+extern const ProcessClass UnsupportedProcess_class;
+
+#endif
diff --git a/unsupported/UnsupportedProcessList.c b/unsupported/UnsupportedProcessList.c
new file mode 100644
index 0000000..5291797
--- /dev/null
+++ b/unsupported/UnsupportedProcessList.c
@@ -0,0 +1,100 @@
+/*
+htop - UnsupportedProcessList.c
+(C) 2014 Hisham H. Muhammad
+Released under the GNU GPLv2+, see the COPYING file
+in the source distribution for its full text.
+*/
+
+#include "UnsupportedProcessList.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "ProcessList.h"
+#include "UnsupportedProcess.h"
+
+
+ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* dynamicMeters, Hashtable* dynamicColumns, Hashtable* pidMatchList, uid_t userId) {
+ ProcessList* this = xCalloc(1, sizeof(ProcessList));
+ ProcessList_init(this, Class(Process), usersTable, dynamicMeters, dynamicColumns, pidMatchList, userId);
+
+ this->existingCPUs = 1;
+ this->activeCPUs = 1;
+
+ return this;
+}
+
+void ProcessList_delete(ProcessList* this) {
+ ProcessList_done(this);
+ free(this);
+}
+
+void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
+
+ // in pause mode only gather global data for meters (CPU/memory/...)
+ if (pauseProcessUpdate) {
+ return;
+ }
+
+ bool preExisting = true;
+ Process* proc;
+
+ proc = ProcessList_getProcess(super, 1, &preExisting, UnsupportedProcess_new);
+
+ /* Empty values */
+ proc->time = proc->time + 10;
+ proc->pid = 1;
+ proc->ppid = 1;
+ proc->tgid = 0;
+
+ Process_updateComm(proc, "commof16char");
+ Process_updateCmdline(proc, "<unsupported architecture>", 0, 0);
+ Process_updateExe(proc, "/path/to/executable");
+
+ if (proc->settings->ss->flags & PROCESS_FLAG_CWD) {
+ free_and_xStrdup(&proc->procCwd, "/current/working/directory");
+ }
+
+ proc->updated = true;
+
+ proc->state = RUNNING;
+ proc->isKernelThread = false;
+ proc->isUserlandThread = false;
+ proc->show = true; /* Reflected in proc->settings-> "hideXXX" really */
+ proc->pgrp = 0;
+ proc->session = 0;
+ proc->tty_nr = 0;
+ proc->tty_name = NULL;
+ proc->tpgid = 0;
+ proc->processor = 0;
+
+ proc->percent_cpu = 2.5;
+ proc->percent_mem = 2.5;
+ Process_updateCPUFieldWidths(proc->percent_cpu);
+
+ proc->st_uid = 0;
+ proc->user = "nobody"; /* Update whenever proc->st_uid is changed */
+
+ proc->priority = 0;
+ proc->nice = 0;
+ proc->nlwp = 1;
+ proc->starttime_ctime = 1433116800; // Jun 01, 2015
+ Process_fillStarttimeBuffer(proc);
+
+ proc->m_virt = 100;
+ proc->m_resident = 100;
+
+ proc->minflt = 20;
+ proc->majflt = 20;
+
+ if (!preExisting)
+ ProcessList_add(super, proc);
+}
+
+bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id) {
+ assert(id < super->existingCPUs);
+
+ (void) super; (void) id;
+
+ return true;
+}
diff --git a/unsupported/UnsupportedProcessList.h b/unsupported/UnsupportedProcessList.h
new file mode 100644
index 0000000..cbf25af
--- /dev/null
+++ b/unsupported/UnsupportedProcessList.h
@@ -0,0 +1,21 @@
+#ifndef HEADER_UnsupportedProcessList
+#define HEADER_UnsupportedProcessList
+/*
+htop - UnsupportedProcessList.h
+(C) 2014 Hisham H. Muhammad
+Released under the GNU GPLv2+, see the COPYING file
+in the source distribution for its full text.
+*/
+
+#include "ProcessList.h"
+
+
+ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* dynamicMeters, Hashtable* dynamicColumns, Hashtable* pidMatchList, uid_t userId);
+
+void ProcessList_delete(ProcessList* this);
+
+void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
+
+bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id);
+
+#endif