summaryrefslogtreecommitdiffstats
path: root/darwin
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 /darwin
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 'darwin')
-rw-r--r--darwin/DarwinProcess.c7
-rw-r--r--darwin/DarwinProcess.h7
-rw-r--r--darwin/Platform.c2
-rw-r--r--darwin/Platform.h3
-rw-r--r--darwin/ProcessField.h16
5 files changed, 20 insertions, 15 deletions
diff --git a/darwin/DarwinProcess.c b/darwin/DarwinProcess.c
index c463193b..8f11e338 100644
--- a/darwin/DarwinProcess.c
+++ b/darwin/DarwinProcess.c
@@ -18,7 +18,7 @@ in the source distribution for its full text.
#include "Process.h"
-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, },
@@ -45,7 +45,6 @@ ProcessFieldData Process_fields[] = {
[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, },
[TRANSLATED] = { .name = "TRANSLATED", .title = "T ", .description = "Translation info (T translated, N native)", .flags = 0, },
- [LAST_PROCESSFIELD] = { .name = "*** report bug! ***", .title = NULL, .description = NULL, .flags = 0, },
};
Process* DarwinProcess_new(const Settings* settings) {
@@ -73,7 +72,7 @@ static void DarwinProcess_writeField(const Process* this, RichString* str, Proce
char buffer[256]; buffer[255] = '\0';
int attr = CRT_colors[DEFAULT_COLOR];
int n = sizeof(buffer) - 1;
- switch ((int) field) {
+ switch (field) {
// add Platform-specific fields here
case TRANSLATED: xSnprintf(buffer, n, "%c ", dp->translated ? 'T' : 'N'); break;
default:
@@ -87,7 +86,7 @@ static long DarwinProcess_compareByKey(const Process* v1, const Process* v2, Pro
const DarwinProcess* p1 = (const DarwinProcess*)v1;
const DarwinProcess* p2 = (const DarwinProcess*)v2;
- switch ((int) key) {
+ switch (key) {
// add Platform-specific fields here
case TRANSLATED:
return SPACESHIP_NUMBER(p1->translated, p2->translated);
diff --git a/darwin/DarwinProcess.h b/darwin/DarwinProcess.h
index 33dbcd14..60b57dfa 100644
--- a/darwin/DarwinProcess.h
+++ b/darwin/DarwinProcess.h
@@ -12,11 +12,6 @@ in the source distribution for its full text.
#include "DarwinProcessList.h"
#include "Settings.h"
-typedef enum DarwinProcessFields_ {
- // Add platform-specific fields here, with ids >= 100
- TRANSLATED = 100,
- LAST_PROCESSFIELD = 101,
-} DarwinProcessField;
typedef struct DarwinProcess_ {
Process super;
@@ -29,7 +24,7 @@ typedef struct DarwinProcess_ {
extern const ProcessClass DarwinProcess_class;
-extern ProcessFieldData Process_fields[];
+extern ProcessFieldData Process_fields[LAST_PROCESSFIELD];
Process* DarwinProcess_new(const Settings* settings);
diff --git a/darwin/Platform.c b/darwin/Platform.c
index 235044f9..0fe2ac7f 100644
--- a/darwin/Platform.c
+++ b/darwin/Platform.c
@@ -110,8 +110,6 @@ const MeterClass* const Platform_meterTypes[] = {
NULL
};
-int Platform_numberOfFields = LAST_PROCESSFIELD;
-
double Platform_timebaseToNS = 1.0;
void Platform_init(void) {
diff --git a/darwin/Platform.h b/darwin/Platform.h
index 74b46190..1c743725 100644
--- a/darwin/Platform.h
+++ b/darwin/Platform.h
@@ -19,12 +19,9 @@ in the source distribution for its full text.
#include "ProcessLocksScreen.h"
#include "SignalsPanel.h"
-extern ProcessFieldData Process_fields[];
extern ProcessField Platform_defaultFields[];
-extern int Platform_numberOfFields;
-
extern double Platform_timebaseToNS;
extern const SignalItem Platform_signals[];
diff --git a/darwin/ProcessField.h b/darwin/ProcessField.h
new file mode 100644
index 00000000..5a8090fe
--- /dev/null
+++ b/darwin/ProcessField.h
@@ -0,0 +1,16 @@
+#ifndef HEADER_DarwinProcessField
+#define HEADER_DarwinProcessField
+/*
+htop - darwin/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 \
+ TRANSLATED = 100, \
+ // End of list
+
+
+#endif /* HEADER_DarwinProcessField */

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