aboutsummaryrefslogtreecommitdiff
path: root/src/common/tuklib_cpucores.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2013-08-03 13:52:58 +0300
committerLasse Collin <lasse.collin@tukaani.org>2013-08-03 13:52:58 +0300
commit124eb69c7857f618b4807588c51bc9ba21bf8691 (patch)
treef8ba68d7ef2b9ba36448ea60e343a30a9d3c2075 /src/common/tuklib_cpucores.c
parentmacosx: separate liblzma package (diff)
downloadxz-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/tuklib_cpucores.c')
-rw-r--r--src/common/tuklib_cpucores.c13
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);