summaryrefslogtreecommitdiffstats
path: root/freebsd
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2020-10-21 19:11:26 +0200
committercgzones <cgzones@googlemail.com>2020-10-29 22:21:42 +0100
commit049046c700ea42e8f9bb77f5efbb5a66ed3c4651 (patch)
treeeedfebf20d42e83d23be9c6034a9ded7ca554213 /freebsd
parent97ea45ca9a4ee639681e3048be4813b56c969bdd (diff)
FreeBSD: update Process
Diffstat (limited to 'freebsd')
-rw-r--r--freebsd/FreeBSDProcess.c26
-rw-r--r--freebsd/FreeBSDProcess.h12
-rw-r--r--freebsd/FreeBSDProcessList.c5
3 files changed, 21 insertions, 22 deletions
diff --git a/freebsd/FreeBSDProcess.c b/freebsd/FreeBSDProcess.c
index 616a7196..fee2c2c8 100644
--- a/freebsd/FreeBSDProcess.c
+++ b/freebsd/FreeBSDProcess.c
@@ -19,16 +19,6 @@ in the source distribution for its full text.
const char* const nodevStr = "nodev";
-const ProcessClass FreeBSDProcess_class = {
- .super = {
- .extends = Class(Process),
- .display = Process_display,
- .delete = Process_delete,
- .compare = FreeBSDProcess_compare
- },
- .writeField = FreeBSDProcess_writeField,
-};
-
ProcessFieldData Process_fields[] = {
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },
[PID] = { .name = "PID", .title = " PID ", .description = "Process/thread ID", .flags = 0, },
@@ -85,7 +75,7 @@ void Process_delete(Object* cast) {
free(this);
}
-void FreeBSDProcess_writeField(const Process* this, RichString* str, ProcessField field) {
+static void FreeBSDProcess_writeField(const Process* this, RichString* str, ProcessField field) {
const FreeBSDProcess* fp = (const FreeBSDProcess*) this;
char buffer[256]; buffer[255] = '\0';
int attr = CRT_colors[DEFAULT_COLOR];
@@ -118,7 +108,7 @@ void FreeBSDProcess_writeField(const Process* this, RichString* str, ProcessFiel
RichString_append(str, attr, buffer);
}
-long FreeBSDProcess_compare(const void* v1, const void* v2) {
+static long FreeBSDProcess_compare(const void* v1, const void* v2) {
const FreeBSDProcess *p1, *p2;
const Settings *settings = ((const Process*)v1)->settings;
if (settings->direction == 1) {
@@ -147,5 +137,15 @@ bool Process_isThread(const Process* this) {
if (fp->kernel == 1 )
return 1;
else
- return (Process_isUserlandThread(this));
+ return Process_isUserlandThread(this);
}
+
+const ProcessClass FreeBSDProcess_class = {
+ .super = {
+ .extends = Class(Process),
+ .display = Process_display,
+ .delete = Process_delete,
+ .compare = FreeBSDProcess_compare
+ },
+ .writeField = FreeBSDProcess_writeField,
+};
diff --git a/freebsd/FreeBSDProcess.h b/freebsd/FreeBSDProcess.h
index d6873d09..d2fee956 100644
--- a/freebsd/FreeBSDProcess.h
+++ b/freebsd/FreeBSDProcess.h
@@ -34,9 +34,13 @@ typedef struct FreeBSDProcess_ {
const char* ttyPath;
} FreeBSDProcess;
-#define Process_isKernelThread(_process) (_process->kernel == 1)
+static inline bool Process_isKernelThread(const Process* this) {
+ return ((const FreeBSDProcess*)this)->kernel == 1;
+}
-#define Process_isUserlandThread(_process) (_process->pid != _process->tgid)
+static inline bool Process_isUserlandThread(const Process* this) {
+ return this->pid != this->tgid;
+}
extern const ProcessClass FreeBSDProcess_class;
@@ -48,10 +52,6 @@ Process* FreeBSDProcess_new(const Settings* settings);
void Process_delete(Object* cast);
-void FreeBSDProcess_writeField(const Process* this, RichString* str, ProcessField field);
-
-long FreeBSDProcess_compare(const void* v1, const void* v2);
-
bool Process_isThread(const Process* this);
#endif
diff --git a/freebsd/FreeBSDProcessList.c b/freebsd/FreeBSDProcessList.c
index caa04ccd..4c418114 100644
--- a/freebsd/FreeBSDProcessList.c
+++ b/freebsd/FreeBSDProcessList.c
@@ -479,7 +479,7 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
Process* proc = ProcessList_getProcess(super, kproc->ki_pid, &preExisting, FreeBSDProcess_new);
FreeBSDProcess* fp = (FreeBSDProcess*) proc;
- proc->show = ! ((hideKernelThreads && Process_isKernelThread(fp)) || (hideUserlandThreads && Process_isUserlandThread(proc)));
+ proc->show = ! ((hideKernelThreads && Process_isKernelThread(proc)) || (hideUserlandThreads && Process_isUserlandThread(proc)));
if (!preExisting) {
fp->jid = kproc->ki_jid;
@@ -567,9 +567,8 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
if (settings->flags & PROCESS_FLAG_FREEBSD_TTY)
fp->ttyPath = (kproc->ki_tdev == NODEV) ? nodevStr : Hashtable_get(fpl->ttys, kproc->ki_tdev);
- if (Process_isKernelThread(fp)) {
+ if (Process_isKernelThread(proc))
super->kernelThreads++;
- }
super->totalTasks++;
if (proc->state == 'R')

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