mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-22 16:37:40 +08:00
[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. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@290878 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -27,12 +27,24 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#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) && \
|
#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) && \
|
||||||
__libcpp_has_include(<__external_threading>)
|
__libcpp_has_include(<__external_threading>)
|
||||||
#include <__external_threading>
|
#include <__external_threading>
|
||||||
#else
|
#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 <pthread.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -45,7 +57,8 @@
|
|||||||
|
|
||||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
_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
|
// Mutex
|
||||||
typedef pthread_mutex_t __libcpp_mutex_t;
|
typedef pthread_mutex_t __libcpp_mutex_t;
|
||||||
#define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
|
#define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
|
||||||
@@ -134,7 +147,8 @@ void *__libcpp_tls_get(__libcpp_tls_key __key);
|
|||||||
_LIBCPP_THREAD_ABI_VISIBILITY
|
_LIBCPP_THREAD_ABI_VISIBILITY
|
||||||
void __libcpp_tls_set(__libcpp_tls_key __key, void *__p);
|
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)
|
int __libcpp_recursive_mutex_init(__libcpp_mutex_t *__m)
|
||||||
{
|
{
|
||||||
|
@@ -6,5 +6,5 @@
|
|||||||
// Source Licenses. See LICENSE.TXT for details.
|
// Source Licenses. See LICENSE.TXT for details.
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
#define _LIBCPP_HAS_THREAD_API_PTHREAD
|
#define _LIBCPP_BUILDING_THREAD_API_EXTERNAL_PTHREAD
|
||||||
#include <__threading_support>
|
#include <__threading_support>
|
||||||
|
Reference in New Issue
Block a user