atomic_long_inc_and_test(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… atomic_long_inc_and_test(9) β€” the Kernel API Manual, bestie edition πŸŽ€

okay so you opened the Kernel API Manual page for atomic_long_inc_and_test(9) and you're like "what is this, actually?" β€” don't worry, I got you. This one is genuinely iconic: it bumps a number up by one, atomically, and then tells you if you landed on zero. That's it. That's the whole vibe. ✨


🌸 NAME 🌸

atomic_long_inc_and_test β€” atomic increment and test if zero with full ordering

Like, atomic increment. Not "kinda increment". Not "increment but a race condition ate it". Atomic. Then it checks if the result is zero. And it does the whole thing with full ordering. Slay. πŸ‘‘


πŸ¦‹ SYNOPSIS πŸ¦‹

bool atomic_long_inc_and_test (atomic_long_t *v );

That's the whole signature, no cap. Returns a bool, takes a pointer to an atomic_long_t. πŸ’–


πŸŽ€ ARGUMENTS πŸŽ€

  • v β€” pointer to atomic_long_t. Yeah. That's the argument. It's a pointer, it points at an atomic_long_t, and honestly that's the entire personality of this parameter. 🫢

🧚 DESCRIPTION 🧚

So here's the tea: it atomically updates v to (v + 1) with full ordering.

Yes bestie, it literally does v + 1. In an atomic way. With full ordering. The function is not trying to be mysterious β€” it's giving "I do exactly what my name says" main character energy. πŸ”₯

⚠️ Important, fr fr: this one is unsafe to use in noinstr code. If you're in noinstr land, you need to use raw_atomic_long_inc_and_test there instead. Do not skip this. Do not vibe past it. This is the lowkey most important line on the page. 😭

⭐ RETURN ⭐

  • true β€” if the resulting value of v is zero.
  • false β€” otherwise.

That's the vibe check. Zero or not zero. Iconic binary behaviour. 🌈


πŸ¦„ SEE ALSO πŸ¦„

The source of all this is the kernel file ./include/linux/atomic/atomic-instrumented.h, and the family tree is enormous β€” like, this function has so many relatives. Here's the whole guest list, nobody left out, periodt:


🫢 okay that's the whole page!! go forth and increment atomically, bestie. and remember: not in noinstr code. use raw_atomic_long_inc_and_test there. iykyk πŸ’€

signing off from ./include/linux/atomic, dated October 2026 β€” this has been your girl atomic_long_inc_and_test(9), mwah πŸ’‹

πŸ“¦ where this page comes from