__ptr_test_bit(9)
π
__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:
rol64(9),ror64(9)rol32(9),ror32(9)rol16(9),ror16(9)rol8(9),ror8(9)sign_extend32(9),sign_extend64(9)get_count_order_long(9)parity8(9)__ffs64(9)fns(9)assign_bit(9)__ptr_set_bit(9)__ptr_clear_bit(9)
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms