Re: [RFC 3/3] kernel.h: use new typechecking macros in min()/max()and friends

From: Peter Zijlstra
Date: Sat Apr 14 2012 - 17:01:49 EST


On Sat, 2012-04-14 at 18:14 -0400, Sasha Levin wrote:
> #define min(x, y) ({ \
> - typeof(x) _min1 = (x); \
> - typeof(y) _min2 = (y); \
> - (void) (&_min1 == &_min2); \
> - _min1 < _min2 ? _min1 : _min2; })
> + typecmp2((x), (y)); \
> + (x) < (y) ? (x) : (y); })

Problem with this is that it evaluates x and y multiple times.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/