X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=para.h;h=a580b14c9946bf9d10d1062a49b445e295ba72ff;hp=f41e8b67acfcf90fe07745fa30b4723245e8e8dd;hb=8fe757457fa56a6a1c9f17c466391d790ff58c58;hpb=f6f50d03a09d6bc423324206d274336e9905bbb4 diff --git a/para.h b/para.h index f41e8b67..a580b14c 100644 --- a/para.h +++ b/para.h @@ -200,3 +200,11 @@ __printf_2_3 void para_log(int, const char*, ...); p = para_realloc(p, size); \ } \ } + +static inline int para_random(unsigned max) +{ + return ((max + 0.0) * (rand() / (RAND_MAX + 1.0))); +} + +/* Round up x to a multiple of y */ +#define ROUND_UP(x, y) (((x) + (y - 1) / (y)) * (y))