atomic_inc_not_zero(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ¦‹ atomic_inc_not_zero(9) πŸ¦‹

straight out of the Kernel API Manual, section 9, and honestly she's lowkey iconic β€” this is the "bump it, but only if it's not zero" girlie, and she comes with full ordering which is a whole vibe πŸ’…


✨ NAME ✨

atomic_inc_not_zero β€” atomic increment unless zero with full ordering πŸŽ€


🌸 SYNOPSIS 🌸

bool atomic_inc_not_zero (atomic_t *v );

πŸ’– ARGUMENTS πŸ’–

  • v β€” pointer to atomic_t 🫢 that's it, that's the whole argument list, she's low-maintenance.

πŸ”₯ DESCRIPTION πŸ”₯

okay so listen bestie: if (v != 0), this atomically updates v to (v + 1) with full ordering. slay. no cap.

Otherwise, v is not modified at all, and relaxed ordering is provided. so if it's zero, we're not touching it, we're just providing relaxed ordering and minding our business πŸ™ˆ

⚠️ Unsafe to use in noinstr code β€” use raw_atomic_inc_not_zero there. not me warning you twice, this is serious, fr fr πŸ’€

🌈 RETURN 🌈

  • true if v was updated πŸ”₯
  • false otherwise πŸ’€

it's giving very binary, very main character energy πŸ‘‘


πŸŽ€ SEE ALSO πŸŽ€

Kernel file ./include/linux/atomic/atomic-instrumented.h 🧚 β€” and like, the entire atomic family reunion, she brought everyone, prepare yourself:


🌸 and that's the whole page bestie β€” this one lives in ./include/linux/atomic, dated October 2026, and she answers to atomic_inc_not_zero(9) πŸ’– go forth and increment responsibly, ily 🫢✨

πŸ“¦ where this page comes from