raw_atomic64..._if_positive(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… raw_atomic64_dec_if_positive(9) β€” a Kernel API Manual moment

okay so bestie, welcome to the Kernel API Manual, and today's main character is raw_atomic64_dec_if_positive β€” yes, the page header renders it as raw_atomic64..._if_positive(9) because even manpage headers get lazy sometimes, but the function's full government name is in NAME, don't worry 🫢

This one's a 64-bit atomic that only takes a step back if things are still in the positive. Very "will only descend if the vibe is right" of it, honestly πŸ’…


✨ NAME ✨

raw_atomic64_dec_if_positive β€” atomic decrement if positive, with full ordering 🌸

✨ SYNOPSIS ✨

s64 raw_atomic64_dec_if_positive (atomic64_t *v );

✨ ARGUMENTS ✨

  • v β€” pointer to atomic64_t πŸ‘‘ that's it, that's the whole argument list, she's low maintenance

✨ DESCRIPTION ✨

Okay so here's the tea πŸ“ if (v > 0), it atomically updates v to (v - 1) with full ordering. Full ordering, no cap β€” she's doing the whole memory-barrier thing properly ✨

Otherwise β€” meaning the value isn't greater than zero β€” v is not modified, and relaxed ordering is provided instead. So she peeks, goes "nope, not today", and gives you the chill version of the ordering πŸ’€

And here's the important bit bestie, don't skip it: this is safe to use in noinstr code. Anywhere else, prefer atomic64_dec_if_positive. Like, this is the raw one, it's giving "backstage pass" energy β€” great when you need it, overkill when you don't πŸ™ˆ

✨ RETURN ✨

The old value of (v - 1), regardless of whether v was updated. πŸŽ€

Read that again because it's such a mood: you get the (v - 1) value either way. Whether she actually decremented or just stood there looking iconic, the return is the same shape. iykyk ⭐

✨ SEE ALSO ✨

literally the entire atomic family reunion, no one got left off the guest list πŸ‘‘
  • the file itself β€” Kernel file ./include/linux/atomic/atomic-arch-fallback.h πŸ“

and the whole 32-bit raw_atomic_* crew:

and the 64-bit girlies, aka our own extended fam πŸ¦‹:


and that's the whole page bestie, go forth and decrement responsibly πŸ’–

πŸŽ€ cute little sign-off from the source: this page lives in ./include/linux/atomic and it's dated October 2026 β€” so yes, she's from the future, and she's still out here being iconic in the Kernel API Manual as raw_atomic64..._if_positive(9). periodt. 🌈
πŸ“¦ where this page comes from