is_aligned(9)
π 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 datasizeβ size of each elementalignβ required alignment (typically4or8)
π 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 π¦
- Kernel file
./lib/sort.c swap_words_32(9)swap_words_64(9)swap_bytes(9)parent(9)sort_r(9)sort_r_nonatomic(9)
π«Ά 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
- 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