aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-03-15 13:05:15 +0100
committerThomas Voss <mail@thomasvoss.com> 2024-03-15 13:05:15 +0100
commit40d25acd8e352f1e534adb3c0433c67623c23946 (patch)
tree961d15469a4c68a8cf2372862269ffd24e5586db /include
parentfd3b4c38ad9cf702f68bd0138c9ea0b76a25208b (diff)
Add CLAMP()
Diffstat (limited to 'include')
-rw-r--r--include/macros.h5
1 files 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)))