[PATCH] D20573: [libcxx] Allow explicit pthread opt-in
Ben Craig via cfe-commits
cfe-commits at lists.llvm.org
Tue May 24 09:54:01 PDT 2016
bcraig created this revision.
bcraig added reviewers: rmaprath, mclow.lists, EricWF.
bcraig added a subscriber: cfe-commits.
The existing pthread detection code in __config is pretty good for common operating systems. It doesn't allow cmake-time choices to be made for uncommon operating systems though.
This change adds the LIBCXX_HAS_PTHREAD_API cmake flag, which turns into the _LIBCPP_HAS_THREAD_API_PTHREAD preprocessor define. This is a name change from the old _LIBCPP_THREAD_API_PTHREAD. The lit tests want __config_site.in variables to have a _LIBCPP_HAS prefix.
http://reviews.llvm.org/D20573
Files:
CMakeLists.txt
include/__config
include/__config_site.in
include/__threading_support
Index: include/__threading_support
===================================================================
--- include/__threading_support
+++ include/__threading_support
@@ -19,14 +19,14 @@
#ifndef _LIBCPP_HAS_NO_THREADS
-#if defined(_LIBCPP_THREAD_API_PTHREAD)
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
#include <pthread.h>
#include <sched.h>
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if defined(_LIBCPP_THREAD_API_PTHREAD)
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
// Mutex
#define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
@@ -194,7 +194,7 @@
pthread_setspecific(__key, __p);
}
-#else // !_LIBCPP_THREAD_API_PTHREAD
+#else // !_LIBCPP_HAS_THREAD_API_PTHREAD
#error "No thread API selected."
#endif
Index: include/__config_site.in
===================================================================
--- include/__config_site.in
+++ include/__config_site.in
@@ -19,5 +19,6 @@
#cmakedefine _LIBCPP_HAS_NO_MONOTONIC_CLOCK
#cmakedefine _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
#cmakedefine _LIBCPP_HAS_MUSL_LIBC
+#cmakedefine _LIBCPP_HAS_THREAD_API_PTHREAD
#endif // _LIBCPP_CONFIG_SITE
Index: include/__config
===================================================================
--- include/__config
+++ include/__config
@@ -813,17 +813,17 @@
#endif
// Thread API
-#ifndef _LIBCPP_HAS_NO_THREADS
+#if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
# if defined(__FreeBSD__) || \
defined(__NetBSD__) || \
defined(__linux__) || \
defined(__APPLE__) || \
defined(__CloudABI__) || \
defined(__sun__)
-# define _LIBCPP_THREAD_API_PTHREAD
+# define _LIBCPP_HAS_THREAD_API_PTHREAD
# else
# error "No thread API"
-# endif // _LIBCPP_THREAD_API
+# endif // _LIBCPP_HAS_THREAD_API
#endif // _LIBCPP_HAS_NO_THREADS
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -384,6 +384,7 @@
config_define_if_not(LIBCXX_ENABLE_MONOTONIC_CLOCK _LIBCPP_HAS_NO_MONOTONIC_CLOCK)
config_define_if_not(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS)
+config_define_if(LIBCXX_HAS_PTHREAD_API _LIBCPP_HAS_THREAD_API_PTHREAD)
config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC)
if (LIBCXX_NEEDS_SITE_CONFIG)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20573.58255.patch
Type: text/x-patch
Size: 2323 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160524/e9052612/attachment-0001.bin>
More information about the cfe-commits
mailing list