X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdePkg%2FInclude%2FBase.h;h=3f71098861f2b3a6dafe51ce930e89a8fd50a898;hb=2229029afc183e4b84c255893d0a2974d8086863;hp=4afdb7d84c7e1c9ce3731ab16ce245a2b716668a;hpb=0dcec41170f70c47b5b4572d4d1c72f408d4872c;p=mirror_edk2.git diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h index 4afdb7d84c..3f71098861 100644 --- a/MdePkg/Include/Base.h +++ b/MdePkg/Include/Base.h @@ -333,19 +333,6 @@ struct _LIST_ENTRY { // } // -#if defined(__GNUC__) -// -// Use GCC builtin macros for variable argument lists. -// -typedef __builtin_va_list VA_LIST; - -#define VA_START(Marker, Parameter) __builtin_va_start(Marker, Parameter) - -#define VA_ARG(Marker, TYPE) __builtin_va_arg(Marker, TYPE) - -#define VA_END(Marker) __builtin_va_end(Marker) - -#else /** Return the size of argument that has been aligned to sizeof (UINTN). @@ -355,6 +342,19 @@ typedef __builtin_va_list VA_LIST; **/ #define _INT_SIZE_OF(n) ((sizeof (n) + sizeof (UINTN) - 1) &~(sizeof (UINTN) - 1)) +#if defined(__GNUC__) +// +// Use GCC built-in macros for variable argument lists. +// +typedef __builtin_va_list VA_LIST; + +#define VA_START(Marker, Parameter) __builtin_va_start (Marker, Parameter) + +#define VA_ARG(Marker, TYPE) ((sizeof (TYPE) < sizeof (UINTN)) ? (TYPE)(__builtin_va_arg (Marker, UINTN)) : (TYPE)(__builtin_va_arg (Marker, TYPE))) + +#define VA_END(Marker) __builtin_va_end (Marker) + +#else /// /// Pointer to the start of a variable argument list. Same as CHAR8 *. /// @@ -409,6 +409,38 @@ typedef CHAR8 *VA_LIST; #endif +/// +/// Pointer to the start of a variable argument list stored in a memory buffer. Same as UINT8 *. +/// +typedef UINTN *BASE_LIST; + +/** + Returns the size of a data type in sizeof(UINTN) units rounded up to the nearest UINTN boundary. + + @param TYPE The date type to determine the size of. + + @return The size of TYPE in sizeof (UINTN) units rounded up to the nearest UINTN boundary. +**/ +#define _BASE_INT_SIZE_OF(TYPE) ((sizeof (TYPE) + sizeof (UINTN) - 1) / sizeof (UINTN)) + +/** + Returns an argument of a specified type from a variable argument list and updates + the pointer to the variable argument list to point to the next argument. + + This function returns an argument of the type specified by TYPE from the beginning + of the variable argument list specified by Marker. Marker is then updated to point + to the next argument in the variable argument list. The method for computing the + pointer to the next argument in the argument list is CPU specific following the EFIAPI ABI. + + @param Marker Pointer to the beginning of a variable argument list. + @param TYPE The type of argument to retrieve from the beginning + of the variable argument list. + + @return An argument of the type specified by TYPE. + +**/ +#define BASE_ARG(Marker, TYPE) (*(TYPE *) ((Marker += _BASE_INT_SIZE_OF (TYPE)) - _BASE_INT_SIZE_OF (TYPE))) + /** Macro that returns the byte offset of a field in a data structure. @@ -432,7 +464,7 @@ typedef CHAR8 *VA_LIST; This function computes the offset, in bytes, of field specified by Field from the beginning of the data structure specified by TYPE. This offset is subtracted from Record, and is - used to return a pointer to a data structure of the type specified by TYPE.If the data type + used to return a pointer to a data structure of the type specified by TYPE. If the data type specified by TYPE does not contain the field specified by Field, then the module will not compile. @param Record Pointer to the field specified by Field within a data structure of type TYPE. @@ -466,7 +498,7 @@ typedef CHAR8 *VA_LIST; This function rounds the pointer specified by Pointer to the next alignment boundary specified by Alignment. The pointer to the aligned address is returned. - @param Value The value to round up. + @param Pointer The pointer to round up. @param Alignment The alignment boundary to use to return an aligned pointer. @return Pointer to the aligned address. @@ -495,7 +527,6 @@ typedef CHAR8 *VA_LIST; This macro returns the maximum of two operand specified by a and b. Both a and b must be the same numerical types, signed or unsigned. - @param TYPE Any numerical data types. @param a The first operand with any numerical type. @param b The second operand. It should be the same any numerical type with a. @@ -511,7 +542,6 @@ typedef CHAR8 *VA_LIST; This macro returns the minimal of two operand specified by a and b. Both a and b must be the same numerical types, signed or unsigned. - @param TYPE Any numerical data types. @param a The first operand with any numerical type. @param b The second operand. It should be the same any numerical type with a.