qb_atomic_pointer_compare_and_exchange(3)

qb_atomic_pointer_compare_and_exchange3

Compares oldval with the pointer pointed to by atomic and if they are equal, atomically exchanges *atomic with newval.

Usage

#include <qb/qbatomic.h>

int32_t qb_atomic_pointer_compare_and_exchange(
    volatile void *QB_GNUC_MAY_ALIAS   *atomic,  /* a pointer to a void* */
    void                               *oldval,  /* the assumed old value of *atomic */
    void                               *newval   /* the new value of *atomic*/
);

Params

atomic a pointer to a void*

oldval the assumed old value of *atomic

newval the new value of *atomic

Overview

Also acts as a memory barrier.

Return value

QB_TRUE if atomic was equal oldval, else QB_FALSE.

Releases

4 releases since Debian 11 (Bullseye); the text changed 3 times.

  1. 11
  2. 12
  3. 13
  4. Arch

From libqb 2.0.10-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.