clamp_t(9)
π clamp_t(9) β the group chat version
okay so bestie, this is a page straight out of the Kernel API Manual (yes, the clamp_t(9) one β you found it, proud of you π«Ά), and I'm gonna walk you through it like we're texting at 2am.
β¨ NAME β¨
clamp_t β return a value clamped to a given range using a given type π
like... it clamps. with a type. that's the whole vibe.
πΈ SYNOPSIS πΈ
clamp_t (type , val , lo , hi );
four little arguments, one iconic macro. no cap. β
π¦ ARGUMENTS π¦
typeβ the type of variable to use π like, what flavour of number are we working with herevalβ current value π₯ the one that needs to get put in its placeloβ minimum allowable value π the floor, literallyhiβ maximum allowable value π the ceiling, the limit, the final boss
π DESCRIPTION π
So here's the tea: this macro does no typechecking π like zero, none, it does not check your vibes at the door. It just uses temporary variables of type type to make all the comparisons. That's it. That's the whole description. It's giving "small but mighty" energy. π
ngl this is the part where I remind you: no typechecking means no typechecking. fr fr. the macro trusts you completely and that's a lot of pressure. π
π₯ SEE ALSO π₯
The kernel file ./include/linux/minmax.h (yes, that's where the family lives π§) and honestly the whole minmax friend group ate:
min(9), max(9), umin(9), umax(9), min3(9), max3(9), min_t(9), max_t(9), min_not_zero(9), clamp(9), clamp_val(9), min_array(9), max_array(9), in_range(9), swap(9)
collect them all bestie, they're all in there πβ¨
mwah, that's the page! π This little love letter comes to you from ./include/linux, dated October 2026 β clamp responsibly, and remember: the typechecking was inside you all along (jk it wasn't, please be careful ππ
).
π¦ 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