mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-14 21:14:35 +03:00
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:

committed by
cgzones

parent
d872e36308
commit
89473cc9ae
@ -119,10 +119,6 @@ const MeterClass* const Platform_meterTypes[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
int Platform_numberOfFields = LAST_PROCESSFIELD;
|
||||
|
||||
extern char Process_pidFormat[20];
|
||||
|
||||
void Platform_init(void) {
|
||||
/* no platform-specific setup needed */
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ in the source distribution for its full text.
|
||||
|
||||
#define kill(pid, signal) kill(pid / 1024, signal)
|
||||
|
||||
extern ProcessFieldData Process_fields[];
|
||||
typedef struct var kvar_t;
|
||||
|
||||
typedef struct envAccum_ {
|
||||
@ -45,10 +44,6 @@ extern ProcessField Platform_defaultFields[];
|
||||
|
||||
extern const MeterClass* const Platform_meterTypes[];
|
||||
|
||||
extern int Platform_numberOfFields;
|
||||
|
||||
extern char Process_pidFormat[20];
|
||||
|
||||
void Platform_init(void);
|
||||
|
||||
void Platform_done(void);
|
||||
|
22
solaris/ProcessField.h
Normal file
22
solaris/ProcessField.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef HEADER_SolarisProcessField
|
||||
#define HEADER_SolarisProcessField
|
||||
/*
|
||||
htop - solaris/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 \
|
||||
ZONEID = 100, \
|
||||
ZONE = 101, \
|
||||
PROJID = 102, \
|
||||
TASKID = 103, \
|
||||
POOLID = 104, \
|
||||
CONTID = 105, \
|
||||
LWPID = 106, \
|
||||
// End of list
|
||||
|
||||
|
||||
#endif /* HEADER_SolarisProcessField */
|
@ -29,7 +29,7 @@ const ProcessClass SolarisProcess_class = {
|
||||
.compareByKey = SolarisProcess_compareByKey
|
||||
};
|
||||
|
||||
ProcessFieldData Process_fields[] = {
|
||||
ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
||||
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },
|
||||
[PID] = { .name = "PID", .title = " PID ", .description = "Process/thread ID", .flags = 0, },
|
||||
[COMM] = { .name = "Command", .title = "Command ", .description = "Command line", .flags = 0, },
|
||||
@ -62,7 +62,6 @@ ProcessFieldData Process_fields[] = {
|
||||
[POOLID] = { .name = "POOLID", .title = " POLID ", .description = "Pool ID", .flags = 0, },
|
||||
[CONTID] = { .name = "CONTID", .title = " CNTID ", .description = "Contract ID", .flags = 0, },
|
||||
[LWPID] = { .name = "LWPID", .title = " LWPID ", .description = "LWP ID", .flags = 0, },
|
||||
[LAST_PROCESSFIELD] = { .name = "*** report bug! ***", .title = NULL, .description = NULL, .flags = 0, },
|
||||
};
|
||||
|
||||
ProcessPidColumn Process_pidColumns[] = {
|
||||
@ -100,7 +99,7 @@ void SolarisProcess_writeField(const Process* this, RichString* str, ProcessFiel
|
||||
char buffer[256]; buffer[255] = '\0';
|
||||
int attr = CRT_colors[DEFAULT_COLOR];
|
||||
int n = sizeof(buffer) - 1;
|
||||
switch ((int) field) {
|
||||
switch (field) {
|
||||
// add Solaris-specific fields here
|
||||
case ZONEID: xSnprintf(buffer, n, Process_pidFormat, sp->zoneid); break;
|
||||
case PROJID: xSnprintf(buffer, n, Process_pidFormat, sp->projid); break;
|
||||
@ -122,7 +121,7 @@ long SolarisProcess_compareByKey(const void* v1, const void* v2, ProcessField ke
|
||||
const SolarisProcess* p1 = (const SolarisProcess*)v1;
|
||||
const SolarisProcess* p2 = (const SolarisProcess*)v2;
|
||||
|
||||
switch ((int) key) {
|
||||
switch (key) {
|
||||
case ZONEID:
|
||||
return SPACESHIP_NUMBER(p1->zoneid, p2->zoneid);
|
||||
case PROJID:
|
||||
|
@ -13,18 +13,6 @@ in the source distribution for its full text.
|
||||
#include <sys/proc.h>
|
||||
#include <libproc.h>
|
||||
|
||||
typedef enum SolarisProcessField_ {
|
||||
// Add platform-specific fields here, with ids >= 100
|
||||
ZONEID = 100,
|
||||
ZONE = 101,
|
||||
PROJID = 102,
|
||||
TASKID = 103,
|
||||
POOLID = 104,
|
||||
CONTID = 105,
|
||||
LWPID = 106,
|
||||
LAST_PROCESSFIELD = 107,
|
||||
} SolarisProcessField;
|
||||
|
||||
typedef struct SolarisProcess_ {
|
||||
Process super;
|
||||
int kernel;
|
||||
@ -46,7 +34,7 @@ typedef struct SolarisProcess_ {
|
||||
|
||||
extern const ProcessClass SolarisProcess_class;
|
||||
|
||||
extern ProcessFieldData Process_fields[];
|
||||
extern ProcessFieldData Process_fields[LAST_PROCESSFIELD];
|
||||
|
||||
extern ProcessPidColumn Process_pidColumns[];
|
||||
|
||||
|
Reference in New Issue
Block a user