P99

◆ atomic_fetch_max_explicit

#define atomic_fetch_max_explicit (   OBJP,
  OPERAND,
  ORD 
)
Value:
({ \
P99_MACRO_VAR(p00_objp, (OBJP)); \
P99_MACRO_VAR(p00_op, (OPERAND)); \
__typeof__(atomic_load(p00_objp)) p00_ret; \
/* be sure that the result can not be used as an lvalue */ \
register __typeof__(p00_ret = p00_ret) p00_r = atomic_load(p00_objp); \
p00_ret = p00_r; \
while (p00_r <= p00_op) { \
if (atomic_compare_exchange_weak(p00_objp, &p00_ret, p00_op)) break; \
else p00_r = p00_ret; \
} \
p00_r = p00_ret; \
})

Atomically do a max operation between OPERAND and *OBJP.

Returns
the current value hidden in OBJP before the operation.

OPERAND must be assignment compatible with the base type of OBJP.

ORD is the value for the memory consistency. Currently this argument will not be taken into account for types that aren't natively supported with atomic operations.

See also
atomic_fetch_max for a simpler version without ORD parameter
atomic_int
_Atomic

Definition at line 1381 of file p99_atomic.h.

p99_extension
#define p99_extension
Mark an expression as using a compiler extension.
Definition: p99_compiler.h:210