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 // UNSUPPORTED: libcpp-has-no-threads
11 
12 // <atomic>
13 
14 // struct atomic_flag
15 
16 // void atomic_flag_clear(volatile atomic_flag*);
17 // void atomic_flag_clear(atomic_flag*);
18 
19 #include <atomic>
20 #include <cassert>
21 
main()22 int main()
23 {
24     {
25         std::atomic_flag f;
26         f.clear();
27         f.test_and_set();
28         atomic_flag_clear(&f);
29         assert(f.test_and_set() == 0);
30     }
31     {
32         volatile std::atomic_flag f;
33         f.clear();
34         f.test_and_set();
35         atomic_flag_clear(&f);
36         assert(f.test_and_set() == 0);
37     }
38 }
39