aboutsummaryrefslogtreecommitdiffstats
path: root/kerncompat.h
diff options
context:
space:
mode:
authorChris Mason <chris.mason@fusionio.com>2013-02-06 12:51:58 -0500
committerChris Mason <chris.mason@fusionio.com>2013-02-06 12:51:58 -0500
commit82ac34581e8fae6ef3f84758361c75f5b30c576d (patch)
treeb7bb32f9e4b4f5989cc148543bf2782abb0a1c93 /kerncompat.h
parent7b1c567c84a6292c138db3bd1638e19e73e0e593 (diff)
parent2986545ccd655273658e0e4463a669bb1893ba68 (diff)
downloadbtrfs-progs-82ac34581e8fae6ef3f84758361c75f5b30c576d.tar.gz
btrfs-progs-82ac34581e8fae6ef3f84758361c75f5b30c576d.tar.xz
btrfs-progs-82ac34581e8fae6ef3f84758361c75f5b30c576d.zip
Merge branch 'cov-fixes-v1-integration-20130201' of http://git.zabbo.net/cgit/btrfs-progs into merged
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 0ab2baf..9c116b4 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)