[PATCH 2/3] add roundup and rounddown support

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Sat Nov 3 16:58:29 EDT 2012


Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 include/linux/kernel.h |   15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index e9e2f07..92c3391 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -90,5 +90,20 @@
 	__val = __val < __min ? __min: __val;	\
 	__val > __max ? __max: __val; })
 
+
+/* 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);				\
+	__x - (__x % (y));				\
+}							\
+)
+
 #endif /* _LINUX_KERNEL_H */
 
-- 
1.7.10.4




More information about the barebox mailing list