[libcxx] r290878 - [libcxx] Fix testing of the externally-threaded library build
Asiri Rathnayake via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 3 03:32:32 PST 2017
Author: asiri
Date: Tue Jan 3 05:32:31 2017
New Revision: 290878
URL: http://llvm.org/viewvc/llvm-project?rev=290878&view=rev
Log:
[libcxx] Fix testing of the externally-threaded library build
after r290850
Before r290850, building libcxx with -DLIBCXX_HAS_EXTERNAL_THREAD_API=ON had two
uses:
- Allow platform vendors to plug-in an __external_threading header which
should take care of the entire threading infrastructure of libcxx
- Allow testing of an externally-threaded library build; where the thread API
is declared using pthread data structures, and the implementation of this
API is provided as a separate library (test/support/external_threads.cpp)
and linked-in when running the test suite.
r290850 breaks the second use case (pthread data structures are no longer
available). This patch re-stores the ability to build+test an
externally-threaded library variant on a pthread based system.
Modified:
libcxx/trunk/include/__threading_support
libcxx/trunk/test/support/external_threads.cpp
Modified: libcxx/trunk/include/__threading_support
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=290878&r1=290877&r2=290878&view=diff
==============================================================================
--- libcxx/trunk/include/__threading_support (original)
+++ libcxx/trunk/include/__threading_support Tue Jan 3 05:32:31 2017
@@ -28,11 +28,23 @@
#endif
#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) && \
+ !__libcpp_has_include(<__external_threading>)
+// If the <__external_threading> header is absent, build libc++ against a
+// pthread-oriented thread api but leave out its implementation. This setup
+// allows building+testing of an externally-threaded library variant (on any
+// platform that supports pthreads). Here, an 'externally-threaded' library
+// variant is one where the implementation of the libc++ thread api is provided
+// as a separate library.
+#define _LIBCPP_HAS_THREAD_API_EXTERNAL_PTHREAD
+#endif
+
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) && \
__libcpp_has_include(<__external_threading>)
#include <__external_threading>
#else
-#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \
+ defined(_LIBCPP_HAS_THREAD_API_EXTERNAL_PTHREAD)
#include <pthread.h>
#include <sched.h>
#endif
@@ -45,7 +57,8 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \
+ defined(_LIBCPP_HAS_THREAD_API_EXTERNAL_PTHREAD)
// Mutex
typedef pthread_mutex_t __libcpp_mutex_t;
#define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
@@ -134,7 +147,8 @@ void *__libcpp_tls_get(__libcpp_tls_key
_LIBCPP_THREAD_ABI_VISIBILITY
void __libcpp_tls_set(__libcpp_tls_key __key, void *__p);
-#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \
+ defined(_LIBCPP_BUILDING_THREAD_API_EXTERNAL_PTHREAD)
int __libcpp_recursive_mutex_init(__libcpp_mutex_t *__m)
{
Modified: libcxx/trunk/test/support/external_threads.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/external_threads.cpp?rev=290878&r1=290877&r2=290878&view=diff
==============================================================================
--- libcxx/trunk/test/support/external_threads.cpp (original)
+++ libcxx/trunk/test/support/external_threads.cpp Tue Jan 3 05:32:31 2017
@@ -6,5 +6,5 @@
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#define _LIBCPP_HAS_THREAD_API_PTHREAD
+#define _LIBCPP_BUILDING_THREAD_API_EXTERNAL_PTHREAD
#include <__threading_support>
More information about the cfe-commits
mailing list