summaryrefslogtreecommitdiff
path: root/components/OpenBSD
diff options
context:
space:
mode:
authorQuentin Rameau <quinq@fifth.space>2018-04-30 15:14:33 +0200
committerAaron Marcher <me@drkhsh.at>2018-04-30 15:41:09 +0200
commitf088dbfea06363a84533bb9f1a84f756c46bc3b2 (patch)
tree5b41ba6324f37e19f47aef4f2616aee833aefe80 /components/OpenBSD
parent720569bd56cb048ba7abae62be3c2e6839fd5916 (diff)
downloadslstatus-f088dbfea06363a84533bb9f1a84f756c46bc3b2.tar.gz
cpu: OS split
Diffstat (limited to 'components/OpenBSD')
-rw-r--r--components/OpenBSD/cpu.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/components/OpenBSD/cpu.c b/components/OpenBSD/cpu.c
new file mode 100644
index 0000000..11f1812
--- /dev/null
+++ b/components/OpenBSD/cpu.c
@@ -0,0 +1,26 @@
+/* See LICENSE file for copyright and license details. */
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/sysctl.h>
+
+#include "../../util.h"
+
+const char *
+cpu_freq(void)
+{
+ int freq, mib[2];
+ size_t size;
+
+ mib[0] = CTL_HW;
+ mib[1] = HW_CPUSPEED;
+
+ size = sizeof(freq);
+
+ if (sysctl(mib, 2, &freq, &size, NULL, 0) == -1) {
+ fprintf(stderr, "sysctl 'HW_CPUSPEED': %s\n", strerror(errno));
+ return NULL;
+ }
+
+ return bprintf("%d", freq);
+}