libstdc++: Make atomic<T*>::wait() const [PR102994]

Message ID CAMmuTO9Z4rMGN0rhG=PHisSwPzonaggj68te1odk5O5TPEL4+A@mail.gmail.com
State Committed
Headers
Series libstdc++: Make atomic<T*>::wait() const [PR102994] |

Commit Message

Thomas Rodgers Nov. 5, 2021, 9:44 p.m. UTC
  
  

Comments

Jonathan Wakely Nov. 5, 2021, 9:48 p.m. UTC | #1
OK, thanks.


On Fri, 5 Nov 2021 at 21:46, Thomas Rodgers via Libstdc++ <
libstdc++@gcc.gnu.org> wrote:

>
>
  
Jonathan Wakely Nov. 5, 2021, 11:46 p.m. UTC | #2
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:
>
> >
> >
  
Thomas Rodgers Nov. 9, 2021, 6:09 p.m. UTC | #3
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:
> >
> > >
> > >
>
>
  
Jonathan Wakely Nov. 9, 2021, 7:40 p.m. UTC | #4
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:
>> >
>> > >
>> > >
>>
>>
  
Thomas Rodgers Nov. 24, 2021, 1:27 a.m. UTC | #5
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:
>>> >
>>> > >
>>> > >
>>>
>>>
  
Jonathan Wakely Nov. 25, 2021, 9:24 p.m. UTC | #6
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!
  
Thomas Rodgers Dec. 10, 2021, 2:14 a.m. UTC | #7
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!
>
>
  

Patch

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