CK_PR_CAS(3)
π CK_PR_CAS π (that's ck_pr_cas(3), bestie)
okay so. hi. sit down. we're learning the atomic compare-and-swap family from Concurrency Kit and honestly? it's giving main character energy. π
This page covers ck_pr_cas_ptr, ck_pr_cas_ptr_value, ck_pr_cas_ptr_2, ck_pr_cas_ptr_2_value, ck_pr_cas_double, ck_pr_cas_double_value, ck_pr_cas_char, ck_pr_cas_char_value, ck_pr_cas_uint, ck_pr_cas_uint_value, ck_pr_cas_int, ck_pr_cas_int_value, ck_pr_cas_64_2, ck_pr_cas_64_2_value, ck_pr_cas_64, ck_pr_cas_64_value, ck_pr_cas_32, ck_pr_cas_32_value, ck_pr_cas_16, ck_pr_cas_16_value, ck_pr_cas_8, and ck_pr_cas_8_value β all of them atomic compare-and-swap operations. yes. all of them. we're doing the whole girl group. π
β¨ LIBRARY β¨
Concurrency Kit (libck, -lck) π
πΈ SYNOPSIS πΈ
#include <ck_pr.h>
bool
ck_pr_cas_ptr(void *target, void *old_value, void *new_value);
bool
ck_pr_cas_ptr_value(void *target, void *old_value, void *new_value,
void *original_value);
bool
ck_pr_cas_ptr_2(void *target, void *old_value, void *new_value);
bool
ck_pr_cas_ptr_2_value(void *target, void *old_value, void *new_value,
void *original_value);
bool
ck_pr_cas_double(double *target, double old_value, double new_value);
bool
ck_pr_cas_double_value(double *target, double old_value,
double new_value, double *original_value);
bool
ck_pr_cas_char(char *target, char old_value, char new_value);
bool
ck_pr_cas_char_value(char *target, char old_value, char new_value,
char *original_value);
bool
ck_pr_cas_uint(unsigned int *target, unsigned int old_value,
unsigned int new_value);
bool
ck_pr_cas_uint_value(unsigned int *target, unsigned int old_value,
unsigned int new_value, unsigned int *original_value);
bool
ck_pr_cas_int(int *target, int old_value, int new_value);
bool
ck_pr_cas_int_value(int *target, int old_value, int new_value,
int *original_value);
bool
ck_pr_cas_64_2(uint64_t target[static 2], uint64_t old_value[static 2],
uint64_t new_value[static 2]);
bool
ck_pr_cas_64_2_value(uint64_t target[static 2],
uint64_t old_value[static 2], uint64_t new_value[static 2],
uint64_t original_value[static 2]);
bool
ck_pr_cas_64(uint64_t *target, uint64_t old_value, uint64_t new_value);
bool
ck_pr_cas_64_value(uint64_t *target, uint64_t old_value,
uint64_t new_value, uint64_t *original_value);
bool
ck_pr_cas_32(uint32_t *target, uint32_t old_value, uint32_t new_value);
bool
ck_pr_cas_32_value(uint32_t *target, uint32_t old_value,
uint32_t new_value, uint32_t *original_value);
bool
ck_pr_cas_16(uint16_t *target, uint16_t old_value, uint16_t new_value);
bool
ck_pr_cas_16_value(uint16_t *target, uint16_t old_value,
uint16_t new_value, uint16_t *original_value);
bool
ck_pr_cas_8(uint8_t *target, uint8_t old_value, uint8_t new_value);
bool
ck_pr_cas_8_value(uint8_t *target, uint8_t old_value, uint8_t new_value,
uint8_t *original_value);
π¦ DESCRIPTION π¦
okay so the ck_pr_cas(3) family β the whole squad β does one very specific, very iconic thing: it atomically compares the value sitting in target for equality with old_value, and if they match, it replaces the value that target points to with the value you gave in new_value. π
and if target was not equal to old_value? then literally nothing happens. no modification. no touchy. target stays exactly as it was. π«Ά
now, the *_value girlies have a lil extra: they unconditionally update original_value. like, no matter what, original_value gets updated. that's their whole thing. periodt. β¨
π₯ RETURN VALUES π₯
this family returns true if the value in target was modified as a result of the operation. otherwise? false. that's it. that's the tea. π
π SEE ALSO π
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_btr(3)
Additional information available at http://concurrencykit.org/ π
okay that's the whole page bestie, you ate it, you understood it, i'm so proud of you π₯Ήπ
this was the ck_pr_cas(3) page, dated April 11, 2013 β yeah she's a lil vintage but she still serves β¨π
π¦ 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