clamp(9)
π clamp(9) π
okay bestie, welcome to the Kernel API Manual page for clamp β and yes, this is exactly the kind of tiny macro that has main character energy in the kernel β¨
π NAME π
clamp β return a value clamped to a given range with typechecking
π¦ SYNOPSIS π¦
clamp (val , lo , hi );
πΈ ARGUMENTS πΈ
valβ current valueloβ lowest allowable valuehiβ highest allowable value
β¨ DESCRIPTION β¨
This macro checks val/lo/hi to make sure they have compatible signedness.
lowkey that's the whole vibe check: typechecking the signedness situation before anything else gets cute π
π₯ SEE ALSO π₯
Kernel file ./include/linux/minmax.h β and these iconic friends are all linked up:
min(9)max(9)umin(9)umax(9)min3(9)max3(9)min_t(9)max_t(9)min_not_zero(9)clamp_t(9)clamp_val(9)min_array(9)max_array(9)in_range(9)swap(9)
mwah π signed off from ./include/linux, dated October 2026, still serving clamp(9) realness β bye bestie π«Άπ
π¦ 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