diff options
author | Daniel Lange <DLange@git.local> | 2024-01-10 11:17:08 +0100 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2024-01-10 11:17:08 +0100 |
commit | e7372d18a1a661d8c3dba9f51e1f17b5f94171a7 (patch) | |
tree | e8270dd60ec096bee8157dbadf029e15ed584592 /unsupported | |
parent | 937052b231259a47d881d539ad5748245ef55b99 (diff) | |
download | debian_htop-e7372d18a1a661d8c3dba9f51e1f17b5f94171a7.tar.gz debian_htop-e7372d18a1a661d8c3dba9f51e1f17b5f94171a7.tar.bz2 debian_htop-e7372d18a1a661d8c3dba9f51e1f17b5f94171a7.zip |
New upstream version 3.3.0
Diffstat (limited to 'unsupported')
-rw-r--r-- | unsupported/Platform.c | 17 | ||||
-rw-r--r-- | unsupported/Platform.h | 37 | ||||
-rw-r--r-- | unsupported/UnsupportedMachine.c | 56 | ||||
-rw-r--r-- | unsupported/UnsupportedMachine.h | 17 | ||||
-rw-r--r-- | unsupported/UnsupportedProcess.c | 32 | ||||
-rw-r--r-- | unsupported/UnsupportedProcess.h | 4 | ||||
-rw-r--r-- | unsupported/UnsupportedProcessList.h | 21 | ||||
-rw-r--r-- | unsupported/UnsupportedProcessTable.c (renamed from unsupported/UnsupportedProcessList.c) | 56 | ||||
-rw-r--r-- | unsupported/UnsupportedProcessTable.h | 17 |
9 files changed, 174 insertions, 83 deletions
diff --git a/unsupported/Platform.c b/unsupported/Platform.c index 33d7c41..dbfddd9 100644 --- a/unsupported/Platform.c +++ b/unsupported/Platform.c @@ -16,6 +16,7 @@ in the source distribution for its full text. #include "ClockMeter.h" #include "DateMeter.h" #include "DateTimeMeter.h" +#include "FileDescriptorMeter.h" #include "HostnameMeter.h" #include "LoadAverageMeter.h" #include "Macros.h" @@ -70,6 +71,7 @@ const MeterClass* const Platform_meterTypes[] = { &RightCPUs4Meter_class, &LeftCPUs8Meter_class, &RightCPUs8Meter_class, + &FileDescriptorMeter_class, &BlankMeter_class, NULL }; @@ -90,7 +92,7 @@ void Platform_setBindings(Htop_Action* keys) { (void) keys; } -int Platform_getUptime() { +int Platform_getUptime(void) { return 0; } @@ -100,8 +102,8 @@ void Platform_getLoadAverage(double* one, double* five, double* fifteen) { *fifteen = 0; } -int Platform_getMaxPid() { - return 1; +pid_t Platform_getMaxPid(void) { + return INT_MAX; } double Platform_setCPUValues(Meter* this, unsigned int cpu) { @@ -129,15 +131,14 @@ char* Platform_getProcessEnv(pid_t pid) { return NULL; } -char* Platform_getInodeFilename(pid_t pid, ino_t inode) { +FileLocks_ProcessData* Platform_getProcessLocks(pid_t pid) { (void)pid; - (void)inode; return NULL; } -FileLocks_ProcessData* Platform_getProcessLocks(pid_t pid) { - (void)pid; - return NULL; +void Platform_getFileDescriptors(double* used, double* max) { + *used = 1337; + *max = 4711; } bool Platform_getDiskIO(DiskIOData* data) { diff --git a/unsupported/Platform.h b/unsupported/Platform.h index 5c874d4..c4cd06a 100644 --- a/unsupported/Platform.h +++ b/unsupported/Platform.h @@ -8,6 +8,9 @@ Released under the GNU GPLv2+, see the COPYING file in the source distribution for its full text. */ +#include <stdbool.h> +#include <sys/types.h> + #include "Action.h" #include "BatteryMeter.h" #include "DiskIOMeter.h" @@ -40,7 +43,7 @@ int Platform_getUptime(void); void Platform_getLoadAverage(double* one, double* five, double* fifteen); -int Platform_getMaxPid(void); +pid_t Platform_getMaxPid(void); double Platform_setCPUValues(Meter* this, unsigned int cpu); @@ -50,10 +53,10 @@ void Platform_setSwapValues(Meter* this); char* Platform_getProcessEnv(pid_t pid); -char* Platform_getInodeFilename(pid_t pid, ino_t inode); - FileLocks_ProcessData* Platform_getProcessLocks(pid_t pid); +void Platform_getFileDescriptors(double* used, double* max); + bool Platform_getDiskIO(DiskIOData* data); bool Platform_getNetworkIO(NetworkIOData* data); @@ -80,7 +83,9 @@ static inline void Platform_gettime_monotonic(uint64_t* msec) { Generic_gettime_monotonic(msec); } -static inline Hashtable* Platform_dynamicMeters(void) { return NULL; } +static inline Hashtable* Platform_dynamicMeters(void) { + return NULL; +} static inline void Platform_dynamicMetersDone(ATTR_UNUSED Hashtable* table) { } @@ -90,12 +95,30 @@ 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 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 const char* Platform_dynamicColumnName(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; +} + +static inline Hashtable* Platform_dynamicScreens(void) { + return NULL; +} + +static inline void Platform_defaultDynamicScreens(ATTR_UNUSED Settings* settings) { } + +static inline void Platform_addDynamicScreen(ATTR_UNUSED ScreenSettings* ss) { } + +static inline void Platform_addDynamicScreenAvailableColumns(ATTR_UNUSED Panel* availableColumns, ATTR_UNUSED const char* screen) { } -static inline bool Platform_dynamicColumnWriteField(ATTR_UNUSED const Process* proc, ATTR_UNUSED RichString* str, ATTR_UNUSED unsigned int key) { return false; } +static inline void Platform_dynamicScreensDone(ATTR_UNUSED Hashtable* screens) { } #endif diff --git a/unsupported/UnsupportedMachine.c b/unsupported/UnsupportedMachine.c new file mode 100644 index 0000000..a6635ac --- /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 0000000..4ec760f --- /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/UnsupportedProcess.c b/unsupported/UnsupportedProcess.c index 2aca048..3d6d883 100644 --- a/unsupported/UnsupportedProcess.c +++ b/unsupported/UnsupportedProcess.c @@ -44,10 +44,10 @@ const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = { [TGID] = { .name = "TGID", .title = "TGID", .description = "Thread group ID (i.e. process ID)", .flags = 0, .pidColumn = true, }, }; -Process* UnsupportedProcess_new(const Settings* settings) { +Process* UnsupportedProcess_new(const Machine* host) { Process* this = xCalloc(1, sizeof(UnsupportedProcess)); Object_setClass(this, Class(UnsupportedProcess)); - Process_init(this, settings); + Process_init(this, host); return this; } @@ -58,23 +58,24 @@ void Process_delete(Object* cast) { free(cast); } -static void UnsupportedProcess_writeField(const Process* this, RichString* str, ProcessField field) { - const UnsupportedProcess* up = (const UnsupportedProcess*) this; - bool coloring = this->settings->highlightMegabytes; +static void UnsupportedProcess_rowWriteField(const Row* super, RichString* str, ProcessField field) { + const UnsupportedProcess* up = (const UnsupportedProcess*) super; + + bool coloring = super->host->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); + Process_writeField(&up->super, str, field); return; } + RichString_appendWide(str, attr, buffer); } @@ -94,11 +95,18 @@ static int UnsupportedProcess_compareByKey(const Process* v1, const Process* v2, const ProcessClass UnsupportedProcess_class = { .super = { - .extends = Class(Process), - .display = Process_display, - .delete = Process_delete, - .compare = Process_compare + .super = { + .extends = Class(Process), + .display = Row_display, + .delete = Process_delete, + .compare = Process_compare + }, + .isHighlighted = Process_rowIsHighlighted, + .isVisible = Process_rowIsVisible, + .matchesFilter = Process_rowMatchesFilter, + .compareByParent = Process_compareByParent, + .sortKeyString = Process_rowGetSortKey, + .writeField = UnsupportedProcess_rowWriteField }, - .writeField = UnsupportedProcess_writeField, .compareByKey = UnsupportedProcess_compareByKey }; diff --git a/unsupported/UnsupportedProcess.h b/unsupported/UnsupportedProcess.h index e30169c..21956dd 100644 --- a/unsupported/UnsupportedProcess.h +++ b/unsupported/UnsupportedProcess.h @@ -7,7 +7,7 @@ Released under the GNU GPLv2+, see the COPYING file in the source distribution for its full text. */ -#include "Settings.h" +#include "Machine.h" typedef struct UnsupportedProcess_ { @@ -19,7 +19,7 @@ typedef struct UnsupportedProcess_ { extern const ProcessFieldData Process_fields[LAST_PROCESSFIELD]; -Process* UnsupportedProcess_new(const Settings* settings); +Process* UnsupportedProcess_new(const Machine* host); void Process_delete(Object* cast); diff --git a/unsupported/UnsupportedProcessList.h b/unsupported/UnsupportedProcessList.h deleted file mode 100644 index cbf25af..0000000 --- a/unsupported/UnsupportedProcessList.h +++ /dev/null @@ -1,21 +0,0 @@ -#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 diff --git a/unsupported/UnsupportedProcessList.c b/unsupported/UnsupportedProcessTable.c index 5291797..db43f1e 100644 --- a/unsupported/UnsupportedProcessList.c +++ b/unsupported/UnsupportedProcessTable.c @@ -1,66 +1,64 @@ /* -htop - UnsupportedProcessList.c +htop - UnsupportedProcessTable.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 "config.h" // IWYU pragma: keep + +#include "UnsupportedProcessTable.h" #include <stdlib.h> #include <string.h> -#include "ProcessList.h" +#include "ProcessTable.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); +ProcessTable* ProcessTable_new(Machine* host, Hashtable* pidMatchList) { + UnsupportedProcessTable* this = xCalloc(1, sizeof(UnsupportedProcessTable)); + Object_setClass(this, Class(ProcessTable)); - this->existingCPUs = 1; - this->activeCPUs = 1; + ProcessTable* super = &this->super; + ProcessTable_init(super, Class(Process), host, pidMatchList); return this; } -void ProcessList_delete(ProcessList* this) { - ProcessList_done(this); +void ProcessTable_delete(Object* cast) { + UnsupportedProcessTable* this = (UnsupportedProcessTable*) cast; + ProcessTable_done(&this->super); free(this); } -void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) { - - // in pause mode only gather global data for meters (CPU/memory/...) - if (pauseProcessUpdate) { - return; - } - +void ProcessTable_goThroughEntries(ProcessTable* super) { bool preExisting = true; Process* proc; - proc = ProcessList_getProcess(super, 1, &preExisting, UnsupportedProcess_new); + proc = ProcessTable_getProcess(super, 1, &preExisting, UnsupportedProcess_new); /* Empty values */ proc->time = proc->time + 10; - proc->pid = 1; - proc->ppid = 1; - proc->tgid = 0; + Process_setPid(proc, 1); + Process_setParent(proc, 1); + Process_setThreadGroup(proc, 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) { + const Settings* settings = proc->host->settings; + if (settings->ss->flags & PROCESS_FLAG_CWD) { free_and_xStrdup(&proc->procCwd, "/current/working/directory"); } - proc->updated = true; + proc->super.updated = true; proc->state = RUNNING; proc->isKernelThread = false; proc->isUserlandThread = false; - proc->show = true; /* Reflected in proc->settings-> "hideXXX" really */ + proc->super.show = true; /* Reflected in settings-> "hideXXX" really */ proc->pgrp = 0; proc->session = 0; proc->tty_nr = 0; @@ -88,13 +86,5 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) { 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; + ProcessTable_add(super, proc); } diff --git a/unsupported/UnsupportedProcessTable.h b/unsupported/UnsupportedProcessTable.h new file mode 100644 index 0000000..1de8087 --- /dev/null +++ b/unsupported/UnsupportedProcessTable.h @@ -0,0 +1,17 @@ +#ifndef HEADER_UnsupportedProcessTable +#define HEADER_UnsupportedProcessTable +/* +htop - UnsupportedProcessTable.h +(C) 2014 Hisham H. Muhammad +Released under the GNU GPLv2+, see the COPYING file +in the source distribution for its full text. +*/ + +#include "ProcessTable.h" + + +typedef struct UnsupportedProcessTable_ { + ProcessTable super; +} UnsupportedProcessTable; + +#endif |