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