Eric Fiselier | fa1e5db | 2016-01-19 21:52:04 +0000 | [diff] [blame] | 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 | |
Eric Fiselier | 00f4a49 | 2015-08-19 17:21:46 +0000 | [diff] [blame] | 10 | #ifndef ATOMIC_HELPERS_H |
| 11 | #define ATOMIC_HELPERS_H |
| 12 | |
| 13 | #include <cassert> |
| 14 | |
| 15 | #include "test_macros.h" |
| 16 | |
| 17 | struct UserAtomicType |
| 18 | { |
| 19 | int i; |
| 20 | |
| 21 | explicit UserAtomicType(int d = 0) TEST_NOEXCEPT : i(d) {} |
| 22 | |
| 23 | friend bool operator==(const UserAtomicType& x, const UserAtomicType& y) |
| 24 | { return x.i == y.i; } |
| 25 | }; |
| 26 | |
| 27 | template < template <class TestArg> class TestFunctor > |
| 28 | struct TestEachIntegralType { |
| 29 | void operator()() const { |
| 30 | TestFunctor<char>()(); |
| 31 | TestFunctor<signed char>()(); |
| 32 | TestFunctor<unsigned char>()(); |
| 33 | TestFunctor<short>()(); |
| 34 | TestFunctor<unsigned short>()(); |
| 35 | TestFunctor<int>()(); |
| 36 | TestFunctor<unsigned int>()(); |
| 37 | TestFunctor<long>()(); |
| 38 | TestFunctor<unsigned long>()(); |
| 39 | TestFunctor<long long>()(); |
| 40 | TestFunctor<unsigned long long>()(); |
| 41 | TestFunctor<wchar_t>(); |
| 42 | #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS |
| 43 | TestFunctor<char16_t>()(); |
| 44 | TestFunctor<char32_t>()(); |
| 45 | #endif |
| 46 | } |
| 47 | }; |
| 48 | |
| 49 | template < template <class TestArg> class TestFunctor > |
| 50 | struct TestEachAtomicType { |
| 51 | void operator()() const { |
| 52 | TestEachIntegralType<TestFunctor>()(); |
| 53 | TestFunctor<UserAtomicType>()(); |
| 54 | TestFunctor<int*>()(); |
| 55 | TestFunctor<const int*>()(); |
| 56 | } |
| 57 | }; |
| 58 | |
| 59 | |
| 60 | #endif // ATOMIC_HELPER_H |