raw_atomic64_add_negative(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… raw_atomic64_add_negative ✨

so this is a page from the Kernel API Manual and bestie, it's lowkey iconic β€” it's giving "one job, full ordering, no notes" πŸŽ€


🌸 NAME 🌸

raw_atomic64_add_negative β€” the atomic add that ALSO tells you if the result went negative, and it does it with full ordering πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

bool raw_atomic64_add_negative (s64 i , atomic64_t *v );

πŸŽ€ ARGUMENTS πŸŽ€

  • i β€” an s64, aka the value you're adding in. that's it, that's the number πŸ’«
  • v β€” a pointer to an atomic64_t. this is the thing getting updated, she's the main character here πŸ‘‘

πŸ’œ DESCRIPTION πŸ’œ

okay so here's the tea: this bad boy atomically updates v to (v + i), and it does it with full ordering. like, all the ordering. not relaxed, not acquire, not release β€” full. slay ✨

and ngl, the cute part: it's safe to use in noinstr code 🫢 literally built different for that context.

but bestie, listen β€” prefer atomic64_add_negative elsewhere. this raw version is the specialist; she's here for the noinstr moments. iykyk πŸ’…

πŸ”₯ RETURN πŸ”₯

returns true if the resulting value of v is negative 😭 and false otherwise 🌈


πŸ‘‘ SEE ALSO πŸ‘‘

first up, the actual kernel file this lives in, no cap:

  • Kernel file ./include/linux/atomic/atomic-arch-fallback.h

and now, the whole entire friend group 🫢 (yes, all of them, i'm not skipping a single one):


and that's the whole page bestie, we ate and left zero crumbs πŸ“

source file: ./include/linux/atomic β€” dated: October 2026 β€” mwah, see u in the next manpage πŸ’‹ ✨ periodt ✨

πŸ“¦ where this page comes from