diff options
Diffstat (limited to 'kerncompat.h')
-rw-r--r-- | kerncompat.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/kerncompat.h b/kerncompat.h index 0ab2baf9..9c116b4f 100644 --- a/kerncompat.h +++ b/kerncompat.h @@ -207,6 +207,16 @@ static inline long IS_ERR(const void *ptr) ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; }) /* + * This looks more complex than it should be. But we need to + * get the type for the ~ right in round_down (it needs to be + * as wide as the result!), and we want to evaluate the macro + * arguments just once each. + */ +#define __round_mask(x, y) ((__typeof__(x))((y)-1)) +#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1) +#define round_down(x, y) ((x) & ~__round_mask(x, y)) + +/* * printk */ #define printk(fmt, args...) fprintf(stderr, fmt, ##args) |