CK_PR_NEG(3)

πŸ’… ck_pr_neg β€” atomic negation operations ✨

okay so bestie, welcome to the ck_pr_neg(3) page, part of the Concurrency Kit family 🫢


πŸŽ€ NAME πŸŽ€

ck_pr_neg_ptr, ck_pr_neg_ptr_zero, ck_pr_neg_double, ck_pr_neg_double_zero, ck_pr_neg_char, ck_pr_neg_char_zero, ck_pr_neg_uint, ck_pr_neg_uint_zero, ck_pr_neg_int, ck_pr_neg_int_zero, ck_pr_neg_64, ck_pr_neg_64_zero, ck_pr_neg_32, ck_pr_neg_32_zero, ck_pr_neg_16, ck_pr_neg_16_zero, ck_pr_neg_8, ck_pr_neg_8_zero β€” atomic negation operations 🌈

like. that's the whole squad. eighteen of them. they negate things. atomically. periodt.


πŸ“š LIBRARY πŸ“š

Concurrency Kit (that's libck, linked with -lck) πŸ’–


✨ SYNOPSIS ✨

first things first, you gotta bring in the header:

#include <ck_pr.h>

and then here's every single one of the babies, verbatim, no cap:

void
ck_pr_neg_ptr(void *target);

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

void
ck_pr_neg_double(double *target);

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

void
ck_pr_neg_char(char *target);

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

void
ck_pr_neg_uint(unsigned int *target);

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

void
ck_pr_neg_int(int *target);

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

void
ck_pr_neg_64(uint64_t *target);

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

void
ck_pr_neg_32(uint32_t *target);

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

void
ck_pr_neg_16(uint16_t *target);

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

void
ck_pr_neg_8(uint8_t *target);

void
ck_pr_neg_8_zero(uint8_t *target, bool *z);
🫢 notice the pattern bestie: one plain version per type, plus a _zero variant that takes an extra bool *z. that's the whole vibe.

🌸 DESCRIPTION 🌸

okay so the ck_pr_neg(3) family of functions atomically negate the value pointed to by target. πŸ’…

that's it. that's the description. it flips the sign, and it does it atomically, so no other thread is gonna catch it mid-negation being messy. main character energy only πŸ‘‘


⭐ RETURN VALUES ⭐

so the ck_pr_neg_zero functions β€” the ones with _zero in the name, iykyk β€” set the value pointed to by z to true if the result of the negation operation was 0. πŸŽ€

if it wasn't 0? they set the pointed-to value to false. simple as that.

πŸ™ˆ literally: *z is a little "hey, did this land on zero?" flag. obsessed.

πŸ¦‹ SEE ALSO πŸ¦‹

go read these next bestie, they're all family:

and if you want even more, additional information is available at http://concurrencykit.org/ 🌈


okay that's the whole page, you ate it πŸ’– this was ck_pr_neg(3) from the Concurrency Kit, dated April 7, 2013 β€” go negate something atomically, bestie, slay βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from