1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <atomic>
11 
12 // struct atomic_flag
13 
14 // void atomic_flag_clear_explicit(volatile atomic_flag*, memory_order);
15 // void atomic_flag_clear_explicit(atomic_flag*, memory_order);
16 
17 #include <atomic>
18 #include <cassert>
19 
main()20 int main()
21 {
22     {
23         std::atomic_flag f;
24         f.test_and_set();
25         atomic_flag_clear_explicit(&f, std::memory_order_relaxed);
26         assert(f.test_and_set() == 0);
27     }
28     {
29         std::atomic_flag f;
30         f.test_and_set();
31         atomic_flag_clear_explicit(&f, std::memory_order_release);
32         assert(f.test_and_set() == 0);
33     }
34     {
35         std::atomic_flag f;
36         f.test_and_set();
37         atomic_flag_clear_explicit(&f, std::memory_order_seq_cst);
38         assert(f.test_and_set() == 0);
39     }
40     {
41         volatile std::atomic_flag f;
42         f.test_and_set();
43         atomic_flag_clear_explicit(&f, std::memory_order_relaxed);
44         assert(f.test_and_set() == 0);
45     }
46     {
47         volatile std::atomic_flag f;
48         f.test_and_set();
49         atomic_flag_clear_explicit(&f, std::memory_order_release);
50         assert(f.test_and_set() == 0);
51     }
52     {
53         volatile std::atomic_flag f;
54         f.test_and_set();
55         atomic_flag_clear_explicit(&f, std::memory_order_seq_cst);
56         assert(f.test_and_set() == 0);
57     }
58 }
59