diff --git a/hypervisor/include/lib/util.h b/hypervisor/include/lib/util.h index 176455a3e..c7e3604d2 100644 --- a/hypervisor/include/lib/util.h +++ b/hypervisor/include/lib/util.h @@ -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