is_aligned(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… is_aligned β€” Kernel API Manual energy ✨

okay so this is the is_aligned page from the Kernel API Manual, and it's lowkey a vibe check for pointers and sizes. Let's get into it, bestie 🫢


🌸 NAME 🌸

is_aligned β€” is this pointer & size okay for word-wide copying?


✨ SYNOPSIS ✨

bool is_aligned (const void *base , size_t size , unsigned char align );

πŸŽ€ ARGUMENTS πŸŽ€

  • base β€” pointer to data
  • size β€” size of each element
  • align β€” required alignment (typically 4 or 8)

πŸ’– DESCRIPTION πŸ’–

Returns true if elements can be copied using word loads and stores. The size must be a multiple of the alignment, and β€” fr fr, this is the exact wording β€” the base address must be if we do not have CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS.

For some reason, gcc doesn't know to optimize if (a & mask || b & mask) to if ((a | b) & mask), so we do that by hand. iconic little workaround, ngl πŸ’…


πŸ¦‹ SEE ALSO πŸ¦‹


🫢 cute little sign-off: source/version is ./lib, dated October 2026, and the page is is_aligned(9) β€” bye bestie, go align something slay πŸ’–βœ¨

πŸ“¦ where this page comes from