-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<memory>: Fix atomic smart pointers array type interaction #1339
Changes from all commits
975ac24
0fd8850
6fa66d0
3946766
f452d2d
b078b52
8a2e4bb
50cca4e
0f3da1f
dccfdc1
44ef6a8
af7874f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,7 +108,8 @@ void test_notify_all_notifies_all(UnderlyingType old_value, const UnderlyingType | |
template <class UnderlyingType> | ||
void test_notify_all_notifies_all_ptr(UnderlyingType old_value, const UnderlyingType new_value, | ||
const std::chrono::steady_clock::duration waiting_duration) { | ||
test_notify_all_notifies_all_impl<std::atomic, UnderlyingType>(old_value, new_value, waiting_duration); | ||
// increased waiting_duration because timing assumption might not hold for atomic smart pointers | ||
test_notify_all_notifies_all_impl<std::atomic, UnderlyingType>(old_value, new_value, 3 * waiting_duration); | ||
Comment on lines
+111
to
+112
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm slightly concerned about this change because the test suite should never contain timing assumptions that could lead to sporadic failures. That said, no change requested, because this is clearly a pre-existing issue. |
||
} | ||
|
||
|
||
|
@@ -228,6 +229,21 @@ inline void test_atomic_wait() { | |
test_atomic_wait_func_ptr(std::make_shared<int>('a'), std::make_shared<int>('a'), waiting_duration); | ||
test_atomic_wait_func_ptr( | ||
std::weak_ptr{std::make_shared<int>('a')}, std::weak_ptr{std::make_shared<int>('a')}, waiting_duration); | ||
test_atomic_wait_func_ptr(std::make_shared<int[]>(0), std::make_shared<int[]>(0), waiting_duration); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No change requested: I note that the zero-runtime-length arrays being used in the test cases are unusual; however, I believe this is conforming, and the code also tests one-element arrays, so I have no objection to this (even if I would have used non-zero numbers for all). |
||
test_atomic_wait_func_ptr( | ||
std::weak_ptr{std::make_shared<int[]>(0)}, std::weak_ptr{std::make_shared<int[]>(0)}, waiting_duration); | ||
test_atomic_wait_func_ptr(std::make_shared<int[]>(1), std::make_shared<int[]>(1), waiting_duration); | ||
test_atomic_wait_func_ptr( | ||
std::weak_ptr{std::make_shared<int[]>(1)}, std::weak_ptr{std::make_shared<int[]>(1)}, waiting_duration); | ||
test_atomic_wait_func_ptr(std::make_shared<int[2]>(), std::make_shared<int[2]>(), waiting_duration); | ||
test_atomic_wait_func_ptr( | ||
std::weak_ptr{std::make_shared<int[2]>()}, std::weak_ptr{std::make_shared<int[2]>()}, waiting_duration); | ||
test_atomic_wait_func_ptr(std::make_shared<int[][2]>(2), std::make_shared<int[][2]>(2), waiting_duration); | ||
test_atomic_wait_func_ptr( | ||
std::weak_ptr{std::make_shared<int[][2]>(2)}, std::weak_ptr{std::make_shared<int[][2]>(2)}, waiting_duration); | ||
test_atomic_wait_func_ptr(std::make_shared<int[2][2]>(), std::make_shared<int[2][2]>(), waiting_duration); | ||
test_atomic_wait_func_ptr( | ||
std::weak_ptr{std::make_shared<int[2][2]>()}, std::weak_ptr{std::make_shared<int[2][2]>()}, waiting_duration); | ||
|
||
test_notify_all_notifies_all<char>(1, 2, waiting_duration); | ||
test_notify_all_notifies_all<signed char>(1, 2, waiting_duration); | ||
|
@@ -248,6 +264,25 @@ inline void test_atomic_wait() { | |
test_notify_all_notifies_all(three_chars{1, 1, 3}, three_chars{1, 2, 3}, waiting_duration); | ||
test_notify_all_notifies_all(big_char_like{'a'}, big_char_like{'b'}, waiting_duration); | ||
|
||
test_notify_all_notifies_all_ptr(std::make_shared<int>('a'), std::make_shared<int>('a'), waiting_duration); | ||
test_notify_all_notifies_all_ptr( | ||
std::weak_ptr{std::make_shared<int>('a')}, std::weak_ptr{std::make_shared<int>('a')}, waiting_duration); | ||
Comment on lines
+267
to
+269
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No change requested: Nice catch, |
||
test_notify_all_notifies_all_ptr(std::make_shared<int[]>(0), std::make_shared<int[]>(0), waiting_duration); | ||
test_notify_all_notifies_all_ptr( | ||
std::weak_ptr{std::make_shared<int[]>(0)}, std::weak_ptr{std::make_shared<int[]>(0)}, waiting_duration); | ||
test_notify_all_notifies_all_ptr(std::make_shared<int[]>(1), std::make_shared<int[]>(1), waiting_duration); | ||
test_notify_all_notifies_all_ptr( | ||
std::weak_ptr{std::make_shared<int[]>(1)}, std::weak_ptr{std::make_shared<int[]>(1)}, waiting_duration); | ||
test_notify_all_notifies_all_ptr(std::make_shared<int[2]>(), std::make_shared<int[2]>(), waiting_duration); | ||
test_notify_all_notifies_all_ptr( | ||
std::weak_ptr{std::make_shared<int[2]>()}, std::weak_ptr{std::make_shared<int[2]>()}, waiting_duration); | ||
test_notify_all_notifies_all_ptr(std::make_shared<int[][2]>(2), std::make_shared<int[][2]>(2), waiting_duration); | ||
test_notify_all_notifies_all_ptr( | ||
std::weak_ptr{std::make_shared<int[][2]>(2)}, std::weak_ptr{std::make_shared<int[][2]>(2)}, waiting_duration); | ||
test_notify_all_notifies_all_ptr(std::make_shared<int[2][2]>(), std::make_shared<int[2][2]>(), waiting_duration); | ||
test_notify_all_notifies_all_ptr( | ||
std::weak_ptr{std::make_shared<int[2][2]>()}, std::weak_ptr{std::make_shared<int[2][2]>()}, waiting_duration); | ||
|
||
#ifndef __clang__ // TRANSITION, LLVM-46685 | ||
test_pad_bits<with_padding_bits<2>>(waiting_duration); | ||
test_pad_bits<with_padding_bits<4>>(waiting_duration); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No change requested: Regarding the ABI implications that @strega-nil-ms mentioned in #1339 (review) - while changing data members is always concerning from an ABI perspective, I agree that the actual bits being stored are the same. Additionally, the previous code would generally fail to compile for simple cases like
store()
, which indicates that we shouldn't have to worry about mismatch issues. (The one time we can make unrestricted changes to layout is when the code couldn't compile at all before - this is not quite "wouldn't compile at all" but close.)