* [PATCH] atomic.h: Reword confusing comment for qatomic_cmpxchg
@ 2024-02-23 18:20 Peter Maydell
2024-02-23 18:21 ` Richard Henderson
2024-02-26 8:46 ` Zhao Liu
0 siblings, 2 replies; 4+ messages in thread
From: Peter Maydell @ 2024-02-23 18:20 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson, Jonathan Cameron
The qatomic_cmpxchg() and qatomic_cmpxchg__nocheck() macros have
a comment that reads:
Returns the eventual value, failed or not
This is somewhere between cryptic and wrong, since the value actually
returned is the value that was in memory before the cmpxchg. Reword
to match how we describe these macros in atomics.rst.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
include/qemu/atomic.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h
index f1d3d1702a9..99110abefb3 100644
--- a/include/qemu/atomic.h
+++ b/include/qemu/atomic.h
@@ -202,7 +202,7 @@
qatomic_xchg__nocheck(ptr, i); \
})
-/* Returns the eventual value, failed or not */
+/* Returns the old value of '*ptr' (whether the cmpxchg failed or not) */
#define qatomic_cmpxchg__nocheck(ptr, old, new) ({ \
typeof_strip_qual(*ptr) _old = (old); \
(void)__atomic_compare_exchange_n(ptr, &_old, new, false, \
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] atomic.h: Reword confusing comment for qatomic_cmpxchg
2024-02-23 18:20 [PATCH] atomic.h: Reword confusing comment for qatomic_cmpxchg Peter Maydell
@ 2024-02-23 18:21 ` Richard Henderson
2024-02-23 18:23 ` Jonathan Cameron via
2024-02-26 8:46 ` Zhao Liu
1 sibling, 1 reply; 4+ messages in thread
From: Richard Henderson @ 2024-02-23 18:21 UTC (permalink / raw)
To: Peter Maydell, qemu-devel; +Cc: Jonathan Cameron
On 2/23/24 08:20, Peter Maydell wrote:
> The qatomic_cmpxchg() and qatomic_cmpxchg__nocheck() macros have
> a comment that reads:
> Returns the eventual value, failed or not
>
> This is somewhere between cryptic and wrong, since the value actually
> returned is the value that was in memory before the cmpxchg. Reword
> to match how we describe these macros in atomics.rst.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> include/qemu/atomic.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h
> index f1d3d1702a9..99110abefb3 100644
> --- a/include/qemu/atomic.h
> +++ b/include/qemu/atomic.h
> @@ -202,7 +202,7 @@
> qatomic_xchg__nocheck(ptr, i); \
> })
>
> -/* Returns the eventual value, failed or not */
> +/* Returns the old value of '*ptr' (whether the cmpxchg failed or not) */
> #define qatomic_cmpxchg__nocheck(ptr, old, new) ({ \
> typeof_strip_qual(*ptr) _old = (old); \
> (void)__atomic_compare_exchange_n(ptr, &_old, new, false, \
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] atomic.h: Reword confusing comment for qatomic_cmpxchg
2024-02-23 18:21 ` Richard Henderson
@ 2024-02-23 18:23 ` Jonathan Cameron via
0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron via @ 2024-02-23 18:23 UTC (permalink / raw)
To: Richard Henderson; +Cc: Peter Maydell, qemu-devel
On Fri, 23 Feb 2024 08:21:42 -1000
Richard Henderson <richard.henderson@linaro.org> wrote:
> On 2/23/24 08:20, Peter Maydell wrote:
> > The qatomic_cmpxchg() and qatomic_cmpxchg__nocheck() macros have
> > a comment that reads:
> > Returns the eventual value, failed or not
> >
> > This is somewhere between cryptic and wrong, since the value actually
> > returned is the value that was in memory before the cmpxchg. Reword
> > to match how we describe these macros in atomics.rst.
> >
> > Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> > ---
> > include/qemu/atomic.h | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h
> > index f1d3d1702a9..99110abefb3 100644
> > --- a/include/qemu/atomic.h
> > +++ b/include/qemu/atomic.h
> > @@ -202,7 +202,7 @@
> > qatomic_xchg__nocheck(ptr, i); \
> > })
> >
> > -/* Returns the eventual value, failed or not */
> > +/* Returns the old value of '*ptr' (whether the cmpxchg failed or not) */
> > #define qatomic_cmpxchg__nocheck(ptr, old, new) ({ \
> > typeof_strip_qual(*ptr) _old = (old); \
> > (void)__atomic_compare_exchange_n(ptr, &_old, new, false, \
>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
As the person it confused ;)
>
> r~
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] atomic.h: Reword confusing comment for qatomic_cmpxchg
2024-02-23 18:20 [PATCH] atomic.h: Reword confusing comment for qatomic_cmpxchg Peter Maydell
2024-02-23 18:21 ` Richard Henderson
@ 2024-02-26 8:46 ` Zhao Liu
1 sibling, 0 replies; 4+ messages in thread
From: Zhao Liu @ 2024-02-26 8:46 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel, Richard Henderson, Jonathan Cameron
On Fri, Feb 23, 2024 at 06:20:35PM +0000, Peter Maydell wrote:
> Date: Fri, 23 Feb 2024 18:20:35 +0000
> From: Peter Maydell <peter.maydell@linaro.org>
> Subject: [PATCH] atomic.h: Reword confusing comment for qatomic_cmpxchg
> X-Mailer: git-send-email 2.34.1
>
> The qatomic_cmpxchg() and qatomic_cmpxchg__nocheck() macros have
> a comment that reads:
> Returns the eventual value, failed or not
>
> This is somewhere between cryptic and wrong, since the value actually
> returned is the value that was in memory before the cmpxchg. Reword
> to match how we describe these macros in atomics.rst.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> include/qemu/atomic.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
>
> diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h
> index f1d3d1702a9..99110abefb3 100644
> --- a/include/qemu/atomic.h
> +++ b/include/qemu/atomic.h
> @@ -202,7 +202,7 @@
> qatomic_xchg__nocheck(ptr, i); \
> })
>
> -/* Returns the eventual value, failed or not */
> +/* Returns the old value of '*ptr' (whether the cmpxchg failed or not) */
> #define qatomic_cmpxchg__nocheck(ptr, old, new) ({ \
> typeof_strip_qual(*ptr) _old = (old); \
> (void)__atomic_compare_exchange_n(ptr, &_old, new, false, \
> --
> 2.34.1
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-02-26 8:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-23 18:20 [PATCH] atomic.h: Reword confusing comment for qatomic_cmpxchg Peter Maydell
2024-02-23 18:21 ` Richard Henderson
2024-02-23 18:23 ` Jonathan Cameron via
2024-02-26 8:46 ` Zhao Liu
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 NNTP newsgroup(s).