[libcxx-commits] [libcxx] 92832e4 - [libc++] Enable <atomic> when threads are disabled

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Nov 17 20:03:18 PST 2021


Author: Louis Dionne
Date: 2021-11-17T23:02:58-05:00
New Revision: 92832e4889ae6038cc8b3e6e449af2a9b9374ab4

URL: https://github.com/llvm/llvm-project/commit/92832e4889ae6038cc8b3e6e449af2a9b9374ab4
DIFF: https://github.com/llvm/llvm-project/commit/92832e4889ae6038cc8b3e6e449af2a9b9374ab4.diff

LOG: [libc++] Enable <atomic> when threads are disabled

std::atomic is, for the most part, just a thin veneer on top of compiler
builtins. Hence, it should be available even when threads are not available
on the system, and in fact there has been requests for such support.

This patch:
- Moves __libcpp_thread_poll_with_backoff to its own header so it can
  be used in <atomic> when threads are disabled.
- Adds a dummy backoff policy for atomic polling that doesn't know about
  threads.
- Adjusts the <atomic> feature-test macros so they are provided even when
  threads are disabled.
- Runs the <atomic> tests when threads are disabled.

rdar://77873569

Differential Revision: https://reviews.llvm.org/D114109

Added: 
    libcxx/include/__thread/poll_with_backoff.h
    libcxx/test/libcxx/diagnostics/detail.headers/thread/poll_with_backoff.module.verify.cpp

Modified: 
    libcxx/include/CMakeLists.txt
    libcxx/include/__config
    libcxx/include/__memory/shared_ptr.h
    libcxx/include/__threading_support
    libcxx/include/atomic
    libcxx/include/module.modulemap
    libcxx/include/thread
    libcxx/include/version
    libcxx/src/memory.cpp
    libcxx/test/libcxx/atomics/atomics.align/align.pass.cpp
    libcxx/test/libcxx/atomics/atomics.flag/init_bool.pass.cpp
    libcxx/test/libcxx/atomics/atomics.order/memory_order.underlying_type.pass.cpp
    libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.verify.cpp
    libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.verify.cpp
    libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.verify.cpp
    libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.verify.cpp
    libcxx/test/libcxx/atomics/diagnose_invalid_memory_order.verify.cpp
    libcxx/test/libcxx/atomics/ext-int.verify.cpp
    libcxx/test/libcxx/atomics/version.pass.cpp
    libcxx/test/libcxx/double_include.sh.cpp
    libcxx/test/libcxx/min_max_macros.compile.pass.cpp
    libcxx/test/libcxx/no_assert_include.compile.pass.cpp
    libcxx/test/std/atomics/atomics.fences/atomic_signal_fence.pass.cpp
    libcxx/test/std/atomics/atomics.fences/atomic_thread_fence.pass.cpp
    libcxx/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp
    libcxx/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
    libcxx/test/std/atomics/atomics.flag/atomic_flag_test.pass.cpp
    libcxx/test/std/atomics/atomics.flag/atomic_flag_test_and_set.pass.cpp
    libcxx/test/std/atomics/atomics.flag/atomic_flag_test_and_set_explicit.pass.cpp
    libcxx/test/std/atomics/atomics.flag/atomic_flag_test_explicit.pass.cpp
    libcxx/test/std/atomics/atomics.flag/clear.pass.cpp
    libcxx/test/std/atomics/atomics.flag/default.pass.cpp
    libcxx/test/std/atomics/atomics.flag/init.pass.cpp
    libcxx/test/std/atomics/atomics.flag/test_and_set.pass.cpp
    libcxx/test/std/atomics/atomics.general/replace_failure_order.pass.cpp
    libcxx/test/std/atomics/atomics.general/replace_failure_order_codegen.sh.cpp
    libcxx/test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp
    libcxx/test/std/atomics/atomics.lockfree/lockfree.pass.cpp
    libcxx/test/std/atomics/atomics.order/kill_dependency.pass.cpp
    libcxx/test/std/atomics/atomics.order/memory_order.pass.cpp
    libcxx/test/std/atomics/atomics.order/memory_order_new.pass.cpp
    libcxx/test/std/atomics/atomics.types.generic/address.pass.cpp
    libcxx/test/std/atomics/atomics.types.generic/bool.pass.cpp
    libcxx/test/std/atomics/atomics.types.generic/constexpr_noexcept.compile.pass.cpp
    libcxx/test/std/atomics/atomics.types.generic/copy_semantics_traits.pass.cpp
    libcxx/test/std/atomics/atomics.types.generic/cstdint_typedefs.pass.cpp
    libcxx/test/std/atomics/atomics.types.generic/integral.pass.cpp
    libcxx/test/std/atomics/atomics.types.generic/integral_typedefs.pass.cpp
    libcxx/test/std/atomics/atomics.types.generic/standard_layout.compile.pass.cpp
    libcxx/test/std/atomics/atomics.types.generic/throw.pass.cpp
    libcxx/test/std/atomics/atomics.types.generic/trivially_copyable.pass.cpp
    libcxx/test/std/atomics/atomics.types.generic/trivially_copyable.verify.cpp
    libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong.pass.cpp
    libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong_explicit.pass.cpp
    libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak.pass.cpp
    libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak_explicit.pass.cpp
    libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange.pass.cpp
    libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange_explicit.pass.cpp
    libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.pass.cpp
    libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.pass.cpp
    libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and.pass.cpp
    libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and_explicit.pass.cpp
    libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or.pass.cpp
    libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or_explicit.pass.cpp
    libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.pass.cpp
    libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.pass.cpp
    libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor.pass.cpp
    libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor_explicit.pass.cpp
    libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_init.pass.cpp
    libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_is_lock_free.pass.cpp
    libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load.pass.cpp
    libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load_explicit.pass.cpp
    libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store.pass.cpp
    libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store_explicit.pass.cpp
    libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_var_init.pass.cpp
    libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/copy.assign.ptr.volatile.verify.cpp
    libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/copy.assign.volatile.verify.cpp
    libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/ctor.pass.cpp
    libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/dtor.pass.cpp
    libcxx/test/std/atomics/types.pass.cpp
    libcxx/test/std/depr/depr.atomics/depr.atomics.nonmembers/atomic_init.depr_in_cxx20.verify.cpp
    libcxx/test/std/language.support/support.limits/support.limits.general/atomic.version.pass.cpp
    libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.pass.cpp
    libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp
    libcxx/utils/generate_feature_test_macro_components.py
    libcxx/utils/generate_header_inclusion_tests.py
    libcxx/utils/generate_header_tests.py

Removed: 
    libcxx/test/libcxx/atomics/libcpp-has-no-threads.compile.fail.cpp
    libcxx/test/libcxx/atomics/libcpp-has-no-threads.pass.cpp


################################################################################
diff  --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 9d7abc870a9ef..1947aa1a8506f 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -283,6 +283,7 @@ set(files
   __support/xlocale/__nop_locale_mgmt.h
   __support/xlocale/__posix_l_fallback.h
   __support/xlocale/__strtonum_fallback.h
+  __thread/poll_with_backoff.h
   __threading_support
   __tree
   __tuple

diff  --git a/libcxx/include/__config b/libcxx/include/__config
index 18d0c86e48ee1..dbf4383cd6e38 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -1190,10 +1190,9 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
 #  define _LIBCPP_HAS_GCC_ATOMIC_IMP
 #endif
 
-#if (!defined(_LIBCPP_HAS_C_ATOMIC_IMP) && \
-     !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \
-     !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP)) \
-     || defined(_LIBCPP_HAS_NO_THREADS)
+#if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && \
+    !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \
+    !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP)
 #  define _LIBCPP_HAS_NO_ATOMIC_HEADER
 #else
 #  ifndef _LIBCPP_ATOMIC_FLAG_TYPE

diff  --git a/libcxx/include/__memory/shared_ptr.h b/libcxx/include/__memory/shared_ptr.h
index 7b08641762d84..9c7df88459563 100644
--- a/libcxx/include/__memory/shared_ptr.h
+++ b/libcxx/include/__memory/shared_ptr.h
@@ -1572,7 +1572,7 @@ basic_ostream<_CharT, _Traits>&
 operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p);
 
 
-#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
+#if !defined(_LIBCPP_HAS_NO_THREADS)
 
 class _LIBCPP_TYPE_VIS __sp_mut
 {
@@ -1712,7 +1712,7 @@ atomic_compare_exchange_weak_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v
     return atomic_compare_exchange_weak(__p, __v, __w);
 }
 
-#endif // !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
+#endif // !defined(_LIBCPP_HAS_NO_THREADS)
 
 _LIBCPP_END_NAMESPACE_STD
 

