*[klæmp]
n. 夹钳
vt. 夹紧, 强加
【化】 卡子
【医】 夹, 夹具
/klæmp; klæmp/ n 1 (also cramp) device for holding things tightly together, usu by means of a screw 夹具; 夹铗. 2 piece of wood, metal, etc used for strengthening other materials or fastening things together 夹板; 压板.
v 1 [Tn] grip or hold (sth) (as if) with a clamp (像)用夹具夹住(某物): He kept his pipe clamped between his teeth. 他一直叼着烟斗. 2 [Tn, Tn.pr] ~ A and B (together); ~ A to B fasten (one thing to another) with a clamp 用夹具将(一物与另一物)夹紧, 固定住: clamp two boards together 把两块板夹在一起. 3 (phr v) clamp down on sb/sth (infml 口) become stricter about sth; use one’s authority against sb or to prevent or suppress sth 对某事更严格; 利用权势反对某人或防止或压制某事: The Government intends to clamp down on soccer hooliganism. 政府拟采取措施严禁在足球比赛中闹事.
下面是从内核里的代码里摘抄的一段:clamp这里是讲一个全局变量的值,控制在0到100内。
static void __init kfree_rcu_batch_init(void) /// 函数名是一个非常有用的唯一标识符。如果只贴代码片段,可能你得全局搜索找半天,如果是是给出函数名称,会加快找到出处的时间。
{
int cpu;
int i;
/* Clamp it to [0:100] seconds interval. */ ///这里是讲一个全局变量的值,控制在0到100内。
if (rcu_delay_page_cache_fill_msec < 0 ||
rcu_delay_page_cache_fill_msec > 100 * MSEC_PER_SEC) {
rcu_delay_page_cache_fill_msec =
clamp(rcu_delay_page_cache_fill_msec, 0,
(int) (100 * MSEC_PER_SEC));
pr_info("Adjusting rcutree.rcu_delay_page_cache_fill_msec to %d ms.\n",
rcu_delay_page_cache_fill_msec);
}
比如在mtu的处理里还专门有clamp函数,来限制mtu的范围。
mtu = clamp(dev->mtu, (unsigned int)ETH_MIN_MTU, (unsigned int)(max - sizeof(struct iphdr)));
/**
* clamp - return a value clamped to a given range with strict typechecking
* @val: current value
* @lo: lowest allowable value
* @hi: highest allowable value
*
* This macro does strict typechecking of @lo/@hi to make sure they are of the
* same type as @val. See the unnecessary pointer comparisons.
*/
#define clamp(val, lo, hi) min((typeof(val))max(val, lo), hi)