CK_PR_BTR(3)
π ck_pr_btr(3) β the bit test-and-reset girlies π
okay so bestie, welcome to CK_PR_BTR(3) β no cap, this is the manual page for the atomic bit test-and-reset operations. it's giving "tiny function, huge main character energy" β¨
πΈ LIBRARY πΈ
Concurrency Kit β link it with -lck and you're sooo set, fr fr π
β¨ SYNOPSIS β¨
first things first, you gotta bring the header in:
#include <ck_pr.h>
and then, like, pick your fighter π β here's the whole squad:
bool
ck_pr_btr_ptr(void *target, unsigned int bit_index);
bool
ck_pr_btr_uint(uint *target, unsigned int bit_index);
bool
ck_pr_btr_int(int *target, unsigned int bit_index);
bool
ck_pr_btr_64(uint64_t *target, unsigned int bit_index);
bool
ck_pr_btr_32(uint32_t *target, unsigned int bit_index);
bool
ck_pr_btr_16(uint16_t *target, unsigned int bit_index);
π¦ DESCRIPTION π¦
so the ck_pr_btr(3) family of functions is lowkey iconic: it atomically fetches the value of the bit in target at index bit_index, and then sets that bit to 0. that's it. that's the whole vibe. test it, then reset it. π
no other thread is gonna catch you mid-operation, that's the whole point β atomicity is the moment, periodt. β¨
π RETURN VALUES π
this whole family of functions returns the original value of the bit at offset bit_index inside the value that target points to. so you get the tea on what the bit was before you yeeted it back down to 0. π
π SEE ALSO π
go read these next, bestie, they're all part of the same friend group π«Ά:
ck_pr_fence_load(3)ck_pr_fence_load_depends(3)ck_pr_fence_store(3)ck_pr_fence_memory(3)ck_pr_load(3)ck_pr_store(3)ck_pr_fas(3)ck_pr_faa(3)ck_pr_inc(3)ck_pr_dec(3)ck_pr_neg(3)ck_pr_not(3)ck_pr_sub(3)ck_pr_and(3)ck_pr_or(3)ck_pr_xor(3)ck_pr_add(3)ck_pr_btc(3)ck_pr_bts(3)ck_pr_cas(3)
and if you want even more lore, there's additional information available at http://concurrencykit.org/ π
okay that's the whole page bestie, you ate that π
mwah! this was ck_pr_btr(3), dated April 11, 2013 β ily, go be atomic, and don't forget to link with -lck πβ¨π
π¦ 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