swap_words_32(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 NAME 🌸

okay so bestie, this is swap_words_32(9) from the Kernel API Manual, and it does exactly what it says on the tin: swap_words_32 β€” swap two elements in 32-bit chunks. iconic behavior, no cap πŸ’…

✨ SYNOPSIS ✨

void swap_words_32 (void *a , void *b , size_t n );

πŸŽ€ ARGUMENTS πŸŽ€

  • a β€” pointer to the first element to swap. yes queen, the first one.
  • b β€” pointer to the second element to swap. the other half of the swap, periodt.
  • n β€” element size, and it must be a multiple of 4. don't try to be cute with a weird size, fr fr.

πŸ’– DESCRIPTION πŸ’–

so what it does: it exchanges the two objects in memory. it exploits base+index addressing, which basically all CPUs have, to minimize loop overhead computations. lowkey efficient, highkey iconic ⚑

for some reason, on x86 gcc 7.3.0 adds a redundant test of n at the bottom of the loop, even though the zero flag is still valid from the subtract (since the intervening mov instructions don't alter the flags). Gcc 8.1.0 doesn't have that problem. not me side-eyeing the compiler πŸ’€

πŸ¦‹ SEE ALSO πŸ¦‹


okay bye bestie 🫢 this little manual moment is from the ./lib source, dated October 2026, and it's giving swap_words_32(9) in the Kernel API Manual energy βœ¨πŸ’…πŸŽ€

πŸ“¦ where this page comes from