Skip to content

Commit

Permalink
atomic.h: Reword confusing comment for qatomic_cmpxchg
Browse files Browse the repository at this point in the history
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>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Message-id: 20240223182035.1048541-1-peter.maydell@linaro.org
  • Loading branch information
pm215 committed Mar 5, 2024
1 parent 728b923 commit d346fee
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/qemu/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, \
Expand Down

0 comments on commit d346fee

Please sign in to comment.