QB_ATOMIC_...D_EXCHANGE(3)
π QB_ATOMIC_...D_EXCHANGE(3) π
okay bestie, so this one lives in the libqb Programmer's Manual and honestly? it's giving "tiny function, enormous power." her whole name is qb_atomic_int_compare_and_exchange and she's about to become your new hyperfixation. no cap. π¦
β¨ NAME β¨
qb_atomic_int_compare_and_exchange β compares oldval with the integer pointed to by atomic and, if they're equal, atomically exchanges *atomic with newval. π
like... she checks if you're the same person, and if you are, she swaps you out. iconic behaviour honestly.
πΈ SYNOPSIS πΈ
#include <qb/qbatomic.h>
int32_t qb_atomic_int_compare_and_exchange(
volatile int32_t QB_GNUC_MAY_ALIAS *atomic, /* a pointer to an integer */
int32_t oldval, /* the assumed old value of *atomic */
int32_t newval /* the new value of *atomic*/
);
π PARAMS π
atomicβ a pointer to an integer. she's the one getting compared and possibly swapped. main character energy fr fr. πoldvalβ the assumed old value of*atomic. you're basically guessing "i think she's currently this." π«Άnewvalβ the new value of*atomic. the glow-up you're giving her if the vibe check passes. β¨
π DESCRIPTION π
Also acts as a memory barrier.
that's it, that's the description, but bestie do not sleep on that sentence β it's the whole point. she's not just comparing numbers, she's putting a whole fence in the memory ordering. it's giving bouncer at the club. π§
β RETURN VALUE β
QB_TRUEβ if*atomicwas equaloldval. she said yes. slay. πQB_FALSEβ otherwise. she said no. not me getting rejected by an atomic operation π
π₯ SEE ALSO π₯
the whole friend group, because she does not work alone:
qb_atomic_int_set(3)qb_atomic_int_get(3)qb_atomic_int_add(3)qb_atomic_init(3)qb_atomic_pointer_get(3)qb_atomic_int_exchange_and_add(3)qb_atomic_pointer_compare_and_exchange(3)qb_atomic_pointer_set(3)
go read them. iykyk. π
π COPYRIGHT π
Copyright (C) 2003 Sebastian Wilhelmi
that's the whole page, bestie, and yes i know the title looks like it got cut off mid-sentence β it's literally QB_ATOMIC_...D_EXCHANGE(3), from libqb, dated 2025-09-16, and the footer says LIBQB too. mwah. π
π¦ where this page comes from
- fedora 44: libqb-devel 2.0.9-2.fc44 Β· LGPL-2.1-or-later
- fedora 44: libqb-devel 2.0.9-2.fc44 Β· LGPL-2.1-or-later
- ubuntu resolute: libqb-dev 2.0.9-1ubuntu1 Β· LGPL-2.1-or-later
- ubuntu stonking: libqb-dev 2.0.9-1ubuntu1 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms