From 43bc2ac724e1e1340827dd777ec4dbb6b94b4603 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sat, 17 May 2014 00:53:41 -0400 Subject: added MIN, MAX, and CLAMP macros to common_funcs --- src/common/common_funcs.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/common/common_funcs.h') diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h index f8d10eb3..dca4dc47 100644 --- a/src/common/common_funcs.h +++ b/src/common/common_funcs.h @@ -22,6 +22,11 @@ template<> struct CompileTimeAssert {}; #define b32(x) (b16(x) | (b16(x) >>16) ) #define ROUND_UP_POW2(x) (b32(x - 1) + 1) +#define MIN(a, b) ((a)<(b)?(a):(b)) +#define MAX(a, b) ((a)>(b)?(a):(b)) + +#define CLAMP(x, min, max) (((x) > max) ? max : (((x) < min) ? min : (x))) + #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) #ifndef _WIN32 -- cgit v1.2.3