summaryrefslogtreecommitdiffstats
path: root/src/include/util/align.H
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/util/align.H')
-rw-r--r--src/include/util/align.H18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/include/util/align.H b/src/include/util/align.H
index 55073256d..8ba0e06b9 100644
--- a/src/include/util/align.H
+++ b/src/include/util/align.H
@@ -25,14 +25,20 @@
#include <limits.h>
-// Return a number >= input that is aligned on a 4-byte boundary
-#define ALIGN_4(u) ((u + 0x3ull) & ~0x3ull)
+// Return a number >= input that is aligned up to the next 4-byte boundary
+#define ALIGN_4(u) (((u) + 0x3ull) & ~0x3ull)
-// Return a number >= input that is aligned on a 8-byte bounday
-#define ALIGN_8(u) ((u + 0x7ull) & ~0x7ull)
+// Return a number <= input that is rounded down to nearest 4-byte boundary
+#define ALIGN_DOWN_4(u) ((u) & ~3ull)
-// Return a number >= input that is aligned on a page boundary
-#define ALIGN_PAGE(u) ((u + (PAGESIZE-1)) & ~(PAGESIZE-1))
+// Return a number >= input that is aligned up to the next 8-byte bounday
+#define ALIGN_8(u) (((u) + 0x7ull) & ~0x7ull)
+
+// Return a number <= input that is rounded down to nearest 8-byte boundary
+#define ALIGN_DOWN_8(u) ((u) & ~7ull)
+
+// Return a number >= input that is aligned up to the next page boundary
+#define ALIGN_PAGE(u) (((u) + (PAGESIZE-1)) & ~(PAGESIZE-1))
// Return a number <= input that is aligned on a page boundary
#define ALIGN_PAGE_DOWN(u) ((u) - (u)%PAGESIZE)
OpenPOWER on IntegriCloud