summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2018-02-25 00:53:35 -0800
committerVito Caputo <vcaputo@pengaru.com>2018-02-27 23:03:29 -0800
commit0aa9efd5c69a956d88adc25abd154289ecfbede7 (patch)
treea605fefa8f8990317e5fc9bc1f6e0dc14f5bbbb6 /src
parent6f39c7145f19a2644d36bde00a77f7514e1f4545 (diff)
util: add windows flavor of get_ncpus()
Diffstat (limited to 'src')
-rw-r--r--src/util.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index c324a0b..500ac75 100644
--- a/src/util.c
+++ b/src/util.c
@@ -3,6 +3,10 @@
#include <string.h>
#include <unistd.h>
+#ifdef __WIN32__
+#include <windows.h>
+#endif
+
#include "util.h"
#define SYSFS_CPU "/sys/devices/system/cpu/cpu"
@@ -10,6 +14,13 @@
unsigned get_ncpus(void)
{
+#ifdef __WIN32__
+ SYSTEM_INFO sysinfo;
+
+ GetSystemInfo(&sysinfo);
+
+ return sysinfo.dwNumberOfProcessors;
+#else
char path[cstrlen(SYSFS_CPU "1024") + 1];
unsigned n;
@@ -20,4 +31,5 @@ unsigned get_ncpus(void)
}
return n == 0 ? 1 : n;
+#endif
}
© All Rights Reserved