From d3cc4a1e9b31eb56012549d934df327903e1d0d5 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Tue, 16 Jul 2019 18:27:19 +0200 Subject: [PATCH] Library: CLAMP --- lib/util.h | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/util.h b/lib/util.h index 8aa02f4..b37c527 100644 --- a/lib/util.h +++ b/lib/util.h @@ -23,6 +23,7 @@ typedef int32_t s32; #define MIN(x,y) ((x) < (y) ? (x) : (y)) #define MAX(x,y) ((x) > (y) ? (x) : (y)) +#define CLAMP(x,min,max) ({ typeof(x) _t=x; (_t < min) ? min : (_t > max) ? max : _t; }) #define UNUSED __attribute__((unused)) -- 2.39.2