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
25template <class T>
26void
27test()
28{
29    typedef std::atomic<T> A;
30    A t;
31    bool b1 = std::atomic_is_lock_free(static_cast<const A*>(&t));
32    volatile A vt;
33    bool b2 = std::atomic_is_lock_free(static_cast<const volatile A*>(&vt));
34    assert(b1 == b2);
35}
36
37struct A
38{
39    char _[4];
40};
41
42int main()
43{
44    test<A>();
45    test<char>();
46    test<signed char>();
47    test<unsigned char>();
48    test<short>();
49    test<unsigned short>();
50    test<int>();
51    test<unsigned int>();
52    test<long>();
53    test<unsigned long>();
54    test<long long>();
55    test<unsigned long long>();
56    test<wchar_t>();
57#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
58    test<char16_t>();
59    test<char32_t>();
60#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
61    test<int*>();
62    test<const int*>();
63}
64