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 // atomic_flag() = default; 17*0a6a1f1dSLionel Sambuc 18*0a6a1f1dSLionel Sambuc #include <atomic> 19*0a6a1f1dSLionel Sambuc #include <new> 20*0a6a1f1dSLionel Sambuc #include <cassert> 21*0a6a1f1dSLionel Sambuc main()22*0a6a1f1dSLionel Sambucint main() 23*0a6a1f1dSLionel Sambuc { 24*0a6a1f1dSLionel Sambuc std::atomic_flag f; 25*0a6a1f1dSLionel Sambuc f.clear(); 26*0a6a1f1dSLionel Sambuc assert(f.test_and_set() == 0); 27*0a6a1f1dSLionel Sambuc { 28*0a6a1f1dSLionel Sambuc typedef std::atomic_flag A; 29*0a6a1f1dSLionel Sambuc _ALIGNAS_TYPE(A) char storage[sizeof(A)] = {1}; 30*0a6a1f1dSLionel Sambuc A& zero = *new (storage) A(); 31*0a6a1f1dSLionel Sambuc assert(!zero.test_and_set()); 32*0a6a1f1dSLionel Sambuc zero.~A(); 33*0a6a1f1dSLionel Sambuc } 34*0a6a1f1dSLionel Sambuc } 35