STRUCT CRC_VARIANT(9)
π struct crc_variant(9) π
okay so real talk β we're in the Kernel API Manual bestie, and this page is all about struct crc_variant, which (spoiler) describes a CRC variant. that's it, that's the whole vibe. she's a little struct with big main character energy π
β¨ NAME β¨
struct crc_variant β literally just describes a CRC variant, no cap π
πΈ SYNOPSIS πΈ
struct crc_variant {
int bits;
bool le;
u64 poly;
u64 (*func)(u64 crc, const u8 *p, size_t len);
};
look at her. iconic. four members. not one of them extra π¦
π«Ά Members π«Ά
bitsβ the number of bits in the CRC, and the range is1 <= bits <= 64. so like, anywhere from bebe CRC-1 all the way up to the big girl CRC-64 πleβtrueif it's a "little endian" CRC (that's the reversed mapping between bits and polynomial coefficients in each byte), orfalseif it's a "big endian" CRC (the natural mapping between bits and polynomial coefficients in each byte). so basically this flag is the vibe check on which way your bits are facing πpolyβ the generator polynomial, but with the highest-order term omitted (she's humble like that, she leaves the top term at home). and bit-reversed ifleistrueβ do not forget this part bestie, it matters πfuncβ the function that actually computes a CRC π₯. its type signature usesu64so that it can fit any CRC up to CRC-64. the CRC comes in as an argument, and it's expected to be returned in, the least significant bits of theu64. and heads up, the function is expected to not invert the CRC at the beginning and end β like, none of that, leave the inverting alone π
fr fr, that last bit about func is the one people get wrong. no inverting at the start, no inverting at the end, periodt π
π SEE ALSO π
Kernel file ./lib/crc/tests/crc_kunit.c β go read it, iykyk π
okay that's the whole page!! β¨ source lives in ./lib/crc/tests and this lil cutie is dated October 2026 β stay slay, stay byte-aligned, drink water πππ¦π
π¦ 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