diff mbox

[U-Boot,5/6] linux/kernel.h: add typechecking to roundup macro

Message ID 1415100418-29016-6-git-send-email-yamada.m@jp.panasonic.com
State Superseded
Delegated to: Tom Rini
Headers show

Commit Message

Masahiro Yamada Nov. 4, 2014, 11:26 a.m. UTC
This commit replaces roundup macro with the one from Linux Kernel.

DEFINE_ALIGN_BUFFER must be fixed because typechecking can not
be used in this context.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
---

 include/common.h       | 2 +-
 include/linux/kernel.h | 9 +++++++--
 2 files changed, 8 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/include/common.h b/include/common.h
index c1bdaec..ce0a734 100644
--- a/include/common.h
+++ b/include/common.h
@@ -967,7 +967,7 @@  static inline phys_addr_t map_to_sysmem(const void *ptr)
  * Usage of this macro shall be avoided or used with extreme care!
  */
 #define DEFINE_ALIGN_BUFFER(type, name, size, align)			\
-	static char __##name[roundup(size * sizeof(type), align)]	\
+	static char __##name[ALIGN(size * sizeof(type), align)]	\
 			__aligned(align);				\
 									\
 	static type *name = (type *)__##name
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index f84a764..0e838de 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -61,8 +61,13 @@ 
 # define DIV_ROUND_UP_SECTOR_T(ll,d) DIV_ROUND_UP(ll,d)
 #endif
 
-#define roundup(x, y)		((((x) + ((y) - 1)) / (y)) * (y))
-
+/* The `const' in roundup() prevents gcc-3.3 from calling __divdi3 */
+#define roundup(x, y) (					\
+{							\
+	const typeof(y) __y = y;			\
+	(((x) + (__y - 1)) / __y) * __y;		\
+}							\
+)
 #define rounddown(x, y) (				\
 {							\
 	typeof(x) __x = (x);				\