From 1cb1641dde2a15c58cfd144158b93d84be0137b9 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