From: Zhang Yanfei <[email protected]>

This patch imports Macros for align operation:
- _ALIGN_UP(addr, size): align addr up on a size boundary
- _ALIGN_DOWN(addr, size): align addr down on a size boundary
- _ALIGN(addr, size): align addr up on a size boundary

Signed-off-by: Zhang Yanfei <[email protected]>
---
 kexec/kexec.h |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/kexec/kexec.h b/kexec/kexec.h
index 94c62c1..916a24b 100644
--- a/kexec/kexec.h
+++ b/kexec/kexec.h
@@ -100,6 +100,18 @@ do { \
        } \
 } while(0)
 
+#define _ALIGN_UP_MASK(addr, mask)   (((addr) + (mask)) & ~(mask))
+#define _ALIGN_DOWN_MASK(addr, mask) ((addr) & ~(mask))
+
+/* align addr on a size boundary - adjust address up/down if needed */
+#define _ALIGN_UP(addr, size)       \
+       _ALIGN_UP_MASK(addr, (typeof(addr))(size) - 1)
+#define _ALIGN_DOWN(addr, size)             \
+       _ALIGN_DOWN_MASK(addr, (typeof(addr))(size) - 1)
+
+/* align addr on a size boundary - adjust address up if needed */
+#define _ALIGN(addr, size)     _ALIGN_UP(addr, size)
+
 extern unsigned long long mem_min, mem_max;
 extern int kexec_debug;
 
-- 
1.7.1

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

Reply via email to