summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2010-02-12 21:42:46 +0100
committerKarel Zak <kzak@redhat.com>2010-02-12 21:42:46 +0100
commit1cb1641dde2a15c58cfd144158b93d84be0137b9 (patch)
treef588cdae37a3681c81018fdce6a74db11f4f076a /include
parent4bc7b0e24d9560c7d58727f1d4d184df2c2ea884 (diff)
downloadutil-linux-old-1cb1641dde2a15c58cfd144158b93d84be0137b9.tar.gz
include: add min/max macros
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/c.h13
1 files changed, 13 insertions, 0 deletions
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 */