Windows support in thread::hardware_concurrency.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@185451 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Howard Hinnant 2013-07-02 17:53:48 +00:00
parent dbc8cf059e
commit 725ae713f2

View File

@ -23,6 +23,9 @@
#if defined(__NetBSD__)
#pragma weak pthread_create // Do not create libpthread dependency
#endif
#if defined(_WIN32)
#include <windows.h>
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@ -79,6 +82,10 @@ thread::hardware_concurrency() _NOEXCEPT
if (result < 0)
return 0;
return static_cast<unsigned>(result);
#elif defined(_WIN32)
SYSTEM_INFO info;
GetSystemInfo(&info);
return info.dwNumberOfProcessors;
#else // defined(CTL_HW) && defined(HW_NCPU)
// TODO: grovel through /proc or check cpuid on x86 and similar
// instructions on other architectures.