X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=para.h;h=218b8147add53bf6805b0a8135927a8e36faa95a;hp=d69acdf63e0cdfb30c62d24f6c5f335040090507;hb=9864bc0d0bc68fd885187bf92c5271db56888ea1;hpb=2e0a7f6ff3d11d63a9dc733db149e2f4b431ed2f diff --git a/para.h b/para.h index d69acdf6..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 @@ -157,6 +169,9 @@ int tv_convex_combination(const long a, const struct timeval *tv1, const long b, const struct timeval *tv2, struct timeval *result); void ms2tv(const long unsigned n, struct timeval *tv); +void compute_chunk_time(long unsigned chunk_num, + struct timeval *chunk_tv, struct timeval *stream_start, + struct timeval *result); /** The enum of all status items. */ enum status_items {STATUS_ITEM_ENUM NUM_STAT_ITEMS};