[libcxx] r185451 - Windows support in thread::hardware_concurrency.

Howard Hinnant hhinnant at apple.com
Tue Jul 2 10:53:48 PDT 2013


Author: hhinnant
Date: Tue Jul  2 12:53:48 2013
New Revision: 185451

URL: http://llvm.org/viewvc/llvm-project?rev=185451&view=rev
Log:
Windows support in thread::hardware_concurrency.

Modified:
    libcxx/trunk/src/thread.cpp

Modified: libcxx/trunk/src/thread.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/thread.cpp?rev=185451&r1=185450&r2=185451&view=diff
==============================================================================
--- libcxx/trunk/src/thread.cpp (original)
+++ libcxx/trunk/src/thread.cpp Tue Jul  2 12:53:48 2013
@@ -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.





More information about the cfe-commits mailing list