wrapping_sub(9)
π wrapping_sub(9)
okay so this is a page from the Kernel API Manual and it's about wrapping_sub β yes bestie, subtraction that's allowed to wrap around, on purpose, no cap π
β¨ NAME β¨
wrapping_sub β intentionally perform a wrapping subtraction π
like, the wrapping is the point, it's not a bug, it's a feature π
πΈ SYNOPSIS πΈ
wrapping_sub (type , a , b );
three things go in, one thing comes out, and the vibes are immaculate β¨
π¦ ARGUMENTS π¦
typeβ the type for the result of the calculation π this is what your answer is gonna be, so pick it with intentionaβ the minuend; the value you're subtracting from π«Ά the main character of this operation, honestlybβ the subtrahend; the value you subtract fromaπΈ the supporting role, but she delivers
ngl the naming is lowkey giving math class but fr fr a - b and you're done π
π DESCRIPTION π
Returns the potentially wrapped-around subtraction β and the whole reason this exists is so you don't trip any of the wrap-around sanitizers that might be enabled πβ¨
like bestie, the sanitizers will absolutely jump you if you do unsigned wrap math the "normal" way. this is the intentional, sanctioned, no-sneaky-surprises way to do it. the wrap is expected, the wrap is documented, the wrap is slaying π
it's giving "I know exactly what I'm doing" energy and I'm obsessed π
π SEE ALSO π
the kernel file ./include/linux/overflow.h is literally right there holding the whole overflow family together π§ and here's the entire squad, all (9) sections, no gatekeeping:
check_add_overflow(9)wrapping_add(9)wrapping_assign_add(9)check_sub_overflow(9)wrapping_assign_sub(9)check_mul_overflow(9)wrapping_mul(9)check_shl_overflow(9)overflows_type(9)range_overflows(9)range_overflows_t(9)range_end_overflows(9)range_end_overflows_t(9)castable_to_type(9)size_mul(9)size_add(9)size_sub(9)array_size(9)array3_size(9)flex_array_size(9)struct_size(9)struct_size_t(9)struct_offset(9)__DEFINE_FLEX(9)_DEFINE_FLEX(9)DEFINE_RAW_FLEX(9)DEFINE_FLEX(9)STACK_FLEX_ARRAY_SIZE(9)typeof_flex_counter(9)overflows_flex_counter_type(9)__set_flex_counter(9)
anyway that's the whole page, go forth and subtract with intent ππ¦
signed, sealed, delivered from ./include/linux β October 2026 edition, mwah ππ
π¦ 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