diff --git a/src/print_cpu_usage.c b/src/print_cpu_usage.c index bc4b784c..a7ee2e46 100644 --- a/src/print_cpu_usage.c +++ b/src/print_cpu_usage.c @@ -39,6 +39,13 @@ #include "i3status.h" struct cpu_usage { +#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) + long user; + long nice; + long system; + long idle; + long total; +#else int user; int nice; int system; @@ -47,6 +54,7 @@ struct cpu_usage { int spin; #endif int total; +#endif }; #if defined(__linux__) @@ -66,7 +74,12 @@ void print_cpu_usage(cpu_usage_ctx_t *ctx) { const char *walk; char *outwalk = ctx->buf; struct cpu_usage curr_all = {0, 0, 0, 0, 0}; - int diff_idle, diff_total, diff_usage; +#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) + long diff_idle, diff_total; +#else + int diff_idle, diff_total; +#endif + int diff_usage; bool colorful_output = false; #if defined(__linux__) @@ -153,6 +166,9 @@ void print_cpu_usage(cpu_usage_ctx_t *ctx) { curr_all.user = cp_time[CP_USER]; curr_all.nice = cp_time[CP_NICE]; curr_all.system = cp_time[CP_SYS]; +#if defined(__DragonFly__) + curr_all.system += cp_time[CP_INTR]; +#endif curr_all.idle = cp_time[CP_IDLE]; #if defined(__OpenBSD__) curr_all.spin = cp_time[CP_SPIN];