BITMAP BITOPS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸŽ€ bitmap bitops πŸŽ€

okay bestie, welcome to bitmap bitops(9) from the Kernel API Manual β€” literally the backstage pass to bitmap bit-twiddling and I'm obsessed πŸ’…βœ¨

also, the following operations in asm/bitops.h apply to bitmaps.:

  • set_bit(bit, addr) β€” does *addr |= bit, so it sets that bit πŸ’–
  • clear_bit(bit, addr) β€” clears it with *addr &= ~bit 🧼
  • change_bit(bit, addr) β€” flips it via *addr ^= bit πŸ”
  • test_bit(bit, addr) β€” asks "is bit set in *addr?" πŸ‘€
  • test_and_set_bit(bit, addr) β€” sets bit and returns old value 🫢
  • test_and_clear_bit(bit, addr) β€” clears bit and returns old value 🧚
  • test_and_change_bit(bit, addr) β€” changes bit and returns old value 🌸
  • find_first_zero_bit(addr, nbits) β€” positions first zero bit in *addr πŸ•΅οΈβ€β™€οΈ
  • find_first_bit(addr, nbits) β€” positions first set bit in *addr ⭐
  • find_next_zero_bit(addr, nbits, bit) β€” positions next zero bit in *addr >= bit πŸ”
  • find_next_bit(addr, nbits, bit) β€” positions next set bit in *addr >= bit πŸ”₯
  • find_next_and_bit(addr1, addr2, nbits, bit) β€” same as find_next_bit, but in (*addr1 & *addr2) πŸ‘‘

🌈 SEE ALSO 🌈

mwah πŸ’‹ β€” this cutie came from ./include/linux, dated October 2026, and it's bitmap bitops(9) signing off 🫢

πŸ“¦ where this page comes from