aboutsummaryrefslogtreecommitdiffstats
path: root/kerncompat.h
diff options
context:
space:
mode:
Diffstat (limited to 'kerncompat.h')
-rw-r--r--kerncompat.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/kerncompat.h b/kerncompat.h
index a38a9b0..c18fdf3 100644
--- a/kerncompat.h
+++ b/kerncompat.h
@@ -203,6 +203,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)