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