add CPU spin support on OpenBSD (#471)
* add CPU spin support on OpenBSD * use consistent ifdefs
This commit is contained in:
parent
db279644c3
commit
126fcaef25
@ -43,6 +43,9 @@ struct cpu_usage {
|
||||
int nice;
|
||||
int system;
|
||||
int idle;
|
||||
#if defined(__OpenBSD__)
|
||||
int spin;
|
||||
#endif
|
||||
int total;
|
||||
};
|
||||
|
||||
@ -151,7 +154,12 @@ void print_cpu_usage(cpu_usage_ctx_t *ctx) {
|
||||
curr_all.nice = cp_time[CP_NICE];
|
||||
curr_all.system = cp_time[CP_SYS];
|
||||
curr_all.idle = cp_time[CP_IDLE];
|
||||
#if defined(__OpenBSD__)
|
||||
curr_all.spin = cp_time[CP_SPIN];
|
||||
curr_all.total = curr_all.user + curr_all.nice + curr_all.system + curr_all.idle + curr_all.spin;
|
||||
#else
|
||||
curr_all.total = curr_all.user + curr_all.nice + curr_all.system + curr_all.idle;
|
||||
#endif
|
||||
diff_idle = curr_all.idle - prev_all.idle;
|
||||
diff_total = curr_all.total - prev_all.total;
|
||||
diff_usage = (diff_total ? (1000 * (diff_total - diff_idle) / diff_total + 5) / 10 : 0);
|
||||
|
Loading…
Reference in New Issue
Block a user