From 65357c8c46154de4e4eca14075bfe5523bb5fc14 Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Mon, 7 Dec 2020 10:26:01 +0100 Subject: New upstream version 3.0.3 --- solaris/SolarisProcess.c | 60 ++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 32 deletions(-) (limited to 'solaris/SolarisProcess.c') diff --git a/solaris/SolarisProcess.c b/solaris/SolarisProcess.c index ab0bcab..e0a3db2 100644 --- a/solaris/SolarisProcess.c +++ b/solaris/SolarisProcess.c @@ -2,7 +2,7 @@ htop - SolarisProcess.c (C) 2015 Hisham H. Muhammad (C) 2017,2018 Guy M. Broome -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 -ProcessClass SolarisProcess_class = { +const ProcessClass SolarisProcess_class = { .super = { .extends = Class(Process), .display = Process_display, .delete = Process_delete, .compare = SolarisProcess_compare }, - .writeField = (Process_WriteField) SolarisProcess_writeField, + .writeField = SolarisProcess_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, }, @@ -79,11 +80,11 @@ ProcessPidColumn Process_pidColumns[] = { { .id = 0, .label = NULL }, }; -SolarisProcess* SolarisProcess_new(Settings* settings) { +Process* SolarisProcess_new(const Settings* settings) { SolarisProcess* this = xCalloc(1, sizeof(SolarisProcess)); Object_setClass(this, Class(SolarisProcess)); Process_init(&this->super, settings); - return this; + return &this->super; } void Process_delete(Object* cast) { @@ -93,8 +94,8 @@ void Process_delete(Object* cast) { free(sp); } -void SolarisProcess_writeField(Process* this, RichString* str, ProcessField field) { - SolarisProcess* sp = (SolarisProcess*) this; +void SolarisProcess_writeField(const Process* this, RichString* str, ProcessField field) { + const SolarisProcess* sp = (const SolarisProcess*) this; char buffer[256]; buffer[255] = '\0'; int attr = CRT_colors[DEFAULT_COLOR]; int n = sizeof(buffer) - 1; @@ -105,14 +106,7 @@ void SolarisProcess_writeField(Process* this, RichString* str, ProcessField fiel case TASKID: xSnprintf(buffer, n, Process_pidFormat, sp->taskid); break; case POOLID: xSnprintf(buffer, n, Process_pidFormat, sp->poolid); break; case CONTID: xSnprintf(buffer, n, Process_pidFormat, sp->contid); break; - case ZONE:{ - xSnprintf(buffer, n, "%-*s ", ZONENAME_MAX/4, sp->zname); break; - if (buffer[ZONENAME_MAX/4] != '\0') { - buffer[ZONENAME_MAX/4] = ' '; - buffer[(ZONENAME_MAX/4)+1] = '\0'; - } - break; - } + case ZONE: xSnprintf(buffer, n, "%-*s ", ZONENAME_MAX/4, sp->zname); break; case PID: xSnprintf(buffer, n, Process_pidFormat, sp->realpid); break; case PPID: xSnprintf(buffer, n, Process_pidFormat, sp->realppid); break; case LWPID: xSnprintf(buffer, n, Process_pidFormat, sp->lwpid); break; @@ -124,41 +118,43 @@ void SolarisProcess_writeField(Process* this, RichString* str, ProcessField fiel } long SolarisProcess_compare(const void* v1, const void* v2) { - SolarisProcess *p1, *p2; - Settings* settings = ((Process*)v1)->settings; + const SolarisProcess *p1, *p2; + const Settings* settings = ((const Process*)v1)->settings; + if (settings->direction == 1) { - p1 = (SolarisProcess*)v1; - p2 = (SolarisProcess*)v2; + p1 = (const SolarisProcess*)v1; + p2 = (const SolarisProcess*)v2; } else { - p2 = (SolarisProcess*)v1; - p1 = (SolarisProcess*)v2; + p2 = (const SolarisProcess*)v1; + p1 = (const SolarisProcess*)v2; } + switch ((int) settings->sortKey) { case ZONEID: - return (p1->zoneid - p2->zoneid); + return SPACESHIP_NUMBER(p1->zoneid, p2->zoneid); case PROJID: - return (p1->projid - p2->projid); + return SPACESHIP_NUMBER(p1->projid, p2->projid); case TASKID: - return (p1->taskid - p2->taskid); + return SPACESHIP_NUMBER(p1->taskid, p2->taskid); case POOLID: - return (p1->poolid - p2->poolid); + return SPACESHIP_NUMBER(p1->poolid, p2->poolid); case CONTID: - return (p1->contid - p2->contid); + return SPACESHIP_NUMBER(p1->contid, p2->contid); case ZONE: return strcmp(p1->zname ? p1->zname : "global", p2->zname ? p2->zname : "global"); case PID: - return (p1->realpid - p2->realpid); + return SPACESHIP_NUMBER(p1->realpid, p2->realpid); case PPID: - return (p1->realppid - p2->realppid); + return SPACESHIP_NUMBER(p1->realppid, p2->realppid); case LWPID: - return (p1->lwpid - p2->lwpid); + return SPACESHIP_NUMBER(p1->lwpid, p2->lwpid); default: return Process_compare(v1, v2); } } -bool Process_isThread(Process* this) { - SolarisProcess* fp = (SolarisProcess*) this; +bool Process_isThread(const Process* this) { + const SolarisProcess* fp = (const SolarisProcess*) this; if (fp->kernel == 1 ) { return 1; -- cgit v1.2.3