Skip to content

Commit

Permalink
Do not use argument twice in AO_REAL_PTR_AS_MACRO on E2K
Browse files Browse the repository at this point in the history
(fix of commit 707a7b2)

Issue #61 (libatomic_ops).

* src/atomic_ops_stack.h [AO_REAL_PTR_AS_MACRO
&& AO_USE_ALMOST_LOCK_FREE && AO_STACK_USE_CPTR] (AO_REAL_NEXT_PTR):
Call AO_real_next_ptr_i() instead of direct evaluation of the
expression.
* src/atomic_ops_stack.h [AO_REAL_PTR_AS_MACRO
&& AO_USE_ALMOST_LOCK_FREE && AO_STACK_USE_CPTR] (AO_real_next_ptr_i):
New inline function.
  • Loading branch information
ivmai committed May 21, 2024
1 parent df051b6 commit cc9bc49
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/atomic_ops_stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,13 @@ typedef union AO__stack {
#elif defined(AO_USE_ALMOST_LOCK_FREE)
# ifdef AO_STACK_USE_CPTR
# define AO_REAL_NEXT_PTR(x) \
((AO_uintptr_t *)(*(AO_internal_ptr_t *)&(x) \
- ((AO_uintptr_t)(*(AO_internal_ptr_t *)&(x)) & AO_BIT_MASK)))
((AO_uintptr_t *)AO_real_next_ptr_i(*(const AO_internal_ptr_t *)&(x)))
/* Implemented as an inline function because the argument is used twice. */
AO_INLINE AO_internal_ptr_t
AO_real_next_ptr_i(AO_internal_ptr_t next)
{
return next - ((unsigned)(AO_uintptr_t)next & AO_BIT_MASK);
}
# else
# define AO_REAL_NEXT_PTR(x) \
(AO_uintptr_t *)((x) & ~(AO_uintptr_t)AO_BIT_MASK)
Expand Down

0 comments on commit cc9bc49

Please sign in to comment.