X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=para.h;h=f095a6aa385d2f717048f1e25e15741a15632617;hp=c5e12fe6da3ef864bdc16bb0eaa178a8b5965cee;hb=1199398;hpb=f7527caf231e06672f6079026eeb338a68e69474 diff --git a/para.h b/para.h index c5e12fe6..f095a6aa 100644 --- a/para.h +++ b/para.h @@ -165,6 +165,16 @@ _static_inline_ long int para_random(unsigned max) return ((max + 0.0) * (random() / (RAND_MAX + 1.0))); } +/** Round up x to next multiple of y. */ +#define ROUND_UP(x, y) ({ \ + const typeof(y) _divisor = y; \ + ((x) + _divisor - 1) / _divisor * _divisor; }) + +/** Round down x to multiple of y. */ +#define ROUND_DOWN(x, y) ({ \ + const typeof(y) _divisor = y; \ + (x) / _divisor * _divisor; }) + /** Divide and round up to next integer. */ #define DIV_ROUND_UP(x, y) ({ \ typeof(y) _divisor = y; \