diff options
author | Daniel Lange <DLange@git.local> | 2020-12-07 10:26:01 +0100 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2020-12-07 10:26:01 +0100 |
commit | 65357c8c46154de4e4eca14075bfe5523bb5fc14 (patch) | |
tree | 8f430ee5a0d5de377c4e7c94e47842a27c70d7e8 /dragonflybsd/DragonFlyBSDProcess.c | |
parent | f80394a20254938142011855f2954b3f63fe5909 (diff) | |
download | debian_htop-65357c8c46154de4e4eca14075bfe5523bb5fc14.tar.gz debian_htop-65357c8c46154de4e4eca14075bfe5523bb5fc14.tar.bz2 debian_htop-65357c8c46154de4e4eca14075bfe5523bb5fc14.zip |
New upstream version 3.0.3upstream/3.0.3
Diffstat (limited to 'dragonflybsd/DragonFlyBSDProcess.c')
-rw-r--r-- | dragonflybsd/DragonFlyBSDProcess.c | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/dragonflybsd/DragonFlyBSDProcess.c b/dragonflybsd/DragonFlyBSDProcess.c index 770143b..9311f03 100644 --- a/dragonflybsd/DragonFlyBSDProcess.c +++ b/dragonflybsd/DragonFlyBSDProcess.c @@ -2,7 +2,7 @@ htop - dragonflybsd/DragonFlyBSDProcess.c (C) 2015 Hisham H. Muhammad (C) 2017 Diederik de Groot -Released under the GNU GPL, see the COPYING file +Released under the GNU GPLv2, see the COPYING file in the source distribution for its full text. */ @@ -18,14 +18,14 @@ in the source distribution for its full text. #include <sys/syscall.h> -ProcessClass DragonFlyBSDProcess_class = { +const ProcessClass DragonFlyBSDProcess_class = { .super = { .extends = Class(Process), .display = Process_display, .delete = Process_delete, .compare = DragonFlyBSDProcess_compare }, - .writeField = (Process_WriteField) DragonFlyBSDProcess_writeField, + .writeField = DragonFlyBSDProcess_writeField, }; ProcessFieldData Process_fields[] = { @@ -44,10 +44,11 @@ ProcessFieldData Process_fields[] = { [NICE] = { .name = "NICE", .title = " NI ", .description = "Nice value (the higher the value, the more it lets other processes take priority)", .flags = 0, }, [STARTTIME] = { .name = "STARTTIME", .title = "START ", .description = "Time the process was started", .flags = 0, }, [PROCESSOR] = { .name = "PROCESSOR", .title = "CPU ", .description = "Id of the CPU the process last executed on", .flags = 0, }, - [M_SIZE] = { .name = "M_SIZE", .title = " VIRT ", .description = "Total program size in virtual memory", .flags = 0, }, + [M_VIRT] = { .name = "M_VIRT", .title = " VIRT ", .description = "Total program size in virtual memory", .flags = 0, }, [M_RESIDENT] = { .name = "M_RESIDENT", .title = " RES ", .description = "Resident set size, size of the text and data sections, plus stack usage", .flags = 0, }, [ST_UID] = { .name = "ST_UID", .title = " UID ", .description = "User ID of the process owner", .flags = 0, }, [PERCENT_CPU] = { .name = "PERCENT_CPU", .title = "CPU% ", .description = "Percentage of the CPU time the process used in the last sampling", .flags = 0, }, + [PERCENT_NORM_CPU] = { .name = "PERCENT_NORM_CPU", .title = "NCPU%", .description = "Normalized percentage of the CPU time the process used in the last sampling (normalized by cpu count)", .flags = 0, }, [PERCENT_MEM] = { .name = "PERCENT_MEM", .title = "MEM% ", .description = "Percentage of the memory the process is using, based on resident memory size", .flags = 0, }, [USER] = { .name = "USER", .title = "USER ", .description = "Username of the process owner (or user ID if name cannot be determined)", .flags = 0, }, [TIME] = { .name = "TIME", .title = " TIME+ ", .description = "Total time the process has spent in user and system time", .flags = 0, }, @@ -69,11 +70,11 @@ ProcessPidColumn Process_pidColumns[] = { { .id = 0, .label = NULL }, }; -DragonFlyBSDProcess* DragonFlyBSDProcess_new(Settings* settings) { +Process* DragonFlyBSDProcess_new(const Settings* settings) { DragonFlyBSDProcess* this = xCalloc(1, sizeof(DragonFlyBSDProcess)); Object_setClass(this, Class(DragonFlyBSDProcess)); Process_init(&this->super, settings); - return this; + return &this->super; } void Process_delete(Object* cast) { @@ -83,8 +84,8 @@ void Process_delete(Object* cast) { free(this); } -void DragonFlyBSDProcess_writeField(Process* this, RichString* str, ProcessField field) { - DragonFlyBSDProcess* fp = (DragonFlyBSDProcess*) this; +void DragonFlyBSDProcess_writeField(const Process* this, RichString* str, ProcessField field) { + const DragonFlyBSDProcess* fp = (const DragonFlyBSDProcess*) this; char buffer[256]; buffer[255] = '\0'; int attr = CRT_colors[DEFAULT_COLOR]; int n = sizeof(buffer) - 1; @@ -92,7 +93,7 @@ void DragonFlyBSDProcess_writeField(Process* this, RichString* str, ProcessField // add Platform-specific fields here case PID: xSnprintf(buffer, n, Process_pidFormat, (fp->kernel ? -1 : this->pid)); break; case JID: xSnprintf(buffer, n, Process_pidFormat, fp->jid); break; - case JAIL:{ + case JAIL: { xSnprintf(buffer, n, "%-11s ", fp->jname); if (buffer[11] != '\0') { buffer[11] = ' '; @@ -108,31 +109,34 @@ void DragonFlyBSDProcess_writeField(Process* this, RichString* str, ProcessField } long DragonFlyBSDProcess_compare(const void* v1, const void* v2) { - DragonFlyBSDProcess *p1, *p2; - Settings *settings = ((Process*)v1)->settings; + const DragonFlyBSDProcess *p1, *p2; + const Settings *settings = ((const Process*)v1)->settings; + if (settings->direction == 1) { - p1 = (DragonFlyBSDProcess*)v1; - p2 = (DragonFlyBSDProcess*)v2; + p1 = (const DragonFlyBSDProcess*)v1; + p2 = (const DragonFlyBSDProcess*)v2; } else { - p2 = (DragonFlyBSDProcess*)v1; - p1 = (DragonFlyBSDProcess*)v2; + p2 = (const DragonFlyBSDProcess*)v1; + p1 = (const DragonFlyBSDProcess*)v2; } + switch ((int) settings->sortKey) { // add Platform-specific fields here case JID: - return (p1->jid - p2->jid); + return SPACESHIP_NUMBER(p1->jid, p2->jid); case JAIL: - return strcmp(p1->jname ? p1->jname : "", p2->jname ? p2->jname : ""); + return SPACESHIP_NULLSTR(p1->jname, p2->jname); default: return Process_compare(v1, v2); } } -bool Process_isThread(Process* this) { - DragonFlyBSDProcess* fp = (DragonFlyBSDProcess*) this; +bool Process_isThread(const Process* this) { + const DragonFlyBSDProcess* fp = (const DragonFlyBSDProcess*) this; - if (fp->kernel == 1 ) + if (fp->kernel == 1 ) { return 1; - else + } else { return (Process_isUserlandThread(this)); + } } |