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// bool atomic_flag_test_and_set(volatile atomic_flag*);
15// bool atomic_flag_test_and_set(atomic_flag*);
16
17#include <atomic>
18#include <cassert>
19
20int main()
21{
22    {
23        std::atomic_flag f;
24        f.clear();
25        assert(atomic_flag_test_and_set(&f) == 0);
26        assert(f.test_and_set() == 1);
27    }
28    {
29        volatile std::atomic_flag f;
30        f.clear();
31        assert(atomic_flag_test_and_set(&f) == 0);
32        assert(f.test_and_set() == 1);
33    }
34}
35