]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Include/Base.h
Reviewed the description in the FatBinPkg .dec file.
[mirror_edk2.git] / MdePkg / Include / Base.h
index 00cce609f5622bce72c70ca9f9d3ac408487f765..f429acd65834ad8edeb39d730e494ce7011ee6db 100644 (file)
@@ -342,6 +342,19 @@ struct _LIST_ENTRY {
 **/\r
 #define _INT_SIZE_OF(n) ((sizeof (n) + sizeof (UINTN) - 1) &~(sizeof (UINTN) - 1))\r
 \r
+#if defined(__GNUC__)\r
+//\r
+// Use GCC built-in macros for variable argument lists.\r
+//\r
+typedef __builtin_va_list VA_LIST;\r
+\r
+#define VA_START(Marker, Parameter)  __builtin_va_start (Marker, Parameter)\r
+\r
+#define VA_ARG(Marker, TYPE)         ((sizeof (TYPE) < sizeof (UINTN)) ? (TYPE)(__builtin_va_arg (Marker, UINTN)) : (TYPE)(__builtin_va_arg (Marker, TYPE)))\r
+\r
+#define VA_END(Marker)               __builtin_va_end (Marker)\r
+\r
+#else\r
 ///\r
 /// Pointer to the start of a variable argument list. Same as CHAR8 *.\r
 ///\r
@@ -394,6 +407,31 @@ typedef CHAR8 *VA_LIST;
 **/\r
 #define VA_END(Marker)      (Marker = (VA_LIST) 0)\r
 \r
+#endif\r
+\r
+///\r
+/// Pointer to the start of a variable argument list stored in a memory buffer. Same as UINT8 *.\r
+///\r
+typedef UINTN  *BASE_LIST;\r
+\r
+/**\r
+  Returns an argument of a specified type from a variable argument list and updates \r
+  the pointer to the variable argument list to point to the next argument. \r
+\r
+  This function returns an argument of the type specified by TYPE from the beginning \r
+  of the variable argument list specified by Marker.  Marker is then updated to point \r
+  to the next argument in the variable argument list.  The method for computing the \r
+  pointer to the next argument in the argument list is CPU specific following the EFIAPI ABI.\r
+\r
+  @param   Marker   Pointer to the beginning of a variable argument list.\r
+  @param   TYPE     The type of argument to retrieve from the beginning \r
+                    of the variable argument list.\r
+  \r
+  @return  An argument of the type specified by TYPE.\r
+\r
+**/\r
+#define BASE_ARG(Marker, TYPE) (*(TYPE *)((UINT8 *)(Marker = (BASE_LIST)((UINT8 *)Marker + _INT_SIZE_OF (TYPE))) - _INT_SIZE_OF (TYPE)))\r
+\r
 /**\r
   Macro that returns the byte offset of a field in a data structure. \r
 \r
@@ -417,7 +455,7 @@ typedef CHAR8 *VA_LIST;
 \r
   This function computes the offset, in bytes, of field specified by Field from the beginning \r
   of the  data structure specified by TYPE.  This offset is subtracted from Record, and is \r
-  used to return a pointer to a data structure of the type specified by TYPE.If the data type \r
+  used to return a pointer to a data structure of the type specified by TYPE. If the data type \r
   specified by TYPE does not contain the field specified by Field, then the module will not compile. \r
    \r
   @param   Record   Pointer to the field specified by Field within a data structure of type TYPE. \r
@@ -451,7 +489,7 @@ typedef CHAR8 *VA_LIST;
   This function rounds the pointer specified by Pointer to the next alignment boundary \r
   specified by Alignment. The pointer to the aligned address is returned.  \r
 \r
-  @param   Value      The value to round up.\r
+  @param   Pointer    The pointer to round up.\r
   @param   Alignment  The alignment boundary to use to return an aligned pointer.\r
   \r
   @return  Pointer to the aligned address.\r
@@ -480,7 +518,6 @@ typedef CHAR8 *VA_LIST;
   This macro returns the maximum of two operand specified by a and b.  \r
   Both a and b must be the same numerical types, signed or unsigned.\r
 \r
-  @param   TYPE     Any numerical data types.\r
   @param   a        The first operand with any numerical type.\r
   @param   b        The second operand. It should be the same any numerical type with a.\r
   \r
@@ -496,7 +533,6 @@ typedef CHAR8 *VA_LIST;
   This macro returns the minimal of two operand specified by a and b.  \r
   Both a and b must be the same numerical types, signed or unsigned.\r
 \r
-  @param   TYPE     Any numerical data types.\r
   @param   a        The first operand with any numerical type.\r
   @param   b        The second operand. It should be the same any numerical type with a.\r
   \r