5 * This looks more complex than it should be. But we need to
6 * get the type for the ~ right in round_down (it needs to be
7 * as wide as the result!), and we want to evaluate the macro
8 * arguments just once each.
10 #define __round_mask(x, y) ((__typeof__(x))((y)-1))
11 #define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1)
12 #define round_down(x, y) ((x) & ~__round_mask(x, y))
14 #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
17 #define roundup(x, y) ( \
19 const typeof(y) __y = y; \
20 (((x) + (__y - 1)) / __y) * __y; \