X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=para.h;h=5dec070f00458bd59d62fbb8fed1b3bc60cb31da;hb=c64fd11b94ff98667642751fba69c60ab4af01a4;hp=f41e8b67acfcf90fe07745fa30b4723245e8e8dd;hpb=f6f50d03a09d6bc423324206d274336e9905bbb4;p=paraslash.git diff --git a/para.h b/para.h index f41e8b67..5dec070f 100644 --- a/para.h +++ b/para.h @@ -200,3 +200,14 @@ __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)) + +/** Get the size of an array */ +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))