X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=para.h;h=218b8147add53bf6805b0a8135927a8e36faa95a;hp=a39ed97df45502a0f93dcd8217cf5d9d6e792c78;hb=9864bc0d0bc68fd885187bf92c5271db56888ea1;hpb=04a8d064400936dc6ecd3b137397cb2ce2cc25d7 diff --git a/para.h b/para.h index a39ed97d..218b8147 100644 --- a/para.h +++ b/para.h @@ -30,12 +30,24 @@ /** used in various contexts */ #define MAXLINE 255 -/** compute the minimum of \a a and \a b */ -#define PARA_MIN(a,b) ((a) < (b) ? (a) : (b)) -/** compute the maximum of \a a and \a b */ -#define PARA_MAX(a,b) ((a) > (b) ? (a) : (b)) -/** compute the absolute value of \a a */ -#define PARA_ABS(a) ((a) > 0 ? (a) : -(a)) +/** Compute the minimum of \a x and \a y. */ +#define PARA_MIN(x, y) ({ \ + typeof(x) _min1 = (x); \ + typeof(y) _min2 = (y); \ + (void) (&_min1 == &_min2); \ + _min1 < _min2 ? _min1 : _min2; }) + +/** Compute the maximum of \a x and \a y. */ +#define PARA_MAX(x, y) ({ \ + typeof(x) _max1 = (x); \ + typeof(y) _max2 = (y); \ + (void) (&_max1 == &_max2); \ + _max1 < _max2 ? _max2 : _max1; }) + +/** Compute the absolute value of \a x. */ +#define PARA_ABS(x) ({ \ + typeof(x) _x = (x); \ + _x > 0? _x : -_x; }) /** debug loglevel, gets really noisy */ #define DEBUG 1