diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2018-02-25 00:53:35 -0800 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2018-02-27 23:03:29 -0800 |
commit | 0aa9efd5c69a956d88adc25abd154289ecfbede7 (patch) | |
tree | a605fefa8f8990317e5fc9bc1f6e0dc14f5bbbb6 /src | |
parent | 6f39c7145f19a2644d36bde00a77f7514e1f4545 (diff) |
util: add windows flavor of get_ncpus()
Diffstat (limited to 'src')
-rw-r--r-- | src/util.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -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 } |