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++03, c++11
10 // REQUIRES: with_system_cxx_lib=macosx10.9 || \
11 // REQUIRES: with_system_cxx_lib=macosx10.10 || \
12 // REQUIRES: with_system_cxx_lib=macosx10.11 || \
13 // REQUIRES: with_system_cxx_lib=macosx10.12 || \
14 // REQUIRES: with_system_cxx_lib=macosx10.13 || \
15 // REQUIRES: with_system_cxx_lib=macosx10.14 || \
16 // REQUIRES: with_system_cxx_lib=macosx10.15
17 
18 // Test the availability markup on std::counting_semaphore and std::binary_semaphore.
19 
20 #include <chrono>
21 #include <semaphore>
22 
23 
24 int main(int, char**)
25 {
26     {
27         // Tests for std::counting_semaphore with non-default template argument
28         std::counting_semaphore<20> sem(10);
29         sem.release(); // expected-error {{is unavailable}}
30         sem.release(5); // expected-error {{is unavailable}}
31         sem.acquire(); // expected-error {{is unavailable}}
32         sem.try_acquire_for(std::chrono::milliseconds{3}); // expected-error 1-2 {{is unavailable}}
33         sem.try_acquire(); // expected-error {{is unavailable}}
34         sem.try_acquire_until(std::chrono::steady_clock::now()); // expected-error 1-2 {{is unavailable}}
35     }
36     {
37         // Tests for std::counting_semaphore with default template argument
38         std::counting_semaphore<> sem(10);
39         sem.release(); // expected-error {{is unavailable}}
40         sem.release(5); // expected-error {{is unavailable}}
41         sem.acquire(); // expected-error {{is unavailable}}
42         sem.try_acquire_for(std::chrono::milliseconds{3}); // expected-error 1-2 {{is unavailable}}
43         sem.try_acquire(); // expected-error {{is unavailable}}
44         sem.try_acquire_until(std::chrono::steady_clock::now()); // expected-error 1-2 {{is unavailable}}
45     }
46     {
47         // Tests for std::binary_semaphore
48         std::binary_semaphore sem(10);
49         sem.release(); // expected-error {{is unavailable}}
50         sem.release(5); // expected-error {{is unavailable}}
51         sem.acquire(); // expected-error {{is unavailable}}
52         sem.try_acquire_for(std::chrono::milliseconds{3}); // expected-error 1-2 {{is unavailable}}
53         sem.try_acquire(); // expected-error {{is unavailable}}
54         sem.try_acquire_until(std::chrono::steady_clock::now()); // expected-error 1-2 {{is unavailable}}
55     }
56 }
57