summaryrefslogtreecommitdiff
path: root/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'util.h')
-rw-r--r--util.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/util.h b/util.h
index 13a8637..d4933c4 100644
--- a/util.h
+++ b/util.h
@@ -30,7 +30,7 @@
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
/*
- * min() macro with strict type-checking.
+ * min()/max() macros with strict type-checking.
* Taken from linux/kernel.h
*/
#undef min
@@ -40,6 +40,13 @@
(void) (&_min1 == &_min2); \
_min1 < _min2 ? _min1 : _min2; })
+#undef max
+#define max(x, y) ({ \
+ typeof(x) _max1 = (x); \
+ typeof(y) _max2 = (y); \
+ (void) (&_max1 == &_max2); \
+ _max1 > _max2 ? _max1 : _max2; })
+
static inline void __noreturn panic(const char *fmt, ...)
{
va_list vl;