[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1282238299-28315-1-git-send-email-hagen@jauu.net>
Date: Thu, 19 Aug 2010 19:18:18 +0200
From: Hagen Paul Pfeifer <hagen@...u.net>
To: linux-kernel@...r.kernel.org
Cc: Hagen Paul Pfeifer <hagen@...u.net>,
Andrew Morton <akpm@...ux-foundation.org>,
Joe Perches <joe@...ches.com>, Ingo Molnar <mingo@...e.hu>
Subject: [PATCH 1/2] 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.
Signed-off-by: Hagen Paul Pfeifer <hagen@...u.net>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Joe Perches <joe@...ches.com>
Cc: Ingo Molnar <mingo@...e.hu>
---
include/linux/kernel.h | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 2b0a35e..9a9b52c 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -640,6 +640,22 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
(void) (&_max1 == &_max2); \
_max1 > _max2 ? _max1 : _max2; })
+#define min3(x, y, z) ({ \
+ typeof(x) _min1 = (x); \
+ typeof(y) _min2 = (y); \
+ typeof(z) _min3 = (z); \
+ (void) (&_min1 == &_min2 == &_min3); \
+ _min1 < _min2 ? (_min1 < _min3 ? _min1 : _min3) : \
+ (_min2 < _min3 ? _min2 : _min3); })
+
+#define max3(x, y, z) ({ \
+ typeof(x) _max1 = (x); \
+ typeof(y) _max2 = (y); \
+ typeof(z) _max3 = (z); \
+ (void) (&_max1 == &_max2 == &_max3); \
+ _max1 > _max2 ? (_max1 > _max3 ? _max1 : _max3) : \
+ (_max2 > _max3 ? _max2 : _max3); })
+
/**
* clamp - return a value clamped to a given range with strict typechecking
* @val: current value
--
1.7.2.1.95.g3d045.dirty
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists