From 0aa9efd5c69a956d88adc25abd154289ecfbede7 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sun, 25 Feb 2018 00:53:35 -0800 Subject: util: add windows flavor of get_ncpus() --- src/util.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/util.c') 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 #include +#ifdef __WIN32__ +#include +#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 } -- cgit v1.2.1