aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kernel.h
diff options
context:
space:
mode:
authorHagen Paul Pfeifer <hagen@jauu.net>2010-10-26 17:22:21 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-26 19:52:12 -0400
commitf27c85c56b32c42bcc54a43189c1e00fdceb23ec (patch)
treea3d8bd30d840082ea2709f47da5dca940aab0884 /include/linux/kernel.h
parentc5c6dd4e2dce3cb4d705d97183bc42b4e33e2606 (diff)
kernel.h: add {min,max}3 macros
Introduce two additional min/max macros to compare three operands. This will save some cycles as well as some bytes on the stack and last but not least more pleasing as macro nesting. [akpm@linux-foundation.org: fix warnings] Signed-off-by: Hagen Paul Pfeifer <hagen@jauu.net> Cc: Joe Perches <joe@perches.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Hartley Sweeten <hsweeten@visionengravers.com> Cc: Russell King <linux@arm.linux.org.uk> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Herbert Xu <herbert@gondor.apana.org.au> Cc: Roland Dreier <rolandd@cisco.com> Cc: Sean Hefty <sean.hefty@intel.com> Cc: Pekka Enberg <penberg@cs.helsinki.fi> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r--include/linux/kernel.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index edef168a0406..8e786a27cfe6 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -651,6 +651,24 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
651 (void) (&_max1 == &_max2); \ 651 (void) (&_max1 == &_max2); \
652 _max1 > _max2 ? _max1 : _max2; }) 652 _max1 > _max2 ? _max1 : _max2; })
653 653
654#define min3(x, y, z) ({ \
655 typeof(x) _min1 = (x); \
656 typeof(y) _min2 = (y); \
657 typeof(z) _min3 = (z); \
658 (void) (&_min1 == &_min2); \
659 (void) (&_min1 == &_min3); \
660 _min1 < _min2 ? (_min1 < _min3 ? _min1 : _min3) : \
661 (_min2 < _min3 ? _min2 : _min3); })
662
663#define max3(x, y, z) ({ \
664 typeof(x) _max1 = (x); \
665 typeof(y) _max2 = (y); \
666 typeof(z) _max3 = (z); \
667 (void) (&_max1 == &_max2); \
668 (void) (&_max1 == &_max3); \
669 _max1 > _max2 ? (_max1 > _max3 ? _max1 : _max3) : \
670 (_max2 > _max3 ? _max2 : _max3); })
671
654/** 672/**
655 * min_not_zero - return the minimum that is _not_ zero, unless both are zero 673 * min_not_zero - return the minimum that is _not_ zero, unless both are zero
656 * @x: value1 674 * @x: value1