coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
clamp.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: GPL-2.0-only */
2
3
#ifndef COMMONLIB_CLAMP_H
4
#define COMMONLIB_CLAMP_H
5
6
#include <
stdint.h
>
7
8
/*
9
* Clamp a value, so that it is between a lower and an upper bound.
10
*/
11
static
inline
u32
clamp_u32
(
const
u32
min,
const
u32
val
,
const
u32
max)
12
{
13
if
(
val
> max)
14
return
max;
15
16
if
(
val
< min)
17
return
min;
18
19
return
val
;
20
}
21
22
#endif
/* COMMONLIB_CLAMP_H */
clamp_u32
static u32 clamp_u32(const u32 min, const u32 val, const u32 max)
Definition:
clamp.h:11
stdint.h
u32
uint32_t u32
Definition:
stdint.h:51
val
u8 val
Definition:
sys.c:300
src
commonlib
include
commonlib
clamp.h
Generated by
1.9.1