blob: 6cbc0c35c0f5b28516c8a8b53a61f87de0979b59 [file] [log] [blame]
Eric Fiselierfa1e5db2016-01-19 21:52:04 +00001//===----------------------------------------------------------------------===//
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 Fiselier00f4a492015-08-19 17:21:46 +000010#ifndef ATOMIC_HELPERS_H
11#define ATOMIC_HELPERS_H
12
13#include <cassert>
14
15#include "test_macros.h"
16
17struct 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
27template < template <class TestArg> class TestFunctor >
28struct 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
49template < template <class TestArg> class TestFunctor >
50struct 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