diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2013-08-03 13:52:58 +0300 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2013-08-03 13:52:58 +0300 |
commit | 124eb69c7857f618b4807588c51bc9ba21bf8691 (patch) | |
tree | f8ba68d7ef2b9ba36448ea60e343a30a9d3c2075 /src/common | |
parent | macosx: separate liblzma package (diff) | |
download | xz-124eb69c7857f618b4807588c51bc9ba21bf8691.tar.xz |
Windows: Add Windows support to tuklib_cpucores().
It is used for Cygwin too. I'm not sure if that is
a good or bad idea.
Thanks to Vincent Torri.
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/tuklib_cpucores.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/common/tuklib_cpucores.c b/src/common/tuklib_cpucores.c index 1da13df7..93413a3c 100644 --- a/src/common/tuklib_cpucores.c +++ b/src/common/tuklib_cpucores.c @@ -12,6 +12,12 @@ #include "tuklib_cpucores.h" +#if defined(_WIN32) || defined(__CYGWIN__) +# ifndef _WIN32_WINNT +# define _WIN32_WINNT 0x0500 +# endif +# include <windows.h> + #if defined(TUKLIB_CPUCORES_SYSCTL) # ifdef HAVE_SYS_PARAM_H # include <sys/param.h> @@ -33,7 +39,12 @@ tuklib_cpucores(void) { uint32_t ret = 0; -#if defined(TUKLIB_CPUCORES_SYSCTL) +#if defined(_WIN32) || defined(__CYGWIN__) + SYSTEM_INFO sysinfo; + GetSystemInfo(&sysinfo); + ret = sysinfo.dwNumberOfProcessors; + +#elif defined(TUKLIB_CPUCORES_SYSCTL) int name[2] = { CTL_HW, HW_NCPU }; int cpus; size_t cpus_size = sizeof(cpus); |