summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2019-01-16 02:10:28 +0000
committerEric Fiselier <eric@efcs.ca>2019-01-16 02:10:28 +0000
commitede2383b71efecb8a0ca6d3c0481c27fd541f374 (patch)
tree5126dd68e276ed395d667ce12d9cc466afe74048
parent685a8292b343c5dcb5af1ca24d9fb61ca01369f6 (diff)
Fix feature test macros for atomics/mutexes without threadinglinaro-local/ci/tcwg_kernel/llvm-master-arm-lts-defconfig
-rw-r--r--libcxx/include/version16
-rw-r--r--libcxx/test/std/language.support/support.limits/support.limits.general/atomic.version.pass.cpp34
-rwxr-xr-xlibcxx/test/std/language.support/support.limits/support.limits.general/generate_feature_test_macro_components.py22
-rw-r--r--libcxx/test/std/language.support/support.limits/support.limits.general/shared_mutex.version.pass.cpp82
-rw-r--r--libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp112
5 files changed, 189 insertions, 77 deletions
diff --git a/libcxx/include/version b/libcxx/include/version
index d37aba139af..e37afc44860 100644
--- a/libcxx/include/version
+++ b/libcxx/include/version
@@ -135,7 +135,9 @@ __cpp_lib_void_t 201411L <type_traits>
# define __cpp_lib_quoted_string_io 201304L
# define __cpp_lib_result_of_sfinae 201210L
# define __cpp_lib_robust_nonmodifying_seq_ops 201304L
-# define __cpp_lib_shared_timed_mutex 201402L
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+# define __cpp_lib_shared_timed_mutex 201402L
+# endif
# define __cpp_lib_string_udls 201304L
# define __cpp_lib_transformation_trait_aliases 201304L
# define __cpp_lib_transparent_operators 201210L
@@ -152,7 +154,9 @@ __cpp_lib_void_t 201411L <type_traits>
# define __cpp_lib_apply 201603L
# define __cpp_lib_array_constexpr 201603L
# define __cpp_lib_as_const 201510L
-# define __cpp_lib_atomic_is_always_lock_free 201603L
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+# define __cpp_lib_atomic_is_always_lock_free 201603L
+# endif
# define __cpp_lib_bool_constant 201505L
// # define __cpp_lib_boyer_moore_searcher 201603L
# define __cpp_lib_byte 201603L
@@ -188,7 +192,9 @@ __cpp_lib_void_t 201411L <type_traits>
# define __cpp_lib_raw_memory_algorithms 201606L
# define __cpp_lib_sample 201603L
# define __cpp_lib_scoped_lock 201703L
-# define __cpp_lib_shared_mutex 201505L
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+# define __cpp_lib_shared_mutex 201505L
+# endif
// # define __cpp_lib_shared_ptr_arrays 201611L
# define __cpp_lib_shared_ptr_weak_type 201606L
# define __cpp_lib_string_view 201606L
@@ -203,7 +209,9 @@ __cpp_lib_void_t 201411L <type_traits>
#endif
#if _LIBCPP_STD_VER > 17
-// # define __cpp_lib_atomic_ref 201806L
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+// # define __cpp_lib_atomic_ref 201806L
+# endif
// # define __cpp_lib_bind_front 201811L
// # define __cpp_lib_bit_cast 201806L
# if !defined(_LIBCPP_NO_HAS_CHAR8_T)
diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/atomic.version.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/atomic.version.pass.cpp
index 4c0b351213a..4ba37542c9e 100644
--- a/libcxx/test/std/language.support/support.limits/support.limits.general/atomic.version.pass.cpp
+++ b/libcxx/test/std/language.support/support.limits/support.limits.general/atomic.version.pass.cpp
@@ -10,6 +10,8 @@
// WARNING: This test was generated by generate_feature_test_macros_tests.py and
// should not be edited manually.
+// UNSUPPORTED: libcpp-has-no-threads
+
// <atomic>
// Test the feature test macros defined by <atomic>
@@ -53,11 +55,17 @@
#elif TEST_STD_VER == 17
-# ifndef __cpp_lib_atomic_is_always_lock_free
-# error "__cpp_lib_atomic_is_always_lock_free should be defined in c++17"
-# endif
-# if __cpp_lib_atomic_is_always_lock_free != 201603L
-# error "__cpp_lib_atomic_is_always_lock_free should have the value 201603L in c++17"
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+# ifndef __cpp_lib_atomic_is_always_lock_free
+# error "__cpp_lib_atomic_is_always_lock_free should be defined in c++17"
+# endif
+# if __cpp_lib_atomic_is_always_lock_free != 201603L
+# error "__cpp_lib_atomic_is_always_lock_free should have the value 201603L in c++17"
+# endif
+# else
+# ifdef __cpp_lib_atomic_is_always_lock_free
+# error "__cpp_lib_atomic_is_always_lock_free should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
+# endif
# endif
# ifdef __cpp_lib_atomic_ref
@@ -70,11 +78,17 @@
#elif TEST_STD_VER > 17
-# ifndef __cpp_lib_atomic_is_always_lock_free
-# error "__cpp_lib_atomic_is_always_lock_free should be defined in c++2a"
-# endif
-# if __cpp_lib_atomic_is_always_lock_free != 201603L
-# error "__cpp_lib_atomic_is_always_lock_free should have the value 201603L in c++2a"
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+# ifndef __cpp_lib_atomic_is_always_lock_free
+# error "__cpp_lib_atomic_is_always_lock_free should be defined in c++2a"
+# endif
+# if __cpp_lib_atomic_is_always_lock_free != 201603L
+# error "__cpp_lib_atomic_is_always_lock_free should have the value 201603L in c++2a"
+# endif
+# else
+# ifdef __cpp_lib_atomic_is_always_lock_free
+# error "__cpp_lib_atomic_is_always_lock_free should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
+# endif
# endif
# if !defined(_LIBCPP_VERSION)
diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/generate_feature_test_macro_components.py b/libcxx/test/std/language.support/support.limits/support.limits.general/generate_feature_test_macro_components.py
index d51df45431f..2f13ed022a2 100755
--- a/libcxx/test/std/language.support/support.limits/support.limits.general/generate_feature_test_macro_components.py
+++ b/libcxx/test/std/language.support/support.limits/support.limits.general/generate_feature_test_macro_components.py
@@ -148,14 +148,18 @@ feature_test_macros = sorted([ add_version_header(x) for x in [
"values": {
"c++14": 201402L,
},
- "headers": ["shared_mutex"]
+ "headers": ["shared_mutex"],
+ "depends": "!defined(_LIBCPP_HAS_NO_THREADS)",
+ "internal_depends": "!defined(_LIBCPP_HAS_NO_THREADS)",
},
# C++17 macros
{"name": "__cpp_lib_atomic_is_always_lock_free",
"values": {
"c++17": 201603L,
},
- "headers": ["atomic"]
+ "headers": ["atomic"],
+ "depends": "!defined(_LIBCPP_HAS_NO_THREADS)",
+ "internal_depends": "!defined(_LIBCPP_HAS_NO_THREADS)",
},
{"name": "__cpp_lib_filesystem",
"values": {
@@ -446,6 +450,8 @@ feature_test_macros = sorted([ add_version_header(x) for x in [
"c++17": 201505L,
},
"headers": ["shared_mutex"],
+ "depends": "!defined(_LIBCPP_HAS_NO_THREADS)",
+ "internal_depends": "!defined(_LIBCPP_HAS_NO_THREADS)",
},
{"name": "__cpp_lib_scoped_lock",
"values": {
@@ -553,6 +559,8 @@ feature_test_macros = sorted([ add_version_header(x) for x in [
},
"headers": ["atomic"],
"unimplemented": True,
+ "depends": "!defined(_LIBCPP_HAS_NO_THREADS)",
+ "internal_depends": "!defined(_LIBCPP_HAS_NO_THREADS)",
},
]], key=lambda tc: tc["name"])
@@ -802,6 +810,10 @@ def generate_synopsis(test_list):
result += "*/"
return result
+def is_threading_header_unsafe_to_include(h):
+ # NOTE: "<mutex>" does not blow up when included without threads.
+ return h in ['atomic', 'shared_mutex']
+
def produce_tests():
headers = set([h for tc in feature_test_macros for h in tc["headers"]])
for h in headers:
@@ -810,6 +822,9 @@ def produce_tests():
for tc in test_list:
assert 'unimplemented' in tc.keys()
continue
+ test_tags = ""
+ if is_threading_header_unsafe_to_include(h):
+ test_tags += '\n// UNSUPPORTED: libcpp-has-no-threads\n'
test_body = \
"""//===----------------------------------------------------------------------===//
//
@@ -822,7 +837,7 @@ def produce_tests():
//
// WARNING: This test was generated by generate_feature_test_macros_tests.py and
// should not be edited manually.
-
+{test_tags}
// <{header}>
// Test the feature test macros defined by <{header}>
@@ -852,6 +867,7 @@ def produce_tests():
int main() {{}}
""".format(header=h,
+ test_tags=test_tags,
synopsis=generate_synopsis(test_list),
cxx11_tests=generate_std_test(test_list, 'c++11').strip(),
cxx14_tests=generate_std_test(test_list, 'c++14').strip(),
diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/shared_mutex.version.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/shared_mutex.version.pass.cpp
index a86aebe7027..98bdf704bd0 100644
--- a/libcxx/test/std/language.support/support.limits/support.limits.general/shared_mutex.version.pass.cpp
+++ b/libcxx/test/std/language.support/support.limits/support.limits.general/shared_mutex.version.pass.cpp
@@ -10,6 +10,8 @@
// WARNING: This test was generated by generate_feature_test_macros_tests.py and
// should not be edited manually.
+// UNSUPPORTED: libcpp-has-no-threads
+
// <shared_mutex>
// Test the feature test macros defined by <shared_mutex>
@@ -38,43 +40,73 @@
# error "__cpp_lib_shared_mutex should not be defined before c++17"
# endif
-# ifndef __cpp_lib_shared_timed_mutex
-# error "__cpp_lib_shared_timed_mutex should be defined in c++14"
-# endif
-# if __cpp_lib_shared_timed_mutex != 201402L
-# error "__cpp_lib_shared_timed_mutex should have the value 201402L in c++14"
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+# ifndef __cpp_lib_shared_timed_mutex
+# error "__cpp_lib_shared_timed_mutex should be defined in c++14"
+# endif
+# if __cpp_lib_shared_timed_mutex != 201402L
+# error "__cpp_lib_shared_timed_mutex should have the value 201402L in c++14"
+# endif
+# else
+# ifdef __cpp_lib_shared_timed_mutex
+# error "__cpp_lib_shared_timed_mutex should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
+# endif
# endif
#elif TEST_STD_VER == 17
-# ifndef __cpp_lib_shared_mutex
-# error "__cpp_lib_shared_mutex should be defined in c++17"
-# endif
-# if __cpp_lib_shared_mutex != 201505L
-# error "__cpp_lib_shared_mutex should have the value 201505L in c++17"
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+# ifndef __cpp_lib_shared_mutex
+# error "__cpp_lib_shared_mutex should be defined in c++17"
+# endif
+# if __cpp_lib_shared_mutex != 201505L
+# error "__cpp_lib_shared_mutex should have the value 201505L in c++17"
+# endif
+# else
+# ifdef __cpp_lib_shared_mutex
+# error "__cpp_lib_shared_mutex should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
+# endif
# endif
-# ifndef __cpp_lib_shared_timed_mutex
-# error "__cpp_lib_shared_timed_mutex should be defined in c++17"
-# endif
-# if __cpp_lib_shared_timed_mutex != 201402L
-# error "__cpp_lib_shared_timed_mutex should have the value 201402L in c++17"
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+# ifndef __cpp_lib_shared_timed_mutex
+# error "__cpp_lib_shared_timed_mutex should be defined in c++17"
+# endif
+# if __cpp_lib_shared_timed_mutex != 201402L
+# error "__cpp_lib_shared_timed_mutex should have the value 201402L in c++17"
+# endif
+# else
+# ifdef __cpp_lib_shared_timed_mutex
+# error "__cpp_lib_shared_timed_mutex should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
+# endif
# endif
#elif TEST_STD_VER > 17
-# ifndef __cpp_lib_shared_mutex
-# error "__cpp_lib_shared_mutex should be defined in c++2a"
-# endif
-# if __cpp_lib_shared_mutex != 201505L
-# error "__cpp_lib_shared_mutex should have the value 201505L in c++2a"
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+# ifndef __cpp_lib_shared_mutex
+# error "__cpp_lib_shared_mutex should be defined in c++2a"
+# endif
+# if __cpp_lib_shared_mutex != 201505L
+# error "__cpp_lib_shared_mutex should have the value 201505L in c++2a"
+# endif
+# else
+# ifdef __cpp_lib_shared_mutex
+# error "__cpp_lib_shared_mutex should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
+# endif
# endif
-# ifndef __cpp_lib_shared_timed_mutex
-# error "__cpp_lib_shared_timed_mutex should be defined in c++2a"
-# endif
-# if __cpp_lib_shared_timed_mutex != 201402L
-# error "__cpp_lib_shared_timed_mutex should have the value 201402L in c++2a"
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+# ifndef __cpp_lib_shared_timed_mutex
+# error "__cpp_lib_shared_timed_mutex should be defined in c++2a"
+# endif
+# if __cpp_lib_shared_timed_mutex != 201402L
+# error "__cpp_lib_shared_timed_mutex should have the value 201402L in c++2a"
+# endif
+# else
+# ifdef __cpp_lib_shared_timed_mutex
+# error "__cpp_lib_shared_timed_mutex should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
+# endif
# endif
#endif // TEST_STD_VER > 17
diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp
index 6f7d649f5de..27931b447fb 100644
--- a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp
+++ b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp
@@ -749,11 +749,17 @@
# error "__cpp_lib_shared_ptr_weak_type should not be defined before c++17"
# endif
-# ifndef __cpp_lib_shared_timed_mutex
-# error "__cpp_lib_shared_timed_mutex should be defined in c++14"
-# endif
-# if __cpp_lib_shared_timed_mutex != 201402L
-# error "__cpp_lib_shared_timed_mutex should have the value 201402L in c++14"
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+# ifndef __cpp_lib_shared_timed_mutex
+# error "__cpp_lib_shared_timed_mutex should be defined in c++14"
+# endif
+# if __cpp_lib_shared_timed_mutex != 201402L
+# error "__cpp_lib_shared_timed_mutex should have the value 201402L in c++14"
+# endif
+# else
+# ifdef __cpp_lib_shared_timed_mutex
+# error "__cpp_lib_shared_timed_mutex should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
+# endif
# endif
# ifndef __cpp_lib_string_udls
@@ -873,11 +879,17 @@
# error "__cpp_lib_as_const should have the value 201510L in c++17"
# endif
-# ifndef __cpp_lib_atomic_is_always_lock_free
-# error "__cpp_lib_atomic_is_always_lock_free should be defined in c++17"
-# endif
-# if __cpp_lib_atomic_is_always_lock_free != 201603L
-# error "__cpp_lib_atomic_is_always_lock_free should have the value 201603L in c++17"
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+# ifndef __cpp_lib_atomic_is_always_lock_free
+# error "__cpp_lib_atomic_is_always_lock_free should be defined in c++17"
+# endif
+# if __cpp_lib_atomic_is_always_lock_free != 201603L
+# error "__cpp_lib_atomic_is_always_lock_free should have the value 201603L in c++17"
+# endif
+# else
+# ifdef __cpp_lib_atomic_is_always_lock_free
+# error "__cpp_lib_atomic_is_always_lock_free should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
+# endif
# endif
# ifdef __cpp_lib_atomic_ref
@@ -1289,11 +1301,17 @@
# error "__cpp_lib_scoped_lock should have the value 201703L in c++17"
# endif
-# ifndef __cpp_lib_shared_mutex
-# error "__cpp_lib_shared_mutex should be defined in c++17"
-# endif
-# if __cpp_lib_shared_mutex != 201505L
-# error "__cpp_lib_shared_mutex should have the value 201505L in c++17"
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+# ifndef __cpp_lib_shared_mutex
+# error "__cpp_lib_shared_mutex should be defined in c++17"
+# endif
+# if __cpp_lib_shared_mutex != 201505L
+# error "__cpp_lib_shared_mutex should have the value 201505L in c++17"
+# endif
+# else
+# ifdef __cpp_lib_shared_mutex
+# error "__cpp_lib_shared_mutex should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
+# endif
# endif
# if !defined(_LIBCPP_VERSION)
@@ -1316,11 +1334,17 @@
# error "__cpp_lib_shared_ptr_weak_type should have the value 201606L in c++17"
# endif
-# ifndef __cpp_lib_shared_timed_mutex
-# error "__cpp_lib_shared_timed_mutex should be defined in c++17"
-# endif
-# if __cpp_lib_shared_timed_mutex != 201402L
-# error "__cpp_lib_shared_timed_mutex should have the value 201402L in c++17"
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+# ifndef __cpp_lib_shared_timed_mutex
+# error "__cpp_lib_shared_timed_mutex should be defined in c++17"
+# endif
+# if __cpp_lib_shared_timed_mutex != 201402L
+# error "__cpp_lib_shared_timed_mutex should have the value 201402L in c++17"
+# endif
+# else
+# ifdef __cpp_lib_shared_timed_mutex
+# error "__cpp_lib_shared_timed_mutex should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
+# endif
# endif
# ifndef __cpp_lib_string_udls
@@ -1467,11 +1491,17 @@
# error "__cpp_lib_as_const should have the value 201510L in c++2a"
# endif
-# ifndef __cpp_lib_atomic_is_always_lock_free
-# error "__cpp_lib_atomic_is_always_lock_free should be defined in c++2a"
-# endif
-# if __cpp_lib_atomic_is_always_lock_free != 201603L
-# error "__cpp_lib_atomic_is_always_lock_free should have the value 201603L in c++2a"
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+# ifndef __cpp_lib_atomic_is_always_lock_free
+# error "__cpp_lib_atomic_is_always_lock_free should be defined in c++2a"
+# endif
+# if __cpp_lib_atomic_is_always_lock_free != 201603L
+# error "__cpp_lib_atomic_is_always_lock_free should have the value 201603L in c++2a"
+# endif
+# else
+# ifdef __cpp_lib_atomic_is_always_lock_free
+# error "__cpp_lib_atomic_is_always_lock_free should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
+# endif
# endif
# if !defined(_LIBCPP_VERSION)
@@ -1994,11 +2024,17 @@
# error "__cpp_lib_scoped_lock should have the value 201703L in c++2a"
# endif
-# ifndef __cpp_lib_shared_mutex
-# error "__cpp_lib_shared_mutex should be defined in c++2a"
-# endif
-# if __cpp_lib_shared_mutex != 201505L
-# error "__cpp_lib_shared_mutex should have the value 201505L in c++2a"
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+# ifndef __cpp_lib_shared_mutex
+# error "__cpp_lib_shared_mutex should be defined in c++2a"
+# endif
+# if __cpp_lib_shared_mutex != 201505L
+# error "__cpp_lib_shared_mutex should have the value 201505L in c++2a"
+# endif
+# else
+# ifdef __cpp_lib_shared_mutex
+# error "__cpp_lib_shared_mutex should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
+# endif
# endif
# if !defined(_LIBCPP_VERSION)
@@ -2021,11 +2057,17 @@
# error "__cpp_lib_shared_ptr_weak_type should have the value 201606L in c++2a"
# endif
-# ifndef __cpp_lib_shared_timed_mutex
-# error "__cpp_lib_shared_timed_mutex should be defined in c++2a"
-# endif
-# if __cpp_lib_shared_timed_mutex != 201402L
-# error "__cpp_lib_shared_timed_mutex should have the value 201402L in c++2a"
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+# ifndef __cpp_lib_shared_timed_mutex
+# error "__cpp_lib_shared_timed_mutex should be defined in c++2a"
+# endif
+# if __cpp_lib_shared_timed_mutex != 201402L
+# error "__cpp_lib_shared_timed_mutex should have the value 201402L in c++2a"
+# endif
+# else
+# ifdef __cpp_lib_shared_timed_mutex
+# error "__cpp_lib_shared_timed_mutex should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
+# endif
# endif
# ifndef __cpp_lib_string_udls