Re: [PATCH rtems-libbsd 2/2] rtemsbsd/atomic: Return a value for CMPSET

2021-10-07 Thread Chris Johns
OK

On 8/10/21 7:43 am, Kinsey Moore wrote:
> When the cmpset and fcmpset functions were refactored, the return value
> of the operation was discarded instead of being returned for SMP builds
> outside of gcc 4.x. This had the effect of turning these functions into
> a long busywait loop that eventually failed due to integer overflow.
> 
> This patch restores the use of the return value of the atomic
> operations.
> ---
>  rtemsbsd/include/machine/atomic.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/rtemsbsd/include/machine/atomic.h 
> b/rtemsbsd/include/machine/atomic.h
> index 9465fefd..f25dc5d0 100644
> --- a/rtemsbsd/include/machine/atomic.h
> +++ b/rtemsbsd/include/machine/atomic.h
> @@ -530,7 +530,7 @@ atomic_clear_rel_long(volatile long *p, long v)
>  #elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
>  #define _ATOMIC_CMPSET(T, p, cmp, set, mo) \
>   atomic_##T *q = (atomic_##T *)RTEMS_DEVOLATILE(T *, p); \
> - atomic_compare_exchange_strong_explicit(q, , set, \
> + rv = atomic_compare_exchange_strong_explicit(q, , set, \
>  mo, memory_order_relaxed)
>  #else
>  #define _ATOMIC_CMPSET(T, p, cmp, set, mo) \
> @@ -676,7 +676,7 @@ atomic_cmpset_rel_ptr(volatile uintptr_t *p, uintptr_t 
> cmp, uintptr_t set)
>  #elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
>  #define _ATOMIC_FCMPSET(T, p, cmp, set, mo) \
>   atomic_##T *q = (atomic_##T *)RTEMS_DEVOLATILE(T *, p); \
> - atomic_compare_exchange_strong_explicit(q, cmp, set, \
> + rv = atomic_compare_exchange_strong_explicit(q, cmp, set, \
> mo, memory_order_relaxed)
>  #else
>  #define _ATOMIC_FCMPSET(T, p, cmp, set, mo) \
> 
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH rtems-libbsd 2/2] rtemsbsd/atomic: Return a value for CMPSET

2021-10-07 Thread Kinsey Moore
When the cmpset and fcmpset functions were refactored, the return value
of the operation was discarded instead of being returned for SMP builds
outside of gcc 4.x. This had the effect of turning these functions into
a long busywait loop that eventually failed due to integer overflow.

This patch restores the use of the return value of the atomic
operations.
---
 rtemsbsd/include/machine/atomic.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/rtemsbsd/include/machine/atomic.h 
b/rtemsbsd/include/machine/atomic.h
index 9465fefd..f25dc5d0 100644
--- a/rtemsbsd/include/machine/atomic.h
+++ b/rtemsbsd/include/machine/atomic.h
@@ -530,7 +530,7 @@ atomic_clear_rel_long(volatile long *p, long v)
 #elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
 #define _ATOMIC_CMPSET(T, p, cmp, set, mo) \
atomic_##T *q = (atomic_##T *)RTEMS_DEVOLATILE(T *, p); \
-   atomic_compare_exchange_strong_explicit(q, , set, \
+   rv = atomic_compare_exchange_strong_explicit(q, , set, \
 mo, memory_order_relaxed)
 #else
 #define _ATOMIC_CMPSET(T, p, cmp, set, mo) \
@@ -676,7 +676,7 @@ atomic_cmpset_rel_ptr(volatile uintptr_t *p, uintptr_t cmp, 
uintptr_t set)
 #elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
 #define _ATOMIC_FCMPSET(T, p, cmp, set, mo) \
atomic_##T *q = (atomic_##T *)RTEMS_DEVOLATILE(T *, p); \
-   atomic_compare_exchange_strong_explicit(q, cmp, set, \
+   rv = atomic_compare_exchange_strong_explicit(q, cmp, set, \
mo, memory_order_relaxed)
 #else
 #define _ATOMIC_FCMPSET(T, p, cmp, set, mo) \
-- 
2.30.2

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel