hv: add clamp macro for convenience

Add clamp macro to clamp a value within a range.

Tracked-On: #8500
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
Signed-off-by: Qiang Zhang <qiang4.zhang@intel.com>
This commit is contained in:
Qiang Zhang 2023-08-31 13:58:37 +08:00 committed by acrnsi-robot
parent 9a6e940849
commit c000a3f70b
1 changed files with 3 additions and 0 deletions

View File

@ -22,6 +22,9 @@
#define max(x, y) (((x) < (y)) ? (y) : (x))
/** return a value of v clamped to the range [l, h] */
#define clamp(v, l, h) (max(min((v), (h)), (l)))
/** Replaces 'x' by the string "x". */
#define STRINGIFY(x) #x