Move the duplicated alignment macros to a common location.

Change-Id: I11cb1c3034a3a4e7d8e8c0793f5c85fa623155b2
diff --git a/vm/Common.h b/vm/Common.h
index 208ed20..19de943 100644
--- a/vm/Common.h
+++ b/vm/Common.h
@@ -40,6 +40,11 @@
 #define LIKELY(exp) (__builtin_expect((exp) != 0, true))
 #define UNLIKELY(exp) (__builtin_expect((exp) != 0, false))
 
+#define ALIGN_UP(x, n) (((size_t)(x) + (n) - 1) & ~((n) - 1))
+#define ALIGN_DOWN(x, n) ((size_t)(x) & -(n))
+#define ALIGN_UP_TO_PAGE_SIZE(p) ALIGN_UP(p, SYSTEM_PAGE_SIZE)
+#define ALIGN_DOWN_TO_PAGE_SIZE(p) ALIGN_DOWN(p, SYSTEM_PAGE_SIZE)
+
 /*
  * If "very verbose" logging is enabled, make it equivalent to LOGV.
  * Otherwise, make it disappear.
diff --git a/vm/Misc.c b/vm/Misc.c
index f8d23ca..f5fd34a 100644
--- a/vm/Misc.c
+++ b/vm/Misc.c
@@ -30,9 +30,6 @@
 #include <cutils/ashmem.h>
 #include <sys/mman.h>
 
-#define ALIGN_UP_TO_PAGE_SIZE(p) \
-    (((size_t)(p) + (SYSTEM_PAGE_SIZE - 1)) & ~(SYSTEM_PAGE_SIZE - 1))
-
 /*
  * Print a hex dump in this format:
  *
diff --git a/vm/alloc/HeapSource.c b/vm/alloc/HeapSource.c
index a3e8893..7c9c2b4 100644
--- a/vm/alloc/HeapSource.c
+++ b/vm/alloc/HeapSource.c
@@ -34,11 +34,6 @@
 static void setIdealFootprint(size_t max);
 static size_t getMaximumSize(const HeapSource *hs);
 
-#define ALIGN_UP_TO_PAGE_SIZE(p) \
-    (((size_t)(p) + (SYSTEM_PAGE_SIZE - 1)) & ~(SYSTEM_PAGE_SIZE - 1))
-#define ALIGN_DOWN_TO_PAGE_SIZE(p) \
-    ((size_t)(p) & ~(SYSTEM_PAGE_SIZE - 1))
-
 #define HEAP_UTILIZATION_MAX        1024
 #define DEFAULT_HEAP_UTILIZATION    512     // Range 1..HEAP_UTILIZATION_MAX
 #define HEAP_IDEAL_FREE             (2 * 1024 * 1024)
diff --git a/vm/alloc/MarkSweep.c b/vm/alloc/MarkSweep.c
index 872128c..ce9bc90 100644
--- a/vm/alloc/MarkSweep.c
+++ b/vm/alloc/MarkSweep.c
@@ -37,10 +37,6 @@
 
 #define LOGE_GC(...)    LOG(LOG_ERROR, GC_LOG_TAG, __VA_ARGS__)
 
-#define ALIGN_DOWN(x, n) ((size_t)(x) & -(n))
-#define ALIGN_UP(x, n) (((size_t)(x) + (n) - 1) & ~((n) - 1))
-#define ALIGN_UP_TO_PAGE_SIZE(p) ALIGN_UP(p, SYSTEM_PAGE_SIZE)
-
 typedef unsigned long Word;
 const size_t kWordSize = sizeof(Word);