From 124eb69c7857f618b4807588c51bc9ba21bf8691 Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Sat, 3 Aug 2013 13:52:58 +0300 Subject: 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. --- src/common/tuklib_cpucores.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/common/tuklib_cpucores.c') 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 + #if defined(TUKLIB_CPUCORES_SYSCTL) # ifdef HAVE_SYS_PARAM_H # include @@ -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); -- cgit v1.2.3