From: Martin Mares Date: Tue, 16 Jul 2019 16:27:19 +0000 (+0200) Subject: Library: CLAMP X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=d3cc4a1e9b31eb56012549d934df327903e1d0d5;p=home-hw.git Library: CLAMP --- 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))