Home | History | Annotate | Download | only in atomics.types.operations.req
      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 // template <class T>
     15 //     bool
     16 //     atomic_is_lock_free(const volatile atomic<T>* obj);
     17 //
     18 // template <class T>
     19 //     bool
     20 //     atomic_is_lock_free(const atomic<T>* obj);
     21 
     22 #include <atomic>
     23 #include <cassert>
     24 
     25 #include "atomic_helpers.h"
     26 
     27 template <class T>
     28 struct TestFn {
     29   void operator()() const {
     30     typedef std::atomic<T> A;
     31     A t;
     32     bool b1 = std::atomic_is_lock_free(static_cast<const A*>(&t));
     33     volatile A vt;
     34     bool b2 = std::atomic_is_lock_free(static_cast<const volatile A*>(&vt));
     35     assert(b1 == b2);
     36   }
     37 };
     38 
     39 struct A
     40 {
     41     char _[4];
     42 };
     43 
     44 int main()
     45 {
     46     TestFn<A>()();
     47     TestEachAtomicType<TestFn>()();
     48 }
     49