raw_atomic_..._if_positive(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… raw_atomic_..._if_positive β€” Kernel API Manual, bestie ✨

okay so this is a page from the Kernel API Manual and it's about raw_atomic_long_dec_if_positive, which lowkey has main character energy for a function name. stay with me, it's actually iconic πŸŽ€


✨ NAME ✨

raw_atomic_long_dec_if_positive β€” atomic decrement if positive, with full ordering. that's it, that's the vibe 🌸


πŸ¦‹ SYNOPSIS πŸ¦‹

long raw_atomic_long_dec_if_positive (atomic_long_t *v );

copy it exactly like that, spacing and all, no cap πŸ’…


πŸŽ€ ARGUMENTS πŸŽ€

  • v β€” pointer to atomic_long_t. that's the whole argument, she's a one-parameter queen πŸ‘‘

πŸ’– DESCRIPTION πŸ’–

okay so here's the tea β˜• β€” if (v > 0), she atomically updates v to (v - 1) and does it with full ordering. otherwise? v is literally not modified at all, and you just get relaxed ordering. so she only does the thing when the thing is safe to do. we love a boundaries-having function 🫢

also she's safe to use in noinstr code β€” but if you're anywhere else, prefer atomic_long_dec_if_positive instead. like, raw_ is the backstage pass version, use it only when you actually need it ✨


πŸ”₯ RETURN πŸ”₯

the old value of (v - 1), regardless of whether v was updated. yes, even when nothing changed, you still get that value back. consistency queen πŸ’€


🌈 SEE ALSO 🌈

kernel file ./include/linux/atomic/atomic-long.h β€” the whole family lives there, go say hi πŸ¦‹

like i said. the whole family. every single one of them, iykyk πŸ’œ


and that's the page!! mwah πŸ’‹ this one came from the kernel source at ./include/linux/atomic, dated October 2026, and it's filed under raw_atomic_..._if_positive(9) in case you need to find her again. go forth and decrement responsibly, bestie 🧚✨

πŸ“¦ where this page comes from