summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.c')
-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