commit - 74aa03b4ed1f95ccb2ef2b70f63162e47cb3d4b4
commit + 7531eddb5c1c5d5778955b6935e033f865bde366
blob - 8a53c442e8dcc4ca0241a0699eee206c605e19ed
blob + abefccb23efc5f36794e0c01518bbd51f513671a
--- bedstatus/freebsd.c
+++ bedstatus/freebsd.c
static long pagesize;
static int ncpu;
static struct cpu_times *old = NULL, *new, *diff;
+static char **cpuspeed_sysctls = NULL;
static bool xsysctl (const char *name, void *ptr, size_t len)
{
return SYSCTL ("hw.acpi.battery.rate", pwr);
}
+static bool cpu_speed (int *mhz)
+{
+ int x, sum = 0, n = 0;
+
+ for (int i = 0; i < ncpu; ++i) {
+ if (!SYSCTL (cpuspeed_sysctls[i], &x))
+ continue;
+ sum += x;
+ ++n;
+ }
+
+ *mhz = sum / n;
+
+ return n > 0;
+}
+
void init_backend (void)
{
pagesize = getpagesize ();
new = calloc (ncpu, sizeof (struct cpu_times));
diff = calloc (ncpu, sizeof (struct cpu_times));
}
+
+ cpuspeed_sysctls = calloc (ncpu, sizeof (char *));
+ for (int i = 0; i < ncpu; ++i) {
+ asprintf (&cpuspeed_sysctls[i], "dev.cpu.%d.freq", i);
+ }
}
void update_status (struct status *st)
memset (st, 0, sizeof (*st));
st->has_mem_usage = mem_usage (&st->mem_usage);
st->has_cpu_usage = cpu_usage (&st->cpu_usage);
+ st->has_cpu_speed = cpu_speed (&st->cpu_speed);
st->has_bat_perc = bat_perc (&st->bat_perc);
st->has_bat_rem = bat_rem (&st->bat_rem);
st->has_bat_charging = bat_charging (&st->bat_charging);