packing(9)
π packing(9) π
okay so welcome to the Kernel API Manual, bestie β section 9, the packing page. This one is lowkey a translator between number formats, and we're gonna get you through it. π
β¨ NAME β¨
packing β converts numbers (currently u64) between a packed and an unpacked format. Unpacked means laid out in memory in the CPU's native understanding of integers, while packed means anything else that requires translation. That's the whole vibe check: native layout vs. needs-translation layout. π¦
π SYNOPSIS π
int packing (void *pbuf , u64 *uval , int startbit , int endbit , size_t pbuflen , enum packing_op op , u8 quirks );
π ARGUMENTS π
pbufβ pointer to a buffer holding the packed value. That's where the packed bits live.uvalβ pointer to anu64holding the unpacked value. That's the native-layout number.startbitβ the index (in logical notation, compensated for quirks) where the packed value starts withinpbuf. It must be larger than, or equal to,endbit. Bestie, respect the order. π«Άendbitβ the index (in logical notation, compensated for quirks) where the packed value ends withinpbuf. It must be smaller than, or equal to,startbit. Yep, same relationship, other side.pbuflenβ the length in bytes of the packed buffer pointed to bypbuf. It's giving "know your buffer size." πopβ ifPACK, thenuvalwill be treated as const pointer and copied (packed) intopbuf, betweenstartbitandendbit. IfUNPACK, thenpbufwill be treated as const pointer and the logical value betweenstartbitandendbitwill be copied (unpacked) touval. Two directions, one enum, no cap. πquirksβ a bit mask ofQUIRK_LITTLE_ENDIAN,QUIRK_LSW32_IS_FIRSTandQUIRK_MSB_ON_THE_RIGHT. These are the little endian/bit-order gremlins and you gotta name them. π§
β οΈ NOTE β οΈ
this is deprecated, prefer to usepackorunpackin new code.
No cap, deprecated means deprecated. If you're writing new code, use pack or unpack, not this. π
π₯ RETURN π₯
0 on success, EINVAL or ERANGE if called incorrectly. Assuming correct usage, return code may be discarded. If op is PACK, pbuf is modified. If op is UNPACK, uval is modified.
So: success is 0; bad calls get EINVAL or ERANGE; and if you're using it correctly, you can discard the return code. Also heads up: PACK mutates pbuf, UNPACK mutates uval. Main character mutation energy. π
π SEE ALSO π
Kernel file ./lib/packing.c, plus calculate_box_addr(9), pack(9), unpack(9), pack_fields_u8(9), pack_fields_u16(9), unpack_fields_u8(9), unpack_fields_u16(9). Go read those next, bestie. π
and that's the page, bestie β brought to you by the Kernel API Manual, source/version ./lib, dated October 2026. packing(9) out. ππ
β¨
π¦ 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