[PATCH] D29757: [libcxx] Threading support: Externalize hardware_concurrency()

Asiri Rathnayake via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 24 06:38:13 PST 2017


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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29757.89664.patch
Type: text/x-patch
Size: 519 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170224/6696ab41/attachment-0001.bin>


More information about the cfe-commits mailing list