Skip to content

Commit 271c27b

Browse files
committed
Try to fix issues with long long
1 parent 96b358f commit 271c27b

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

libcxx/test/support/atomic_helpers.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,15 @@ constexpr bool msvc_is_lock_free_macro_value() {
5555
# pragma clang diagnostic ignored "-Wc++11-extensions"
5656
#endif
5757

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.
6058
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))
6267

6368
template <class T>
6469
struct LockFreeStatusInfo {
@@ -78,6 +83,8 @@ struct LockFreeStatusInfo {
7883
static const bool status_known = LockFreeStatusInfo::value != LockFreeStatus::unknown;
7984
};
8085

86+
#undef COMPARE_TYPES
87+
8188
// This doesn't work in C++03 due to issues with scoped enumerations. Just disable the test.
8289
#if TEST_STD_VER >= 11
8390
static_assert(LockFreeStatusInfo<char>::status_known, "");

0 commit comments

Comments
 (0)