1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // UNSUPPORTED: c++98, c++03 10 // REQUIRES: verify-support 11 // REQUIRES: with_system_cxx_lib=macosx 12 // REQUIRES: availability=macosx10.9 || availability=macosx10.10 || availability=macosx10.11 || availability=macosx10.12 || availability=macosx10.13 || availability=macosx10.14 || availability=macosx10.15 13 14 // Test the availability markup on std::counting_semaphore and std::binary_semaphore. 15 16 #include <chrono> 17 #include <semaphore> 18 19 20 int main(int, char**) 21 { 22 { 23 // Tests for std::counting_semaphore with non-default template argument 24 std::counting_semaphore<20> sem(10); 25 sem.release(); // expected-error {{is unavailable}} 26 sem.release(5); // expected-error {{is unavailable}} 27 sem.acquire(); // expected-error {{is unavailable}} 28 sem.try_acquire_for(std::chrono::milliseconds{3}); // expected-error 1-2 {{is unavailable}} 29 sem.try_acquire(); // expected-error {{is unavailable}} 30 sem.try_acquire_until(std::chrono::steady_clock::now()); // expected-error 1-2 {{is unavailable}} 31 } 32 { 33 // Tests for std::counting_semaphore with default template argument 34 std::counting_semaphore<> sem(10); 35 sem.release(); // expected-error {{is unavailable}} 36 sem.release(5); // expected-error {{is unavailable}} 37 sem.acquire(); // expected-error {{is unavailable}} 38 sem.try_acquire_for(std::chrono::milliseconds{3}); // expected-error 1-2 {{is unavailable}} 39 sem.try_acquire(); // expected-error {{is unavailable}} 40 sem.try_acquire_until(std::chrono::steady_clock::now()); // expected-error 1-2 {{is unavailable}} 41 } 42 { 43 // Tests for std::binary_semaphore 44 std::binary_semaphore sem(10); 45 sem.release(); // expected-error {{is unavailable}} 46 sem.release(5); // expected-error {{is unavailable}} 47 sem.acquire(); // expected-error {{is unavailable}} 48 sem.try_acquire_for(std::chrono::milliseconds{3}); // expected-error 1-2 {{is unavailable}} 49 sem.try_acquire(); // expected-error {{is unavailable}} 50 sem.try_acquire_until(std::chrono::steady_clock::now()); // expected-error 1-2 {{is unavailable}} 51 } 52 } 53