$OpenBSD: patch-openbsd_Platform_c,v 1.7 2019/05/10 23:38:58 ians Exp $

Use sched.h macros instead of hardcoding, the former broke when we introduced
CP_SPIN cpu state.

https://github.com/hishamhm/htop/pull/817

Index: openbsd/Platform.c
--- openbsd/Platform.c.orig
+++ openbsd/Platform.c
@@ -46,7 +46,7 @@ extern ProcessFieldData Process_fields[];
 
 #define MAXCPU 256
 // XXX: probably should be a struct member
-static int64_t old_v[MAXCPU][5];
+static int64_t old_v[MAXCPU][CPUSTATES];
 
 /*
  * Copyright (c) 1984, 1989, William LeFebvre, Rice University
@@ -209,13 +209,13 @@ double Platform_setCPUValues(Meter* this, int cpu) {
    int64_t new_v[CPUSTATES], diff_v[CPUSTATES], scratch_v[CPUSTATES];
    double *v = this->values;
    size_t size = sizeof(double) * CPUSTATES;
-   int mib[] = { CTL_KERN, KERN_CPTIME2, cpu-1 };
+   int mib[] = { CTL_KERN, KERN_CPTIME2, pl->cpuIndex[cpu-1] };
    if (sysctl(mib, 3, new_v, &size, NULL, 0) == -1) {
       return 0.;
    }
 
    // XXX: why?
-   cpuData->totalPeriod = 1;
+   //cpuData->totalPeriod = 1;
 
    percentages(CPUSTATES, diff_v, new_v,
          (int64_t *)old_v[cpu-1], scratch_v);
@@ -225,7 +225,7 @@ double Platform_setCPUValues(Meter* this, int cpu) {
       v[i] = diff_v[i] / 10.;
    }
 
-   Meter_setItems(this, 4);
+   Meter_setItems(this, CP_IDLE);
 
    perc = v[0] + v[1] + v[2] + v[3];
 
@@ -286,7 +286,7 @@ void Platform_setSwapValues(Meter* this) {
    this->total = pl->totalSwap = total;
    this->values[0] = pl->usedSwap = used;
 
-   free(swdev);
+   //free(swdev);
 }
 
 void Platform_setTasksValues(Meter* this) {
