diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2020-12-15 19:44:48 +0100 |
---|---|---|
committer | cgzones <cgzones@googlemail.com> | 2020-12-19 21:13:32 +0100 |
commit | 89473cc9ae950bbb5e291d1f186d372f66f66394 (patch) | |
tree | d1e21dbd0df28c00c467695711c8dde884e746a1 /linux | |
parent | d872e363081a892d65dede6a90721d3a2e8b0ee6 (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 'linux')
-rw-r--r-- | linux/LinuxProcess.c | 7 | ||||
-rw-r--r-- | linux/LinuxProcess.h | 50 | ||||
-rw-r--r-- | linux/Platform.c | 4 | ||||
-rw-r--r-- | linux/Platform.h | 2 | ||||
-rw-r--r-- | linux/ProcessField.h | 53 |
5 files changed, 58 insertions, 58 deletions
diff --git a/linux/LinuxProcess.c b/linux/LinuxProcess.c index 24d735e1..a8b62cc0 100644 --- a/linux/LinuxProcess.c +++ b/linux/LinuxProcess.c @@ -30,7 +30,7 @@ int pageSizeKB; /* Used to identify kernel threads in Comm and Exe columns */ static const char *const kthreadID = "KTHREAD"; -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, }, @@ -100,7 +100,6 @@ ProcessFieldData Process_fields[] = { [PROC_COMM] = { .name = "COMM", .title = "COMM ", .description = "comm string of the process from /proc/[pid]/comm", .flags = 0, }, [PROC_EXE] = { .name = "EXE", .title = "EXE ", .description = "Basename of exe of the process from /proc/[pid]/exe", .flags = 0, }, [CWD] = { .name ="CWD", .title = "CWD ", .description = "The current working directory of the process", .flags = PROCESS_FLAG_LINUX_CWD, }, - [LAST_PROCESSFIELD] = { .name = "*** report bug! ***", .title = NULL, .description = NULL, .flags = 0, }, }; ProcessPidColumn Process_pidColumns[] = { @@ -608,7 +607,7 @@ static void LinuxProcess_writeField(const Process* this, RichString* str, Proces char buffer[256]; buffer[255] = '\0'; int attr = CRT_colors[DEFAULT_COLOR]; size_t n = sizeof(buffer) - 1; - switch ((int)field) { + switch (field) { case TTY_NR: { if (lp->ttyDevice) { xSnprintf(buffer, n, "%-9s", lp->ttyDevice + 5 /* skip "/dev/" */); @@ -753,7 +752,7 @@ static long LinuxProcess_compareByKey(const Process* v1, const Process* v2, Proc const LinuxProcess* p1 = (const LinuxProcess*)v1; const LinuxProcess* p2 = (const LinuxProcess*)v2; - switch ((int) key) { + switch (key) { case M_DRS: return SPACESHIP_NUMBER(p2->m_drs, p1->m_drs); case M_DT: diff --git a/linux/LinuxProcess.h b/linux/LinuxProcess.h index 992e548d..16667827 100644 --- a/linux/LinuxProcess.h +++ b/linux/LinuxProcess.h @@ -30,54 +30,6 @@ in the source distribution for its full text. #define PROCESS_FLAG_LINUX_CWD 0x00020000 -typedef enum LinuxProcessField_ { - CMINFLT = 11, - CMAJFLT = 13, - UTIME = 14, - STIME = 15, - CUTIME = 16, - CSTIME = 17, - M_SHARE = 41, - M_TRS = 42, - M_DRS = 43, - M_LRS = 44, - M_DT = 45, - #ifdef HAVE_OPENVZ - CTID = 100, - VPID = 101, - #endif - #ifdef HAVE_VSERVER - VXID = 102, - #endif - RCHAR = 103, - WCHAR = 104, - SYSCR = 105, - SYSCW = 106, - RBYTES = 107, - WBYTES = 108, - CNCLWB = 109, - IO_READ_RATE = 110, - IO_WRITE_RATE = 111, - IO_RATE = 112, - CGROUP = 113, - OOM = 114, - IO_PRIORITY = 115, - #ifdef HAVE_DELAYACCT - PERCENT_CPU_DELAY = 116, - PERCENT_IO_DELAY = 117, - PERCENT_SWAP_DELAY = 118, - #endif - M_PSS = 119, - M_SWAP = 120, - M_PSSWP = 121, - CTXT = 122, - SECATTR = 123, - PROC_COMM = 124, - PROC_EXE = 125, - CWD = 126, - LAST_PROCESSFIELD = 127, -} LinuxProcessField; - /* LinuxProcessMergedCommand is populated by LinuxProcess_makeCommandStr: It * contains the merged Command string, and the information needed by * LinuxProcess_writeCommand to color the string. str will be NULL for kernel @@ -175,7 +127,7 @@ extern int pageSize; extern int pageSizeKB; -extern ProcessFieldData Process_fields[]; +extern ProcessFieldData Process_fields[LAST_PROCESSFIELD]; extern ProcessPidColumn Process_pidColumns[]; diff --git a/linux/Platform.c b/linux/Platform.c index 590fc7aa..d048a804 100644 --- a/linux/Platform.c +++ b/linux/Platform.c @@ -65,9 +65,7 @@ in the source distribution for its full text. #endif -ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_VIRT, M_RESIDENT, (int)M_SHARE, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 }; - -int Platform_numberOfFields = LAST_PROCESSFIELD; +ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_VIRT, M_RESIDENT, M_SHARE, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 }; const SignalItem Platform_signals[] = { { .name = " 0 Cancel", .number = 0 }, diff --git a/linux/Platform.h b/linux/Platform.h index 280b997c..be0331b9 100644 --- a/linux/Platform.h +++ b/linux/Platform.h @@ -20,8 +20,6 @@ in the source distribution for its full text. extern ProcessField Platform_defaultFields[]; -extern int Platform_numberOfFields; - extern const SignalItem Platform_signals[]; extern const unsigned int Platform_numberOfSignals; diff --git a/linux/ProcessField.h b/linux/ProcessField.h new file mode 100644 index 00000000..6e2eff38 --- /dev/null +++ b/linux/ProcessField.h @@ -0,0 +1,53 @@ +#ifndef HEADER_LinuxProcessField +#define HEADER_LinuxProcessField +/* +htop - linux/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 \ + CMINFLT = 11, \ + CMAJFLT = 13, \ + UTIME = 14, \ + STIME = 15, \ + CUTIME = 16, \ + CSTIME = 17, \ + M_SHARE = 41, \ + M_TRS = 42, \ + M_DRS = 43, \ + M_LRS = 44, \ + M_DT = 45, \ + CTID = 100, \ + VPID = 101, \ + VXID = 102, \ + RCHAR = 103, \ + WCHAR = 104, \ + SYSCR = 105, \ + SYSCW = 106, \ + RBYTES = 107, \ + WBYTES = 108, \ + CNCLWB = 109, \ + IO_READ_RATE = 110, \ + IO_WRITE_RATE = 111, \ + IO_RATE = 112, \ + CGROUP = 113, \ + OOM = 114, \ + IO_PRIORITY = 115, \ + PERCENT_CPU_DELAY = 116, \ + PERCENT_IO_DELAY = 117, \ + PERCENT_SWAP_DELAY = 118, \ + M_PSS = 119, \ + M_SWAP = 120, \ + M_PSSWP = 121, \ + CTXT = 122, \ + SECATTR = 123, \ + PROC_COMM = 124, \ + PROC_EXE = 125, \ + CWD = 126, \ + // End of list + + +#endif /* HEADER_LinuxProcessField */ |