[all-commits] [llvm/llvm-project] 92832e: [libc++] Enable <atomic> when threads are disabled

Louis Dionne via All-commits all-commits at lists.llvm.org
Wed Nov 17 20:03:22 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 92832e4889ae6038cc8b3e6e449af2a9b9374ab4
      https://github.com/llvm/llvm-project/commit/92832e4889ae6038cc8b3e6e449af2a9b9374ab4
  Author: Louis Dionne <ldionne.2 at gmail.com>
  Date:   2021-11-17 (Wed, 17 Nov 2021)

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

  Log Message:
  -----------
  [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




More information about the All-commits mailing list