+++ /dev/null
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php \r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
-\r
-Module Name:\r
-\r
- EfiStdArg.h\r
-\r
-Abstract:\r
-\r
- Support for variable length argument lists using the ANSI standard.\r
- \r
- Since we are using the ANSI standard we used the standard nameing and\r
- did not folow the coding convention\r
-\r
- VA_LIST - typedef for argument list.\r
- VA_START (VA_LIST Marker, argument before the ...) - Init Marker for use.\r
- VA_END (VA_LIST Marker) - Clear Marker\r
- VA_ARG (VA_LIST Marker, var arg size) - Use Marker to get an argumnet from\r
- the ... list. You must know the size and pass it in this macro.\r
-\r
- example:\r
-\r
- UINTN\r
- ExampleVarArg (\r
- IN UINTN NumberOfArgs,\r
- ...\r
- )\r
- {\r
- VA_LIST Marker;\r
- UINTN Index;\r
- UINTN Result;\r
-\r
- //\r
- // Initialize the Marker\r
- //\r
- VA_START (Marker, NumberOfArgs);\r
- for (Index = 0, Result = 0; Index < NumberOfArgs; Index++) {\r
- //\r
- // The ... list is a series of UINTN values, so average them up.\r
- //\r
- Result += VA_ARG (Marker, UINTN);\r
- }\r
-\r
- VA_END (Marker);\r
- return Result\r
- }\r
-\r
---*/\r
-\r
-#ifndef _EFISTDARG_H_\r
-#define _EFISTDARG_H_\r
-\r
-/**\r
- Return the size of argument that has been aligned to sizeof (UINTN).\r
-\r
- @param n The parameter size to be aligned.\r
-\r
- @return The aligned size.\r
-**/\r
-#define _INT_SIZE_OF(n) ((sizeof (n) + sizeof (UINTN) - 1) &~(sizeof (UINTN) - 1))\r
-\r
-#if defined(__CC_ARM)\r
-//\r
-// RVCT ARM variable argument list support.\r
-//\r
-\r
-///\r
-/// Variable used to traverse the list of arguments. This type can vary by \r
-/// implementation and could be an array or structure. \r
-///\r
-#ifdef __APCS_ADSABI\r
- typedef int *va_list[1];\r
- #define VA_LIST va_list\r
-#else\r
- typedef struct __va_list { void *__ap; } va_list;\r
- #define VA_LIST va_list\r
-#endif\r
-\r
-#define VA_START(Marker, Parameter) __va_start(Marker, Parameter)\r
-\r
-#define VA_ARG(Marker, TYPE) __va_arg(Marker, TYPE)\r
-\r
-#define VA_END(Marker) ((void)0)\r
-\r
-#define VA_COPY(Dest, Start) __va_copy (Dest, Start)\r
-\r
-#elif defined(__GNUC__)\r
-\r
-#if defined(MDE_CPU_X64) && !defined(NO_MSABI_VA_FUNCS)\r
-//\r
-// X64 only. Use MS ABI version of GCC built-in macros for variable argument lists.\r
-//\r
-///\r
-/// Both GCC and LLVM 3.8 for X64 support new variable argument intrinsics for Microsoft ABI\r
-///\r
-\r
-///\r
-/// Variable used to traverse the list of arguments. This type can vary by\r
-/// implementation and could be an array or structure.\r
-///\r
-typedef __builtin_ms_va_list VA_LIST;\r
-\r
-#define VA_START(Marker, Parameter) __builtin_ms_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_ms_va_end (Marker)\r
-\r
-#define VA_COPY(Dest, Start) __builtin_ms_va_copy (Dest, Start)\r
-\r
-#else\r
-//\r
-// Use GCC built-in macros for variable argument lists.\r
-//\r
-\r
-///\r
-/// Variable used to traverse the list of arguments. This type can vary by \r
-/// implementation and could be an array or structure. \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
-#define VA_COPY(Dest, Start) __builtin_va_copy (Dest, Start)\r
-\r
-#endif\r
-\r
-#else\r
-\r
-#ifndef VA_START\r
-\r
-///\r
-/// Variable used to traverse the list of arguments. This type can vary by \r
-/// implementation and could be an array or structure. \r
-///\r
-typedef CHAR8 *VA_LIST;\r
-\r
-/**\r
- Retrieves a pointer to the beginning of a variable argument list, based on \r
- the name of the parameter that immediately precedes the variable argument list. \r
-\r
- This function initializes Marker to point to the beginning of the variable \r
- argument list that immediately follows Parameter. The method for computing the \r
- pointer to the next argument in the argument list is CPU-specific following the \r
- EFIAPI ABI.\r
-\r
- @param Marker The VA_LIST used to traverse the list of arguments.\r
- @param Parameter The name of the parameter that immediately precedes \r
- the variable argument list.\r
- \r
- @return A pointer to the beginning of a variable argument list.\r
-\r
-**/\r
-#define VA_START(Marker, Parameter) (Marker = (VA_LIST) ((UINTN) & (Parameter) + _INT_SIZE_OF (Parameter)))\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 VA_LIST used to traverse the list of arguments.\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 VA_ARG(Marker, TYPE) (*(TYPE *) ((Marker += _INT_SIZE_OF (TYPE)) - _INT_SIZE_OF (TYPE)))\r
-\r
-/**\r
- Terminates the use of a variable argument list.\r
-\r
- This function initializes Marker so it can no longer be used with VA_ARG(). \r
- After this macro is used, the only way to access the variable argument list is \r
- by using VA_START() again.\r
-\r
- @param Marker VA_LIST used to traverse the list of arguments.\r
- \r
-**/\r
-#define VA_END(Marker) (Marker = (VA_LIST) 0)\r
-\r
-#define VA_COPY(dest, src) ((void)((dest) = (src)))\r
-\r
-#endif\r
-\r
-#endif\r
-\r
-#endif\r