From 36a26c69b4c70396ef569c3452690fba0c1dec08 Mon Sep 17 00:00:00 2001 From: Nicholas Bellinger Date: Tue, 26 Jul 2011 00:35:26 -0700 Subject: [PATCH] kernel.h: Add DIV_ROUND_UP_ULL and DIV_ROUND_UP_SECTOR_T macro usage Add new DIV_ROUND_UP_SECTOR_T macro usage for 32-bit architectures requiring a new DIV_ROUND_UP_ULL, and existing 64-bit usage with DIV_ROUND_UP. Reported-by: Linus Torvalds Reported-by: Andrew Morton Signed-off-by: Nicholas A. Bellinger --- include/linux/kernel.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 567a6f7bbeed..2642497c36fb 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -56,6 +56,14 @@ #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) +#define DIV_ROUND_UP_ULL(ll,d) \ + ({ unsigned long long _tmp = (ll)+(d)-1; do_div(_tmp, d); _tmp; }) + +#if BITS_PER_LONG == 32 +# define DIV_ROUND_UP_SECTOR_T(ll,d) DIV_ROUND_UP_ULL(ll, d) +#else +# define DIV_ROUND_UP_SECTOR_T(ll,d) DIV_ROUND_UP(ll,d) +#endif /* The `const' in roundup() prevents gcc-3.3 from calling __divdi3 */ #define roundup(x, y) ( \