Skip to content

[libc++] Drop support for the C++20 Synchronization Library before C++20 #82008

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion libcxx/.clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ AttributeMacros: [
'_LIBCPP_CONSTEXPR_SINCE_CXX23',
'_LIBCPP_CONSTEXPR',
'_LIBCPP_CONSTINIT',
'_LIBCPP_DEPRECATED_ATOMIC_SYNC',
'_LIBCPP_DEPRECATED_IN_CXX11',
'_LIBCPP_DEPRECATED_IN_CXX14',
'_LIBCPP_DEPRECATED_IN_CXX17',
Expand Down
4 changes: 3 additions & 1 deletion libcxx/docs/ReleaseNotes/20.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ Deprecations and Removals
- TODO: The ``LIBCXX_ENABLE_ASSERTIONS`` CMake variable and the ``_LIBCPP_ENABLE_ASSERTIONS`` macro that were used to enable
the safe mode will be removed in LLVM 20.

- TODO: The C++20 synchronization library will be removed entirely in language modes prior to C++20 in LLVM 20.
- Support for the C++20 synchronization library (``<barrier>``, ``<latch>``, ``atomic::wait``, etc.) has been
removed in language modes prior to C++20. If you are using these features prior to C++20, you will need to
update to ``-std=c++20``.

- TODO: The relational operators for ``std::chrono::weekday`` will be removed entirely, and the
``_LIBCPP_ENABLE_REMOVED_WEEKDAY_RELATIONAL_OPERATORS`` macro that was used to re-enable this extension will be
Expand Down
16 changes: 8 additions & 8 deletions libcxx/include/__atomic/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,8 @@ _LIBCPP_HIDE_FROM_ABI bool atomic_compare_exchange_strong_explicit(
return __o->compare_exchange_strong(*__e, __d, __s, __f);
}

#if _LIBCPP_STD_VER >= 20

// atomic_wait

template <class _Tp>
Expand Down Expand Up @@ -462,29 +464,27 @@ atomic_wait_explicit(const atomic<_Tp>* __o, typename atomic<_Tp>::value_type __
// atomic_notify_one

template <class _Tp>
_LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void
atomic_notify_one(volatile atomic<_Tp>* __o) _NOEXCEPT {
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void atomic_notify_one(volatile atomic<_Tp>* __o) _NOEXCEPT {
__o->notify_one();
}
template <class _Tp>
_LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void
atomic_notify_one(atomic<_Tp>* __o) _NOEXCEPT {
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void atomic_notify_one(atomic<_Tp>* __o) _NOEXCEPT {
__o->notify_one();
}

// atomic_notify_all

template <class _Tp>
_LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void
atomic_notify_all(volatile atomic<_Tp>* __o) _NOEXCEPT {
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void atomic_notify_all(volatile atomic<_Tp>* __o) _NOEXCEPT {
__o->notify_all();
}
template <class _Tp>
_LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void
atomic_notify_all(atomic<_Tp>* __o) _NOEXCEPT {
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void atomic_notify_all(atomic<_Tp>* __o) _NOEXCEPT {
__o->notify_all();
}

#endif // _LIBCPP_STD_VER >= 20

// atomic_fetch_add

template <class _Tp>
Expand Down
2 changes: 2 additions & 0 deletions libcxx/include/__atomic/atomic_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ struct __atomic_base // false
return std::__cxx_atomic_compare_exchange_strong(std::addressof(__a_), std::addressof(__e), __d, __m, __m);
}

#if _LIBCPP_STD_VER >= 20
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void wait(_Tp __v, memory_order __m = memory_order_seq_cst) const
volatile _NOEXCEPT {
std::__atomic_wait(*this, __v, __m);
Expand All @@ -117,6 +118,7 @@ struct __atomic_base // false
std::__atomic_notify_all(*this);
}
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT { std::__atomic_notify_all(*this); }
#endif // _LIBCPP_STD_VER >= 20

#if _LIBCPP_STD_VER >= 20
_LIBCPP_HIDE_FROM_ABI constexpr __atomic_base() noexcept(is_nothrow_default_constructible_v<_Tp>) : __a_(_Tp()) {}
Expand Down
38 changes: 18 additions & 20 deletions libcxx/include/__atomic/atomic_flag.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,24 @@ struct atomic_flag {
__cxx_atomic_store(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(false), __m);
}

_LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void
wait(bool __v, memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT {
#if _LIBCPP_STD_VER >= 20
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void wait(bool __v, memory_order __m = memory_order_seq_cst) const
volatile _NOEXCEPT {
std::__atomic_wait(*this, _LIBCPP_ATOMIC_FLAG_TYPE(__v), __m);
}
_LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void
wait(bool __v, memory_order __m = memory_order_seq_cst) const _NOEXCEPT {
std::__atomic_wait(*this, _LIBCPP_ATOMIC_FLAG_TYPE(__v), __m);
}
_LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() volatile _NOEXCEPT {
std::__atomic_notify_one(*this);
}
_LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() _NOEXCEPT {
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() volatile _NOEXCEPT {
std::__atomic_notify_one(*this);
}
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() _NOEXCEPT { std::__atomic_notify_one(*this); }
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() volatile _NOEXCEPT {
std::__atomic_notify_all(*this);
}
_LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT {
std::__atomic_notify_all(*this);
}
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT { std::__atomic_notify_all(*this); }
#endif

#if _LIBCPP_STD_VER >= 20
_LIBCPP_HIDE_FROM_ABI constexpr atomic_flag() _NOEXCEPT : __a_(false) {}
Expand Down Expand Up @@ -144,45 +142,45 @@ inline _LIBCPP_HIDE_FROM_ABI void atomic_flag_clear_explicit(atomic_flag* __o, m
__o->clear(__m);
}

inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
#if _LIBCPP_STD_VER >= 20
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
atomic_flag_wait(const volatile atomic_flag* __o, bool __v) _NOEXCEPT {
__o->wait(__v);
}

inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
atomic_flag_wait(const atomic_flag* __o, bool __v) _NOEXCEPT {
__o->wait(__v);
}

inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
atomic_flag_wait_explicit(const volatile atomic_flag* __o, bool __v, memory_order __m) _NOEXCEPT {
__o->wait(__v, __m);
}

inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
atomic_flag_wait_explicit(const atomic_flag* __o, bool __v, memory_order __m) _NOEXCEPT {
__o->wait(__v, __m);
}

inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
atomic_flag_notify_one(volatile atomic_flag* __o) _NOEXCEPT {
__o->notify_one();
}

inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
atomic_flag_notify_one(atomic_flag* __o) _NOEXCEPT {
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void atomic_flag_notify_one(atomic_flag* __o) _NOEXCEPT {
__o->notify_one();
}

inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
atomic_flag_notify_all(volatile atomic_flag* __o) _NOEXCEPT {
__o->notify_all();
}

inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
atomic_flag_notify_all(atomic_flag* __o) _NOEXCEPT {
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void atomic_flag_notify_all(atomic_flag* __o) _NOEXCEPT {
__o->notify_all();
}
#endif // _LIBCPP_STD_VER >= 20

_LIBCPP_END_NAMESPACE_STD

Expand Down
8 changes: 0 additions & 8 deletions libcxx/include/__config
Original file line number Diff line number Diff line change
Expand Up @@ -699,14 +699,6 @@ typedef __char32_t char32_t;
# define _LIBCPP_DEPRECATED_(m)
# endif

# if _LIBCPP_STD_VER < 20
# define _LIBCPP_DEPRECATED_ATOMIC_SYNC \
_LIBCPP_DEPRECATED_("The C++20 synchronization library has been deprecated prior to C++20. Please update to " \
"using -std=c++20 if you need to use these facilities.")
# else
# define _LIBCPP_DEPRECATED_ATOMIC_SYNC /* nothing */
# endif

# if !defined(_LIBCPP_CXX03_LANG)
# define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
# else
Expand Down
92 changes: 46 additions & 46 deletions libcxx/include/atomic
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ struct atomic
bool compare_exchange_strong(T& expc, T desr,
memory_order m = memory_order_seq_cst) noexcept;

void wait(T, memory_order = memory_order::seq_cst) const volatile noexcept;
void wait(T, memory_order = memory_order::seq_cst) const noexcept;
void notify_one() volatile noexcept;
void notify_one() noexcept;
void notify_all() volatile noexcept;
void notify_all() noexcept;
void wait(T, memory_order = memory_order::seq_cst) const volatile noexcept; // since C++20
void wait(T, memory_order = memory_order::seq_cst) const noexcept; // since C++20
void notify_one() volatile noexcept; // since C++20
void notify_one() noexcept; // since C++20
void notify_all() volatile noexcept; // since C++20
void notify_all() noexcept; // since C++20
};

template <>
Expand Down Expand Up @@ -184,12 +184,12 @@ struct atomic<integral>
integral operator^=(integral op) volatile noexcept;
integral operator^=(integral op) noexcept;

void wait(integral, memory_order = memory_order::seq_cst) const volatile noexcept;
void wait(integral, memory_order = memory_order::seq_cst) const noexcept;
void notify_one() volatile noexcept;
void notify_one() noexcept;
void notify_all() volatile noexcept;
void notify_all() noexcept;
void wait(integral, memory_order = memory_order::seq_cst) const volatile noexcept; // since C++20
void wait(integral, memory_order = memory_order::seq_cst) const noexcept; // since C++20
void notify_one() volatile noexcept; // since C++20
void notify_one() noexcept; // since C++20
void notify_all() volatile noexcept; // since C++20
void notify_all() noexcept; // since C++20
};

template <class T>
Expand Down Expand Up @@ -254,12 +254,12 @@ struct atomic<T*>
T* operator-=(ptrdiff_t op) volatile noexcept;
T* operator-=(ptrdiff_t op) noexcept;

void wait(T*, memory_order = memory_order::seq_cst) const volatile noexcept;
void wait(T*, memory_order = memory_order::seq_cst) const noexcept;
void notify_one() volatile noexcept;
void notify_one() noexcept;
void notify_all() volatile noexcept;
void notify_all() noexcept;
void wait(T*, memory_order = memory_order::seq_cst) const volatile noexcept; // since C++20
void wait(T*, memory_order = memory_order::seq_cst) const noexcept; // since C++20
void notify_one() volatile noexcept; // since C++20
void notify_one() noexcept; // since C++20
void notify_all() volatile noexcept; // since C++20
void notify_all() noexcept; // since C++20
};

template<>
Expand Down Expand Up @@ -321,12 +321,12 @@ struct atomic<floating-point-type> { // since C++20
floating-point-type operator-=(floating-point-type) volatile noexcept;
floating-point-type operator-=(floating-point-type) noexcept;

void wait(floating-point-type, memory_order = memory_order::seq_cst) const volatile noexcept;
void wait(floating-point-type, memory_order = memory_order::seq_cst) const noexcept;
void notify_one() volatile noexcept;
void notify_one() noexcept;
void notify_all() volatile noexcept;
void notify_all() noexcept;
void wait(floating-point-type, memory_order = memory_order::seq_cst) const volatile noexcept; // since C++20
void wait(floating-point-type, memory_order = memory_order::seq_cst) const noexcept; // since C++20
void notify_one() volatile noexcept; // since C++20
void notify_one() noexcept; // since C++20
void notify_all() volatile noexcept; // since C++20
void notify_all() noexcept; // since C++20
};

// [atomics.nonmembers], non-member functions
Expand Down Expand Up @@ -443,23 +443,23 @@ template<class T>
memory_order) noexcept;

template<class T>
void atomic_wait(const volatile atomic<T>*, atomic<T>::value_type) noexcept;
void atomic_wait(const volatile atomic<T>*, atomic<T>::value_type) noexcept; // since C++20
template<class T>
void atomic_wait(const atomic<T>*, atomic<T>::value_type) noexcept;
void atomic_wait(const atomic<T>*, atomic<T>::value_type) noexcept; // since C++20
template<class T>
void atomic_wait_explicit(const volatile atomic<T>*, atomic<T>::value_type,
void atomic_wait_explicit(const volatile atomic<T>*, atomic<T>::value_type, // since C++20
memory_order) noexcept;
template<class T>
void atomic_wait_explicit(const atomic<T>*, atomic<T>::value_type,
void atomic_wait_explicit(const atomic<T>*, atomic<T>::value_type, // since C++20
memory_order) noexcept;
template<class T>
void atomic_notify_one(volatile atomic<T>*) noexcept;
void atomic_notify_one(volatile atomic<T>*) noexcept; // since C++20
template<class T>
void atomic_notify_one(atomic<T>*) noexcept;
void atomic_notify_one(atomic<T>*) noexcept; // since C++20
template<class T>
void atomic_notify_all(volatile atomic<T>*) noexcept;
void atomic_notify_all(volatile atomic<T>*) noexcept; // since C++20
template<class T>
void atomic_notify_all(atomic<T>*) noexcept;
void atomic_notify_all(atomic<T>*) noexcept; // since C++20

// Atomics for standard typedef types

Expand Down Expand Up @@ -534,12 +534,12 @@ typedef struct atomic_flag
void clear(memory_order m = memory_order_seq_cst) volatile noexcept;
void clear(memory_order m = memory_order_seq_cst) noexcept;

void wait(bool, memory_order = memory_order::seq_cst) const volatile noexcept;
void wait(bool, memory_order = memory_order::seq_cst) const noexcept;
void notify_one() volatile noexcept;
void notify_one() noexcept;
void notify_all() volatile noexcept;
void notify_all() noexcept;
void wait(bool, memory_order = memory_order::seq_cst) const volatile noexcept; // since C++20
void wait(bool, memory_order = memory_order::seq_cst) const noexcept; // since C++20
void notify_one() volatile noexcept; // since C++20
void notify_one() noexcept; // since C++20
void notify_all() volatile noexcept; // since C++20
void notify_all() noexcept; // since C++20
} atomic_flag;

bool atomic_flag_test(volatile atomic_flag* obj) noexcept;
Expand All @@ -557,14 +557,14 @@ void atomic_flag_clear(atomic_flag* obj) noexcept;
void atomic_flag_clear_explicit(volatile atomic_flag* obj, memory_order m) noexcept;
void atomic_flag_clear_explicit(atomic_flag* obj, memory_order m) noexcept;

void atomic_wait(const volatile atomic_flag* obj, T old) noexcept;
void atomic_wait(const atomic_flag* obj, T old) noexcept;
void atomic_wait_explicit(const volatile atomic_flag* obj, T old, memory_order m) noexcept;
void atomic_wait_explicit(const atomic_flag* obj, T old, memory_order m) noexcept;
void atomic_one(volatile atomic_flag* obj) noexcept;
void atomic_one(atomic_flag* obj) noexcept;
void atomic_all(volatile atomic_flag* obj) noexcept;
void atomic_all(atomic_flag* obj) noexcept;
void atomic_wait(const volatile atomic_flag* obj, T old) noexcept; // since C++20
void atomic_wait(const atomic_flag* obj, T old) noexcept; // since C++20
void atomic_wait_explicit(const volatile atomic_flag* obj, T old, memory_order m) noexcept; // since C++20
void atomic_wait_explicit(const atomic_flag* obj, T old, memory_order m) noexcept; // since C++20
void atomic_one(volatile atomic_flag* obj) noexcept; // since C++20
void atomic_one(atomic_flag* obj) noexcept; // since C++20
void atomic_all(volatile atomic_flag* obj) noexcept; // since C++20
void atomic_all(atomic_flag* obj) noexcept; // since C++20

// fences

Expand Down
10 changes: 5 additions & 5 deletions libcxx/include/barrier
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace std
{

template<class CompletionFunction = see below>
class barrier
class barrier // since C++20
{
public:
using arrival_token = see below;
Expand Down Expand Up @@ -68,7 +68,7 @@ namespace std
_LIBCPP_PUSH_MACROS
# include <__undef_macros>

# if _LIBCPP_STD_VER >= 14
# if _LIBCPP_STD_VER >= 20

_LIBCPP_BEGIN_NAMESPACE_STD

Expand Down Expand Up @@ -254,7 +254,7 @@ public:
# endif // !_LIBCPP_HAS_NO_TREE_BARRIER

template <class _CompletionF = __empty_completion>
class _LIBCPP_DEPRECATED_ATOMIC_SYNC barrier {
class barrier {
__barrier_base<_CompletionF> __b_;

public:
Expand Down Expand Up @@ -290,7 +290,7 @@ public:

_LIBCPP_END_NAMESPACE_STD

# endif // _LIBCPP_STD_VER >= 14
# endif // _LIBCPP_STD_VER >= 20

_LIBCPP_POP_MACROS

Expand All @@ -305,4 +305,4 @@ _LIBCPP_POP_MACROS
# include <variant>
#endif

#endif //_LIBCPP_BARRIER
#endif // _LIBCPP_BARRIER
Loading
Loading