aboutsummaryrefslogtreecommitdiffstats
path: root/unsupported
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2021-09-21 08:35:19 +0200
committerDaniel Lange <DLange@git.local>2021-09-21 08:35:19 +0200
commit69f439eff387a6ecb52734e400b297a3c85f2285 (patch)
tree2a988b7868b749654796183ba70b4272965da1bf /unsupported
parentc55320e9e2a8916e911bcd39ab37b79e3a7d03b2 (diff)
downloaddebian_htop-69f439eff387a6ecb52734e400b297a3c85f2285.tar.gz
debian_htop-69f439eff387a6ecb52734e400b297a3c85f2285.tar.bz2
debian_htop-69f439eff387a6ecb52734e400b297a3c85f2285.zip
New upstream version 3.1.0upstream/3.1.0
Diffstat (limited to 'unsupported')
-rw-r--r--unsupported/Platform.c58
-rw-r--r--unsupported/Platform.h55
-rw-r--r--unsupported/UnsupportedProcess.c90
-rw-r--r--unsupported/UnsupportedProcess.h14
-rw-r--r--unsupported/UnsupportedProcessList.c44
-rw-r--r--unsupported/UnsupportedProcessList.h7
6 files changed, 202 insertions, 66 deletions
diff --git a/unsupported/Platform.c b/unsupported/Platform.c
index 94e1b7c..6fbe518 100644
--- a/unsupported/Platform.c
+++ b/unsupported/Platform.c
@@ -6,19 +6,24 @@ 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 "Platform.h"
-#include "Macros.h"
#include "CPUMeter.h"
-#include "MemoryMeter.h"
-#include "SwapMeter.h"
-#include "TasksMeter.h"
-#include "LoadAverageMeter.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"
@@ -39,9 +44,11 @@ const MeterClass* const Platform_meterTypes[] = {
&LoadMeter_class,
&MemoryMeter_class,
&SwapMeter_class,
+ &MemorySwapMeter_class,
&TasksMeter_class,
&BatteryMeter_class,
&HostnameMeter_class,
+ &SysArchMeter_class,
&UptimeMeter_class,
&AllCPUsMeter_class,
&AllCPUs2Meter_class,
@@ -59,6 +66,8 @@ const MeterClass* const Platform_meterTypes[] = {
NULL
};
+static const char Platform_unsupported[] = "unsupported";
+
void Platform_init(void) {
/* no platform-specific setup needed */
}
@@ -86,13 +95,15 @@ int Platform_getMaxPid() {
return 1;
}
-double Platform_setCPUValues(Meter* this, int cpu) {
+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;
}
@@ -104,25 +115,20 @@ void Platform_setSwapValues(Meter* this) {
(void) this;
}
-bool Process_isThread(const Process* this) {
- (void) this;
- return false;
-}
-
char* Platform_getProcessEnv(pid_t pid) {
(void) pid;
return NULL;
}
char* Platform_getInodeFilename(pid_t pid, ino_t inode) {
- (void)pid;
- (void)inode;
- return NULL;
+ (void)pid;
+ (void)inode;
+ return NULL;
}
FileLocks_ProcessData* Platform_getProcessLocks(pid_t pid) {
- (void)pid;
- return NULL;
+ (void)pid;
+ return NULL;
}
bool Platform_getDiskIO(DiskIOData* data) {
@@ -130,14 +136,8 @@ bool Platform_getDiskIO(DiskIOData* data) {
return false;
}
-bool Platform_getNetworkIO(unsigned long int* bytesReceived,
- unsigned long int* packetsReceived,
- unsigned long int* bytesTransmitted,
- unsigned long int* packetsTransmitted) {
- *bytesReceived = 0;
- *packetsReceived = 0;
- *bytesTransmitted = 0;
- *packetsTransmitted = 0;
+bool Platform_getNetworkIO(NetworkIOData* data) {
+ (void)data;
return false;
}
@@ -145,3 +145,11 @@ 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
index 4254122..cdf1d0f 100644
--- a/unsupported/Platform.h
+++ b/unsupported/Platform.h
@@ -11,9 +11,13 @@ 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 "UnsupportedProcess.h"
+#include "generic/gettime.h"
+#include "unsupported/UnsupportedProcess.h"
+
extern const SignalItem Platform_signals[];
@@ -35,14 +39,12 @@ void Platform_getLoadAverage(double* one, double* five, double* fifteen);
int Platform_getMaxPid(void);
-double Platform_setCPUValues(Meter* this, int cpu);
+double Platform_setCPUValues(Meter* this, unsigned int cpu);
void Platform_setMemoryValues(Meter* this);
void Platform_setSwapValues(Meter* this);
-bool Process_isThread(const Process* this);
-
char* Platform_getProcessEnv(pid_t pid);
char* Platform_getInodeFilename(pid_t pid, ino_t inode);
@@ -51,11 +53,46 @@ FileLocks_ProcessData* Platform_getProcessLocks(pid_t pid);
bool Platform_getDiskIO(DiskIOData* data);
-bool Platform_getNetworkIO(unsigned long int* bytesReceived,
- unsigned long int* packetsReceived,
- unsigned long int* bytesTransmitted,
- unsigned long int* packetsTransmitted);
+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 bool Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) {
+ return false;
+}
+
+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; }
-void Platform_getBattery(double *percent, ACPresence *isOnAC);
+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/UnsupportedProcess.c b/unsupported/UnsupportedProcess.c
index eb52910..1b9159b 100644
--- a/unsupported/UnsupportedProcess.c
+++ b/unsupported/UnsupportedProcess.c
@@ -5,10 +5,16 @@ Released under the GNU GPLv2, see the COPYING file
in the source distribution for its full text.
*/
-#include "Process.h"
-#include "UnsupportedProcess.h"
+#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, },
@@ -17,37 +23,83 @@ const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
[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_NR] = { .name = "TTY_NR", .title = " TTY ", .description = "Controlling terminal", .flags = 0, },
+ [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, },
- [MAJFLT] = { .name = "MAJFLT", .title = " MAJFLT ", .description = "Number of major faults which have required loading a memory page from disk", .flags = 0, },
+ [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, },
- [M_RESIDENT] = { .name = "M_RESIDENT", .title = " RES ", .description = "Resident set size, size of the text and data sections, plus stack usage", .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, },
- [PERCENT_MEM] = { .name = "PERCENT_MEM", .title = "MEM% ", .description = "Percentage of the memory the process is using, based on resident memory size", .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, },
+ [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, },
+ [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, },
+ [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(Settings* settings) {
- Process* this = xCalloc(1, sizeof(Process));
- Object_setClass(this, Class(Process));
+Process* UnsupportedProcess_new(const Settings* settings) {
+ Process* this = xCalloc(1, sizeof(UnsupportedProcess));
+ Object_setClass(this, Class(UnsupportedProcess));
Process_init(this, settings);
return this;
}
-void UnsupportedProcess_delete(Object* cast) {
- Process* this = (Process*) cast;
- Object_setClass(this, Class(Process));
- Process_done((Process*)cast);
+void Process_delete(Object* cast) {
+ Process* super = (Process*) cast;
+ Process_done(super);
// free platform-specific fields here
- free(this);
+ 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,
+ .getCommandStr = NULL,
+ .compareByKey = UnsupportedProcess_compareByKey
+};
diff --git a/unsupported/UnsupportedProcess.h b/unsupported/UnsupportedProcess.h
index e1812f1..f39a3fb 100644
--- a/unsupported/UnsupportedProcess.h
+++ b/unsupported/UnsupportedProcess.h
@@ -9,12 +9,20 @@ in the source distribution for its full text.
#include "Settings.h"
-#define Process_delete UnsupportedProcess_delete
+
+typedef struct UnsupportedProcess_ {
+ Process super;
+
+ /* Add platform specific fields */
+} UnsupportedProcess;
+
extern const ProcessFieldData Process_fields[LAST_PROCESSFIELD];
-Process* UnsupportedProcess_new(Settings* settings);
+Process* UnsupportedProcess_new(const Settings* settings);
+
+void Process_delete(Object* cast);
-void UnsupportedProcess_delete(Object* cast);
+extern const ProcessClass UnsupportedProcess_class;
#endif
diff --git a/unsupported/UnsupportedProcessList.c b/unsupported/UnsupportedProcessList.c
index 098eb48..0486e49 100644
--- a/unsupported/UnsupportedProcessList.c
+++ b/unsupported/UnsupportedProcessList.c
@@ -5,16 +5,21 @@ Released under the GNU GPLv2, see the COPYING file
in the source distribution for its full text.
*/
-#include "ProcessList.h"
-#include "UnsupportedProcess.h"
+#include "UnsupportedProcessList.h"
#include <stdlib.h>
#include <string.h>
+#include "ProcessList.h"
+#include "UnsupportedProcess.h"
+
-ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId) {
+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, pidMatchList, userId);
+ ProcessList_init(this, Class(Process), usersTable, dynamicMeters, dynamicColumns, pidMatchList, userId);
+
+ this->existingCPUs = 1;
+ this->activeCPUs = 1;
return this;
}
@@ -41,23 +46,33 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
proc->pid = 1;
proc->ppid = 1;
proc->tgid = 0;
- proc->comm = "<unsupported architecture>";
- proc->basenameOffset = 0;
+
+ Process_updateComm(proc, "commof16char");
+ Process_updateCmdline(proc, "<unsupported architecture>", 0, 0);
+ Process_updateExe(proc, "/path/to/executable");
+
+ if (proc->settings->flags & PROCESS_FLAG_CWD) {
+ free_and_xStrdup(&proc->procCwd, "/current/working/directory");
+ }
+
proc->updated = true;
proc->state = 'R';
+ 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->st_uid = 0;
- proc->flags = 0;
proc->processor = 0;
proc->percent_cpu = 2.5;
proc->percent_mem = 2.5;
- proc->user = "nobody";
+
+ proc->st_uid = 0;
+ proc->user = "nobody"; /* Update whenever proc->st_uid is changed */
proc->priority = 0;
proc->nice = 0;
@@ -70,4 +85,15 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
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
index 1c53771..08dae0c 100644
--- a/unsupported/UnsupportedProcessList.h
+++ b/unsupported/UnsupportedProcessList.h
@@ -7,10 +7,15 @@ Released under the GNU GPLv2, see the COPYING file
in the source distribution for its full text.
*/
-ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId);
+#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

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