@@ -55,10 +55,15 @@ constexpr bool msvc_is_lock_free_macro_value() {
55
55
# pragma clang diagnostic ignored "-Wc++11-extensions"
56
56
#endif
57
57
58
- // The entire LockFreeStatus exists entirely to work around the support for C++03, which many of our atomic tests
59
- // run under. This is a bit of a hack, but it's the best we can do.
60
58
enum class LockFreeStatus : int { unknown = -1 , never = 0 , sometimes = 1 , always = 2 };
61
- #define COMPARE_TYPES (T1, T2 ) (sizeof (T1) == sizeof (T2) && TEST_ALIGNOF(T1) >= TEST_ALIGNOF(T2))
59
+
60
+ // We should really be checking whether the alignment of T is greater-than-or-equal-to the alignment required
61
+ // for T to be atomic, but this is basically impossible to implement portably. Instead, we assume that any type
62
+ // aligned to at least its size is going to be atomic if there exists atomic operations for that size at all,
63
+ // which is true on most platforms. This technically reduces our test coverage in the sense that if a type has
64
+ // an alignment requirement less than its size but could still be made lockfree, LockFreeStatusInfo will report
65
+ // that we don't know whether it is lockfree or not.
66
+ #define COMPARE_TYPES (T, FundamentalT ) (sizeof (T) == sizeof (FundamentalT) && TEST_ALIGNOF(T) >= sizeof (T))
62
67
63
68
template <class T >
64
69
struct LockFreeStatusInfo {
@@ -78,6 +83,8 @@ struct LockFreeStatusInfo {
78
83
static const bool status_known = LockFreeStatusInfo::value != LockFreeStatus::unknown;
79
84
};
80
85
86
+ #undef COMPARE_TYPES
87
+
81
88
// This doesn't work in C++03 due to issues with scoped enumerations. Just disable the test.
82
89
#if TEST_STD_VER >= 11
83
90
static_assert (LockFreeStatusInfo<char >::status_known, " " );
0 commit comments