If you are interested, the last version I had is the following. The
compile_time_assert is linus' idea. We had an illegal assembler
statement there originally, containing the line number and the
error statement. One or the other will do until gcc gets the
__builtin_ct_assert() function.
#define compile_time_assert(x) \
do { switch (0) { case 0: case (x) != 0: ; } } while (0)
#define __MIN(x,y) ({\
typeof(x) _x = x; \
typeof(y) _y = y; \
_x < _y ? _x : _y ; \
})
#define MIN(x,y) ({\
const typeof(x) _x = ~(typeof(x))0; \
const typeof(y) _y = ~(typeof(y))0; \
compile_time_assert(sizeof(_x) == sizeof(_y));\
compile_time_assert( (_x > (typeof(x))0 && _y > (typeof(y))0) \
|| (_x < (typeof(x))0 && _y < (typeof(y))0)); \
__MIN(x,y); \
})
Peter
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/