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