[libcxx] r351291 - Fix feature test macros for atomics/mutexes without threading

Eric Fiselier eric at efcs.ca
Tue Jan 15 18:10:29 PST 2019


Author: ericwf
Date: Tue Jan 15 18:10:28 2019
New Revision: 351291

URL: http://llvm.org/viewvc/llvm-project?rev=351291&view=rev
Log:
Fix feature test macros for atomics/mutexes without threading

Modified:
    libcxx/trunk/include/version
    libcxx/trunk/test/std/language.support/support.limits/support.limits.general/atomic.version.pass.cpp
    libcxx/trunk/test/std/language.support/support.limits/support.limits.general/generate_feature_test_macro_components.py
    libcxx/trunk/test/std/language.support/support.limits/support.limits.general/shared_mutex.version.pass.cpp
    libcxx/trunk/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp

Modified: libcxx/trunk/include/version
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/version?rev=351291&r1=351290&r2=351291&view=diff
==============================================================================
--- libcxx/trunk/include/version (original)
+++ libcxx/trunk/include/version Tue Jan 15 18:10:28 2019
@@ -135,7 +135,9 @@ __cpp_lib_void_t
 # 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
 # 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
 # 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
 #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)

Modified: libcxx/trunk/test/std/language.support/support.limits/support.limits.general/atomic.version.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.limits/support.limits.general/atomic.version.pass.cpp?rev=351291&r1=351290&r2=351291&view=diff
==============================================================================
--- libcxx/trunk/test/std/language.support/support.limits/support.limits.general/atomic.version.pass.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.limits/support.limits.general/atomic.version.pass.cpp Tue Jan 15 18:10:28 2019
@@ -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)

Modified: libcxx/trunk/test/std/language.support/support.limits/support.limits.general/generate_feature_test_macro_components.py
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.limits/support.limits.general/generate_feature_test_macro_components.py?rev=351291&r1=351290&r2=351291&view=diff
==============================================================================
--- libcxx/trunk/test/std/language.support/support.limits/support.limits.general/generate_feature_test_macro_components.py (original)
+++ libcxx/trunk/test/std/language.support/support.limits/support.limits.general/generate_feature_test_macro_components.py Tue Jan 15 18:10:28 2019
@@ -148,14 +148,18 @@ feature_test_macros = sorted([ add_versi
    "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_versi
      "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_versi
    },
    "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(),

Modified: libcxx/trunk/test/std/language.support/support.limits/support.limits.general/shared_mutex.version.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.limits/support.limits.general/shared_mutex.version.pass.cpp?rev=351291&r1=351290&r2=351291&view=diff
==============================================================================
--- libcxx/trunk/test/std/language.support/support.limits/support.limits.general/shared_mutex.version.pass.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.limits/support.limits.general/shared_mutex.version.pass.cpp Tue Jan 15 18:10:28 2019
@@ -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"
-# 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_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_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"
-# 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_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_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

Modified: libcxx/trunk/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp?rev=351291&r1=351290&r2=351291&view=diff
==============================================================================
--- libcxx/trunk/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp Tue Jan 15 18:10:28 2019
@@ -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




More information about the libcxx-commits mailing list