Interface __PrefixCMPXCHGSuffix

Inline function

SpaceUser/kernel
ContextSync/async/rt-irq
May blockNo
SPLAny
Dynamic memoryNo

#include <ARCH/BITOPS.H>

static __finline__ long __PrefixCMPXCHGSuffix(type *ptr, type old, type new);

Description

This family of inline functions compare a memory location with old argument and if they are equal, they write new argument to the memory location. This operation is performed atomically.

Parts of function name — Prefix and Suffix determine atomicity requirements and data type.

Arguments

Returns

This function returns non-zero if the compare didn't match (in that case the memory location is unchanged) and zero if it matched (in that case, new was written to the memory location). It may return any non-zero value in the case of mismatch, do not pass the value directly to __likely or __unlikely because they expect int argument — use if (__likely(__CMPXCHG...(...) != 0)).

See also

__PrefixOpSuffix, __PrefixOpSuffixCondition, __CMPXCHG64_AVAILABLE