CK_PR_FENCE_ATOMIC_LOAD(3)
π CK_PR_FENCE_ATOMIC_LOAD β the "bestie, please order my atomics before my loads" page
okay so you're in the Concurrency Kit manual, specifically CK_PR_FENCE_ATOMIC_LOAD(3), and honestly? this one is a whole vibe once it clicks. it lives in libck, so you link it with -lck. that's the library situation. πΈ
β¨ NAME β¨
ck_pr_fence_atomic_load β bestie, it's here to enforce ordering of atomic read-modify-write operations relative to load operations. yes queen, the atomics go first, the loads know about it. π
π LIBRARY π
Concurrency Kit</purgle> β that's libck, and you link it with -lck. simple as that, no cap. π
oops that was a typo, lemme fix: Concurrency Kit (libck,-lck). we move. π
π¦ SYNOPSIS π¦
#include <ck_pr.h>
void
ck_pr_fence_atomic_load(void);
void
ck_pr_fence_strict_atomic_load(void);
two icons, both void, both taking literally nothing. they just show up and do the work. π
π DESCRIPTION π
okay so the way that ck_pr_fence_atomic_load() works is: it enforces the ordering of any atomic read-modify-write operations relative to any load operations that come after you invoke the function. atomics before β loads after β and this fence is the little bestie standing between them making sure everybody knows their order. fr fr.
this function always serves as an implicit compiler barrier. always. no exceptions. periodt. π«Ά
but here's the tea β β on architectures that implement CK_MD_TSO, this operation only serves as a compiler barrier and no fences are emitted. like, the hardware already has your back, so libck doesn't bother emitting anything. it's giving "you don't need me but i'm here anyway." π
and if you're the type who wants the fence unconditionally emitted, no matter what the architecture thinks it can get away with? that's what ck_pr_fence_strict_atomic_load() is for. it does not skip leg day. it emits. π
π₯ EXAMPLE π₯
here's the whole thing, verbatim, because you deserve to see it in its natural habitat:
#include <ck_pr.h>
static int a = 0;
static int b = 0;
void
function(void)
{
int c;
ck_pr_fas_int(&a, 1);
/*
* Guarantee that the update to a is completed
* with respect to the load of *b.
*/
ck_pr_fence_atomic_load();
c = ck_pr_load_int(&b);
return;
}
so like. we fetch-and-set a to 1. then the fence shows up to guarantee that the update to a is completed with respect to the load of *b. then we load b into c. that's it, that's the whole dance. the fence is the hype woman between the store and the load. main character energy honestly. β¨
π RETURN VALUES π
this function has no return value. it's a void girlie. it gives you nothing back and expects nothing from you. iconic behavior. π
π SEE ALSO π
go read these next, bestie, they're all in the family:
ck_pr_stall(3)ck_pr_fence_atomic(3)ck_pr_fence_atomic_store(3)ck_pr_fence_store(3)ck_pr_fence_load(3)ck_pr_fence_load_atomic(3)ck_pr_fence_load_store(3)ck_pr_fence_load_depends(3)ck_pr_fence_memory(3)ck_pr_barrier(3)ck_pr_fas(3)ck_pr_load(3)ck_pr_store(3)ck_pr_faa(3)ck_pr_inc(3)ck_pr_dec(3)ck_pr_neg(3)ck_pr_not(3)ck_pr_add(3)ck_pr_sub(3)ck_pr_and(3)ck_pr_or(3)ck_pr_xor(3)ck_pr_cas(3)ck_pr_btc(3)ck_pr_bts(3)ck_pr_btr(3)
more lore is available at http://concurrencykit.org/ β go drink your water and read the docs. π
π and that's the page, bestie π this one's from the Concurrency Kit corner of the world, dated May 16, 2013 (yes, a classic, we stan an older icon), filed under CK_PR_FENCE_ATOMIC_LOAD(3). now go emit some fences responsibly. mwah. ππ¦
π¦ where this page comes from
- alpine 3.24: ck-doc 0.7.2-r1 Β· BSD-2-Clause AND Apache-2.0
- debian bookworm: libck-dev 0.7.1-10 Β· BSD-2-Clause
- debian trixie: libck-dev 0.7.2-6 Β· BSD-2-Clause
- epel 10: ck-devel 0.7.2-1.el10_1 Β· BSD-2-clause AND Apache-2.0 AND BSD-3-clause
- epel 9: ck-devel 0.7.0-10.el9 Β· BSD
- fedora 43: ck-devel 0.7.2-2.fc43 Β· BSD-2-clause AND Apache-2.0 AND BSD-3-clause
- fedora 43: ck-devel 0.7.2-2.fc43 Β· BSD-2-clause AND Apache-2.0 AND BSD-3-clause
- fedora 44: ck-devel 0.7.2-4.fc44 Β· BSD-2-clause AND Apache-2.0 AND BSD-3-clause
- fedora 44: ck-devel 0.7.2-4.fc44 Β· BSD-2-clause AND Apache-2.0 AND BSD-3-clause
- nixos 26.05: ck 0.7.2
- nixpkgs unstable: ck 0.7.2
- opensuse-leap 16.0: ck-devel 0.7.2-bp160.1.9 Β· Apache-2.0 AND BSD-2-Clause
- opensuse-leap 16.0: ck-devel 0.7.2-bp160.1.9 Β· Apache-2.0 AND BSD-2-Clause
- opensuse-leap 16.0: ck-devel 0.7.2-bp160.1.9 Β· Apache-2.0 AND BSD-2-Clause
- ubuntu jammy: libck-dev 0.7.1-6ubuntu2 Β· BSD-2-Clause
- ubuntu noble: libck-dev 0.7.1-13build1 Β· BSD-2-Clause
- ubuntu questing: libck-dev 0.7.2-5ubuntu1
- ubuntu resolute: libck-dev 0.7.2-5ubuntu2 Β· BSD-2-Clause
- ubuntu stonking: libck-dev 0.7.2-11 Β· BSD-2-Clause
- Copyright 2013 Samy Al Bahra
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms