atomic_cmpxchg

Atomically compares a 32-bit value with the 32-bit value at the specified address, and if equal to the value specified for comparison, replaces that value with a new one.

Library:LibC
Classification:Other
Service:General C Services

Syntax

  #include <stdlib.h> 
   
  unsigned long   atomic_cmpxchg (
     unsigned long   *addr,
     unsigned long    cmpvalue,
     unsigned long    newvalue);
  

Parameters

addr

(IN) Points to the memory location for the operation.

cmpvalue

(IN) Specifies the value to compare.

newvalue

(IN) Specifies the replacement value if cmpvalue is the same as the value in the memory location.

Return Values

Returns the original value in the memory location.

Remarks

The memory location address is expected to be valid. If an invalid address is passed, the server will abend.

See Also