]> err.no Git - util-linux/commitdiff
include: add min/max macros
authorKarel Zak <kzak@redhat.com>
Fri, 12 Feb 2010 20:42:46 +0000 (21:42 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 12 Feb 2010 20:42:46 +0000 (21:42 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
include/c.h

index 413366b2e058789e1abb3e51cde82367390b8a9a..6615f6feaa9b2a3f050d6c1f073e0f4ed1cc36c2 100644 (file)
 # 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 */