rmaprath updated this revision to Diff 89664.
rmaprath added a comment.
Different take on the patch: Externalize this function only for the
externally-thread-api variant.
This is much less intrusive. Note that I haven't added the declaration of
`__libcpp_thread_hw_concurrency()` into `__threading_support` because it
doesn't belong there (needs to be provided through a custom
`__external_threading` header instead).
There is no easy way to test this apart from building an actual
external-thread-api libc++ variant. We could do some form of testing with the
external-thread-library configuration, but it still requires some not-so-pretty
changes that is probably best avoided.
https://reviews.llvm.org/D29757
Files:
src/thread.cpp
Index: src/thread.cpp
===================================================================
--- src/thread.cpp
+++ src/thread.cpp
@@ -77,7 +77,10 @@
unsigned
thread::hardware_concurrency() _NOEXCEPT
{
-#if defined(CTL_HW) && defined(HW_NCPU)
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+ // Defer to the external threading implementation
+ return __libcpp_thread_hw_concurrency();
+#elif defined(CTL_HW) && defined(HW_NCPU)
unsigned n;
int mib[2] = {CTL_HW, HW_NCPU};
std::size_t s = sizeof(n);
Index: src/thread.cpp
===================================================================
--- src/thread.cpp
+++ src/thread.cpp
@@ -77,7 +77,10 @@
unsigned
thread::hardware_concurrency() _NOEXCEPT
{
-#if defined(CTL_HW) && defined(HW_NCPU)
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+ // Defer to the external threading implementation
+ return __libcpp_thread_hw_concurrency();
+#elif defined(CTL_HW) && defined(HW_NCPU)
unsigned n;
int mib[2] = {CTL_HW, HW_NCPU};
std::size_t s = sizeof(n);
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits