mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-12 12:14:36 +03:00
Resolve merge conflicts, merge #298 "Macro cleanup" from @BenBE
This commit is contained in:
@ -150,7 +150,7 @@ int Platform_getUptime() {
|
||||
void Platform_getLoadAverage(double* one, double* five, double* fifteen) {
|
||||
double results[3];
|
||||
|
||||
if(3 == getloadavg(results, 3)) {
|
||||
if (3 == getloadavg(results, 3)) {
|
||||
*one = results[0];
|
||||
*five = results[1];
|
||||
*fifteen = results[2];
|
||||
@ -177,7 +177,7 @@ ProcessPidColumn Process_pidColumns[] = {
|
||||
};
|
||||
|
||||
static double Platform_setCPUAverageValues(Meter* mtr) {
|
||||
const ProcessList *dpl = mtr->pl;
|
||||
const ProcessList* dpl = mtr->pl;
|
||||
int cpus = dpl->cpuCount;
|
||||
double sumNice = 0.0;
|
||||
double sumNormal = 0.0;
|
||||
@ -201,22 +201,22 @@ double Platform_setCPUValues(Meter* mtr, int cpu) {
|
||||
return Platform_setCPUAverageValues(mtr);
|
||||
}
|
||||
|
||||
const DarwinProcessList *dpl = (const DarwinProcessList *)mtr->pl;
|
||||
const processor_cpu_load_info_t prev = &dpl->prev_load[cpu-1];
|
||||
const processor_cpu_load_info_t curr = &dpl->curr_load[cpu-1];
|
||||
const DarwinProcessList* dpl = (const DarwinProcessList*)mtr->pl;
|
||||
const processor_cpu_load_info_t prev = &dpl->prev_load[cpu - 1];
|
||||
const 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) {
|
||||
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;
|
||||
= ((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;
|
||||
|
||||
@ -229,7 +229,7 @@ double Platform_setCPUValues(Meter* mtr, int cpu) {
|
||||
}
|
||||
|
||||
void Platform_setMemoryValues(Meter* mtr) {
|
||||
const DarwinProcessList *dpl = (const DarwinProcessList *)mtr->pl;
|
||||
const DarwinProcessList* dpl = (const DarwinProcessList*)mtr->pl;
|
||||
const struct vm_statistics* vm = &dpl->vm_stats;
|
||||
double page_K = (double)vm_page_size / (double)1024;
|
||||
|
||||
@ -240,13 +240,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) {
|
||||
@ -284,25 +284,25 @@ char* Platform_getProcessEnv(pid_t pid) {
|
||||
p += sizeof(int);
|
||||
|
||||
// skip exe
|
||||
p = strchr(p, 0)+1;
|
||||
p = strchr(p, 0) + 1;
|
||||
|
||||
// skip padding
|
||||
while(!*p && p < endp)
|
||||
while (!*p && p < endp)
|
||||
++p;
|
||||
|
||||
// skip argv
|
||||
for (; argc-- && p < endp; p = strrchr(p, 0)+1)
|
||||
for (; argc-- && p < endp; p = strrchr(p, 0) + 1)
|
||||
;
|
||||
|
||||
// skip padding
|
||||
while(!*p && p < endp)
|
||||
while (!*p && p < endp)
|
||||
++p;
|
||||
|
||||
size_t size = endp - p;
|
||||
env = xMalloc(size+2);
|
||||
env = xMalloc(size + 2);
|
||||
memcpy(env, p, size);
|
||||
env[size] = 0;
|
||||
env[size+1] = 0;
|
||||
env[size + 1] = 0;
|
||||
}
|
||||
}
|
||||
free(buf);
|
||||
@ -329,10 +329,10 @@ bool Platform_getDiskIO(DiskIOData* data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Platform_getNetworkIO(unsigned long int *bytesReceived,
|
||||
unsigned long int *packetsReceived,
|
||||
unsigned long int *bytesTransmitted,
|
||||
unsigned long int *packetsTransmitted) {
|
||||
bool Platform_getNetworkIO(unsigned long int* bytesReceived,
|
||||
unsigned long int* packetsReceived,
|
||||
unsigned long int* bytesTransmitted,
|
||||
unsigned long int* packetsTransmitted) {
|
||||
// TODO
|
||||
*bytesReceived = 0;
|
||||
*packetsReceived = 0;
|
||||
|
Reference in New Issue
Block a user