CK_PR_FENCE_ATOMIC_STORE(3)

πŸ“¦
version 0.7.2 Β· 2 versions
, in alpine 3.24, debian trixie, epel 10, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– CK_PR_FENCE_ATOMIC_STORE(3) πŸ’–

okay bestie, you're in section 3 of the manual (the library-call girlies section πŸŽ€), and this page is literally about ck_pr_fence_atomic_store β€” enforce ordering of atomic read-modify-write operations to store operations. say it with me. slay. ✨


🌸 LIBRARY 🌸

Concurrency Kit, aka libck, aka the bestie you link with using -lck. πŸ’…


✨ SYNOPSIS ✨

#include <ck_pr.h>

void
ck_pr_fence_atomic_store(void);

void
ck_pr_fence_strict_atomic_store(void);

two icons, one header. no cap. 🫢


πŸ‘‘ DESCRIPTION πŸ‘‘

so here's the vibe. The ck_pr_fence_atomic_store() function enforces the ordering of any atomic read-modify-write operations relative to any store operations following the function invocation. it's giving boundaries. 🌈

it always serves as an implicit compiler barrier. periodt. 🧚

but okay, plot twist: on architectures implementing CK_MD_TSO, this operation only serves as a compiler barrier and no fences are emitted. like, the hardware already had your back, so it's lowkey chilling. πŸ’€

and if you're the kind of main character who wants to force the unconditional emission of a fence? that's what ck_pr_fence_strict_atomic_store() is for. use it when you need it fr fr. πŸ”₯


πŸ¦‹ EXAMPLE πŸ¦‹

#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 store into the value pointed
         * to by b.
         */
        ck_pr_fence_atomic_store();
        c = ck_pr_store_int(&b, 2);

        return;
}

not the comment in the middle explaining the entire plot 😭 iconic. the fence is the moment where a's update is done before anything touches what b points to. obsessed. πŸ’œ


⭐ RETURN VALUES ⭐

This function has no return value. literally returns nothing. gives nothing but vibes and ordering guarantees. πŸ’…


🌈 SEE ALSO 🌈

the whole friend group, all in one place:

Additional information available at http://concurrencykit.org/ 🌐✨


ok that's the whole page bestie, go forth and fence responsibly 🫢

mwah πŸ’‹ this was the CK_PR_FENCE_ATOMIC_STORE(3) page, dated May 16, 2013 β€” yeah she's vintage, she's still that girl, and she ate. bye pookie πŸ‘‘πŸ’–

πŸ“¦ where this page comes from