summaryrefslogtreecommitdiffstats
path: root/darwin/Platform.c
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2015-08-19 13:56:46 -0300
committerHisham Muhammad <hisham@gobolinux.org>2015-08-19 13:56:46 -0300
commitf70649a1785f0453c7af8c46e2d6712b07384994 (patch)
tree5355703c92163253c18b37ca46c464635ac06819 /darwin/Platform.c
parent907f8298a0337510f9f048df65a9f5d032f09d14 (diff)
Standardize indentation.
Diffstat (limited to 'darwin/Platform.c')
-rw-r--r--darwin/Platform.c91
1 files changed, 45 insertions, 46 deletions
diff --git a/darwin/Platform.c b/darwin/Platform.c
index 94d75da6..57c4d0ce 100644
--- a/darwin/Platform.c
+++ b/darwin/Platform.c
@@ -85,17 +85,17 @@ char* Process_pidFormat = "%7u ";
char* Process_tpgidFormat = "%7u ";
int Platform_getUptime() {
- struct timeval bootTime, currTime;
- int mib[2] = { CTL_KERN, KERN_BOOTTIME };
- size_t size = sizeof(bootTime);
+ struct timeval bootTime, currTime;
+ int mib[2] = { CTL_KERN, KERN_BOOTTIME };
+ size_t size = sizeof(bootTime);
- int err = sysctl(mib, 2, &bootTime, &size, NULL, 0);
- if (err) {
- return -1;
- }
- gettimeofday(&currTime, NULL);
+ int err = sysctl(mib, 2, &bootTime, &size, NULL, 0);
+ if (err) {
+ return -1;
+ }
+ gettimeofday(&currTime, NULL);
- return (int) difftime(currTime.tv_sec, bootTime.tv_sec);
+ return (int) difftime(currTime.tv_sec, bootTime.tv_sec);
}
void Platform_getLoadAverage(double* one, double* five, double* fifteen) {
@@ -142,46 +142,45 @@ void Process_setupColumnWidths() {
}
double Platform_setCPUValues(Meter* mtr, int cpu) {
- /* All just from CPUMeter.c */
- static const int CPU_METER_NICE = 0;
- static const int CPU_METER_NORMAL = 1;
- static const int CPU_METER_KERNEL = 2;
-
- DarwinProcessList *dpl = (DarwinProcessList *)mtr->pl;
- processor_cpu_load_info_t prev = &dpl->prev_load[cpu-1];
- processor_cpu_load_info_t curr = &dpl->curr_load[cpu-1];
- double total = 0;
-
- /* Take the sums */
- for(size_t i = 0; i < CPU_STATE_MAX; ++i) {
- total += (double)curr->cpu_ticks[i] - (double)prev->cpu_ticks[i];
- }
-
- mtr->values[CPU_METER_NICE]
- = ((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;
- mtr->values[CPU_METER_KERNEL]
- = ((double)curr->cpu_ticks[CPU_STATE_SYSTEM] - (double)prev->cpu_ticks[CPU_STATE_SYSTEM])* 100.0 / total;
-
- Meter_setItems(mtr, 3);
-
- /* Convert to percent and return */
- total = mtr->values[CPU_METER_NICE] + mtr->values[CPU_METER_NORMAL] + mtr->values[CPU_METER_KERNEL];
-
- return MIN(100.0, MAX(0.0, total));
-}
+ /* All just from CPUMeter.c */
+ static const int CPU_METER_NICE = 0;
+ static const int CPU_METER_NORMAL = 1;
+ static const int CPU_METER_KERNEL = 2;
+
+ DarwinProcessList *dpl = (DarwinProcessList *)mtr->pl;
+ processor_cpu_load_info_t prev = &dpl->prev_load[cpu-1];
+ processor_cpu_load_info_t curr = &dpl->curr_load[cpu-1];
+ double total = 0;
+
+ /* Take the sums */
+ for(size_t i = 0; i < CPU_STATE_MAX; ++i) {
+ total += (double)curr->cpu_ticks[i] - (double)prev->cpu_ticks[i];
+ }
-void Platform_setMemoryValues(Meter* mtr) {
- DarwinProcessList *dpl = (DarwinProcessList *)mtr->pl;
- vm_statistics64_t vm = &dpl->vm_stats;
- double page_K = (double)vm_page_size / (double)1024;
+ mtr->values[CPU_METER_NICE]
+ = ((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;
+ mtr->values[CPU_METER_KERNEL]
+ = ((double)curr->cpu_ticks[CPU_STATE_SYSTEM] - (double)prev->cpu_ticks[CPU_STATE_SYSTEM])* 100.0 / total;
- mtr->total = dpl->host_info.max_mem / 1024;
- mtr->values[0] = (double)(vm->active_count + vm->wire_count) * page_K;
- mtr->values[1] = (double)vm->purgeable_count * page_K;
- mtr->values[2] = (double)vm->inactive_count * page_K;
+ Meter_setItems(mtr, 3);
+ /* Convert to percent and return */
+ total = mtr->values[CPU_METER_NICE] + mtr->values[CPU_METER_NORMAL] + mtr->values[CPU_METER_KERNEL];
+
+ return MIN(100.0, MAX(0.0, total));
+}
+
+void Platform_setMemoryValues(Meter* mtr) {
+ DarwinProcessList *dpl = (DarwinProcessList *)mtr->pl;
+ vm_statistics64_t vm = &dpl->vm_stats;
+ double page_K = (double)vm_page_size / (double)1024;
+
+ mtr->total = dpl->host_info.max_mem / 1024;
+ mtr->values[0] = (double)(vm->active_count + vm->wire_count) * page_K;
+ mtr->values[1] = (double)vm->purgeable_count * page_K;
+ mtr->values[2] = (double)vm->inactive_count * page_K;
}
void Platform_setSwapValues(Meter* this) {

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