* libstdc++: Make atomic<T*>::wait() const [PR102994]
@ 2021-11-05 21:44 Thomas Rodgers
2021-11-05 21:48 ` Jonathan Wakely
0 siblings, 1 reply; 8+ messages in thread
From: Thomas Rodgers @ 2021-11-05 21:44 UTC (permalink / raw)
To: libstdc++, gcc Patches
[-- Attachment #1: Type: text/plain, Size: 1 bytes --]
[-- Attachment #2: 0001-libstdc-Make-atomic-T-wait-const-PR102994.patch --]
[-- Type: text/x-patch, Size: 1109 bytes --]
From 360c094a0725bb0cc444115c0377db10e5e9ae1f Mon Sep 17 00:00:00 2001
From: Thomas Rodgers <rodgert@twrodgers.com>
Date: Fri, 5 Nov 2021 14:30:24 -0700
Subject: [PATCH] libstdc++: Make atomic<T*>::wait() const [PR102994]
This was an oversight in the original commit adding wait/notify
to atomic<T>.
libstdc++-v3/ChangeLog:
PR libstdc++/102994
* include/bits/atomic_base.h (__atomic_base<_PTp*>::wait())
add const qualifier.
---
libstdc++-v3/include/bits/atomic_base.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libstdc++-v3/include/bits/atomic_base.h b/libstdc++-v3/include/bits/atomic_base.h
index 9e18aadadaf..a104adc1a10 100644
--- a/libstdc++-v3/include/bits/atomic_base.h
+++ b/libstdc++-v3/include/bits/atomic_base.h
@@ -893,7 +893,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __cpp_lib_atomic_wait
_GLIBCXX_ALWAYS_INLINE void
wait(__pointer_type __old,
- memory_order __m = memory_order_seq_cst) noexcept
+ memory_order __m = memory_order_seq_cst) const noexcept
{
std::__atomic_wait_address_v(&_M_p, __old,
[__m, this]
--
2.31.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: libstdc++: Make atomic<T*>::wait() const [PR102994]
2021-11-05 21:44 libstdc++: Make atomic<T*>::wait() const [PR102994] Thomas Rodgers
@ 2021-11-05 21:48 ` Jonathan Wakely
2021-11-05 23:46 ` Jonathan Wakely
0 siblings, 1 reply; 8+ messages in thread
From: Jonathan Wakely @ 2021-11-05 21:48 UTC (permalink / raw)
To: Thomas Rodgers; +Cc: libstdc++, gcc Patches
OK, thanks.
On Fri, 5 Nov 2021 at 21:46, Thomas Rodgers via Libstdc++ <
libstdc++@gcc.gnu.org> wrote:
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: libstdc++: Make atomic<T*>::wait() const [PR102994]
2021-11-05 21:48 ` Jonathan Wakely
@ 2021-11-05 23:46 ` Jonathan Wakely
2021-11-09 18:09 ` Thomas Rodgers
0 siblings, 1 reply; 8+ messages in thread
From: Jonathan Wakely @ 2021-11-05 23:46 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: Thomas Rodgers, libstdc++, gcc Patches
On Fri, 5 Nov 2021 at 21:51, Jonathan Wakely via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> OK, thanks.
Actually, we should really have a test to verify it can be called on a
const object. Please add something when you commit, it can be dumb and
simple, it just needs to verify that it can be called.
>
>
> On Fri, 5 Nov 2021 at 21:46, Thomas Rodgers via Libstdc++ <
> libstdc++@gcc.gnu.org> wrote:
>
> >
> >
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: libstdc++: Make atomic<T*>::wait() const [PR102994]
2021-11-05 23:46 ` Jonathan Wakely
@ 2021-11-09 18:09 ` Thomas Rodgers
2021-11-09 19:40 ` Jonathan Wakely
0 siblings, 1 reply; 8+ messages in thread
From: Thomas Rodgers @ 2021-11-09 18:09 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: Jonathan Wakely, libstdc++, gcc Patches
[-- Attachment #1: Type: text/plain, Size: 553 bytes --]
Revised patch attached.
On Fri, Nov 5, 2021 at 4:46 PM Jonathan Wakely <jwakely.gcc@gmail.com>
wrote:
> On Fri, 5 Nov 2021 at 21:51, Jonathan Wakely via Libstdc++
> <libstdc++@gcc.gnu.org> wrote:
> >
> > OK, thanks.
>
> Actually, we should really have a test to verify it can be called on a
> const object. Please add something when you commit, it can be dumb and
> simple, it just needs to verify that it can be called.
>
>
> >
> >
> > On Fri, 5 Nov 2021 at 21:46, Thomas Rodgers via Libstdc++ <
> > libstdc++@gcc.gnu.org> wrote:
> >
> > >
> > >
>
>
[-- Attachment #2: 0001-libstdc-Make-atomic-T-wait-const-PR102994.patch --]
[-- Type: text/x-patch, Size: 2571 bytes --]
From 69737be7cda5328eb0f67c9725c3b691bcb6cb2f Mon Sep 17 00:00:00 2001
From: Thomas Rodgers <rodgert@twrodgers.com>
Date: Tue, 9 Nov 2021 09:42:49 -0800
Subject: [PATCH] libstdc++: Make atomic<T*>::wait() const [PR102994]
This was an oversight in the original commit adding wait/notify
to atomic<T>.
libstdc++-v3/ChangeLog:
PR libstdc++/102994
* include/bits/atomic_base.h (__atomic_base<_PTp*>::wait()):
Add const qualifier.
* include/std/atomic (atomic<_Tp*>::wait()):
Likewise.
* testsuite/29_atomics/atomic/wait_notify/102994.cc:
New test.
---
libstdc++-v3/include/bits/atomic_base.h | 2 +-
libstdc++-v3/include/std/atomic | 4 ++--
.../testsuite/29_atomics/atomic/wait_notify/102994.cc | 11 +++++++++++
3 files changed, 14 insertions(+), 3 deletions(-)
create mode 100644 libstdc++-v3/testsuite/29_atomics/atomic/wait_notify/102994.cc
diff --git a/libstdc++-v3/include/bits/atomic_base.h b/libstdc++-v3/include/bits/atomic_base.h
index 9e18aadadaf..a104adc1a10 100644
--- a/libstdc++-v3/include/bits/atomic_base.h
+++ b/libstdc++-v3/include/bits/atomic_base.h
@@ -893,7 +893,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __cpp_lib_atomic_wait
_GLIBCXX_ALWAYS_INLINE void
wait(__pointer_type __old,
- memory_order __m = memory_order_seq_cst) noexcept
+ memory_order __m = memory_order_seq_cst) const noexcept
{
std::__atomic_wait_address_v(&_M_p, __old,
[__m, this]
diff --git a/libstdc++-v3/include/std/atomic b/libstdc++-v3/include/std/atomic
index 936dd50ba1c..c971b712ef6 100644
--- a/libstdc++-v3/include/std/atomic
+++ b/libstdc++-v3/include/std/atomic
@@ -646,9 +646,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__cmpexch_failure_order(__m));
}
-#if __cpp_lib_atomic_wait
+#if __cpp_lib_atomic_wait
void
- wait(__pointer_type __old, memory_order __m = memory_order_seq_cst) noexcept
+ wait(__pointer_type __old, memory_order __m = memory_order_seq_cst) const noexcept
{ _M_b.wait(__old, __m); }
// TODO add const volatile overload
diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/wait_notify/102994.cc b/libstdc++-v3/testsuite/29_atomics/atomic/wait_notify/102994.cc
new file mode 100644
index 00000000000..bc814a708aa
--- /dev/null
+++ b/libstdc++-v3/testsuite/29_atomics/atomic/wait_notify/102994.cc
@@ -0,0 +1,11 @@
+// { dg-options "-std=gnu++20" }
+// { dg-do compile { target c++20 } }
+// { dg-require-gthreads "" }
+
+#include <atomic>
+
+void
+test_it(const std::atomic<char*> &a, char*p)
+{
+ a.wait(p);
+}
--
2.31.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: libstdc++: Make atomic<T*>::wait() const [PR102994]
2021-11-09 18:09 ` Thomas Rodgers
@ 2021-11-09 19:40 ` Jonathan Wakely
2021-11-24 1:27 ` Thomas Rodgers
0 siblings, 1 reply; 8+ messages in thread
From: Jonathan Wakely @ 2021-11-09 19:40 UTC (permalink / raw)
To: Thomas Rodgers; +Cc: libstdc++, gcc Patches
On Tue, 9 Nov 2021 at 18:09, Thomas Rodgers wrote:
> Revised patch attached.
>
OK for trunk and gcc-11, thanks.
> On Fri, Nov 5, 2021 at 4:46 PM Jonathan Wakely <jwakely.gcc@gmail.com>
> wrote:
>
>> On Fri, 5 Nov 2021 at 21:51, Jonathan Wakely via Libstdc++
>> <libstdc++@gcc.gnu.org> wrote:
>> >
>> > OK, thanks.
>>
>> Actually, we should really have a test to verify it can be called on a
>> const object. Please add something when you commit, it can be dumb and
>> simple, it just needs to verify that it can be called.
>>
>>
>> >
>> >
>> > On Fri, 5 Nov 2021 at 21:46, Thomas Rodgers via Libstdc++ <
>> > libstdc++@gcc.gnu.org> wrote:
>> >
>> > >
>> > >
>>
>>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: libstdc++: Make atomic<T*>::wait() const [PR102994]
2021-11-09 19:40 ` Jonathan Wakely
@ 2021-11-24 1:27 ` Thomas Rodgers
2021-11-25 21:24 ` Jonathan Wakely
0 siblings, 1 reply; 8+ messages in thread
From: Thomas Rodgers @ 2021-11-24 1:27 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: libstdc++, gcc Patches
[-- Attachment #1: Type: text/plain, Size: 909 bytes --]
const qualification was also missing in the free functions for
wait/wait_explicit/notify_one/notify_all. Revised patch attached.
On Tue, Nov 9, 2021 at 11:40 AM Jonathan Wakely <jwakely@redhat.com> wrote:
> On Tue, 9 Nov 2021 at 18:09, Thomas Rodgers wrote:
>
>> Revised patch attached.
>>
>
> OK for trunk and gcc-11, thanks.
>
>
>
>> On Fri, Nov 5, 2021 at 4:46 PM Jonathan Wakely <jwakely.gcc@gmail.com>
>> wrote:
>>
>>> On Fri, 5 Nov 2021 at 21:51, Jonathan Wakely via Libstdc++
>>> <libstdc++@gcc.gnu.org> wrote:
>>> >
>>> > OK, thanks.
>>>
>>> Actually, we should really have a test to verify it can be called on a
>>> const object. Please add something when you commit, it can be dumb and
>>> simple, it just needs to verify that it can be called.
>>>
>>>
>>> >
>>> >
>>> > On Fri, 5 Nov 2021 at 21:46, Thomas Rodgers via Libstdc++ <
>>> > libstdc++@gcc.gnu.org> wrote:
>>> >
>>> > >
>>> > >
>>>
>>>
[-- Attachment #2: 0001-libstdc-Make-atomic-T-wait-const-PR102994.patch --]
[-- Type: text/x-patch, Size: 3231 bytes --]
From 337c147b5bb0265522d5aac4beefb3dec1ebe026 Mon Sep 17 00:00:00 2001
From: Thomas Rodgers <rodgert@twrodgers.com>
Date: Tue, 9 Nov 2021 09:42:49 -0800
Subject: [PATCH] libstdc++: Make atomic<T*>::wait() const [PR102994]
This was an oversight in the original commit adding wait/notify
to atomic<T>.
libstdc++-v3/ChangeLog:
PR libstdc++/102994
* include/bits/atomic_base.h (__atomic_base<_PTp*>::wait()):
Add const qualifier.
* include/std/atomic (atomic<_Tp*>::wait(), atomic_wait(),
atomic_wait_explicit(), atomic_notify_one(), atomic_notify_all()):
Likewise.
* testsuite/29_atomics/atomic/wait_notify/102994.cc:
New test.
---
libstdc++-v3/include/bits/atomic_base.h | 2 +-
libstdc++-v3/include/std/atomic | 8 ++++----
.../29_atomics/atomic/wait_notify/102994.cc | 19 +++++++++++++++++++
3 files changed, 24 insertions(+), 5 deletions(-)
create mode 100644 libstdc++-v3/testsuite/29_atomics/atomic/wait_notify/102994.cc
diff --git a/libstdc++-v3/include/bits/atomic_base.h b/libstdc++-v3/include/bits/atomic_base.h
index 9e18aadadaf..a104adc1a10 100644
--- a/libstdc++-v3/include/bits/atomic_base.h
+++ b/libstdc++-v3/include/bits/atomic_base.h
@@ -893,7 +893,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __cpp_lib_atomic_wait
_GLIBCXX_ALWAYS_INLINE void
wait(__pointer_type __old,
- memory_order __m = memory_order_seq_cst) noexcept
+ memory_order __m = memory_order_seq_cst) const noexcept
{
std::__atomic_wait_address_v(&_M_p, __old,
[__m, this]
diff --git a/libstdc++-v3/include/std/atomic b/libstdc++-v3/include/std/atomic
index 936dd50ba1c..9b827b425dc 100644
--- a/libstdc++-v3/include/std/atomic
+++ b/libstdc++-v3/include/std/atomic
@@ -646,9 +646,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__cmpexch_failure_order(__m));
}
-#if __cpp_lib_atomic_wait
+#if __cpp_lib_atomic_wait
void
- wait(__pointer_type __old, memory_order __m = memory_order_seq_cst) noexcept
+ wait(__pointer_type __old, memory_order __m = memory_order_seq_cst) const noexcept
{ _M_b.wait(__old, __m); }
// TODO add const volatile overload
@@ -1434,12 +1434,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp>
inline void
- atomic_notify_one(atomic<_Tp>* __a) noexcept
+ atomic_notify_one(const atomic<_Tp>* __a) noexcept
{ __a->notify_one(); }
template<typename _Tp>
inline void
- atomic_notify_all(atomic<_Tp>* __a) noexcept
+ atomic_notify_all(const atomic<_Tp>* __a) noexcept
{ __a->notify_all(); }
#endif // __cpp_lib_atomic_wait
diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/wait_notify/102994.cc b/libstdc++-v3/testsuite/29_atomics/atomic/wait_notify/102994.cc
new file mode 100644
index 00000000000..28c3d66f451
--- /dev/null
+++ b/libstdc++-v3/testsuite/29_atomics/atomic/wait_notify/102994.cc
@@ -0,0 +1,19 @@
+// { dg-options "-std=gnu++20" }
+// { dg-do compile { target c++20 } }
+// { dg-require-gthreads "" }
+
+#include <atomic>
+
+void
+test1(const std::atomic<char*> &a, char*p)
+{
+ a.wait(p);
+}
+
+void
+test2(const std::atomic<int>* a, int v)
+{
+ std::atomic_wait(a, v);
+ std::atomic_notify_one(a);
+ std::atomic_notify_all(a);
+}
--
2.31.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: libstdc++: Make atomic<T*>::wait() const [PR102994]
2021-11-24 1:27 ` Thomas Rodgers
@ 2021-11-25 21:24 ` Jonathan Wakely
2021-12-10 2:14 ` Thomas Rodgers
0 siblings, 1 reply; 8+ messages in thread
From: Jonathan Wakely @ 2021-11-25 21:24 UTC (permalink / raw)
To: Thomas Rodgers; +Cc: libstdc++, gcc Patches
On Wed, 24 Nov 2021 at 01:27, Thomas Rodgers wrote:
>
> const qualification was also missing in the free functions for wait/wait_explicit/notify_one/notify_all. Revised patch attached.
Please tweak the whitespace in the new test:
> +test1(const std::atomic<char*> &a, char*p)
The '&' should be on the type not the variable, and there should be a
space before 'p':
> +test1(const std::atomic<char*>& a, char* p)
OK for trunk and gcc-11 with that tweak, thanks!
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: libstdc++: Make atomic<T*>::wait() const [PR102994]
2021-11-25 21:24 ` Jonathan Wakely
@ 2021-12-10 2:14 ` Thomas Rodgers
0 siblings, 0 replies; 8+ messages in thread
From: Thomas Rodgers @ 2021-12-10 2:14 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: libstdc++, gcc Patches
Tested uild-x86_64-pc-linux-gnu, pushed to trunk and gcc-11.
On Thu, Nov 25, 2021 at 1:24 PM Jonathan Wakely <jwakely@redhat.com> wrote:
> On Wed, 24 Nov 2021 at 01:27, Thomas Rodgers wrote:
> >
> > const qualification was also missing in the free functions for
> wait/wait_explicit/notify_one/notify_all. Revised patch attached.
>
> Please tweak the whitespace in the new test:
>
> > +test1(const std::atomic<char*> &a, char*p)
>
> The '&' should be on the type not the variable, and there should be a
> space before 'p':
>
> > +test1(const std::atomic<char*>& a, char* p)
>
> OK for trunk and gcc-11 with that tweak, thanks!
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-12-10 2:14 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-05 21:44 libstdc++: Make atomic<T*>::wait() const [PR102994] Thomas Rodgers
2021-11-05 21:48 ` Jonathan Wakely
2021-11-05 23:46 ` Jonathan Wakely
2021-11-09 18:09 ` Thomas Rodgers
2021-11-09 19:40 ` Jonathan Wakely
2021-11-24 1:27 ` Thomas Rodgers
2021-11-25 21:24 ` Jonathan Wakely
2021-12-10 2:14 ` Thomas Rodgers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).