diff options
-rw-r--r-- | Affinity.c | 2 | ||||
-rw-r--r-- | AffinityPanel.c | 4 | ||||
-rw-r--r-- | IncSet.c | 2 | ||||
-rw-r--r-- | ListItem.c | 4 | ||||
-rw-r--r-- | Panel.c | 4 | ||||
-rw-r--r-- | Process.c | 4 | ||||
-rw-r--r-- | Settings.c | 5 | ||||
-rw-r--r-- | darwin/Battery.c | 12 | ||||
-rw-r--r-- | darwin/DarwinProcess.c | 18 | ||||
-rw-r--r-- | darwin/DarwinProcessList.c | 178 | ||||
-rw-r--r-- | darwin/Platform.c | 18 | ||||
-rw-r--r-- | dragonflybsd/DragonFlyBSDProcessList.c | 47 | ||||
-rw-r--r-- | dragonflybsd/Platform.c | 6 | ||||
-rw-r--r-- | freebsd/FreeBSDProcessList.c | 42 | ||||
-rw-r--r-- | freebsd/Platform.c | 6 | ||||
-rw-r--r-- | linux/LinuxProcess.c | 13 | ||||
-rw-r--r-- | linux/LinuxProcessList.c | 24 | ||||
-rw-r--r-- | linux/PressureStallMeter.c | 32 | ||||
-rw-r--r-- | openbsd/OpenBSDProcess.c | 75 | ||||
-rw-r--r-- | openbsd/Platform.c | 10 | ||||
-rw-r--r-- | solaris/Platform.c | 6 | ||||
-rw-r--r-- | solaris/SolarisProcessList.c | 54 | ||||
-rw-r--r-- | unsupported/UnsupportedProcessList.c | 78 | ||||
-rw-r--r-- | zfs/openzfs_sysctl.c | 33 |
24 files changed, 368 insertions, 309 deletions
@@ -65,7 +65,7 @@ Affinity* Affinity_get(Process* proc, ProcessList* pl) { } else { unsigned int id; hwloc_bitmap_foreach_begin(id, cpuset); - Affinity_add(affinity, id); + Affinity_add(affinity, id); hwloc_bitmap_foreach_end(); } } diff --git a/AffinityPanel.c b/AffinityPanel.c index a8cb66ee..e184d64b 100644 --- a/AffinityPanel.c +++ b/AffinityPanel.c @@ -285,7 +285,7 @@ static MaskItem *AffinityPanel_addObject(AffinityPanel* this, hwloc_obj_t obj, u left -= len; } xSnprintf(&indent_buf[off], left, "%s", - obj->next_sibling ? CRT_treeStr[TREE_STR_RTEE] : CRT_treeStr[TREE_STR_BEND]); + obj->next_sibling ? CRT_treeStr[TREE_STR_RTEE] : CRT_treeStr[TREE_STR_BEND]); // Uncomment when further appending to indent_buf //size_t len = strlen(&indent_buf[off]); //off += len; @@ -417,7 +417,7 @@ Affinity* AffinityPanel_getAffinity(Panel* super, ProcessList* pl) { #ifdef HAVE_LIBHWLOC int i; hwloc_bitmap_foreach_begin(i, this->workCpuset) - Affinity_add(affinity, i); + Affinity_add(affinity, i); hwloc_bitmap_foreach_end(); #else for (int i = 0; i < this->pl->cpuCount; i++) { @@ -170,7 +170,7 @@ bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue doSearch = false; } } else if (ch == KEY_RESIZE) { - Panel_resize(panel, COLS, LINES-panel->y-1); + Panel_resize(panel, COLS, LINES - panel->y - 1); } else { if (mode->isFilter) { filterChanged = true; @@ -31,9 +31,9 @@ static void ListItem_display(const Object* cast, RichString* out) { if (this->moving) { RichString_write(out, CRT_colors[DEFAULT_COLOR], #ifdef HAVE_LIBNCURSESW - CRT_utf8 ? "↕ " : + CRT_utf8 ? "↕ " : #endif - "+ "); + "+ "); } else { RichString_prune(out); } @@ -254,8 +254,8 @@ void Panel_draw(Panel* this, bool focus) { int upTo = MINIMUM(first + h, size); int selectionColor = focus - ? this->selectionColor - : CRT_colors[PANEL_SELECTION_UNFOCUS]; + ? this->selectionColor + : CRT_colors[PANEL_SELECTION_UNFOCUS]; if (this->needsRedraw) { int line = 0; @@ -287,8 +287,8 @@ void Process_writeField(const Process* this, RichString* str, ProcessField field for (int i = 0; i < 32; i++) if (indent & (1U << i)) - maxIndent = i+1; - for (int i = 0; i < maxIndent - 1; i++) { + maxIndent = i + 1; + for (int i = 0; i < maxIndent - 1; i++) { int written, ret; if (indent & (1 << i)) ret = snprintf(buf, n, "%s ", CRT_treeStr[TREE_STR_VERT]); @@ -182,8 +182,9 @@ static bool Settings_read(Settings* this, const char* fileName, int initialCpuCo this->delay = atoi(option[1]); } else if (String_eq(option[0], "color_scheme")) { this->colorScheme = atoi(option[1]); - if (this->colorScheme < 0 || this->colorScheme >= LAST_COLORSCHEME) this->colorScheme = 0; - } else if (String_eq(option[0], "enable_mouse")) { + if (this->colorScheme < 0 || this->colorScheme >= LAST_COLORSCHEME) + this->colorScheme = 0; + } else if (String_eq(option[0], "enable_mouse")) { this->enableMouse = atoi(option[1]); } else if (String_eq(option[0], "left_meters")) { Settings_readMeters(this, option[1], 0); diff --git a/darwin/Battery.c b/darwin/Battery.c index 854425b3..c89f5b30 100644 --- a/darwin/Battery.c +++ b/darwin/Battery.c @@ -32,12 +32,12 @@ void Battery_getData(double* level, ACPresence* isOnAC) { /* Get the battery */ for (int i = 0; i < len && battery == NULL; ++i) { CFDictionaryRef candidate = IOPSGetPowerSourceDescription(power_sources, - CFArrayGetValueAtIndex(list, i)); /* GET rule */ + CFArrayGetValueAtIndex(list, i)); /* GET rule */ CFStringRef type; if (NULL != candidate) { type = (CFStringRef) CFDictionaryGetValue(candidate, - CFSTR(kIOPSTransportTypeKey)); /* GET rule */ + CFSTR(kIOPSTransportTypeKey)); /* GET rule */ if (kCFCompareEqualTo == CFStringCompare(type, CFSTR(kIOPSInternalType), 0)) { CFRetain(candidate); @@ -51,17 +51,17 @@ void Battery_getData(double* level, ACPresence* isOnAC) { CFStringRef power_state = CFDictionaryGetValue(battery, CFSTR(kIOPSPowerSourceStateKey)); *isOnAC = (kCFCompareEqualTo == CFStringCompare(power_state, CFSTR(kIOPSACPowerValue), 0)) - ? AC_PRESENT - : AC_ABSENT; + ? AC_PRESENT + : AC_ABSENT; /* Get the percentage remaining */ double current; double max; CFNumberGetValue(CFDictionaryGetValue(battery, CFSTR(kIOPSCurrentCapacityKey)), - kCFNumberDoubleType, ¤t); + kCFNumberDoubleType, ¤t); CFNumberGetValue(CFDictionaryGetValue(battery, CFSTR(kIOPSMaxCapacityKey)), - kCFNumberDoubleType, &max); + kCFNumberDoubleType, &max); *level = (current * 100.0) / max; diff --git a/darwin/DarwinProcess.c b/darwin/DarwinProcess.c index 8ad7a6d8..a92f2661 100644 --- a/darwin/DarwinProcess.c +++ b/darwin/DarwinProcess.c @@ -158,12 +158,12 @@ char *DarwinProcess_getCmdLine(struct kinfo_proc* k, int* basenameOffset) { /* Convert previous '\0'. */ *np = ' '; } - /* Note location of current '\0'. */ - np = cp; - if (*basenameOffset == 0) { - *basenameOffset = cp - sp; - } - } + /* Note location of current '\0'. */ + np = cp; + if (*basenameOffset == 0) { + *basenameOffset = cp - sp; + } + } } /* @@ -247,10 +247,10 @@ void DarwinProcess_setFromLibprocPidinfo(DarwinProcess *proc, DarwinProcessList if (sizeof(pti) == proc_pidinfo(proc->super.pid, PROC_PIDTASKINFO, 0, &pti, sizeof(pti))) { if (0 != proc->utime || 0 != proc->stime) { uint64_t diff = (pti.pti_total_system - proc->stime) - + (pti.pti_total_user - proc->utime); + + (pti.pti_total_user - proc->utime); proc->super.percent_cpu = (double)diff * (double)dpl->super.cpuCount - / ((double)dpl->global_diff * 100000.0); + / ((double)dpl->global_diff * 100000.0); // fprintf(stderr, "%f %llu %llu %llu %llu %llu\n", proc->super.percent_cpu, // proc->stime, proc->utime, pti.pti_total_system, pti.pti_total_user, dpl->global_diff); @@ -263,7 +263,7 @@ void DarwinProcess_setFromLibprocPidinfo(DarwinProcess *proc, DarwinProcessList proc->super.m_resident = pti.pti_resident_size / CRT_pageSize; proc->super.majflt = pti.pti_faults; proc->super.percent_mem = (double)pti.pti_resident_size * 100.0 - / (double)dpl->host_info.max_mem; + / (double)dpl->host_info.max_mem; proc->stime = pti.pti_total_system; proc->utime = pti.pti_total_user; diff --git a/darwin/DarwinProcessList.c b/darwin/DarwinProcessList.c index 3f72a3a7..bb7c56db 100644 --- a/darwin/DarwinProcessList.c +++ b/darwin/DarwinProcessList.c @@ -24,7 +24,7 @@ in the source distribution for its full text. #include <stdbool.h> struct kern { - short int version[3]; + short int version[3]; }; void GetKernelVersion(struct kern *k) { @@ -35,9 +35,11 @@ void GetKernelVersion(struct kern *k) { char str[256] = {0}; size_t size = sizeof(str); int ret = sysctlbyname("kern.osrelease", str, &size, NULL, 0); - if (ret == 0) sscanf(str, "%hd.%hd.%hd", &version_[0], &version_[1], &version_[2]); - } - memcpy(k->version, version_, sizeof(version_)); + if (ret == 0) { + sscanf(str, "%hd.%hd.%hd", &version_[0], &version_[1], &version_[2]); + } + } + memcpy(k->version, version_, sizeof(version_)); } /* compare the given os version with the one installed returns: @@ -46,28 +48,36 @@ positive value if less than the installed version negative value if more than the installed version */ int CompareKernelVersion(short int major, short int minor, short int component) { - struct kern k; - GetKernelVersion(&k); - if ( k.version[0] != major) return k.version[0] - major; - if ( k.version[1] != minor) return k.version[1] - minor; - if ( k.version[2] != component) return k.version[2] - component; - return 0; + struct kern k; + GetKernelVersion(&k); + + if (k.version[0] != major) { + return k.version[0] - major; + } + if (k.version[1] != minor) { + return k.version[1] - minor; + } + if (k.version[2] != component) { + return k.version[2] - component; + } + + return 0; } void ProcessList_getHostInfo(host_basic_info_data_t *p) { mach_msg_type_number_t info_size = HOST_BASIC_INFO_COUNT; if (0 != host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t)p, &info_size)) { - CRT_fatalError("Unable to retrieve host info\n"); + CRT_fatalError("Unable to retrieve host info\n"); } } void ProcessList_freeCPULoadInfo(processor_cpu_load_info_t *p) { if (NULL != p && NULL != *p) { - if (0 != munmap(*p, vm_page_size)) { - CRT_fatalError("Unable to free old CPU load information\n"); - } - *p = NULL; + if (0 != munmap(*p, vm_page_size)) { + CRT_fatalError("Unable to free old CPU load information\n"); + } + *p = NULL; } } @@ -76,18 +86,19 @@ unsigned ProcessList_allocateCPULoadInfo(processor_cpu_load_info_t *p) { unsigned cpu_count; // TODO Improving the accuracy of the load counts woule help a lot. - if (0 != host_processor_info(mach_host_self(), PROCESSOR_CPU_LOAD_INFO, &cpu_count, (processor_info_array_t *)p, &info_size)) { - CRT_fatalError("Unable to retrieve CPU info\n"); + if (0 != host_processor_info(mach_host_self(), PROCESSOR_CPU_LOAD_INFO, &cpu_count, (processor_info_array_t*)p, &info_size)) { + CRT_fatalError("Unable to retrieve CPU info\n"); } return cpu_count; } void ProcessList_getVMStats(vm_statistics_t p) { - mach_msg_type_number_t info_size = HOST_VM_INFO_COUNT; + mach_msg_type_number_t info_size = HOST_VM_INFO_COUNT; - if (host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)p, &info_size) != 0) - CRT_fatalError("Unable to retrieve VM statistics\n"); + if (host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)p, &info_size) != 0) { + CRT_fatalError("Unable to retrieve VM statistics\n"); + } } struct kinfo_proc *ProcessList_getKInfoProcs(size_t *count) { @@ -145,67 +156,68 @@ void ProcessList_delete(ProcessList* this) { } void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) { - DarwinProcessList *dpl = (DarwinProcessList *)super; - bool preExisting = true; - struct kinfo_proc *ps; - size_t count; - DarwinProcess *proc; - - /* Update the global data (CPU times and VM stats) */ - ProcessList_freeCPULoadInfo(&dpl->prev_load); - dpl->prev_load = dpl->curr_load; - ProcessList_allocateCPULoadInfo(&dpl->curr_load); - ProcessList_getVMStats(&dpl->vm_stats); - openzfs_sysctl_updateArcStats(&dpl->zfs); - - // in pause mode only gather global data for meters (CPU/memory/...) - if (pauseProcessUpdate) - return; - - /* Get the time difference */ - dpl->global_diff = 0; - for (int i = 0; i < dpl->super.cpuCount; ++i) { - for (size_t j = 0; j < CPU_STATE_MAX; ++j) { - dpl->global_diff += dpl->curr_load[i].cpu_ticks[j] - dpl->prev_load[i].cpu_ticks[j]; - } - } - - /* Clear the thread counts */ - super->kernelThreads = 0; - super->userlandThreads = 0; - super->totalTasks = 0; - super->runningTasks = 0; - - /* We use kinfo_procs for initial data since : - * - * 1) They always succeed. - * 2) The contain the basic information. - * - * We attempt to fill-in additional information with libproc. - */ - ps = ProcessList_getKInfoProcs(&count); - - for (size_t i = 0; i < count; ++i) { - proc = (DarwinProcess *)ProcessList_getProcess(super, ps[i].kp_proc.p_pid, &preExisting, DarwinProcess_new); - - DarwinProcess_setFromKInfoProc(&proc->super, &ps[i], preExisting); - DarwinProcess_setFromLibprocPidinfo(proc, dpl); - - // Disabled for High Sierra due to bug in macOS High Sierra - bool isScanThreadSupported = ! ( CompareKernelVersion(17, 0, 0) >= 0 && CompareKernelVersion(17, 5, 0) < 0); - - if (isScanThreadSupported){ - DarwinProcess_scanThreads(proc); - } - - super->totalTasks += 1; - - if (!preExisting) { - proc->super.user = UsersTable_getRef(super->usersTable, proc->super.st_uid); - - ProcessList_add(super, &proc->super); - } - } - - free(ps); + DarwinProcessList* dpl = (DarwinProcessList*)super; + bool preExisting = true; + struct kinfo_proc* ps; + size_t count; + DarwinProcess* proc; + + /* Update the global data (CPU times and VM stats) */ + ProcessList_freeCPULoadInfo(&dpl->prev_load); + dpl->prev_load = dpl->curr_load; + ProcessList_allocateCPULoadInfo(&dpl->curr_load); + ProcessList_getVMStats(&dpl->vm_stats); + openzfs_sysctl_updateArcStats(&dpl->zfs); + + // in pause mode only gather global data for meters (CPU/memory/...) + if (pauseProcessUpdate) { + return; + } + + /* Get the time difference */ + dpl->global_diff = 0; + for (int i = 0; i < dpl->super.cpuCount; ++i) { + for (size_t j = 0; j < CPU_STATE_MAX; ++j) { + dpl->global_diff += dpl->curr_load[i].cpu_ticks[j] - dpl->prev_load[i].cpu_ticks[j]; + } + } + + /* Clear the thread counts */ + super->kernelThreads = 0; + super->userlandThreads = 0; + super->totalTasks = 0; + super->runningTasks = 0; + + /* We use kinfo_procs for initial data since : + * + * 1) They always succeed. + * 2) The contain the basic information. + * + * We attempt to fill-in additional information with libproc. + */ + ps = ProcessList_getKInfoProcs(&count); + + for (size_t i = 0; i < count; ++i) { + proc = (DarwinProcess*)ProcessList_getProcess(super, ps[i].kp_proc.p_pid, &preExisting, DarwinProcess_new); + + DarwinProcess_setFromKInfoProc(&proc->super, &ps[i], preExisting); + DarwinProcess_setFromLibprocPidinfo(proc, dpl); + + // Disabled for High Sierra due to bug in macOS High Sierra + bool isScanThreadSupported = ! ( CompareKernelVersion(17, 0, 0) >= 0 && CompareKernelVersion(17, 5, 0) < 0); + + if (isScanThreadSupported) { + DarwinProcess_scanThreads(proc); + } + + super->totalTasks += 1; + + if (!preExisting) { + proc->super.user = UsersTable_getRef(super->usersTable, proc->super.st_uid); + + ProcessList_add(super, &proc->super); + } + } + + free(ps); } diff --git a/darwin/Platform.c b/darwin/Platform.c index 9086c6de..c5a22da4 100644 --- a/darwin/Platform.c +++ b/darwin/Platform.c @@ -211,11 +211,11 @@ double Platform_setCPUValues(Meter* mtr, int cpu) { } mtr->values[CPU_METER_NICE] - = ((double)curr->cpu_ticks[CPU_STATE_NICE] - (double)prev->cpu_ticks[CPU_STATE_NICE])* 100.0 / total; + = ((double)curr->cpu_ticks[CPU_STATE_NICE] - (double)prev->cpu_ticks[CPU_STATE_NICE]) * 100.0 / total; mtr->values[CPU_METER_NORMAL] - = ((double)curr->cpu_ticks[CPU_STATE_USER] - (double)prev->cpu_ticks[CPU_STATE_USER])* 100.0 / total; + = ((double)curr->cpu_ticks[CPU_STATE_USER] - (double)prev->cpu_ticks[CPU_STATE_USER]) * 100.0 / total; mtr->values[CPU_METER_KERNEL] - = ((double)curr->cpu_ticks[CPU_STATE_SYSTEM] - (double)prev->cpu_ticks[CPU_STATE_SYSTEM])* 100.0 / total; + = ((double)curr->cpu_ticks[CPU_STATE_SYSTEM] - (double)prev->cpu_ticks[CPU_STATE_SYSTEM]) * 100.0 / total; mtr->curItems = 3; @@ -239,13 +239,13 @@ void Platform_setMemoryValues(Meter* mtr) { } void Platform_setSwapValues(Meter* mtr) { - int mib[2] = {CTL_VM, VM_SWAPUSAGE}; - struct xsw_usage swapused; - size_t swlen = sizeof(swapused); - sysctl(mib, 2, &swapused, &swlen, NULL, 0); + int mib[2] = {CTL_VM, VM_SWAPUSAGE}; + struct xsw_usage swapused; + size_t swlen = sizeof(swapused); + sysctl(mib, 2, &swapused, &swlen, NULL, 0); - mtr->total = swapused.xsu_total / 1024; - mtr->values[0] = swapused.xsu_used / 1024; + mtr->total = swapused.xsu_total / 1024; + mtr->values[0] = swapused.xsu_used / 1024; } void Platform_setZfsArcValues(Meter* this) { diff --git a/dragonflybsd/DragonFlyBSDProcessList.c b/dragonflybsd/DragonFlyBSDProcessList.c index 2fe20dae..90bc7f7a 100644 --- a/dragonflybsd/DragonFlyBSDProcessList.c +++ b/dragonflybsd/DragonFlyBSDProcessList.c @@ -101,10 +101,10 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, ui pl->cpuCount = MAXIMUM(cpus, 1); if (cpus == 1 ) { - dfpl->cpus = xRealloc(dfpl->cpus, sizeof(CPUData)); + dfpl->cpus = xRealloc(dfpl->cpus, sizeof(CPUData)); } else { - // on smp we need CPUs + 1 to store averages too (as kernel kindly provides that as well) - dfpl->cpus = xRealloc(dfpl->cpus, (pl->cpuCount + 1) * sizeof(CPUData)); + // on smp we need CPUs + 1 to store averages too (as kernel kindly provides that as well) + dfpl->cpus = xRealloc(dfpl->cpus, (pl->cpuCount + 1) * sizeof(CPUData)); } len = sizeof(kernelFScale); @@ -161,12 +161,12 @@ static inline void DragonFlyBSDProcessList_scanCPUTime(ProcessList* pl) { // get rest of CPUs if (cpus > 1) { - // on smp systems DragonFlyBSD kernel concats all CPU states into one long array in - // kern.cp_times sysctl OID - // we store averages in dfpl->cpus[0], and actual cores after that - maxcpu = cpus + 1; - sizeof_cp_time_array = cpus * sizeof(unsigned long) * CPUSTATES; - sysctl(MIB_kern_cp_times, 2, dfpl->cp_times_n, &sizeof_cp_time_array, NULL, 0); + // on smp systems DragonFlyBSD kernel concats all CPU states into one long array in + // kern.cp_times sysctl OID + // we store averages in dfpl->cpus[0], and actual cores after that + maxcpu = cpus + 1; + sizeof_cp_time_array = cpus * sizeof(unsigned long) * CPUSTATES; + sysctl(MIB_kern_cp_times, 2, dfpl->cp_times_n, &sizeof_cp_time_array, NULL, 0); } for (int i = 0; i < maxcpu; i++) { @@ -176,14 +176,14 @@ static inline void DragonFlyBSDProcessList_scanCPUTime(ProcessList* pl) { cp_time_o = dfpl->cp_time_o; } else { if (i == 0 ) { - // average - cp_time_n = dfpl->cp_time_n; - cp_time_o = dfpl->cp_time_o; + // average + cp_time_n = dfpl->cp_time_n; + cp_time_o = dfpl->cp_time_o; } else { - // specific smp cores - cp_times_offset = i - 1; - cp_time_n = dfpl->cp_times_n + (cp_times_offset * CPUSTATES); - cp_time_o = dfpl->cp_times_o + (cp_times_offset * CPUSTATES); + // specific smp cores + cp_times_offset = i - 1; + cp_time_n = dfpl->cp_times_n + (cp_times_offset * CPUSTATES); + cp_time_o = dfpl->cp_times_o + (cp_times_offset * CPUSTATES); } } @@ -192,9 +192,9 @@ static inline void DragonFlyBSDProcessList_scanCPUTime(ProcessList* pl) { unsigned long long total_n = 0; unsigned long long total_d = 0; for (int s = 0; s < CPUSTATES; s++) { - cp_time_d[s] = cp_time_n[s] - cp_time_o[s]; - total_o += cp_time_o[s]; - total_n += cp_time_n[s]; + cp_time_d[s] = cp_time_n[s] - cp_time_o[s]; + total_o += cp_time_o[s]; + total_n += cp_time_n[s]; } // totals @@ -203,8 +203,8 @@ static inline void DragonFlyBSDProcessList_scanCPUTime(ProcessList* pl) { // save current state as old and calc percentages for (int s = 0; s < CPUSTATES; ++s) { - cp_time_o[s] = cp_time_n[s]; - cp_time_p[s] = ((double)cp_time_d[s]) / ((double)total_d) * 100; + cp_time_o[s] = cp_time_n[s]; + cp_time_p[s] = ((double)cp_time_d[s]) / ((double)total_d) * 100; } CPUData* cpuData = &(dfpl->cpus[i]); @@ -344,8 +344,9 @@ retry: } curpos = nextpos; - } - free(jls); + } + + free(jls); } char* DragonFlyBSDProcessList_readJailName(DragonFlyBSDProcessList* dfpl, int jailid) { diff --git a/dragonflybsd/Platform.c b/dragonflybsd/Platform.c index 5b81c610..6f8c2023 100644 --- a/dragonflybsd/Platform.c +++ b/dragonflybsd/Platform.c @@ -154,10 +154,10 @@ double Platform_setCPUValues(Meter* this, int cpu) { const CPUData* cpuData; if (cpus == 1) { - // single CPU box has everything in fpl->cpus[0] - cpuData = &(fpl->cpus[0]); + // single CPU box has everything in fpl->cpus[0] + cpuData = &(fpl->cpus[0]); } else { - cpuData = &(fpl->cpus[cpu]); + cpuData = &(fpl->cpus[cpu]); } double percent; diff --git a/freebsd/FreeBSDProcessList.c b/freebsd/FreeBSDProcessList.c index bfa046b8..8be627c9 100644 --- a/freebsd/FreeBSDProcessList.c +++ b/freebsd/FreeBSDProcessList.c @@ -124,10 +124,10 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, ui pl->cpuCount = MAXIMUM(cpus, 1); if (cpus == 1 ) { - fpl->cpus = xRealloc(fpl->cpus, sizeof(CPUData)); + fpl->cpus = xRealloc(fpl->cpus, sizeof(CPUData)); } else { - // on smp we need CPUs + 1 to store averages too (as kernel kindly provides that as well) - fpl->cpus = xRealloc(fpl->cpus, (pl->cpuCount + 1) * sizeof(CPUData)); + // on smp we need CPUs + 1 to store averages too (as kernel kindly provides that as well) + fpl->cpus = xRealloc(fpl->cpus, (pl->cpuCount + 1) * sizeof(CPUData)); } @@ -187,12 +187,12 @@ static inline void FreeBSDProcessList_scanCPUTime(ProcessList* pl) { // get rest of CPUs if (cpus > 1) { - // on smp systems FreeBSD kernel concats all CPU states into one long array in - // kern.cp_times sysctl OID - // we store averages in fpl->cpus[0], and actual cores after that - maxcpu = cpus + 1; - sizeof_cp_time_array = cpus * sizeof(unsigned long) * CPUSTATES; - sysctl(MIB_kern_cp_times, 2, fpl->cp_times_n, &sizeof_cp_time_array, NULL, 0); + // on smp systems FreeBSD kernel concats all CPU states into one long array in + // kern.cp_times sysctl OID + // we store averages in fpl->cpus[0], and actual cores after that + maxcpu = cpus + 1; + sizeof_cp_time_array = cpus * sizeof(unsigned long) * CPUSTATES; + sysctl(MIB_kern_cp_times, 2, fpl->cp_times_n, &sizeof_cp_time_array, NULL, 0); } for (int i = 0; i < maxcpu; i++) { @@ -202,14 +202,14 @@ static inline void FreeBSDProcessList_scanCPUTime(ProcessList* pl) { cp_time_o = fpl->cp_time_o; } else { if (i == 0 ) { - // average - cp_time_n = fpl->cp_time_n; - cp_time_o = fpl->cp_time_o; + // average + cp_time_n = fpl->cp_time_n; + cp_time_o = fpl->cp_time_o; } else { - // specific smp cores - cp_times_offset = i - 1; - cp_time_n = fpl->cp_times_n + (cp_times_offset * CPUSTATES); - cp_time_o = fpl->cp_times_o + (cp_times_offset * CPUSTATES); + // specific smp cores + cp_times_offset = i - 1; + cp_time_n = fpl->cp_times_n + (cp_times_offset * CPUSTATES); + cp_time_o = fpl->cp_times_o + (cp_times_offset * CPUSTATES); } } @@ -218,9 +218,9 @@ static inline void FreeBSDProcessList_scanCPUTime(ProcessList* pl) { unsigned long long total_n = 0; unsigned long long total_d = 0; for (int s = 0; s < CPUSTATES; s++) { - cp_time_d[s] = cp_time_n[s] - cp_time_o[s]; - total_o += cp_time_o[s]; - total_n += cp_time_n[s]; + cp_time_d[s] = cp_time_n[s] - cp_time_o[s]; + total_o += cp_time_o[s]; + total_n += cp_time_n[s]; } // totals @@ -229,8 +229,8 @@ static inline void FreeBSDProcessList_scanCPUTime(ProcessList* pl) { // save current state as old and calc percentages for (int s = 0; s < CPUSTATES; ++s) { - cp_time_o[s] = cp_time_n[s]; - cp_time_p[s] = ((double)cp_time_d[s]) / ((double)total_d) * 100; + cp_time_o[s] = cp_time_n[s]; + cp_time_p[s] = ((double)cp_time_d[s]) / ((double)total_d) * 100; } CPUData* cpuData = &(fpl->cpus[i]); diff --git a/freebsd/Platform.c b/freebsd/Platform.c index bdd49bf6..32b54293 100644 --- a/freebsd/Platform.c +++ b/freebsd/Platform.c @@ -165,10 +165,10 @@ double Platform_setCPUValues(Meter* this, int cpu) { const CPUData* cpuData; if (cpus == 1) { - // single CPU box has everything in fpl->cpus[0] - cpuData = &(fpl->cpus[0]); + // single CPU box has everything in fpl->cpus[0] + cpuData = &(fpl->cpus[0]); } else { - cpuData = &(fpl->cpus[cpu]); + cpuData = &(fpl->cpus[cpu]); } double percent; diff --git a/linux/LinuxProcess.c b/linux/LinuxProcess.c index 94b43896..a5d7eccf 100644 --- a/linux/LinuxProcess.c +++ b/linux/LinuxProcess.c @@ -194,11 +194,11 @@ bool LinuxProcess_setIOPriority(Process* this, Arg ioprio) { #ifdef HAVE_DELAYACCT void LinuxProcess_printDelay(float delay_percent, char* buffer, int n) { - if (isnan(delay_percent)) { - xSnprintf(buffer, n, " N/A "); - } else { - xSnprintf(buffer, n, "%4.1f ", delay_percent); - } + if (isnan(delay_percent)) { + xSnprintf(buffer, n, " N/A "); + } else { + xSnprintf(buffer, n, "%4.1f ", delay_percent); + } } #endif @@ -379,7 +379,8 @@ long LinuxProcess_compare(const void* v1, const void* v2) { default: return Process_compare(v1, v2); } - test_diff: + +test_diff: return (diff > 0) ? 1 : (diff < 0 ? -1 : 0); } diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c index fb8bfc53..6065d429 100644 --- a/linux/LinuxProcessList.c +++ b/linux/LinuxProcessList.c @@ -419,20 +419,20 @@ static void LinuxProcessList_readIoFile(LinuxProcess* process, const char* dirna while ((line = strsep(&buf, "\n")) != NULL) { switch (line[0]) { case 'r': - if (line[1] == 'c' && String_startsWith(line+2, "har: ")) - process->io_rchar = strtoull(line+7, NULL, 10); - else if (String_startsWith(line+1, "ead_bytes: ")) { - process->io_read_bytes = strtoull(line+12, NULL, 10); + if (line[1] == 'c' && String_startsWith(line + 2, "har: ")) { + process->io_rchar = strtoull(line + 7, NULL, 10); + } else if (String_startsWith(line + 1, "ead_bytes: ")) { + process->io_read_bytes = strtoull(line + 12, NULL, 10); process->io_rate_read_bps = ((double)(process->io_read_bytes - last_read))/(((double)(now - process->io_rate_read_time))/1000); process->io_rate_read_time = now; } break; case 'w': - if (line[1] == 'c' && String_startsWith(line+2, "har: ")) - process->io_wchar = strtoull(line+7, NULL, 10); - else if (String_startsWith(line+1, "rite_bytes: ")) { - process->io_write_bytes = strtoull(line+13, NULL, 10); + if (line[1] == 'c' && String_startsWith(line + 2, "har: ")) { + process->io_wchar = strtoull(line + 7, NULL, 10); + } else if (String_startsWith(line + 1, "rite_bytes: ")) { + process->io_write_bytes = strtoull(line + 13, NULL, 10); process->io_rate_write_bps = ((double)(process->io_write_bytes - last_write))/(((double)(now - process->io_rate_write_time))/1000); process->io_rate_write_time = now; @@ -446,8 +446,8 @@ static void LinuxProcessList_readIoFile(LinuxProcess* process, const char* dirna } break; case 'c': - if (String_startsWith(line+1, "ancelled_write_bytes: ")) { - process->io_cancelled_write_bytes = strtoull(line+23, NULL, 10); + if (String_startsWith(line + 1, "ancelled_write_bytes: ")) { + process->io_cancelled_write_bytes = strtoull(line + 23, NULL, 10); } } } @@ -1087,7 +1087,9 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, const char* continue; // Exception handler. - errorReadingProcess: { + +errorReadingProcess: + { if (preExisting) { ProcessList_remove(pl, proc); } else { diff --git a/linux/PressureStallMeter.c b/linux/PressureStallMeter.c index 9ac0ced2..3b5415c5 100644 --- a/linux/PressureStallMeter.c +++ b/linux/PressureStallMeter.c @@ -24,24 +24,24 @@ static const int PressureStallMeter_attributes[] = { }; static void PressureStallMeter_updateValues(Meter* this, char* buffer, int len) { - const char *file; - if (strstr(Meter_name(this), "CPU")) { - file = "cpu"; - } else if (strstr(Meter_name(this), "IO")) { - file = "io"; - } else { - file = "memory"; - } + const char* file; + if (strstr(Meter_name(this), "CPU")) { + file = "cpu"; + } else if (strstr(Meter_name(this), "IO")) { |