linux/kernel.h: add typechecking to roundup macro
authorMasahiro Yamada <yamada.m@jp.panasonic.com>
Thu, 6 Nov 2014 18:03:30 +0000 (03:03 +0900)
committerTom Rini <trini@ti.com>
Thu, 20 Nov 2014 16:28:25 +0000 (11:28 -0500)
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
include/linux/kernel.h

index c1bdaeccaa48800fcff919fe9a4cc599dcceb2de..ce0a7343f4e402683459b244580ee3b713cf2097 100644 (file)
@@ -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
index f84a764bc900364f9efd5a1e479de908ddfbef9f..0e838de094569ac5b2ede26846ac248e6a37ab81 100644 (file)
 # 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);                            \