From a3e5ea3047b85b73142df4bd8c76ff14ca61b459 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 12 Feb 2010 21:42:46 +0100 Subject: [PATCH] include: add min/max macros Signed-off-by: Karel Zak --- include/c.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/c.h b/include/c.h index 413366b2..6615f6fe 100644 --- a/include/c.h +++ b/include/c.h @@ -46,4 +46,17 @@ # define FALSE 0 #endif + +#define min(x, y) ({ \ + typeof(x) _min1 = (x); \ + typeof(y) _min2 = (y); \ + (void) (&_min1 == &_min2); \ + _min1 < _min2 ? _min1 : _min2; }) + +#define max(x, y) ({ \ + typeof(x) _max1 = (x); \ + typeof(y) _max2 = (y); \ + (void) (&_max1 == &_max2); \ + _max1 > _max2 ? _max1 : _max2; }) + #endif /* UTIL_LINUX_C_H */ -- 2.39.5