// Decide whether to use availability macros.
#if !defined(_LIBCPP_BUILDING_LIBRARY) && \
+ !defined(_LIBCXXABI_BUILDING_LIBRARY) && \
!defined(_LIBCPP_DISABLE_AVAILABILITY) && \
__has_feature(attribute_availability_with_strict) && \
__has_feature(attribute_availability_in_templates) && \
# define _LIBCPP_AVAILABILITY_TO_CHARS \
_LIBCPP_AVAILABILITY_FILESYSTEM
# define _LIBCPP_AVAILABILITY_SYNC \
- /*FIXME:mark this as unavailable on Apple platforms*/
+ __attribute__((unavailable))
#else
# define _LIBCPP_AVAILABILITY_SHARED_MUTEX
# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
};
template<class _Fn, class _BFn>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
bool __libcpp_thread_poll_with_backoff(
_Fn && __f, _BFn && __bf, chrono::nanoseconds __max_elapsed = chrono::nanoseconds::zero());
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)
{
auto const __start = chrono::high_resolution_clock::now();
struct __libcpp_atomic_wait_backoff_impl {
_Atp* __a;
_Fn __test_fn;
+ _LIBCPP_AVAILABILITY_SYNC
_LIBCPP_INLINE_VISIBILITY bool operator()(chrono::nanoseconds __elapsed) const
{
if(__elapsed > chrono::microseconds(64))
};
template <class _Atp, class _Fn>
+_LIBCPP_AVAILABILITY_SYNC
_LIBCPP_INLINE_VISIBILITY bool __cxx_atomic_wait(_Atp* __a, _Fn && __test_fn)
{
__libcpp_atomic_wait_backoff_impl<_Atp, typename decay<_Fn>::type> __backoff_fn = {__a, __test_fn};
};
template <class _Atp, class _Tp>
+_LIBCPP_AVAILABILITY_SYNC
_LIBCPP_INLINE_VISIBILITY bool __cxx_atomic_wait(_Atp* __a, _Tp const __val, memory_order __order)
{
__cxx_atomic_wait_test_fn_impl<_Atp, _Tp> __test_fn = {__a, __val, __order};
memory_order __m = memory_order_seq_cst) _NOEXCEPT
{return __cxx_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);}
- _LIBCPP_INLINE_VISIBILITY void wait(_Tp __v, memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void wait(_Tp __v, memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT
{__cxx_atomic_wait(&__a_, __v, __m);}
- _LIBCPP_INLINE_VISIBILITY void wait(_Tp __v, memory_order __m = memory_order_seq_cst) const _NOEXCEPT
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void wait(_Tp __v, memory_order __m = memory_order_seq_cst) const _NOEXCEPT
{__cxx_atomic_wait(&__a_, __v, __m);}
- _LIBCPP_INLINE_VISIBILITY void notify_one() volatile _NOEXCEPT
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void notify_one() volatile _NOEXCEPT
{__cxx_atomic_notify_one(&__a_);}
- _LIBCPP_INLINE_VISIBILITY void notify_one() _NOEXCEPT
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void notify_one() _NOEXCEPT
{__cxx_atomic_notify_one(&__a_);}
- _LIBCPP_INLINE_VISIBILITY void notify_all() volatile _NOEXCEPT
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void notify_all() volatile _NOEXCEPT
{__cxx_atomic_notify_all(&__a_);}
- _LIBCPP_INLINE_VISIBILITY void notify_all() _NOEXCEPT
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void notify_all() _NOEXCEPT
{__cxx_atomic_notify_all(&__a_);}
_LIBCPP_INLINE_VISIBILITY
// atomic_wait
template <class _Tp>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void atomic_wait(const volatile atomic<_Tp>* __o,
typename atomic<_Tp>::value_type __v) _NOEXCEPT
{
}
template <class _Tp>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void atomic_wait(const atomic<_Tp>* __o,
typename atomic<_Tp>::value_type __v) _NOEXCEPT
{
// atomic_wait_explicit
template <class _Tp>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void atomic_wait_explicit(const volatile atomic<_Tp>* __o,
typename atomic<_Tp>::value_type __v,
memory_order __m) _NOEXCEPT
}
template <class _Tp>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void atomic_wait_explicit(const atomic<_Tp>* __o,
typename atomic<_Tp>::value_type __v,
memory_order __m) _NOEXCEPT
// atomic_notify_one
template <class _Tp>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void atomic_notify_one(volatile atomic<_Tp>* __o) _NOEXCEPT
{
__o->notify_one();
}
template <class _Tp>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void atomic_notify_one(atomic<_Tp>* __o) _NOEXCEPT
{
__o->notify_one();
// atomic_notify_one
template <class _Tp>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void atomic_notify_all(volatile atomic<_Tp>* __o) _NOEXCEPT
{
__o->notify_all();
}
template <class _Tp>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void atomic_notify_all(atomic<_Tp>* __o) _NOEXCEPT
{
__o->notify_all();
void clear(memory_order __m = memory_order_seq_cst) _NOEXCEPT
{__cxx_atomic_store(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(false), __m);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void wait(bool __v, memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT
{__cxx_atomic_wait(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(__v), __m);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void wait(bool __v, memory_order __m = memory_order_seq_cst) const _NOEXCEPT
{__cxx_atomic_wait(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(__v), __m);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void notify_one() volatile _NOEXCEPT
{__cxx_atomic_notify_one(&__a_);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void notify_one() _NOEXCEPT
{__cxx_atomic_notify_one(&__a_);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void notify_all() volatile _NOEXCEPT
{__cxx_atomic_notify_all(&__a_);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void notify_all() _NOEXCEPT
{__cxx_atomic_notify_all(&__a_);}
__o->clear(__m);
}
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_SYNC
void
atomic_flag_wait(const volatile atomic_flag* __o, bool __v) _NOEXCEPT
{
__o->wait(__v);
}
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_SYNC
void
atomic_flag_wait(const atomic_flag* __o, bool __v) _NOEXCEPT
{
__o->wait(__v);
}
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _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_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_SYNC
void
atomic_flag_wait_explicit(const atomic_flag* __o,
bool __v, memory_order __m) _NOEXCEPT
__o->wait(__v, __m);
}
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_SYNC
void
atomic_flag_notify_one(volatile atomic_flag* __o) _NOEXCEPT
{
__o->notify_one();
}
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_SYNC
void
atomic_flag_notify_one(atomic_flag* __o) _NOEXCEPT
{
__o->notify_one();
}
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_SYNC
void
atomic_flag_notify_all(volatile atomic_flag* __o) _NOEXCEPT
{
__o->notify_all();
}
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_SYNC
void
atomic_flag_notify_all(atomic_flag* __o) _NOEXCEPT
{
ptrdiff_t __expected;
unique_ptr<__barrier_algorithm_base,
- decltype(&__destroy_barrier_algorithm_base)> __base;
+ void (*)(__barrier_algorithm_base*)> __base;
__atomic_base<ptrdiff_t> __expected_adjustment;
_CompletionF __completion;
__atomic_base<__barrier_phase_t> __phase;
return numeric_limits<ptrdiff_t>::max();
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
__barrier_base(ptrdiff_t __expected, _CompletionF __completion = _CompletionF())
: __expected(__expected), __base(__construct_barrier_algorithm_base(this->__expected),
&__destroy_barrier_algorithm_base),
__expected_adjustment(0), __completion(move(__completion)), __phase(0)
{
}
- [[nodiscard]] _LIBCPP_INLINE_VISIBILITY
+ [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
arrival_token arrive(ptrdiff_t update)
{
auto const __old_phase = __phase.load(memory_order_relaxed);
}
return __old_phase;
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void wait(arrival_token&& __old_phase) const
{
auto const __test_fn = [=]() -> bool {
};
__libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy());
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void arrive_and_drop()
{
__expected_adjustment.fetch_sub(1, memory_order_relaxed);
: __expected(__expected), __arrived(__expected), __completion(move(__completion)), __phase(false)
{
}
- [[nodiscard]] _LIBCPP_INLINE_VISIBILITY
+ [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
arrival_token arrive(ptrdiff_t update)
{
auto const __old_phase = __phase.load(memory_order_relaxed);
}
return __old_phase;
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void wait(arrival_token&& __old_phase) const
{
__phase.wait(__old_phase, memory_order_acquire);
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void arrive_and_drop()
{
__expected.fetch_sub(1, memory_order_relaxed);
: __phase_arrived_expected(__init(__count))
{
}
- [[nodiscard]] inline _LIBCPP_INLINE_VISIBILITY
+ [[nodiscard]] inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
arrival_token arrive(ptrdiff_t update)
{
auto const __inc = __arrived_unit * update;
}
return __old & __phase_bit;
}
- inline _LIBCPP_INLINE_VISIBILITY
+ inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void wait(arrival_token&& __phase) const
{
auto const __test_fn = [=]() -> bool {
};
__libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy());
}
- inline _LIBCPP_INLINE_VISIBILITY
+ inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void arrive_and_drop()
{
__phase_arrived_expected.fetch_add(__expected_unit, memory_order_relaxed);
return __barrier_base<_CompletionF>::max();
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
barrier(ptrdiff_t __count, _CompletionF __completion = _CompletionF())
: __b(__count, std::move(__completion)) {
}
barrier(barrier const&) = delete;
barrier& operator=(barrier const&) = delete;
- [[nodiscard]] _LIBCPP_INLINE_VISIBILITY
+ [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
arrival_token arrive(ptrdiff_t update = 1)
{
return __b.arrive(update);
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void wait(arrival_token&& __phase) const
{
__b.wait(std::move(__phase));
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void arrive_and_wait()
{
wait(arrive());
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void arrive_and_drop()
{
__b.arrive_and_drop();
latch(const latch&) = delete;
latch& operator=(const latch&) = delete;
- inline _LIBCPP_INLINE_VISIBILITY
+ inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void count_down(ptrdiff_t __update = 1)
{
auto const __old = __a.fetch_sub(__update, memory_order_release);
{
return 0 == __a.load(memory_order_acquire);
}
- inline _LIBCPP_INLINE_VISIBILITY
+ inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void wait() const
{
auto const __test_fn = [=]() -> bool {
};
__cxx_atomic_wait(&__a.__a_, __test_fn);
}
- inline _LIBCPP_INLINE_VISIBILITY
+ inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void arrive_and_wait(ptrdiff_t __update = 1)
{
count_down(__update);
__atomic_semaphore_base(ptrdiff_t __count) : __a(__count)
{
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void release(ptrdiff_t __update = 1)
{
if(0 < __a.fetch_add(__update, memory_order_release))
else
__a.notify_one();
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void acquire()
{
auto const __test_fn = [=]() -> bool {
__cxx_atomic_wait(&__a.__a_, __test_fn);
}
template <class Rep, class Period>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
bool try_acquire_for(chrono::duration<Rep, Period> const& __rel_time)
{
auto const __test_fn = [=]() -> bool {
counting_semaphore(const counting_semaphore&) = delete;
counting_semaphore& operator=(const counting_semaphore&) = delete;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void release(ptrdiff_t __update = 1)
{
__semaphore.release(__update);
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void acquire()
{
__semaphore.acquire();
}
template<class Rep, class Period>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
bool try_acquire_for(chrono::duration<Rep, Period> const& __rel_time)
{
return __semaphore.try_acquire_for(chrono::duration_cast<chrono::nanoseconds>(__rel_time));
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
bool try_acquire()
{
return try_acquire_for(chrono::nanoseconds::zero());
}
template <class Clock, class Duration>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
bool try_acquire_until(chrono::time_point<Clock, Duration> const& __abs_time)
{
auto const current = Clock::now();
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+// REQUIRES: verify-support
+// REQUIRES: with_system_cxx_lib=macosx
+// REQUIRES: availability=macosx10.7 || availability=macosx10.8 || availability=macosx10.9 || availability=macosx10.10 || availability=macosx10.11 || availability=macosx10.12 || availability=macosx10.13 || availability=macosx10.14 || availability=macosx10.15
+
+// Test the availability markup on the C++20 Synchronization Library
+// additions to <atomic>.
+
+#include <atomic>
+
+
+int main(int, char**)
+{
+ {
+ std::atomic<int> i(3);
+ std::memory_order m = std::memory_order_relaxed;
+
+ i.wait(4); // expected-error {{is unavailable}}
+ i.wait(4, m); // expected-error {{is unavailable}}
+ i.notify_one(); // expected-error {{is unavailable}}
+ i.notify_all(); // expected-error {{is unavailable}}
+
+ std::atomic_wait(&i, 4); // expected-error {{is unavailable}}
+ std::atomic_wait_explicit(&i, 4, m); // expected-error {{is unavailable}}
+ std::atomic_notify_one(&i); // expected-error {{is unavailable}}
+ std::atomic_notify_all(&i); // expected-error {{is unavailable}}
+ }
+
+ {
+ std::atomic<int> volatile i(3);
+ std::memory_order m = std::memory_order_relaxed;
+
+ i.wait(4); // expected-error {{is unavailable}}
+ i.wait(4, m); // expected-error {{is unavailable}}
+ i.notify_one(); // expected-error {{is unavailable}}
+ i.notify_all(); // expected-error {{is unavailable}}
+
+ std::atomic_wait(&i, 4); // expected-error {{is unavailable}}
+ std::atomic_wait_explicit(&i, 4, m); // expected-error {{is unavailable}}
+ std::atomic_notify_one(&i); // expected-error {{is unavailable}}
+ std::atomic_notify_all(&i); // expected-error {{is unavailable}}
+ }
+
+ {
+ std::atomic_flag flag;
+ bool b = false;
+ std::memory_order m = std::memory_order_relaxed;
+ flag.wait(b); // expected-error {{is unavailable}}
+ flag.wait(b, m); // expected-error {{is unavailable}}
+ flag.notify_one(); // expected-error {{is unavailable}}
+ flag.notify_all(); // expected-error {{is unavailable}}
+
+ std::atomic_flag_wait(&flag, b); // expected-error {{is unavailable}}
+ std::atomic_flag_wait_explicit(&flag, b, m); // expected-error {{is unavailable}}
+ std::atomic_flag_notify_one(&flag); // expected-error {{is unavailable}}
+ std::atomic_flag_notify_all(&flag); // expected-error {{is unavailable}}
+ }
+
+ {
+ std::atomic_flag volatile flag;
+ bool b = false;
+ std::memory_order m = std::memory_order_relaxed;
+ flag.wait(b); // expected-error {{is unavailable}}
+ flag.wait(b, m); // expected-error {{is unavailable}}
+ flag.notify_one(); // expected-error {{is unavailable}}
+ flag.notify_all(); // expected-error {{is unavailable}}
+
+ std::atomic_flag_wait(&flag, b); // expected-error {{is unavailable}}
+ std::atomic_flag_wait_explicit(&flag, b, m); // expected-error {{is unavailable}}
+ std::atomic_flag_notify_one(&flag); // expected-error {{is unavailable}}
+ std::atomic_flag_notify_all(&flag); // expected-error {{is unavailable}}
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+// REQUIRES: verify-support
+// REQUIRES: with_system_cxx_lib=macosx
+// REQUIRES: availability=macosx10.7 || availability=macosx10.8 || availability=macosx10.9 || availability=macosx10.10 || availability=macosx10.11 || availability=macosx10.12 || availability=macosx10.13 || availability=macosx10.14 || availability=macosx10.15
+
+// Test the availability markup on std::barrier.
+
+#include <barrier>
+#include <utility>
+
+struct CompletionF {
+ void operator()() { }
+};
+
+int main(int, char**)
+{
+ // Availability markup on std::barrier<>
+ {
+ std::barrier<> b(10); // expected-error {{is unavailable}}
+ auto token = b.arrive(); // expected-error {{is unavailable}}
+ (void)b.arrive(10); // expected-error {{is unavailable}}
+ b.wait(std::move(token)); // expected-error {{is unavailable}}
+ b.arrive_and_wait(); // expected-error {{is unavailable}}
+ b.arrive_and_drop(); // expected-error {{is unavailable}}
+ }
+
+ // Availability markup on std::barrier<CompletionF> with non-default CompletionF
+ {
+ std::barrier<CompletionF> b(10); // expected-error {{is unavailable}}
+ auto token = b.arrive(); // expected-error {{is unavailable}}
+ (void)b.arrive(10); // expected-error {{is unavailable}}
+ b.wait(std::move(token)); // expected-error {{is unavailable}}
+ b.arrive_and_wait(); // expected-error {{is unavailable}}
+ b.arrive_and_drop(); // expected-error {{is unavailable}}
+ }
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+// REQUIRES: verify-support
+// REQUIRES: with_system_cxx_lib=macosx
+// REQUIRES: availability=macosx10.7 || availability=macosx10.8 || availability=macosx10.9 || availability=macosx10.10 || availability=macosx10.11 || availability=macosx10.12 || availability=macosx10.13 || availability=macosx10.14 || availability=macosx10.15
+
+// Test the availability markup on std::latch.
+
+#include <latch>
+
+
+int main(int, char**)
+{
+ std::latch latch(10);
+ latch.count_down(); // expected-error {{is unavailable}}
+ latch.count_down(3); // expected-error {{is unavailable}}
+ latch.wait(); // expected-error {{is unavailable}}
+ latch.arrive_and_wait(); // expected-error {{is unavailable}}
+ latch.arrive_and_wait(3); // expected-error {{is unavailable}}
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+// REQUIRES: verify-support
+// REQUIRES: with_system_cxx_lib=macosx
+// REQUIRES: availability=macosx10.7 || availability=macosx10.8 || availability=macosx10.9 || availability=macosx10.10 || availability=macosx10.11 || availability=macosx10.12 || availability=macosx10.13 || availability=macosx10.14 || availability=macosx10.15
+
+// Test the availability markup on std::counting_semaphore and std::binary_semaphore.
+
+#include <chrono>
+#include <semaphore>
+
+
+int main(int, char**)
+{
+ {
+ // Tests for std::counting_semaphore with non-default template argument
+ std::counting_semaphore<20> sem(10);
+ sem.release(); // expected-error {{is unavailable}}
+ sem.release(5); // expected-error {{is unavailable}}
+ sem.acquire(); // expected-error {{is unavailable}}
+ sem.try_acquire_for(std::chrono::milliseconds{3}); // expected-error 1-2 {{is unavailable}}
+ sem.try_acquire(); // expected-error {{is unavailable}}
+ sem.try_acquire_until(std::chrono::steady_clock::now()); // expected-error 1-2 {{is unavailable}}
+ }
+ {
+ // Tests for std::counting_semaphore with default template argument
+ std::counting_semaphore<> sem(10);
+ sem.release(); // expected-error {{is unavailable}}
+ sem.release(5); // expected-error {{is unavailable}}
+ sem.acquire(); // expected-error {{is unavailable}}
+ sem.try_acquire_for(std::chrono::milliseconds{3}); // expected-error 1-2 {{is unavailable}}
+ sem.try_acquire(); // expected-error {{is unavailable}}
+ sem.try_acquire_until(std::chrono::steady_clock::now()); // expected-error 1-2 {{is unavailable}}
+ }
+ {
+ // Tests for std::binary_semaphore
+ std::binary_semaphore sem(10);
+ sem.release(); // expected-error {{is unavailable}}
+ sem.release(5); // expected-error {{is unavailable}}
+ sem.acquire(); // expected-error {{is unavailable}}
+ sem.try_acquire_for(std::chrono::milliseconds{3}); // expected-error 1-2 {{is unavailable}}
+ sem.try_acquire(); // expected-error {{is unavailable}}
+ sem.try_acquire_until(std::chrono::steady_clock::now()); // expected-error 1-2 {{is unavailable}}
+ }
+}