0001 #ifndef _TOOLS_MATH_H
0002 #define _TOOLS_MATH_H
0003
0004
0005
0006
0007
0008
0009
0010 #define __round_mask(x, y) ((__typeof__(x))((y)-1))
0011 #define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1)
0012 #define round_down(x, y) ((x) & ~__round_mask(x, y))
0013
0014 #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
0015
0016 #ifndef roundup
0017 #define roundup(x, y) ( \
0018 { \
0019 const typeof(y) __y = y; \
0020 (((x) + (__y - 1)) / __y) * __y; \
0021 } \
0022 )
0023 #endif
0024
0025 #endif