]>
Commit | Line | Data |
---|---|---|
3eb9473e | 1 | /*++\r |
2 | \r | |
f57387d5 HT |
3 | Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r |
4 | This program and the accompanying materials \r | |
3eb9473e | 5 | are licensed and made available under the terms and conditions of the BSD License \r |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | EfiStdArg.h\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | Support for variable length argument lists using the ANSI standard.\r | |
19 | \r | |
20 | Since we are using the ANSI standard we used the standard nameing and\r | |
21 | did not folow the coding convention\r | |
22 | \r | |
23 | VA_LIST - typedef for argument list.\r | |
24 | VA_START (VA_LIST Marker, argument before the ...) - Init Marker for use.\r | |
25 | VA_END (VA_LIST Marker) - Clear Marker\r | |
26 | VA_ARG (VA_LIST Marker, var arg size) - Use Marker to get an argumnet from\r | |
27 | the ... list. You must know the size and pass it in this macro.\r | |
28 | \r | |
29 | example:\r | |
30 | \r | |
31 | UINTN\r | |
32 | ExampleVarArg (\r | |
33 | IN UINTN NumberOfArgs,\r | |
34 | ...\r | |
35 | )\r | |
36 | {\r | |
37 | VA_LIST Marker;\r | |
38 | UINTN Index;\r | |
39 | UINTN Result;\r | |
40 | \r | |
41 | //\r | |
42 | // Initialize the Marker\r | |
43 | //\r | |
44 | VA_START (Marker, NumberOfArgs);\r | |
45 | for (Index = 0, Result = 0; Index < NumberOfArgs; Index++) {\r | |
46 | //\r | |
47 | // The ... list is a series of UINTN values, so average them up.\r | |
48 | //\r | |
49 | Result += VA_ARG (Marker, UINTN);\r | |
50 | }\r | |
51 | \r | |
52 | VA_END (Marker);\r | |
53 | return Result\r | |
54 | }\r | |
55 | \r | |
56 | --*/\r | |
57 | \r | |
58 | #ifndef _EFISTDARG_H_\r | |
59 | #define _EFISTDARG_H_\r | |
60 | \r | |
61 | #define _EFI_INT_SIZE_OF(n) ((sizeof (n) + sizeof (UINTN) - 1) &~(sizeof (UINTN) - 1))\r | |
62 | \r | |
1afe0401 A |
63 | #if defined(__CC_ARM)\r |
64 | //\r | |
65 | // RVCT ARM variable argument list support.\r | |
66 | //\r | |
67 | \r | |
68 | ///\r | |
69 | /// Variable used to traverse the list of arguments. This type can vary by \r | |
70 | /// implementation and could be an array or structure. \r | |
71 | ///\r | |
72 | #ifdef __APCS_ADSABI\r | |
73 | typedef int *va_list[1];\r | |
74 | #define VA_LIST va_list\r | |
75 | #else\r | |
76 | typedef struct __va_list { void *__ap; } va_list;\r | |
77 | #define VA_LIST va_list\r | |
78 | #endif\r | |
79 | \r | |
80 | #define VA_START(Marker, Parameter) __va_start(Marker, Parameter)\r | |
81 | \r | |
82 | #define VA_ARG(Marker, TYPE) __va_arg(Marker, TYPE)\r | |
83 | \r | |
84 | #define VA_END(Marker) ((void)0)\r | |
85 | \r | |
86 | #define VA_COPY(Dest, Start) __va_copy (Dest, Start)\r | |
87 | \r | |
88 | #elif defined(__GNUC__)\r | |
e8de4680 A |
89 | //\r |
90 | // Use GCC built-in macros for variable argument lists.\r | |
91 | //\r | |
92 | \r | |
93 | ///\r | |
94 | /// Variable used to traverse the list of arguments. This type can vary by \r | |
95 | /// implementation and could be an array or structure. \r | |
96 | ///\r | |
97 | typedef __builtin_va_list VA_LIST;\r | |
98 | \r | |
99 | #define VA_START(Marker, Parameter) __builtin_va_start (Marker, Parameter)\r | |
100 | \r | |
101 | #define VA_ARG(Marker, TYPE) ((sizeof (TYPE) < sizeof (UINTN)) ? (TYPE)(__builtin_va_arg (Marker, UINTN)) : (TYPE)(__builtin_va_arg (Marker, TYPE)))\r | |
102 | \r | |
103 | #define VA_END(Marker) __builtin_va_end (Marker)\r | |
104 | \r | |
1afe0401 A |
105 | #define VA_COPY(Dest, Start) __builtin_va_copy (Dest, Start)\r |
106 | \r | |
e8de4680 A |
107 | #else\r |
108 | \r | |
3eb9473e | 109 | //\r |
110 | // Also support coding convention rules for var arg macros\r | |
111 | //\r | |
112 | #ifndef VA_START\r | |
113 | \r | |
114 | typedef CHAR8 *VA_LIST;\r | |
115 | #define VA_START(ap, v) (ap = (VA_LIST) & (v) + _EFI_INT_SIZE_OF (v))\r | |
116 | #define VA_ARG(ap, t) (*(t *) ((ap += _EFI_INT_SIZE_OF (t)) - _EFI_INT_SIZE_OF (t)))\r | |
117 | #define VA_END(ap) (ap = (VA_LIST) 0)\r | |
1afe0401 | 118 | #define VA_COPY(dest, src) ((void)((dest) = (src)))\r |
3eb9473e | 119 | \r |
e8de4680 A |
120 | #endif\r |
121 | \r | |
122 | \r | |
3eb9473e | 123 | #endif\r |
124 | \r | |
125 | #endif\r |