diff  --git a/libcxx/include/__thread/poll_with_backoff.h b/libcxx/include/__thread/poll_with_backoff.h
new file mode 100644
index 0000000000000..e1d8a9c90c56f
--- /dev/null
+++ b/libcxx/include/__thread/poll_with_backoff.h
@@ -0,0 +1,68 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef _LIBCPP___THREAD_POLL_WITH_BACKOFF_H
+#define _LIBCPP___THREAD_POLL_WITH_BACKOFF_H
+
+#include <__config>
+#include <chrono>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+static _LIBCPP_CONSTEXPR const int __libcpp_polling_count = 64;
+
+// Polls a thread for a condition given by a predicate, and backs off based on a backoff policy
+// before polling again.
+//
+// - __f is the "test function" that should return true if polling succeeded, and false if it failed.
+//
+// - __bf is the "backoff policy", which is called with the duration since we started polling. It should
+//   return false in order to resume polling, and true if polling should stop entirely for some reason.
+//   In general, backoff policies sleep for some time before returning control to the polling loop.
+//
+// - __max_elapsed is the maximum duration to try polling for. If the maximum duration is exceeded,
+//   the polling loop will return false to report a timeout.
+template<class _Fn, class _BFn>
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI
+bool __libcpp_thread_poll_with_backoff(_Fn&& __f, _BFn&& __bf, chrono::nanoseconds __max_elapsed = chrono::nanoseconds::zero()) {
+    auto const __start = chrono::high_resolution_clock::now();
+    for (int __count = 0;;) {
+      if (__f())
+        return true; // _Fn completion means success
+      if (__count < __libcpp_polling_count) {
+        __count += 1;
+        continue;
+      }
+      chrono::nanoseconds const __elapsed = chrono::high_resolution_clock::now() - __start;
+      if (__max_elapsed != chrono::nanoseconds::zero() && __max_elapsed < __elapsed)
+          return false; // timeout failure
+      if (__bf(__elapsed))
+        return false; // _BFn completion means failure
+    }
+}
+
+// A trivial backoff policy that always immediately returns the control to
+// the polling loop.
+//
+// This is not very well-behaved since it will cause the polling loop to spin,
+// so this should most likely only be used on single-threaded systems where there
+// are no other threads to compete with.
+struct __spinning_backoff_policy {
+  _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
+  bool operator()(chrono::nanoseconds const&) const {
+      return false;
+  }
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___THREAD_POLL_WITH_BACKOFF_H

diff  --git a/libcxx/include/__threading_support b/libcxx/include/__threading_support
index 2242a69085298..0094fca2fb389 100644
--- a/libcxx/include/__threading_support
+++ b/libcxx/include/__threading_support
@@ -12,6 +12,7 @@
 
 #include <__availability>
 #include <__config>
+#include <__thread/poll_with_backoff.h>
 #include <chrono>
 #include <errno.h>
 #include <iosfwd>
@@ -267,29 +268,6 @@ struct __libcpp_timed_backoff_policy {
   }
 };
 
-static _LIBCPP_CONSTEXPR const int __libcpp_polling_count = 64;
-
-template<class _Fn, class _BFn>
-_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
-bool __libcpp_thread_poll_with_backoff(
-  _Fn && __f, _BFn && __bf, chrono::nanoseconds __max_elapsed = chrono::nanoseconds::zero())
-{
-    auto const __start = chrono::high_resolution_clock::now();
-    for(int __count = 0;;) {
-      if(__f())
-        return true; // _Fn completion means success
-      if(__count < __libcpp_polling_count) {
-        __count += 1;
-        continue;
-      }
-      chrono::nanoseconds const __elapsed = chrono::high_resolution_clock::now() - __start;
-      if(__max_elapsed != chrono::nanoseconds::zero() && __max_elapsed < __elapsed)
-          return false; // timeout failure
-      if(__bf(__elapsed))
-        return false; // _BFn completion means failure
-    }
-}
-
 #if (!defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
      defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL))
 

diff  --git a/libcxx/include/atomic b/libcxx/include/atomic
index 252ab213fd89a..cfd0e1d054a88 100644
--- a/libcxx/include/atomic
+++ b/libcxx/include/atomic
@@ -520,20 +520,21 @@ template <class T>
 
 #include <__availability>
 #include <__config>
-#include <__threading_support>
+#include <__thread/poll_with_backoff.h>
 #include <cstddef>
 #include <cstdint>
 #include <cstring>
 #include <type_traits>
 #include <version>
 
+#ifndef _LIBCPP_HAS_NO_THREADS
+# include <__threading_support>
+#endif
+
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
-#ifdef _LIBCPP_HAS_NO_THREADS
-# error <atomic> is not supported on this single threaded system
-#endif
 #ifdef _LIBCPP_HAS_NO_ATOMIC_HEADER
 # error <atomic> is not implemented
 #endif
