atomic_long_add_negative(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… atomic_long_add_negative(9) πŸ’…

okay so bestie, welcome to section 9 of the Kernel API Manual β€” we're doing kernel function pages today and honestly? This one is a little baddie. ✨


🌸 NAME 🌸

atomic_long_add_negative β€” does an atomic add and tells you if the result came out negative, with full ordering. Like, it does both things and it does them correctly, no cap. πŸ‘‘


πŸ¦‹ SYNOPSIS πŸ¦‹

bool atomic_long_add_negative (long i , atomic_long_t *v );

πŸŽ€ ARGUMENTS πŸŽ€

  • i β€” the long value you're adding. That's it, that's the number. πŸ’–
  • v β€” a pointer to the atomic_long_t you're messing with. she's the main character here, respect her.

✨ DESCRIPTION ✨

So here's the vibe: this function atomically updates v to (v + i), and it does it with full ordering. Atomic and ordered, she's got her whole life together. 🫢

⚠️ not me warning you: this is unsafe to use in noinstr code. fr fr, don't do it. If you're in noinstr land you need raw_atomic_long_add_negative instead. different function, different vibe, use that one there. πŸ’€

⭐ RETURN ⭐

Returns true if the resulting value of v is negative, and false if it isn't. Binary queen, she gives you one of two answers, no in-between. πŸŽ€


🌈 SEE ALSO 🌈

first up, the kernel file this lives in β€” ./include/linux/atomic/atomic-instrumented.h β€” and then the entire extended friend group 😭 (yes, all of them, I'm not skipping anyone, everybody ate):


okay that's the whole page bestie 🫢 love u, go be atomic, and remember: she was documented under ./include/linux/atomic in October 2026 β€” that's the source and the date, mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from