Windows support in thread::hardware_concurrency.
authorHoward Hinnant <hhinnant@apple.com>
Tue, 2 Jul 2013 17:53:48 +0000 (17:53 +0000)
committerHoward Hinnant <hhinnant@apple.com>
Tue, 2 Jul 2013 17:53:48 +0000 (17:53 +0000)
llvm-svn: 185451

libcxx/src/thread.cpp

index 5bf7414..1fd8bb0 100644 (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.