summaryrefslogtreecommitdiff
path: root/lib/igt_aux.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/igt_aux.h')
-rw-r--r--lib/igt_aux.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index 9bb03b77..0eb96e44 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -228,6 +228,13 @@ void intel_require_files(uint64_t count);
_a > _b ? _a : _b; \
})
+#define clamp(x, min, max) ({ \
+ typeof(min) _min = (min); \
+ typeof(max) _max = (max); \
+ typeof(x) _x = (x); \
+ _x < _min ? _min : _x > _max ? _max : _x; \
+})
+
#define igt_swap(a, b) do { \
typeof(a) _tmp = (a); \
(a) = (b); \