diff options
-rw-r--r-- | include/util.h | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/include/util.h b/include/util.h index 89e07deb1e..e952123e37 100644 --- a/include/util.h +++ b/include/util.h @@ -33,13 +33,24 @@ #define ASSERT(cond) #endif - /* Standard macros / definitions */ #ifndef MAX -#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#define MAX(a, b) \ + ({ \ + __typeof__(a) temp_a = (a); \ + __typeof__(b) temp_b = (b); \ + \ + temp_a > temp_b ? temp_a : temp_b; \ + }) #endif #ifndef MIN -#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#define MIN(a, b) \ + ({ \ + __typeof__(a) temp_a = (a); \ + __typeof__(b) temp_b = (b); \ + \ + temp_a < temp_b ? temp_a : temp_b; \ + }) #endif #ifndef NULL #define NULL ((void *)0) |