Debian Codegraph @

libcxx/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp

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