@@ -1455,6 +1456,16 @@ struct __cxx_atomic_impl : public _Base {
 
 using __cxx_atomic_contention_t = __cxx_atomic_impl<__cxx_contention_t>;
 
+#if defined(_LIBCPP_HAS_NO_THREADS)
+#   define _LIBCPP_HAS_NO_PLATFORM_WAIT
+#endif
+
+// TODO:
+// _LIBCPP_HAS_NO_PLATFORM_WAIT is currently a "dead" macro, in the sense that
+// it is not tied anywhere into the build system or even documented. We should
+// clean it up because it is technically never defined except when threads are
+// disabled. We should clean it up in its own changeset in case we break "bad"
+// users.
 #ifndef _LIBCPP_HAS_NO_PLATFORM_WAIT
 
 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(void const volatile*);
@@ -1506,7 +1517,12 @@ _LIBCPP_INLINE_VISIBILITY void __cxx_atomic_notify_one(__cxx_atomic_impl<_Tp> co
 template <class _Atp, class _Fn>
 _LIBCPP_INLINE_VISIBILITY bool __cxx_atomic_wait(_Atp*, _Fn && __test_fn)
 {
-    return __libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy());
+#if defined(_LIBCPP_HAS_NO_THREADS)
+    using _Policy = __spinning_backoff_policy;
+#else
+    using _Policy = __libcpp_timed_backoff_policy;
+#endif
+    return __libcpp_thread_poll_with_backoff(__test_fn, _Policy());
 }
 
 #endif // _LIBCPP_HAS_NO_PLATFORM_WAIT

diff  --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap
index b159d58b7b96a..f34442ed5c9a9 100644
--- a/libcxx/include/module.modulemap
+++ b/libcxx/include/module.modulemap
@@ -799,6 +799,10 @@ module std [system] {
   module thread {
     header "thread"
     export *
+
+    module __thread {
+      module poll_with_backoff { private header "__thread/poll_with_backoff.h" }
+    }
   }
   module tuple {
     header "tuple"

diff  --git a/libcxx/include/thread b/libcxx/include/thread
index f136da56bb952..a51a11c0d3c83 100644
--- a/libcxx/include/thread
+++ b/libcxx/include/thread
@@ -86,6 +86,7 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
 #include <__debug>
 #include <__functional_base>
 #include <__mutex_base>
+#include <__thread/poll_with_backoff.h>
 #include <__threading_support>
 #include <__utility/decay_copy.h>
 #include <__utility/forward.h>

diff  --git a/libcxx/include/version b/libcxx/include/version
index a4809eb573b41..d2286f5e8207e 100644
--- a/libcxx/include/version
+++ b/libcxx/include/version
@@ -205,9 +205,7 @@ __cpp_lib_void_t                                        201411L <type_traits>
 # define __cpp_lib_apply                                201603L
 # define __cpp_lib_array_constexpr                      201603L
 # define __cpp_lib_as_const                             201510L
-# if !defined(_LIBCPP_HAS_NO_THREADS)
-#   define __cpp_lib_atomic_is_always_lock_free         201603L
-# endif
+# define __cpp_lib_atomic_is_always_lock_free           201603L
 # define __cpp_lib_bool_constant                        201505L
 // # define __cpp_lib_boyer_moore_searcher                 201603L
 # define __cpp_lib_byte                                 201603L
@@ -261,25 +259,13 @@ __cpp_lib_void_t                                        201411L <type_traits>
 # undef  __cpp_lib_array_constexpr
 # define __cpp_lib_array_constexpr                      201811L
 // # define __cpp_lib_assume_aligned                       201811L
-# if !defined(_LIBCPP_HAS_NO_THREADS)
-#   define __cpp_lib_atomic_flag_test                   201907L
-# endif
-# if !defined(_LIBCPP_HAS_NO_THREADS)
-// #   define __cpp_lib_atomic_float                       201711L
-# endif
-# if !defined(_LIBCPP_HAS_NO_THREADS)
-#   define __cpp_lib_atomic_lock_free_type_aliases      201907L
-# endif
-# if !defined(_LIBCPP_HAS_NO_THREADS)
-// #   define __cpp_lib_atomic_ref                         201806L
-# endif
-# if !defined(_LIBCPP_HAS_NO_THREADS)
-// #   define __cpp_lib_atomic_shared_ptr                  201711L
-# endif
-# if !defined(_LIBCPP_HAS_NO_THREADS)
-#   define __cpp_lib_atomic_value_initialization        201911L
-# endif
-# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait)
+# define __cpp_lib_atomic_flag_test                     201907L
+// # define __cpp_lib_atomic_float                         201711L
+# define __cpp_lib_atomic_lock_free_type_aliases        201907L
+// # define __cpp_lib_atomic_ref                           201806L
+// # define __cpp_lib_atomic_shared_ptr                    201711L
+# define __cpp_lib_atomic_value_initialization          201911L
+# if !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait)
 #   define __cpp_lib_atomic_wait                        201907L
 # endif
 # if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_barrier)

diff  --git a/libcxx/src/memory.cpp b/libcxx/src/memory.cpp
index 981ab5571edd6..4c9bf9f073c88 100644
--- a/libcxx/src/memory.cpp
+++ b/libcxx/src/memory.cpp
@@ -8,11 +8,11 @@
 
 #include "memory"
 #ifndef _LIBCPP_HAS_NO_THREADS
-#include "mutex"
-#include "thread"
-#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
-#pragma comment(lib, "pthread")
-#endif
+#   include "mutex"
+#   include "thread"
+#   if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
+#       pragma comment(lib, "pthread")
+#   endif
 #endif
 #include "include/atomic_support.h"
 
@@ -130,7 +130,7 @@ __shared_weak_count::__get_deleter(const type_info&) const noexcept
     return nullptr;
 }
 
-#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
+#if !defined(_LIBCPP_HAS_NO_THREADS)
 
 _LIBCPP_SAFE_STATIC static const std::size_t __sp_mut_count = 16;
 _LIBCPP_SAFE_STATIC static __libcpp_mutex_t mut_back[__sp_mut_count] =
@@ -181,7 +181,7 @@ __get_sp_mut(const void* p)
     return muts[hash<const void*>()(p) & (__sp_mut_count-1)];
 }
 
-#endif // !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
+#endif // !defined(_LIBCPP_HAS_NO_THREADS)
 
 void*
 align(size_t alignment, size_t size, void*& ptr, size_t& space)

diff  --git a/libcxx/test/libcxx/atomics/atomics.align/align.pass.cpp b/libcxx/test/libcxx/atomics/atomics.align/align.pass.cpp
index 2e5a9c149ca44..3c8efde1deb4f 100644
--- a/libcxx/test/libcxx/atomics/atomics.align/align.pass.cpp
+++ b/libcxx/test/libcxx/atomics/atomics.align/align.pass.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 //
-// UNSUPPORTED: libcpp-has-no-threads, c++03
+// UNSUPPORTED: c++03
 // REQUIRES: is-lockfree-runtime-function
 // ADDITIONAL_COMPILE_FLAGS: -Wno-psabi
 // ... since C++20 std::__atomic_base initializes, so we get a warning about an

diff  --git a/libcxx/test/libcxx/atomics/atomics.flag/init_bool.pass.cpp b/libcxx/test/libcxx/atomics/atomics.flag/init_bool.pass.cpp
index 2919fb666bc5a..438f2f8c16940 100644
--- a/libcxx/test/libcxx/atomics/atomics.flag/init_bool.pass.cpp
+++ b/libcxx/test/libcxx/atomics/atomics.flag/init_bool.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/libcxx/atomics/atomics.order/memory_order.underlying_type.pass.cpp b/libcxx/test/libcxx/atomics/atomics.order/memory_order.underlying_type.pass.cpp
index 0f31f43e2b7cb..5379ef8787d56 100644
--- a/libcxx/test/libcxx/atomics/atomics.order/memory_order.underlying_type.pass.cpp
+++ b/libcxx/test/libcxx/atomics/atomics.order/memory_order.underlying_type.pass.cpp
@@ -6,8 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: libcpp-has-no-threads
-
 // This test ensures that std::memory_order has the same size under all
 // standard versions to make sure we're not breaking the ABI. This is
 // relevant because std::memory_order is a scoped enumeration in C++20,

diff  --git a/libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.verify.cpp b/libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.verify.cpp
index f3454b990edc6..a96f909180f62 100644
--- a/libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.verify.cpp
+++ b/libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.verify.cpp
@@ -6,8 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: libcpp-has-no-threads
-
 // <atomic>
 
 // template <class T>

diff  --git a/libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.verify.cpp b/libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.verify.cpp
index 44fb219f7fcc5..530a8553cfef0 100644
--- a/libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.verify.cpp
+++ b/libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.verify.cpp
@@ -6,8 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: libcpp-has-no-threads
-
 // <atomic>
 
 // template <class T>

diff  --git a/libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.verify.cpp b/libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.verify.cpp
index 0ecda4d3a2fbb..a58d7b3e43410 100644
--- a/libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.verify.cpp
+++ b/libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.verify.cpp
@@ -6,8 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: libcpp-has-no-threads
-
 // <atomic>
 
 // template <class T>

diff  --git a/libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.verify.cpp b/libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.verify.cpp
index be1e6fdd4036a..a2fd0d5cc9ddd 100644
--- a/libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.verify.cpp
+++ b/libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.verify.cpp
@@ -6,8 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: libcpp-has-no-threads
-
 // <atomic>
 
 // template <class T>

diff  --git a/libcxx/test/libcxx/atomics/diagnose_invalid_memory_order.verify.cpp b/libcxx/test/libcxx/atomics/diagnose_invalid_memory_order.verify.cpp
index 080731f56e2b9..3eb4cab840da0 100644
--- a/libcxx/test/libcxx/atomics/diagnose_invalid_memory_order.verify.cpp
+++ b/libcxx/test/libcxx/atomics/diagnose_invalid_memory_order.verify.cpp
@@ -11,7 +11,6 @@
 // XFAIL: msvc
 
 // REQUIRES: diagnose-if-support
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/libcxx/atomics/ext-int.verify.cpp b/libcxx/test/libcxx/atomics/ext-int.verify.cpp
index 90034426fadaa..e1aaf67edb434 100644
--- a/libcxx/test/libcxx/atomics/ext-int.verify.cpp
+++ b/libcxx/test/libcxx/atomics/ext-int.verify.cpp
@@ -14,7 +14,6 @@
 
 // UNSUPPORTED: apple-clang-12
 
-// UNSUPPORTED: libcpp-has-no-threads
 // UNSUPPORTED: c++03
 
 #include <atomic>

diff  --git a/libcxx/test/libcxx/atomics/libcpp-has-no-threads.pass.cpp b/libcxx/test/libcxx/atomics/libcpp-has-no-threads.pass.cpp
deleted file mode 100644
index b52ba64252231..0000000000000
--- a/libcxx/test/libcxx/atomics/libcpp-has-no-threads.pass.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-has-no-threads
-
-#ifdef _LIBCPP_HAS_NO_THREADS
-#error This should be XFAILed for the purpose of detecting that the LIT feature\
-   'libcpp-has-no-threads' is available iff _LIBCPP_HAS_NO_THREADS is defined
-#endif
-
-int main(int, char**)
-{
-
-  return 0;
-}

diff  --git a/libcxx/test/libcxx/atomics/version.pass.cpp b/libcxx/test/libcxx/atomics/version.pass.cpp
index 71617252d6006..bb8af8ded1bc0 100644
--- a/libcxx/test/libcxx/atomics/version.pass.cpp
+++ b/libcxx/test/libcxx/atomics/version.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/libcxx/atomics/libcpp-has-no-threads.compile.fail.cpp b/libcxx/test/libcxx/diagnostics/detail.headers/thread/poll_with_backoff.module.verify.cpp
similarity index 56%
rename from libcxx/test/libcxx/atomics/libcpp-has-no-threads.compile.fail.cpp
rename to libcxx/test/libcxx/diagnostics/detail.headers/thread/poll_with_backoff.module.verify.cpp
index 9c6a8f7f55f68..ea2e7729df748 100644
--- a/libcxx/test/libcxx/atomics/libcpp-has-no-threads.compile.fail.cpp
+++ b/libcxx/test/libcxx/diagnostics/detail.headers/thread/poll_with_backoff.module.verify.cpp
@@ -6,17 +6,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-// <atomic>
+// REQUIRES: modules-build
 
-// Test that including <atomic> fails to compile when _LIBCPP_HAS_NO_THREADS
-// is defined.
+// WARNING: This test was generated by 'generate_private_header_tests.py'
+// and should not be edited manually.
 
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_HAS_NO_THREADS
-
-#include <atomic>
-
-int main(int, char**)
-{
-
-  return 0;
-}
+// expected-error@*:* {{use of private header from outside its module: '__thread/poll_with_backoff.h'}}
+#include <__thread/poll_with_backoff.h>

diff  --git a/libcxx/test/libcxx/double_include.sh.cpp b/libcxx/test/libcxx/double_include.sh.cpp
index a7ff19fb29e73..41591b77991ed 100644
--- a/libcxx/test/libcxx/double_include.sh.cpp
+++ b/libcxx/test/libcxx/double_include.sh.cpp
@@ -31,9 +31,7 @@
 #include <algorithm>
 #include <any>
 #include <array>
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <atomic>
-#endif
+#include <atomic>
 #ifndef _LIBCPP_HAS_NO_THREADS
 #    include <barrier>
 #endif

diff  --git a/libcxx/test/libcxx/min_max_macros.compile.pass.cpp b/libcxx/test/libcxx/min_max_macros.compile.pass.cpp
index 896076a73c75f..3d0425a3542ad 100644
--- a/libcxx/test/libcxx/min_max_macros.compile.pass.cpp
+++ b/libcxx/test/libcxx/min_max_macros.compile.pass.cpp
@@ -34,10 +34,8 @@ TEST_MACROS();
 TEST_MACROS();
 #include <array>
 TEST_MACROS();
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <atomic>
+#include <atomic>
 TEST_MACROS();
-#endif
 #ifndef _LIBCPP_HAS_NO_THREADS
 #    include <barrier>
 TEST_MACROS();

diff  --git a/libcxx/test/libcxx/no_assert_include.compile.pass.cpp b/libcxx/test/libcxx/no_assert_include.compile.pass.cpp
index 4be6d4e640be4..8f16a6386c229 100644
--- a/libcxx/test/libcxx/no_assert_include.compile.pass.cpp
+++ b/libcxx/test/libcxx/no_assert_include.compile.pass.cpp
@@ -27,9 +27,7 @@
 #include <algorithm>
 #include <any>
 #include <array>
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <atomic>
-#endif
+#include <atomic>
 #ifndef _LIBCPP_HAS_NO_THREADS
 #    include <barrier>
 #endif

diff  --git a/libcxx/test/std/atomics/atomics.fences/atomic_signal_fence.pass.cpp b/libcxx/test/std/atomics/atomics.fences/atomic_signal_fence.pass.cpp
index 323d77d7aced1..c8e49ae2033a2 100644
--- a/libcxx/test/std/atomics/atomics.fences/atomic_signal_fence.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.fences/atomic_signal_fence.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/std/atomics/atomics.fences/atomic_thread_fence.pass.cpp b/libcxx/test/std/atomics/atomics.fences/atomic_thread_fence.pass.cpp
index ab376868eebc0..1b1b6a6775d82 100644
--- a/libcxx/test/std/atomics/atomics.fences/atomic_thread_fence.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.fences/atomic_thread_fence.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp b/libcxx/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp
index f89d77a479ad4..4ac77af50a118 100644
--- a/libcxx/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp b/libcxx/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
index 53f50ab59cf06..a83ae26b38e79 100644
--- a/libcxx/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/std/atomics/atomics.flag/atomic_flag_test.pass.cpp b/libcxx/test/std/atomics/atomics.flag/atomic_flag_test.pass.cpp
index 44e4668d6d909..4ee4de1e7893b 100644
--- a/libcxx/test/std/atomics/atomics.flag/atomic_flag_test.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.flag/atomic_flag_test.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/std/atomics/atomics.flag/atomic_flag_test_and_set.pass.cpp b/libcxx/test/std/atomics/atomics.flag/atomic_flag_test_and_set.pass.cpp
index 22e4b66d45c5a..1e643fa245eef 100644
--- a/libcxx/test/std/atomics/atomics.flag/atomic_flag_test_and_set.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.flag/atomic_flag_test_and_set.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/std/atomics/atomics.flag/atomic_flag_test_and_set_explicit.pass.cpp b/libcxx/test/std/atomics/atomics.flag/atomic_flag_test_and_set_explicit.pass.cpp
index 9c1c222ed9438..8a5b55ad68ab5 100644
--- a/libcxx/test/std/atomics/atomics.flag/atomic_flag_test_and_set_explicit.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.flag/atomic_flag_test_and_set_explicit.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/std/atomics/atomics.flag/atomic_flag_test_explicit.pass.cpp b/libcxx/test/std/atomics/atomics.flag/atomic_flag_test_explicit.pass.cpp
index ee9b1470b2cde..1132dbd6106af 100644
--- a/libcxx/test/std/atomics/atomics.flag/atomic_flag_test_explicit.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.flag/atomic_flag_test_explicit.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/std/atomics/atomics.flag/clear.pass.cpp b/libcxx/test/std/atomics/atomics.flag/clear.pass.cpp
index 676cfc5ff6236..aaef0497811f9 100644
--- a/libcxx/test/std/atomics/atomics.flag/clear.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.flag/clear.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/std/atomics/atomics.flag/default.pass.cpp b/libcxx/test/std/atomics/atomics.flag/default.pass.cpp
index 6a0d907fde94f..88249463130cb 100644
--- a/libcxx/test/std/atomics/atomics.flag/default.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.flag/default.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/std/atomics/atomics.flag/init.pass.cpp b/libcxx/test/std/atomics/atomics.flag/init.pass.cpp
index 552e8ebcd6dc3..0905f468c9d7d 100644
--- a/libcxx/test/std/atomics/atomics.flag/init.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.flag/init.pass.cpp
@@ -5,8 +5,7 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
+
 // XFAIL: c++03
 
 // <atomic>

diff  --git a/libcxx/test/std/atomics/atomics.flag/test_and_set.pass.cpp b/libcxx/test/std/atomics/atomics.flag/test_and_set.pass.cpp
index 393c4627368ce..dca5ed87f8f24 100644
--- a/libcxx/test/std/atomics/atomics.flag/test_and_set.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.flag/test_and_set.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/std/atomics/atomics.general/replace_failure_order.pass.cpp b/libcxx/test/std/atomics/atomics.general/replace_failure_order.pass.cpp
index 28905216e8faa..732dd65c98bdb 100644
--- a/libcxx/test/std/atomics/atomics.general/replace_failure_order.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.general/replace_failure_order.pass.cpp
@@ -6,8 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: libcpp-has-no-threads
-
 // This test verifies behavior specified by [atomics.types.operations.req]/21:
 //
 //     When only one memory_order argument is supplied, the value of success is

diff  --git a/libcxx/test/std/atomics/atomics.general/replace_failure_order_codegen.sh.cpp b/libcxx/test/std/atomics/atomics.general/replace_failure_order_codegen.sh.cpp
index a4e9e447f2a36..15b9b8cf4f8b3 100644
--- a/libcxx/test/std/atomics/atomics.general/replace_failure_order_codegen.sh.cpp
+++ b/libcxx/test/std/atomics/atomics.general/replace_failure_order_codegen.sh.cpp
@@ -7,7 +7,6 @@
 //===----------------------------------------------------------------------===//
 
 // REQUIRES: clang
-// UNSUPPORTED: libcpp-has-no-threads
 
 // Adding "-fsanitize=thread" directly causes many platforms to fail (because
 // they don't support tsan), and causes other sanitizer builds to fail (e.g.

diff  --git a/libcxx/test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp b/libcxx/test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp
index d9276463f3dab..477208ad18c5c 100644
--- a/libcxx/test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 //
-// UNSUPPORTED: libcpp-has-no-threads, c++03, c++11, c++14
+// UNSUPPORTED: c++03, c++11, c++14
 
 // Fails for 32-bit builds.
 // UNSUPPORTED: LIBCXX-AIX-FIXME

diff  --git a/libcxx/test/std/atomics/atomics.lockfree/lockfree.pass.cpp b/libcxx/test/std/atomics/atomics.lockfree/lockfree.pass.cpp
index e36e46815e5f0..08f00971273da 100644
--- a/libcxx/test/std/atomics/atomics.lockfree/lockfree.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.lockfree/lockfree.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/std/atomics/atomics.order/kill_dependency.pass.cpp b/libcxx/test/std/atomics/atomics.order/kill_dependency.pass.cpp
index 7cad751841e58..c26b230021cc0 100644
--- a/libcxx/test/std/atomics/atomics.order/kill_dependency.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.order/kill_dependency.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/std/atomics/atomics.order/memory_order.pass.cpp b/libcxx/test/std/atomics/atomics.order/memory_order.pass.cpp
index 8e35cf19500b7..54579dbe0626a 100644
--- a/libcxx/test/std/atomics/atomics.order/memory_order.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.order/memory_order.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/std/atomics/atomics.order/memory_order_new.pass.cpp b/libcxx/test/std/atomics/atomics.order/memory_order_new.pass.cpp
index 1bf7879261e44..a291e335cd5fb 100644
--- a/libcxx/test/std/atomics/atomics.order/memory_order_new.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.order/memory_order_new.pass.cpp
@@ -5,8 +5,8 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads, c++03, c++11, c++14, c++17
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
 
 #include <atomic>
 

diff  --git a/libcxx/test/std/atomics/atomics.types.generic/address.pass.cpp b/libcxx/test/std/atomics/atomics.types.generic/address.pass.cpp
index 0bcaa19d38f39..b3aa1fc47629a 100644
--- a/libcxx/test/std/atomics/atomics.types.generic/address.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.generic/address.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/std/atomics/atomics.types.generic/bool.pass.cpp b/libcxx/test/std/atomics/atomics.types.generic/bool.pass.cpp
index 4e1428ddadef7..78234ae6d9630 100644
--- a/libcxx/test/std/atomics/atomics.types.generic/bool.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.generic/bool.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/std/atomics/atomics.types.generic/constexpr_noexcept.compile.pass.cpp b/libcxx/test/std/atomics/atomics.types.generic/constexpr_noexcept.compile.pass.cpp
index 8546541150e75..4dcb1e157ea84 100644
--- a/libcxx/test/std/atomics/atomics.types.generic/constexpr_noexcept.compile.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.generic/constexpr_noexcept.compile.pass.cpp
@@ -5,9 +5,8 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
+
 // UNSUPPORTED: c++03, c++11, c++14, c++17
-// UNSUPPORTED: libcpp-has-no-threads
 
 #include <atomic>
 

diff  --git a/libcxx/test/std/atomics/atomics.types.generic/copy_semantics_traits.pass.cpp b/libcxx/test/std/atomics/atomics.types.generic/copy_semantics_traits.pass.cpp
index 20c49187abbd8..f7173140b6795 100644
--- a/libcxx/test/std/atomics/atomics.types.generic/copy_semantics_traits.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.generic/copy_semantics_traits.pass.cpp
@@ -7,7 +7,6 @@
 //===----------------------------------------------------------------------===//
 
 // UNSUPPORTED: c++03
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 
@@ -28,7 +27,6 @@
 // };
 
 #include <atomic>
-
 #include <type_traits>
 
 template <typename T>

diff  --git a/libcxx/test/std/atomics/atomics.types.generic/cstdint_typedefs.pass.cpp b/libcxx/test/std/atomics/atomics.types.generic/cstdint_typedefs.pass.cpp
index 139b0524a8234..0867007b36f1b 100644
--- a/libcxx/test/std/atomics/atomics.types.generic/cstdint_typedefs.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.generic/cstdint_typedefs.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/std/atomics/atomics.types.generic/integral.pass.cpp b/libcxx/test/std/atomics/atomics.types.generic/integral.pass.cpp
index b585f455b561f..65c48baafde19 100644
--- a/libcxx/test/std/atomics/atomics.types.generic/integral.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.generic/integral.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/std/atomics/atomics.types.generic/integral_typedefs.pass.cpp b/libcxx/test/std/atomics/atomics.types.generic/integral_typedefs.pass.cpp
index 6ae1fa66cb5dd..ee050dea0a4d1 100644
--- a/libcxx/test/std/atomics/atomics.types.generic/integral_typedefs.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.generic/integral_typedefs.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/std/atomics/atomics.types.generic/standard_layout.compile.pass.cpp b/libcxx/test/std/atomics/atomics.types.generic/standard_layout.compile.pass.cpp
index a95986283e2fa..d7987ca2dc600 100644
--- a/libcxx/test/std/atomics/atomics.types.generic/standard_layout.compile.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.generic/standard_layout.compile.pass.cpp
@@ -5,8 +5,7 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
+
 // UNSUPPORTED: c++03
 
 // <atomic>

diff  --git a/libcxx/test/std/atomics/atomics.types.generic/throw.pass.cpp b/libcxx/test/std/atomics/atomics.types.generic/throw.pass.cpp
index 8fd7d4f33d47f..3264100f259e7 100644
--- a/libcxx/test/std/atomics/atomics.types.generic/throw.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.generic/throw.pass.cpp
@@ -7,7 +7,6 @@
 //===----------------------------------------------------------------------===//
 //
 // UNSUPPORTED: c++03, c++11, c++14, c++17
-// UNSUPPORTED: libcpp-has-no-threads
 // UNSUPPORTED: no-exceptions
 
 // <atomic>

diff  --git a/libcxx/test/std/atomics/atomics.types.generic/trivially_copyable.pass.cpp b/libcxx/test/std/atomics/atomics.types.generic/trivially_copyable.pass.cpp
index 747d071490676..4b3b8e59cc10b 100644
--- a/libcxx/test/std/atomics/atomics.types.generic/trivially_copyable.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.generic/trivially_copyable.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 
@@ -18,9 +16,12 @@
 #include <atomic>
 #include <new>
 #include <cassert>
-#include <thread> // for thread_id
 #include <chrono> // for nanoseconds
 
+#ifndef _LIBCPP_HAS_NO_THREADS
+#   include <thread> // for thread_id
+#endif
+
 struct TriviallyCopyable {
   explicit TriviallyCopyable(int i) : i_(i) { }
   int i_;
@@ -33,8 +34,10 @@ void test(T t) {
 
 int main(int, char**) {
   test(TriviallyCopyable(42));
-  test(std::this_thread::get_id());
   test(std::chrono::nanoseconds(2));
+#ifndef _LIBCPP_HAS_NO_THREADS
+  test(std::this_thread::get_id());
+#endif
 
   return 0;
 }

diff  --git a/libcxx/test/std/atomics/atomics.types.generic/trivially_copyable.verify.cpp b/libcxx/test/std/atomics/atomics.types.generic/trivially_copyable.verify.cpp
index 280e6c0f99091..707333ada3044 100644
--- a/libcxx/test/std/atomics/atomics.types.generic/trivially_copyable.verify.cpp
+++ b/libcxx/test/std/atomics/atomics.types.generic/trivially_copyable.verify.cpp
@@ -6,8 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: libcpp-has-no-threads
-
 // <atomic>
 
 // template <class T>

diff  --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong.pass.cpp
index 539b4c654bdf3..e5cf6aa12dc14 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong.pass.cpp
@@ -5,8 +5,7 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
+
 // XFAIL: !non-lockfree-atomics
 
 // <atomic>

diff  --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong_explicit.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong_explicit.pass.cpp
index 38562598b8712..f039069b49e94 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong_explicit.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong_explicit.pass.cpp
@@ -5,8 +5,7 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
+
 // XFAIL: !non-lockfree-atomics
 
 // <atomic>

diff  --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak.pass.cpp
index cb1ab33619d4f..93b7ea525f843 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak.pass.cpp
@@ -5,8 +5,7 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
+
 // XFAIL: !non-lockfree-atomics
 
 // <atomic>

diff  --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak_explicit.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak_explicit.pass.cpp
index 265edbd281177..41967bd3f5646 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak_explicit.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak_explicit.pass.cpp
@@ -5,8 +5,7 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
+
 // XFAIL: !non-lockfree-atomics
 
 // <atomic>

diff  --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange.pass.cpp
index eb02d0aa1f54f..14d159a498ae7 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange.pass.cpp
@@ -5,8 +5,7 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
+
 // XFAIL: !non-lockfree-atomics
 
 // <atomic>

diff  --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange_explicit.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange_explicit.pass.cpp
index e11dc0f65713a..976327975f9d6 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange_explicit.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange_explicit.pass.cpp
@@ -5,8 +5,7 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
+
 // XFAIL: !non-lockfree-atomics
 
 // <atomic>

diff  --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.pass.cpp
index 0e4513c431798..31563789227e9 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.pass.cpp
index 9a7f43a3bf0c6..747a62ae18295 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and.pass.cpp
index 6b5f72a23f531..04b279ca9d4df 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and_explicit.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and_explicit.pass.cpp
index 7b35f1cdf1e03..f6887a28ce147 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and_explicit.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and_explicit.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or.pass.cpp
index d74e0363dde70..76a66dc6d4784 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or_explicit.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or_explicit.pass.cpp
index 02948a5301605..73161232ae7e5 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or_explicit.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or_explicit.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.pass.cpp
index 58d7b8a1bc8d0..37a9586a0ba1a 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.pass.cpp
index 2dd4bc1df7158..19240968ee7e5 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor.pass.cpp
index ae8494176f134..3875f9e2161c1 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor_explicit.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor_explicit.pass.cpp
index 3765dded6d6b6..7521a027755db 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor_explicit.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor_explicit.pass.cpp
@@ -5,8 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 

diff  --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_init.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_init.pass.cpp
index da05491c858a0..4dbf8fb928b8a 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_init.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_init.pass.cpp
@@ -5,8 +5,7 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
+
 // XFAIL: !non-lockfree-atomics
 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
 

diff  --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_is_lock_free.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_is_lock_free.pass.cpp
index c3c4cc6d41739..8b838f62abb1d 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_is_lock_free.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_is_lock_free.pass.cpp
@@ -5,8 +5,7 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
+
 // XFAIL: !is-lockfree-runtime-function
 
 // <atomic>

diff  --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load.pass.cpp
index 408e45821ca5d..c8d103c180bff 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load.pass.cpp
@@ -5,8 +5,7 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
+
 // XFAIL: !non-lockfree-atomics
 
 // <atomic>

diff  --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load_explicit.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load_explicit.pass.cpp
index e14791300ca43..cb9dc1a2ec7ac 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load_explicit.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load_explicit.pass.cpp
@@ -5,8 +5,7 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
+
 // XFAIL: !non-lockfree-atomics
 
 // <atomic>

diff  --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store.pass.cpp
index f1ad50c11c0fa..5915220fd1891 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store.pass.cpp
@@ -5,8 +5,7 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
+
 // XFAIL: !non-lockfree-atomics
 
 // <atomic>

diff  --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store_explicit.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store_explicit.pass.cpp
index cce59bef2b9b3..e9e15a6aeaf53 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store_explicit.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store_explicit.pass.cpp
@@ -5,8 +5,7 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
+
 // XFAIL: !non-lockfree-atomics
 
 // <atomic>

diff  --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_var_init.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_var_init.pass.cpp
index 7891acc8a1b24..3625a218271c0 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_var_init.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_var_init.pass.cpp
@@ -5,8 +5,7 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
+
 // XFAIL: c++03
 
 // <atomic>

diff  --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/copy.assign.ptr.volatile.verify.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/copy.assign.ptr.volatile.verify.cpp
index d9c46f0c34c53..2d1acb623ed5a 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/copy.assign.ptr.volatile.verify.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/copy.assign.ptr.volatile.verify.cpp
@@ -6,8 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: libcpp-has-no-threads
-
 // <atomic>
 
 // std::atomic

diff  --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/copy.assign.volatile.verify.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/copy.assign.volatile.verify.cpp
index 58d71ecd11d72..07e1181edf2bf 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/copy.assign.volatile.verify.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/copy.assign.volatile.verify.cpp
@@ -6,8 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: libcpp-has-no-threads
-
 // <atomic>
 
 // std::atomic

diff  --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/ctor.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/ctor.pass.cpp
index 6036d8e05ac26..021db21c80f25 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/ctor.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/ctor.pass.cpp
@@ -5,8 +5,7 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
+
 // UNSUPPORTED: c++03
 
 // <atomic>

diff  --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/dtor.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/dtor.pass.cpp
index ea85cde7860a7..2ecb580757d72 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/dtor.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/dtor.pass.cpp
@@ -5,8 +5,7 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
+
 // UNSUPPORTED: c++03
 
 // <atomic>

diff  --git a/libcxx/test/std/atomics/types.pass.cpp b/libcxx/test/std/atomics/types.pass.cpp
index 21ff0d373a049..401f9328b2fad 100644
--- a/libcxx/test/std/atomics/types.pass.cpp
+++ b/libcxx/test/std/atomics/types.pass.cpp
@@ -6,8 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: libcpp-has-no-threads
-
 // <atomic>
 
 // Test nested types
@@ -16,21 +14,20 @@
 // class atomic
 // {
 // public:
-//     typedef T                                        value_type;
+//     typedef T value_type;
 // };
 
 #include <atomic>
+#include <chrono>
+#include <memory>
 #include <type_traits>
 
-#include <thread>
-#include <chrono>
+#ifndef _LIBCPP_HAS_NO_THREADS
+#   include <thread>
+#endif
 
 #include "test_macros.h"
 
-#if TEST_STD_VER >= 20
-# include <memory>
-#endif
-
 template <class A, bool Integral>
 struct test_atomic
 {
@@ -170,7 +167,9 @@ int main(int, char**)
     test<LargeTriviallyCopyable>();
 #endif
 
+#ifndef _LIBCPP_HAS_NO_THREADS
     test<std::thread::id>();
+#endif
     test<std::chrono::nanoseconds>();
     test<float>();
 

diff  --git a/libcxx/test/std/depr/depr.atomics/depr.atomics.nonmembers/atomic_init.depr_in_cxx20.verify.cpp b/libcxx/test/std/depr/depr.atomics/depr.atomics.nonmembers/atomic_init.depr_in_cxx20.verify.cpp
index 4cb680ef67fbd..0a79494fb5eb9 100644
--- a/libcxx/test/std/depr/depr.atomics/depr.atomics.nonmembers/atomic_init.depr_in_cxx20.verify.cpp
+++ b/libcxx/test/std/depr/depr.atomics/depr.atomics.nonmembers/atomic_init.depr_in_cxx20.verify.cpp
@@ -5,9 +5,8 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
+
 // UNSUPPORTED: c++03, c++11, c++14, c++17
-// UNSUPPORTED: libcpp-has-no-threads
 
 // <atomic>
 //

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 23af3aeac21e7..39fd1c8263821 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
@@ -11,8 +11,6 @@
 //
 // clang-format off
 
-// UNSUPPORTED: libcpp-has-no-threads
-
 // <atomic>
 
 // Test the feature test macros defined by <atomic>
@@ -118,17 +116,11 @@
 #   error "__cpp_lib_atomic_float should not be defined before c++20"
 # endif
 
-# 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
+# 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
 
 # ifdef __cpp_lib_atomic_lock_free_type_aliases
@@ -157,17 +149,11 @@
 
 #elif TEST_STD_VER == 20
 
-# if !defined(_LIBCPP_HAS_NO_THREADS)
-#   ifndef __cpp_lib_atomic_flag_test
-#     error "__cpp_lib_atomic_flag_test should be defined in c++20"
-#   endif
-#   if __cpp_lib_atomic_flag_test != 201907L
-#     error "__cpp_lib_atomic_flag_test should have the value 201907L in c++20"
-#   endif
-# else
-#   ifdef __cpp_lib_atomic_flag_test
-#     error "__cpp_lib_atomic_flag_test should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
-#   endif
+# ifndef __cpp_lib_atomic_flag_test
+#   error "__cpp_lib_atomic_flag_test should be defined in c++20"
+# endif
+# if __cpp_lib_atomic_flag_test != 201907L
+#   error "__cpp_lib_atomic_flag_test should have the value 201907L in c++20"
 # endif
 
 # if !defined(_LIBCPP_VERSION)
@@ -183,30 +169,18 @@
 #   endif
 # endif
 
-# 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++20"
-#   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++20"
-#   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
+# ifndef __cpp_lib_atomic_is_always_lock_free
+#   error "__cpp_lib_atomic_is_always_lock_free should be defined in c++20"
+# 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++20"
 # endif
 
-# if !defined(_LIBCPP_HAS_NO_THREADS)
-#   ifndef __cpp_lib_atomic_lock_free_type_aliases
-#     error "__cpp_lib_atomic_lock_free_type_aliases should be defined in c++20"
-#   endif
-#   if __cpp_lib_atomic_lock_free_type_aliases != 201907L
-#     error "__cpp_lib_atomic_lock_free_type_aliases should have the value 201907L in c++20"
-#   endif
-# else
-#   ifdef __cpp_lib_atomic_lock_free_type_aliases
-#     error "__cpp_lib_atomic_lock_free_type_aliases should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
-#   endif
+# ifndef __cpp_lib_atomic_lock_free_type_aliases
+#   error "__cpp_lib_atomic_lock_free_type_aliases should be defined in c++20"
+# endif
+# if __cpp_lib_atomic_lock_free_type_aliases != 201907L
+#   error "__cpp_lib_atomic_lock_free_type_aliases should have the value 201907L in c++20"
 # endif
 
 # if !defined(_LIBCPP_VERSION)
@@ -235,20 +209,14 @@
 #   endif
 # endif
 
-# if !defined(_LIBCPP_HAS_NO_THREADS)
-#   ifndef __cpp_lib_atomic_value_initialization
-#     error "__cpp_lib_atomic_value_initialization should be defined in c++20"
-#   endif
-#   if __cpp_lib_atomic_value_initialization != 201911L
-#     error "__cpp_lib_atomic_value_initialization should have the value 201911L in c++20"
-#   endif
-# else
-#   ifdef __cpp_lib_atomic_value_initialization
-#     error "__cpp_lib_atomic_value_initialization should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
-#   endif
+# ifndef __cpp_lib_atomic_value_initialization
+#   error "__cpp_lib_atomic_value_initialization should be defined in c++20"
+# endif
+# if __cpp_lib_atomic_value_initialization != 201911L
+#   error "__cpp_lib_atomic_value_initialization should have the value 201911L in c++20"
 # endif
 
-# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait)
+# if !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait)
 #   ifndef __cpp_lib_atomic_wait
 #     error "__cpp_lib_atomic_wait should be defined in c++20"
 #   endif
@@ -257,7 +225,7 @@
 #   endif
 # else
 #   ifdef __cpp_lib_atomic_wait
-#     error "__cpp_lib_atomic_wait should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait) is not defined!"
+#     error "__cpp_lib_atomic_wait should not be defined when !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait) is not defined!"
 #   endif
 # endif
 
@@ -276,17 +244,11 @@
 
 #elif TEST_STD_VER > 20
 
-# if !defined(_LIBCPP_HAS_NO_THREADS)
-#   ifndef __cpp_lib_atomic_flag_test
-#     error "__cpp_lib_atomic_flag_test should be defined in c++2b"
-#   endif
-#   if __cpp_lib_atomic_flag_test != 201907L
-#     error "__cpp_lib_atomic_flag_test should have the value 201907L in c++2b"
-#   endif
-# else
-#   ifdef __cpp_lib_atomic_flag_test
-#     error "__cpp_lib_atomic_flag_test should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
-#   endif
+# ifndef __cpp_lib_atomic_flag_test
+#   error "__cpp_lib_atomic_flag_test should be defined in c++2b"
+# endif
+# if __cpp_lib_atomic_flag_test != 201907L
+#   error "__cpp_lib_atomic_flag_test should have the value 201907L in c++2b"
 # endif
 
 # if !defined(_LIBCPP_VERSION)
@@ -302,30 +264,18 @@
 #   endif
 # endif
 
-# 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++2b"
-#   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++2b"
-#   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
+# ifndef __cpp_lib_atomic_is_always_lock_free
+#   error "__cpp_lib_atomic_is_always_lock_free should be defined in c++2b"
+# 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++2b"
 # endif
 
-# if !defined(_LIBCPP_HAS_NO_THREADS)
-#   ifndef __cpp_lib_atomic_lock_free_type_aliases
-#     error "__cpp_lib_atomic_lock_free_type_aliases should be defined in c++2b"
-#   endif
-#   if __cpp_lib_atomic_lock_free_type_aliases != 201907L
-#     error "__cpp_lib_atomic_lock_free_type_aliases should have the value 201907L in c++2b"
-#   endif
-# else
-#   ifdef __cpp_lib_atomic_lock_free_type_aliases
-#     error "__cpp_lib_atomic_lock_free_type_aliases should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
-#   endif
+# ifndef __cpp_lib_atomic_lock_free_type_aliases
+#   error "__cpp_lib_atomic_lock_free_type_aliases should be defined in c++2b"
+# endif
+# if __cpp_lib_atomic_lock_free_type_aliases != 201907L
+#   error "__cpp_lib_atomic_lock_free_type_aliases should have the value 201907L in c++2b"
 # endif
 
 # if !defined(_LIBCPP_VERSION)
@@ -354,20 +304,14 @@
 #   endif
 # endif
 
-# if !defined(_LIBCPP_HAS_NO_THREADS)
-#   ifndef __cpp_lib_atomic_value_initialization
-#     error "__cpp_lib_atomic_value_initialization should be defined in c++2b"
-#   endif
-#   if __cpp_lib_atomic_value_initialization != 201911L
-#     error "__cpp_lib_atomic_value_initialization should have the value 201911L in c++2b"
-#   endif
-# else
-#   ifdef __cpp_lib_atomic_value_initialization
-#     error "__cpp_lib_atomic_value_initialization should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
-#   endif
+# ifndef __cpp_lib_atomic_value_initialization
+#   error "__cpp_lib_atomic_value_initialization should be defined in c++2b"
+# endif
+# if __cpp_lib_atomic_value_initialization != 201911L
+#   error "__cpp_lib_atomic_value_initialization should have the value 201911L in c++2b"
 # endif
 
-# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait)
+# if !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait)
 #   ifndef __cpp_lib_atomic_wait
 #     error "__cpp_lib_atomic_wait should be defined in c++2b"
 #   endif
@@ -376,7 +320,7 @@
 #   endif
 # else
 #   ifdef __cpp_lib_atomic_wait
-#     error "__cpp_lib_atomic_wait should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait) is not defined!"
+#     error "__cpp_lib_atomic_wait should not be defined when !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait) is not defined!"
 #   endif
 # endif
 

diff  --git a/libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.pass.cpp
index 7ebef80226db2..dfa5b569081d3 100644
--- a/libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.pass.cpp
+++ b/libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.pass.cpp
@@ -295,17 +295,11 @@
 #   endif
 # endif
 
-# if !defined(_LIBCPP_HAS_NO_THREADS)
-#   ifndef __cpp_lib_atomic_value_initialization
-#     error "__cpp_lib_atomic_value_initialization should be defined in c++20"
-#   endif
-#   if __cpp_lib_atomic_value_initialization != 201911L
-#     error "__cpp_lib_atomic_value_initialization should have the value 201911L in c++20"
-#   endif
-# else
-#   ifdef __cpp_lib_atomic_value_initialization
-#     error "__cpp_lib_atomic_value_initialization should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
-#   endif
+# ifndef __cpp_lib_atomic_value_initialization
+#   error "__cpp_lib_atomic_value_initialization should be defined in c++20"
+# endif
+# if __cpp_lib_atomic_value_initialization != 201911L
+#   error "__cpp_lib_atomic_value_initialization should have the value 201911L in c++20"
 # endif
 
 # ifndef __cpp_lib_constexpr_dynamic_alloc
@@ -439,17 +433,11 @@
 #   endif
 # endif
 
-# if !defined(_LIBCPP_HAS_NO_THREADS)
-#   ifndef __cpp_lib_atomic_value_initialization
-#     error "__cpp_lib_atomic_value_initialization should be defined in c++2b"
-#   endif
-#   if __cpp_lib_atomic_value_initialization != 201911L
-#     error "__cpp_lib_atomic_value_initialization should have the value 201911L in c++2b"
-#   endif
-# else
-#   ifdef __cpp_lib_atomic_value_initialization
-#     error "__cpp_lib_atomic_value_initialization should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
-#   endif
+# ifndef __cpp_lib_atomic_value_initialization
+#   error "__cpp_lib_atomic_value_initialization should be defined in c++2b"
+# endif
+# if __cpp_lib_atomic_value_initialization != 201911L
+#   error "__cpp_lib_atomic_value_initialization should have the value 201911L in c++2b"
 # endif
 
 # ifndef __cpp_lib_constexpr_dynamic_alloc

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 846abbd97bee9..782c09c147a66 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
@@ -1339,17 +1339,11 @@
 #   error "__cpp_lib_atomic_float should not be defined before c++20"
 # endif
 
-# 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
+# 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
 
 # ifdef __cpp_lib_atomic_lock_free_type_aliases
@@ -2140,17 +2134,11 @@
 #   endif
 # endif
 
-# if !defined(_LIBCPP_HAS_NO_THREADS)
-#   ifndef __cpp_lib_atomic_flag_test
-#     error "__cpp_lib_atomic_flag_test should be defined in c++20"
-#   endif
-#   if __cpp_lib_atomic_flag_test != 201907L
-#     error "__cpp_lib_atomic_flag_test should have the value 201907L in c++20"
-#   endif
-# else
-#   ifdef __cpp_lib_atomic_flag_test
-#     error "__cpp_lib_atomic_flag_test should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
-#   endif
+# ifndef __cpp_lib_atomic_flag_test
+#   error "__cpp_lib_atomic_flag_test should be defined in c++20"
+# endif
+# if __cpp_lib_atomic_flag_test != 201907L
+#   error "__cpp_lib_atomic_flag_test should have the value 201907L in c++20"
 # endif
 
 # if !defined(_LIBCPP_VERSION)
@@ -2166,30 +2154,18 @@
 #   endif
 # endif
 
-# 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++20"
-#   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++20"
-#   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
+# ifndef __cpp_lib_atomic_is_always_lock_free
+#   error "__cpp_lib_atomic_is_always_lock_free should be defined in c++20"
+# 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++20"
 # endif
 
-# if !defined(_LIBCPP_HAS_NO_THREADS)
-#   ifndef __cpp_lib_atomic_lock_free_type_aliases
-#     error "__cpp_lib_atomic_lock_free_type_aliases should be defined in c++20"
-#   endif
-#   if __cpp_lib_atomic_lock_free_type_aliases != 201907L
-#     error "__cpp_lib_atomic_lock_free_type_aliases should have the value 201907L in c++20"
-#   endif
-# else
-#   ifdef __cpp_lib_atomic_lock_free_type_aliases
-#     error "__cpp_lib_atomic_lock_free_type_aliases should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
-#   endif
+# ifndef __cpp_lib_atomic_lock_free_type_aliases
+#   error "__cpp_lib_atomic_lock_free_type_aliases should be defined in c++20"
+# endif
+# if __cpp_lib_atomic_lock_free_type_aliases != 201907L
+#   error "__cpp_lib_atomic_lock_free_type_aliases should have the value 201907L in c++20"
 # endif
 
 # if !defined(_LIBCPP_VERSION)
@@ -2218,20 +2194,14 @@
 #   endif
 # endif
 
-# if !defined(_LIBCPP_HAS_NO_THREADS)
-#   ifndef __cpp_lib_atomic_value_initialization
-#     error "__cpp_lib_atomic_value_initialization should be defined in c++20"
-#   endif
-#   if __cpp_lib_atomic_value_initialization != 201911L
-#     error "__cpp_lib_atomic_value_initialization should have the value 201911L in c++20"
-#   endif
-# else
-#   ifdef __cpp_lib_atomic_value_initialization
-#     error "__cpp_lib_atomic_value_initialization should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
-#   endif
+# ifndef __cpp_lib_atomic_value_initialization
+#   error "__cpp_lib_atomic_value_initialization should be defined in c++20"
+# endif
+# if __cpp_lib_atomic_value_initialization != 201911L
+#   error "__cpp_lib_atomic_value_initialization should have the value 201911L in c++20"
 # endif
 
-# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait)
+# if !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait)
 #   ifndef __cpp_lib_atomic_wait
 #     error "__cpp_lib_atomic_wait should be defined in c++20"
 #   endif
@@ -2240,7 +2210,7 @@
 #   endif
 # else
 #   ifdef __cpp_lib_atomic_wait
-#     error "__cpp_lib_atomic_wait should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait) is not defined!"
+#     error "__cpp_lib_atomic_wait should not be defined when !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait) is not defined!"
 #   endif
 # endif
 
@@ -3285,17 +3255,11 @@
 #   endif
 # endif
 
-# if !defined(_LIBCPP_HAS_NO_THREADS)
-#   ifndef __cpp_lib_atomic_flag_test
-#     error "__cpp_lib_atomic_flag_test should be defined in c++2b"
-#   endif
-#   if __cpp_lib_atomic_flag_test != 201907L
-#     error "__cpp_lib_atomic_flag_test should have the value 201907L in c++2b"
-#   endif
-# else
-#   ifdef __cpp_lib_atomic_flag_test
-#     error "__cpp_lib_atomic_flag_test should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
-#   endif
+# ifndef __cpp_lib_atomic_flag_test
+#   error "__cpp_lib_atomic_flag_test should be defined in c++2b"
+# endif
+# if __cpp_lib_atomic_flag_test != 201907L
+#   error "__cpp_lib_atomic_flag_test should have the value 201907L in c++2b"
 # endif
 
 # if !defined(_LIBCPP_VERSION)
@@ -3311,30 +3275,18 @@
 #   endif
 # endif
 
-# 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++2b"
-#   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++2b"
-#   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
+# ifndef __cpp_lib_atomic_is_always_lock_free
+#   error "__cpp_lib_atomic_is_always_lock_free should be defined in c++2b"
+# 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++2b"
 # endif
 
-# if !defined(_LIBCPP_HAS_NO_THREADS)
-#   ifndef __cpp_lib_atomic_lock_free_type_aliases
-#     error "__cpp_lib_atomic_lock_free_type_aliases should be defined in c++2b"
-#   endif
-#   if __cpp_lib_atomic_lock_free_type_aliases != 201907L
-#     error "__cpp_lib_atomic_lock_free_type_aliases should have the value 201907L in c++2b"
-#   endif
-# else
-#   ifdef __cpp_lib_atomic_lock_free_type_aliases
-#     error "__cpp_lib_atomic_lock_free_type_aliases should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
-#   endif
+# ifndef __cpp_lib_atomic_lock_free_type_aliases
+#   error "__cpp_lib_atomic_lock_free_type_aliases should be defined in c++2b"
+# endif
+# if __cpp_lib_atomic_lock_free_type_aliases != 201907L
+#   error "__cpp_lib_atomic_lock_free_type_aliases should have the value 201907L in c++2b"
 # endif
 
 # if !defined(_LIBCPP_VERSION)
@@ -3363,20 +3315,14 @@
 #   endif
 # endif
 
-# if !defined(_LIBCPP_HAS_NO_THREADS)
-#   ifndef __cpp_lib_atomic_value_initialization
-#     error "__cpp_lib_atomic_value_initialization should be defined in c++2b"
-#   endif
-#   if __cpp_lib_atomic_value_initialization != 201911L
-#     error "__cpp_lib_atomic_value_initialization should have the value 201911L in c++2b"
-#   endif
-# else
-#   ifdef __cpp_lib_atomic_value_initialization
-#     error "__cpp_lib_atomic_value_initialization should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
-#   endif
+# ifndef __cpp_lib_atomic_value_initialization
+#   error "__cpp_lib_atomic_value_initialization should be defined in c++2b"
+# endif
+# if __cpp_lib_atomic_value_initialization != 201911L
+#   error "__cpp_lib_atomic_value_initialization should have the value 201911L in c++2b"
 # endif
 
-# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait)
+# if !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait)
 #   ifndef __cpp_lib_atomic_wait
 #     error "__cpp_lib_atomic_wait should be defined in c++2b"
 #   endif
@@ -3385,7 +3331,7 @@
 #   endif
 # else
 #   ifdef __cpp_lib_atomic_wait
-#     error "__cpp_lib_atomic_wait should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait) is not defined!"
+#     error "__cpp_lib_atomic_wait should not be defined when !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait) is not defined!"
 #   endif
 # endif
 

diff  --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py
index d7c9ad94441d7..5ff83304bc5e7 100755
--- a/libcxx/utils/generate_feature_test_macro_components.py
+++ b/libcxx/utils/generate_feature_test_macro_components.py
@@ -95,53 +95,39 @@ def add_version_header(tc):
     "name": "__cpp_lib_atomic_flag_test",
     "values": { "c++20": 201907 },
     "headers": ["atomic"],
-    "test_suite_guard": "!defined(_LIBCPP_HAS_NO_THREADS)",
-    "libcxx_guard": "!defined(_LIBCPP_HAS_NO_THREADS)",
   }, {
     "name": "__cpp_lib_atomic_float",
     "values": { "c++20": 201711 },
     "headers": ["atomic"],
-    "test_suite_guard": "!defined(_LIBCPP_HAS_NO_THREADS)",
-    "libcxx_guard": "!defined(_LIBCPP_HAS_NO_THREADS)",
     "unimplemented": True,
   }, {
     "name": "__cpp_lib_atomic_is_always_lock_free",
     "values": { "c++17": 201603 },
     "headers": ["atomic"],
-    "test_suite_guard": "!defined(_LIBCPP_HAS_NO_THREADS)",
-    "libcxx_guard": "!defined(_LIBCPP_HAS_NO_THREADS)",
   }, {
     "name": "__cpp_lib_atomic_lock_free_type_aliases",
     "values": { "c++20": 201907 },
     "headers": ["atomic"],
-    "test_suite_guard": "!defined(_LIBCPP_HAS_NO_THREADS)",
-    "libcxx_guard": "!defined(_LIBCPP_HAS_NO_THREADS)",
   }, {
     "name": "__cpp_lib_atomic_ref",
     "values": { "c++20": 201806 },
     "headers": ["atomic"],
-    "test_suite_guard": "!defined(_LIBCPP_HAS_NO_THREADS)",
-    "libcxx_guard": "!defined(_LIBCPP_HAS_NO_THREADS)",
     "unimplemented": True,
   }, {
     "name": "__cpp_lib_atomic_shared_ptr",
     "values": { "c++20": 201711 },
     "headers": ["atomic"],
-    "test_suite_guard": "!defined(_LIBCPP_HAS_NO_THREADS)",
-    "libcxx_guard": "!defined(_LIBCPP_HAS_NO_THREADS)",
     "unimplemented": True,
   }, {
     "name": "__cpp_lib_atomic_value_initialization",
     "values": { "c++20": 201911 },
     "headers": ["atomic", "memory"],
-    "test_suite_guard": "!defined(_LIBCPP_HAS_NO_THREADS)",
-    "libcxx_guard": "!defined(_LIBCPP_HAS_NO_THREADS)",
   }, {
     "name": "__cpp_lib_atomic_wait",
     "values": { "c++20": 201907 },
     "headers": ["atomic"],
-    "test_suite_guard": "!defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait)",
-    "libcxx_guard": "!defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait)",
+    "test_suite_guard": "!defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait)",
+    "libcxx_guard": "!defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait)",
   }, {
     "name": "__cpp_lib_barrier",
     "values": { "c++20": 201907 },
@@ -671,7 +657,6 @@ def add_version_header(tc):
 # that includes <thread> should be marked as UNSUPPORTED, because including
 # <thread> is a hard error in that case.
 lit_markup = {
-  "atomic": ["UNSUPPORTED: libcpp-has-no-threads"],
   "barrier": ["UNSUPPORTED: libcpp-has-no-threads"],
   "filesystem": ["UNSUPPORTED: libcpp-has-no-filesystem-library"],
   "format": ["UNSUPPORTED: libcpp-has-no-incomplete-format"],

diff  --git a/libcxx/utils/generate_header_inclusion_tests.py b/libcxx/utils/generate_header_inclusion_tests.py
index 842b048e398c8..7d48094a8f5ec 100755
--- a/libcxx/utils/generate_header_inclusion_tests.py
+++ b/libcxx/utils/generate_header_inclusion_tests.py
@@ -90,7 +90,6 @@ def get_libcxx_paths():
 # that includes <thread> should be marked as UNSUPPORTED, because including
 # <thread> is a hard error in that case.
 lit_markup = {
-  "atomic": ["UNSUPPORTED: libcpp-has-no-threads"],
   "barrier": ["UNSUPPORTED: libcpp-has-no-threads"],
   "filesystem": ["UNSUPPORTED: libcpp-has-no-filesystem-library"],
   "format": ["UNSUPPORTED: libcpp-has-no-incomplete-format"],

diff  --git a/libcxx/utils/generate_header_tests.py b/libcxx/utils/generate_header_tests.py
index cd78b4a7c1a25..a8a30d3f8a8d1 100755
--- a/libcxx/utils/generate_header_tests.py
+++ b/libcxx/utils/generate_header_tests.py
@@ -21,7 +21,6 @@ def get_libcxx_paths():
 script_name, source_root, include_path, libcxx_test_path = get_libcxx_paths()
 
 header_markup = {
-    "atomic": ["ifndef _LIBCPP_HAS_NO_THREADS"],
     "barrier": ["ifndef _LIBCPP_HAS_NO_THREADS"],
     "future": ["ifndef _LIBCPP_HAS_NO_THREADS"],
     "latch": ["ifndef _LIBCPP_HAS_NO_THREADS"],


        


More information about the libcxx-commits mailing list