summaryrefslogtreecommitdiffstats
path: root/libcxx/include/__threading_support
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2017-01-06 20:05:40 +0000
committerEric Fiselier <eric@efcs.ca>2017-01-06 20:05:40 +0000
commit00f6beaed46e86463fb88319845947c45e1dfac3 (patch)
treefd9d2fd628adbc46c2f3ef702e55f829b6aefd32 /libcxx/include/__threading_support
parent08519d7b021d6a6d28dad54e0224123c2c4099a6 (diff)
downloadbcm5719-llvm-00f6beaed46e86463fb88319845947c45e1dfac3.tar.gz
bcm5719-llvm-00f6beaed46e86463fb88319845947c45e1dfac3.zip
[libc++] Cleanup and document <__threading_support>
Summary: This patch attempts to clean up the macro configuration mess in `<__threading_support>`, specifically the mess involving external threading variants. Additionally this patch adds design documentation for `<__threading_support>` and the configuration macros it uses. The primary change in this patch is separating the idea of an "external API" provided by `<__external_threading>` and the idea of having an external threading library. Now `_LIBCPP_HAS_THREAD_API_EXTERNAL` means that libc++ should use `<__external_threading>` and that the header is expected to exist. Additionally the new macro `_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL` is now used to configure for using an "external library" with the default threading API. Reviewers: compnerd, rmaprath Subscribers: smeenai, cfe-commits, mgorny Differential Revision: https://reviews.llvm.org/D28316 llvm-svn: 291275
Diffstat (limited to 'libcxx/include/__threading_support')
-rw-r--r--libcxx/include/__threading_support53
1 files changed, 16 insertions, 37 deletions
diff --git a/libcxx/include/__threading_support b/libcxx/include/__threading_support
index b4383b92c28..2a0705a96f0 100644
--- a/libcxx/include/__threading_support
+++ b/libcxx/include/__threading_support
@@ -17,39 +17,17 @@
#pragma GCC system_header
#endif
-#ifndef _LIBCPP_HAS_NO_THREADS
-
-#ifndef __libcpp_has_include
- #ifndef __has_include
- #define __libcpp_has_include(x) 0
- #else
- #define __libcpp_has_include(x) __has_include(x)
- #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) && \
- __libcpp_has_include(<__external_threading>)
-#include <__external_threading>
-#else
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+# include <__external_threading>
+#elif !defined(_LIBCPP_HAS_NO_THREADS)
-#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \
- defined(_LIBCPP_HAS_THREAD_API_EXTERNAL_PTHREAD)
-#include <pthread.h>
-#include <sched.h>
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
+# include <pthread.h>
+# include <sched.h>
#endif
-#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+#if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
+ defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL)
#define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS
#else
#define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
@@ -57,8 +35,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \
- defined(_LIBCPP_HAS_THREAD_API_EXTERNAL_PTHREAD)
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
// Mutex
typedef pthread_mutex_t __libcpp_mutex_t;
#define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
@@ -175,8 +152,10 @@ void *__libcpp_tls_get(__libcpp_tls_key __key);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_tls_set(__libcpp_tls_key __key, void *__p);
-#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \
- defined(_LIBCPP_BUILDING_THREAD_API_EXTERNAL_PTHREAD)
+#if !defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
+ defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL)
+
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m)
{
@@ -344,10 +323,10 @@ int __libcpp_tls_set(__libcpp_tls_key __key, void *__p)
#endif // _LIBCPP_HAS_THREAD_API_PTHREAD
-_LIBCPP_END_NAMESPACE_STD
+#endif // !_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL || _LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL
-#endif // !_LIBCPP_HAS_THREAD_API_EXTERNAL || !__libcpp_has_include(<__external_threading>)
+_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_HAS_NO_THREADS
+#endif // !_LIBCPP_HAS_NO_THREADS
#endif // _LIBCPP_THREADING_SUPPORT
OpenPOWER on IntegriCloud