]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Generalize ROUND_UP() macro and introduce matching ROUND_UP_PTR()
authorJes Sorensen <Jes.Sorensen@redhat.com>
Tue, 20 Mar 2012 21:04:24 +0000 (08:04 +1100)
committerNeilBrown <neilb@suse.de>
Tue, 20 Mar 2012 21:04:24 +0000 (08:04 +1100)
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
mdadm.h

diff --git a/mdadm.h b/mdadm.h
index 45198bbdee306b223641ed4bb38934b35a668b03..314f3ac585a7ec23ffa628ef29af9b449218ccbd 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -1252,10 +1252,10 @@ static inline int dev2minor(int d)
        return (-1-d) << MdpMinorShift;
 }
 
-static inline int ROUND_UP(int a, int base)
-{
-       return ((a+base-1)/base)*base;
-}
+#define _ROUND_UP(val, base)   (((val) + (base)) & ~(base - 1))
+#define ROUND_UP(val, base)    _ROUND_UP(val, (typeof(val))(base))
+#define ROUND_UP_PTR(ptr, base)        ((typeof(ptr)) \
+                                (ROUND_UP((unsigned long)(ptr), base)))
 
 static inline int is_subarray(char *vers)
 {