__ptr_test_bit(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… __ptr_test_bit β€” from the Kernel API Manual, bestie ✨

Okay so real talk, this one's a tiny little function from the Kernel API Manual and it's honestly so cute and specific: __ptr_test_bit is literally just testing a bit inside a pointer's value. That's the whole vibe. One bit, one pointer, no drama. πŸŽ€


✨ NAME ✨

__ptr_test_bit β€” test that bit in a pointer's value, bestie, go off πŸ‘‘


🌸 SYNOPSIS 🌸

__ptr_test_bit (nr , addr );

That's it. That's the whole call. She's lowkey minimal. πŸ’…


πŸ¦‹ ARGUMENTS πŸ¦‹

  • nr β€” the bit you wanna test, like which one, be specific 🎯
  • addr β€” the address of the pointer variable, iykyk πŸ“

πŸ’– EXAMPLE πŸ’–

Here's how she looks in the wild, no cap:

void *p = foo; if (__ptr_test_bit(bit, p)) { ...  } else { ...  }

So you set up void *p = foo;, you check __ptr_test_bit(bit, p), and then you pick your little branch β€” the ... if it's true, the other ... if it's not. Two paths, one bit check. Iconic. 🌈


πŸ”₯ SEE ALSO πŸ”₯

Okay so there's a whole friend group here and they all live in the kernel file ./include/linux/bitops.h β€” genuinely the main character energy file of bit twiddling:

Like, __ptr_set_bit(9) and __ptr_clear_bit(9) are literally her siblings, so if you're testing a bit you should 100% go say hi to the setter and the clearer too. 🫢


πŸ’€ Friendly reminder bestie: keep the names exactly as written, these are the actual symbols β€” do not come for me with a "typo" accusation.

MwAH, that's the page! πŸŽ€ This little gem comes to you from ./include/linux, dated October 2026, and the page is __ptr_test_bit(9) β€” truly a star. βœ¨πŸ’œ

πŸ“¦ where this page comes from