Rework enum ProcessField

Use only one enum instead of a global and a platform specific one.
Drop Platform_numberOfFields global variable.
Set known size of Process_fields array
This commit is contained in:
Christian Göttsche
2020-12-15 19:44:48 +01:00
committed by cgzones
parent d872e36308
commit 89473cc9ae
41 changed files with 208 additions and 175 deletions

View File

@ -16,7 +16,7 @@ in the source distribution for its full text.
#include "XUtils.h"
ProcessFieldData Process_fields[] = {
ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
[0] = {
.name = "",
.title = NULL,
@ -167,12 +167,6 @@ ProcessFieldData Process_fields[] = {
.description = "Thread group ID (i.e. process ID)",
.flags = 0,
},
[LAST_PROCESSFIELD] = {
.name = "*** report bug! ***",
.title = NULL,
.description = NULL,
.flags = 0,
},
};
ProcessPidColumn Process_pidColumns[] = {
@ -219,7 +213,7 @@ static long OpenBSDProcess_compareByKey(const Process* v1, const Process* v2, Pr
// remove if actually used
(void)p1; (void)p2;
switch ((int) key) {
switch (key) {
// add OpenBSD-specific fields here
default:
return Process_compareByKey_Base(v1, v2, key);

View File

@ -15,11 +15,6 @@ in the source distribution for its full text.
#include "Settings.h"
typedef enum OpenBSDProcessFields_ {
// Add platform-specific fields here, with ids >= 100
LAST_PROCESSFIELD = 100,
} OpenBSDProcessField;
typedef struct OpenBSDProcess_ {
Process super;
} OpenBSDProcess;
@ -30,7 +25,7 @@ typedef struct OpenBSDProcess_ {
extern const ProcessClass OpenBSDProcess_class;
extern ProcessFieldData Process_fields[];
extern ProcessFieldData Process_fields[LAST_PROCESSFIELD];
extern ProcessPidColumn Process_pidColumns[];

View File

@ -44,8 +44,6 @@ in the source distribution for its full text.
ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_VIRT, M_RESIDENT, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 };
int Platform_numberOfFields = LAST_PROCESSFIELD;
/*
* See /usr/include/sys/signal.h
*/

View File

@ -20,12 +20,8 @@ in the source distribution for its full text.
#include "SignalsPanel.h"
extern ProcessFieldData Process_fields[];
extern ProcessField Platform_defaultFields[];
extern int Platform_numberOfFields;
/* see /usr/include/sys/signal.h */
extern const SignalItem Platform_signals[];

15
openbsd/ProcessField.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef HEADER_OpenBSDProcessField
#define HEADER_OpenBSDProcessField
/*
htop - openbsd/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_OpenBSDProcessField */