CK_PR_FENCE_STORE(3)
π ck_pr_fence_store β bestie, we're ordering your stores β¨
okay so this is the manual page for ck_pr_fence_store(3) from the Concurrency Kit β yes, that's section 3 of the manual, the "library functions" section, iykyk. grab a snack, we're doing memory ordering π
π LIBRARY
Concurrency Kit β that's libck, and when you're linking it you pass -lck. that's the whole vibe. π
β¨ SYNOPSIS
like, the receipts:
#include <ck_pr.h>
void
ck_pr_fence_store(void);
void
ck_pr_fence_strict_store(void);
two functions, both returning void, both taking absolutely nothing. no arguments, no drama. π
πΈ DESCRIPTION
so ck_pr_fence_store() enforces the ordering of any memory store, of ck_pr_store() calls, and of atomic read-modify-write operations β all of that gets ordered relative to the moment you invoke this function. it's giving "everything before this line stays before this line" energy. π
one thing that's always true no matter what: this function always serves as an implicit compiler barrier. always. no cap.
now, the architecture tea β:
- on architectures implementing
CK_MD_TSO, this operation only serves as a compiler barrier and no fences are emitted at all. it's just vibes and compiler whispering, fr fr. - on architectures implementing
CK_MD_PSOandCK_MD_RMO, a store fence is emitted. real hardware fence, no pretending.
and if you wanna force that store fence to be emitted unconditionally β like, you don't care what the architecture thinks it needs β you use ck_pr_fence_strict_store(). she does not ask permission. π
π§ EXAMPLE
here's the whole thing, exactly as written, bestie β don't skip it, it's actually cute:
#include <ck_pr.h>
static int a = 0;
static int b = 0;
static int c = 0;
void
function(void)
{
ck_pr_store_int(&a, 1);
/*
* Guarantee that the store to a is completed
* with respect to the stores of b and c.
*/
ck_pr_fence_store();
ck_pr_store_int(&b, 2);
ck_pr_store_int(&c, 2);
return;
}
see what's happening? we slam 1 into a, then we hit the fence, and that fence guarantees the store to a is completed with respect to the stores of b and c. then b and c both get their 2s. the fence is the bouncer at the club door, and b and c are not getting in until a is seated. π€π«Ά
π¦ RETURN VALUES
this function has no return value. nothing. void. it does the thing and dips. π
lowkey the most honest function in the whole library
π SEE ALSO
the whole friend group, alphabetically-ish, all of them, no one left out:
ck_pr_stall(3)ck_pr_fence_atomic(3)ck_pr_fence_atomic_store(3)ck_pr_fence_atomic_load(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)
and there's more lore at http://concurrencykit.org/ if you're obsessed like me. π
k that's the whole page!! this one's dated April 7, 2013 and it lives in section 3 as ck_pr_fence_store(3) β go forth and order your stores correctly bestie, ily, 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