From 40d25acd8e352f1e534adb3c0433c67623c23946 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Fri, 15 Mar 2024 13:05:15 +0100 Subject: Add CLAMP() --- include/macros.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/macros.h b/include/macros.h index 6adc1e4..5be5e4a 100644 --- a/include/macros.h +++ b/include/macros.h @@ -1,8 +1,9 @@ #ifndef MLIB_MACROS_H #define MLIB_MACROS_H -#define MIN(x, y) ((x) < (y) ? (x) : (y)) -#define MAX(x, y) ((x) > (y) ? (x) : (y)) +#define CLAMP(x, min, max) ((x) < (min) ? (min) : (x) > (max) ? (max) : (x)) +#define MIN(x, y) ((x) < (y) ? (x) : (y)) +#define MAX(x, y) ((x) > (y) ? (x) : (y)) #define lengthof(a) (sizeof(a) / sizeof(*(a))) -- cgit v1.2.3