rmaprath created this revision. rmaprath added reviewers: compnerd, EricWF. rmaprath added a subscriber: cfe-commits.
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. This wasn't caught on any of the official bots because we don't have any builds of the externally-threaded library build at the moment (apart from my downstream one). https://reviews.llvm.org/D28229 Files: include/__threading_support test/support/external_threads.cpp Index: test/support/external_threads.cpp =================================================================== --- test/support/external_threads.cpp +++ test/support/external_threads.cpp @@ -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> Index: include/__threading_support =================================================================== --- include/__threading_support +++ include/__threading_support @@ -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 @@ _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) {
Index: test/support/external_threads.cpp =================================================================== --- test/support/external_threads.cpp +++ test/support/external_threads.cpp @@ -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> Index: include/__threading_support =================================================================== --- include/__threading_support +++ include/__threading_support @@ -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 @@ _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) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits