///\r
#define _CR(Record, TYPE, Field) ((TYPE *) ((CHAR8 *) (Record) - (CHAR8 *) &(((TYPE *) 0)->Field)))\r
\r
+///\r
+/// ALIGN_VALUE - aligns a value up to the next boundary of the given alignment.\r
+///\r
+#define ALIGN_VALUE(Value, Alignment) ((Value) + (((Alignment) - (Value)) & ((Alignment) - 1)))\r
+\r
///\r
/// ALIGN_POINTER - aligns a pointer to the lowest boundry\r
///\r
-#define ALIGN_POINTER(p, s) ((VOID *) ((UINTN)(p) + (((s) - ((UINTN) (p))) & ((s) - 1))))\r
+#define ALIGN_POINTER(Pointer, Alignment) ((VOID *) (ALIGN_VALUE ((UINTN)(Pointer), (Alignment))))\r
\r
///\r
/// ALIGN_VARIABLE - aligns a variable up to the next natural boundry for int size of a processor\r
///\r
-#define ALIGN_VARIABLE(Value, Adjustment) \\r
- Adjustment = 0U; \\r
- if ((UINTN) (Value) % sizeof (UINTN)) { \\r
- (Adjustment) = (UINTN)(sizeof (UINTN) - ((UINTN) (Value) % sizeof (UINTN))); \\r
- } \\r
- (Value) = (UINTN)((UINTN) (Value) + (UINTN) (Adjustment))\r
+#define ALIGN_VARIABLE(Value) ALIGN_VALUE ((Value), sizeof (UINTN))\r
+ \r
\r
//\r
// Return the maximum of two operands. \r