]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1. Add new macro: ALIGN_VALUE to round up a value to the next boundary of a given...
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 10 Sep 2008 16:00:20 +0000 (16:00 +0000)
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 10 Sep 2008 16:00:20 +0000 (16:00 +0000)
2. Update ALIGN_POINTER to use the new macro
3. Drop the second parameter of ALIGN_VARIABLE for simplicity. It can also directly use the new macro ALIGN_VALUE.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5869 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Include/Base.h

index a103d934918bf178c43f49fca76f8ca6a914e783..4bc80c17c8459f36d41ff04855561fe0489465f0 100644 (file)
@@ -216,20 +216,21 @@ typedef CHAR8 *VA_LIST;
 ///\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