summaryrefslogtreecommitdiff
path: root/components
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
parent720569bd56cb048ba7abae62be3c2e6839fd5916 (diff)
cpu: OS split
Diffstat (limited to 'components')
-rw-r--r--components/Linux/cpu.c (renamed from components/cpu.c)26
-rw-r--r--components/OpenBSD/cpu.c26
2 files changed, 27 insertions, 25 deletions
diff --git a/components/cpu.c b/components/Linux/cpu.c
index 11e2e98..bfc204c 100644
--- a/components/cpu.c
+++ b/components/Linux/cpu.c
@@ -2,13 +2,9 @@
#include <errno.h>
#include <stdio.h>
#include <string.h>
-#if defined(__OpenBSD__)
-#include <sys/sysctl.h>
-#endif
-#include "../util.h"
+#include "../../util.h"
-#if defined(__linux__)
const char *
cpu_freq(void)
{
@@ -66,23 +62,3 @@ cpu_iowait(void)
return bprintf("%d", perc);
}
-#elif defined(__OpenBSD__)
-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);
-}
-#endif
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);
+}