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 clear(memory_order = memory_order_seq_cst); 17 // void clear(memory_order = memory_order_seq_cst) volatile; 18 19 #include <atomic> 20 #include <cassert> 21 main()22int main() 23 { 24 { 25 std::atomic_flag f = ATOMIC_FLAG_INIT; 26 f.test_and_set(); 27 f.clear(); 28 assert(f.test_and_set() == 0); 29 } 30 { 31 std::atomic_flag f = ATOMIC_FLAG_INIT; 32 f.test_and_set(); 33 f.clear(std::memory_order_relaxed); 34 assert(f.test_and_set() == 0); 35 } 36 { 37 std::atomic_flag f = ATOMIC_FLAG_INIT; 38 f.test_and_set(); 39 f.clear(std::memory_order_release); 40 assert(f.test_and_set() == 0); 41 } 42 { 43 std::atomic_flag f = ATOMIC_FLAG_INIT; 44 f.test_and_set(); 45 f.clear(std::memory_order_seq_cst); 46 assert(f.test_and_set() == 0); 47 } 48 { 49 volatile std::atomic_flag f = ATOMIC_FLAG_INIT; 50 f.test_and_set(); 51 f.clear(); 52 assert(f.test_and_set() == 0); 53 } 54 { 55 volatile std::atomic_flag f = ATOMIC_FLAG_INIT; 56 f.test_and_set(); 57 f.clear(std::memory_order_relaxed); 58 assert(f.test_and_set() == 0); 59 } 60 { 61 volatile std::atomic_flag f = ATOMIC_FLAG_INIT; 62 f.test_and_set(); 63 f.clear(std::memory_order_release); 64 assert(f.test_and_set() == 0); 65 } 66 { 67 volatile std::atomic_flag f = ATOMIC_FLAG_INIT; 68 f.test_and_set(); 69 f.clear(std::memory_order_seq_cst); 70 assert(f.test_and_set() == 0); 71 } 72 } 73