summaryrefslogtreecommitdiffstats
path: root/solaris
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2020-12-15 19:44:48 +0100
committercgzones <cgzones@googlemail.com>2020-12-19 21:13:32 +0100
commit89473cc9ae950bbb5e291d1f186d372f66f66394 (patch)
treed1e21dbd0df28c00c467695711c8dde884e746a1 /solaris
parentd872e363081a892d65dede6a90721d3a2e8b0ee6 (diff)
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
Diffstat (limited to 'solaris')
-rw-r--r--solaris/Platform.c4
-rw-r--r--solaris/Platform.h5
-rw-r--r--solaris/ProcessField.h22
-rw-r--r--solaris/SolarisProcess.c7
-rw-r--r--solaris/SolarisProcess.h14
5 files changed, 26 insertions, 26 deletions
diff --git a/solaris/Platform.c b/solaris/Platform.c
index 014eaf55..b674998b 100644
--- a/solaris/Platform.c
+++ b/solaris/Platform.c
@@ -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 */
}
diff --git a/solaris/Platform.h b/solaris/Platform.h
index c3381152..4daf7164 100644
--- a/solaris/Platform.h
+++ b/solaris/Platform.h
@@ -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);
diff --git a/solaris/ProcessField.h b/solaris/ProcessField.h
new file mode 100644
index 00000000..eb9f1577
--- /dev/null
+++ b/solaris/ProcessField.h
@@ -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 */
diff --git a/solaris/SolarisProcess.c b/solaris/SolarisProcess.c
index f6470a3c..3d4f9538 100644
--- a/solaris/SolarisProcess.c
+++ b/solaris/SolarisProcess.c
@@ -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:
diff --git a/solaris/SolarisProcess.h b/solaris/SolarisProcess.h
index 12e6c99f..5f79754a 100644
--- a/solaris/SolarisProcess.h
+++ b/solaris/SolarisProcess.h
@@ -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[];

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