CK_PR_INC(3)

πŸ’– ck_pr_inc(3) πŸ’–

okay bestie, gather round 🫢 this is the manual page for the ck_pr_inc(3) family of functions β€” atomic increment operations β€” and it lives in Concurrency Kit (libck, link with -lck). it's giving "tiny function, huge responsibility" and honestly? iconic. ✨


🌸 NAME 🌸

say hi to the whole squad, because they all show up to the same party:

  • ck_pr_inc_ptr, ck_pr_inc_ptr_zero, ck_pr_inc_ptr_is_zero
  • ck_pr_inc_double, ck_pr_inc_double_zero, ck_pr_inc_double_is_zero
  • ck_pr_inc_char, ck_pr_inc_char_zero, ck_pr_inc_char_is_zero
  • ck_pr_inc_uint, ck_pr_inc_uint_zero, ck_pr_inc_uint_is_zero
  • ck_pr_inc_int, ck_pr_inc_int_zero, ck_pr_inc_int_is_zero
  • ck_pr_inc_64, ck_pr_inc_64_zero, ck_pr_inc_64_is_zero
  • ck_pr_inc_32, ck_pr_inc_32_zero, ck_pr_inc_32_is_zero
  • ck_pr_inc_16, ck_pr_inc_16_zero, ck_pr_inc_16_is_zero
  • ck_pr_inc_8, ck_pr_inc_8_zero, ck_pr_inc_8_is_zero

…and what are they? atomic increment operations. that's the whole vibe check. πŸ’…


πŸŽ€ LIBRARY πŸŽ€

Concurrency Kit (libck, -lck) β€” yes the link flag is literally -lck, don't @ me, that's just how it is. πŸ’œ


✨ SYNOPSIS ✨

first things first, you gotta pull in the header:

#include <ck_pr.h>

and now, the full roster. every single one, no skips, no cuts πŸ”₯

void
ck_pr_inc_ptr(void *target);

void
ck_pr_inc_ptr_zero(void *target, bool *z);

bool
ck_pr_inc_ptr_is_zero(void *target);

void
ck_pr_inc_double(double *target);

void
ck_pr_inc_double_zero(double *target, bool *z);

bool
ck_pr_inc_double_is_zero(double *target);

void
ck_pr_inc_char(char *target);

void
ck_pr_inc_char_zero(char *target, bool *z);

bool
ck_pr_inc_char_is_zero(char *target);

void
ck_pr_inc_uint(unsigned int *target);

void
ck_pr_inc_uint_zero(unsigned int *target, bool *z);

bool
ck_pr_inc_uint_is_zero(unsigned int *target);

void
ck_pr_inc_int(int *target);

void
ck_pr_inc_int_zero(int *target, bool *z);

bool
ck_pr_inc_int_is_zero(int *target);

void
ck_pr_inc_64(uint64_t *target);

void
ck_pr_inc_64_zero(uint64_t *target, bool *z);

bool
ck_pr_inc_64_is_zero(uint64_t *target);

void
ck_pr_inc_32(uint32_t *target);

void
ck_pr_inc_32_zero(uint32_t *target, bool *z);

bool
ck_pr_inc_32_is_zero(uint32_t *target);

void
ck_pr_inc_16(uint16_t *target);

void
ck_pr_inc_16_zero(uint16_t *target, bool *z);

bool
ck_pr_inc_16_is_zero(uint16_t *target);

void
ck_pr_inc_8(uint8_t *target);

void
ck_pr_inc_8_zero(uint8_t *target, bool *z);

bool
ck_pr_inc_8_is_zero(uint8_t *target);

πŸ¦‹ DESCRIPTION πŸ¦‹

so the ck_pr_inc(3) family of functions atomically increments the value pointed to by target. that's it. that's the whole thing. every type gets its own flavour, every flavour gets the same energy: bump that number, and bump it atomically, so nobody else can catch you mid-bump. πŸ”₯


πŸ‘‘ RETURN VALUES πŸ‘‘

here's where it gets spicy, so listen up bestie 🌢️

  • the ck_pr_inc_zero family sets the value pointed to by z to true if the result of the increment operation was 0. ✨
  • otherwise β€” meaning the result was not 0 β€” those same functions set the value pointed to by z to false. πŸ’…
  • the ck_pr_inc_is_zero family of functions return true if the result of the decrement operation was 0, and false otherwise. πŸ™ˆ
ok so real talk, the page says "decrement" in that last bullet even though this whole manpage is about increment. that's literally what the original says, character for character, so I'm keeping it exactly as-is. no cap. not my typo to fix, bestie. πŸ’€

🌈 SEE ALSO 🌈

go read these next, they're all part of the same friend group 🫢

and if you want even more, there's additional information available at http://concurrencykit.org/ ⭐


mwah πŸ’‹ that's the whole page. this one's from Concurrency Kit (libck, -lck), dated April 7, 2013, and it's filed under ck_pr_inc(3). slay, go increment something atomically, you main character πŸŽ€πŸ’–

πŸ“¦ where this page comes from