summaryrefslogtreecommitdiffstats
path: root/include/c.h
diff options
context:
space:
mode:
authorKarel Zak2010-02-12 21:42:46 +0100
committerKarel Zak2010-02-12 21:42:46 +0100
commit1cb1641dde2a15c58cfd144158b93d84be0137b9 (patch)
treef588cdae37a3681c81018fdce6a74db11f4f076a /include/c.h
parentmount: advise users to use "modprobe", not "insmod" (diff)
downloadkernel-qcow2-util-linux-1cb1641dde2a15c58cfd144158b93d84be0137b9.tar.gz
kernel-qcow2-util-linux-1cb1641dde2a15c58cfd144158b93d84be0137b9.tar.xz
kernel-qcow2-util-linux-1cb1641dde2a15c58cfd144158b93d84be0137b9.zip
include: add min/max macros
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'include/c.h')
-rw-r--r--include/c.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/c.h b/include/c.h
index 413366b2e..6615f6fea 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 */