]>
Commit | Line | Data |
---|---|---|
2aa62f2b | 1 | /** @file\r |
2 | The header <stdarg.h> declares a type and defines three macros, for advancing\r | |
3 | through a list of arguments whose number and types are not known to the\r | |
4 | called function when it is translated.\r | |
5 | \r | |
6 | A function may be called with a variable number of arguments of varying types.\r | |
7 | Its parameter list contains one or more parameters. The rightmost parameter\r | |
8 | plays a special role in the access mechanism, and will be designated paramN\r | |
9 | in this description.\r | |
10 | \r | |
11 | The type va_list is a type suitable for holding information needed by the\r | |
12 | macros va_start, va_arg, and va_end. If access to the varying arguments\r | |
13 | is desired, the called function shall declare an object (referred to as ap\r | |
14 | in these descriptions) having type va_list. The object ap may be passed as\r | |
15 | an argument to another function; if that function invokes the va_arg macro\r | |
16 | with parameter ap, the value of ap in the calling function is indeterminate\r | |
17 | and shall be passed to the va_end macro prior to any further reference to ap.\r | |
18 | \r | |
19 | The va_start and va_arg macros shall be implemented as macros, not as actual\r | |
20 | functions. It is unspecified, by the C library standards, whether va_end\r | |
21 | is a macro or an identifier declared with external linkage. If a macro\r | |
22 | definition is suppressed in order to access an actual function, or a\r | |
23 | program defines an external identifier with the name va_end, the behavior\r | |
24 | is undefined. The va_start and va_end macros shall be invoked in the\r | |
25 | function accepting a varying number of arguments, if access to the varying\r | |
26 | arguments is desired.\r | |
27 | \r | |
28 | Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r | |
29 | This program and the accompanying materials are licensed and made available under\r | |
30 | the terms and conditions of the BSD License that accompanies this distribution.\r | |
31 | The full text of the license may be found at\r | |
32 | http://opensource.org/licenses/bsd-license.php.\r | |
33 | \r | |
34 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
35 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
36 | \r | |
37 | **/\r | |
38 | #ifndef _STDARG_H\r | |
39 | #define _STDARG_H\r | |
40 | #include <sys/EfiCdefs.h>\r | |
41 | \r | |
42 | /** The type va_list is a type suitable for holding information needed by the\r | |
43 | macros va_start, va_arg, and va_end.\r | |
2aa62f2b | 44 | **/\r |
d7ce7006 | 45 | #if defined(__GNUC__)\r |
46 | typedef __builtin_va_list va_list;\r | |
47 | #else\r | |
2aa62f2b | 48 | #define va_list VA_LIST\r |
d7ce7006 | 49 | #endif\r |
2aa62f2b | 50 | \r |
51 | /** The va_start macro shall be invoked before any access to the unnamed arguments.\r | |
52 | The va_start macro initializes ap for subsequent use by va_arg and va_end.\r | |
53 | \r | |
54 | Synopsys: void va_start(va_list ap, paramN);\r | |
55 | \r | |
56 | @param ap An object of type va_list that is to be initialized such\r | |
57 | that subsequent successive invocations of va_arg will\r | |
58 | return the values of the parameters following paramN.\r | |
59 | \r | |
60 | @param paramN The parameter paramN is the identifier of the rightmost\r | |
61 | parameter in the variable parameter list in the function\r | |
62 | definition (the one just before the ,...). If the\r | |
63 | parameter parmN is declared with the register storage\r | |
64 | class, with a function of array type, or with a type that\r | |
65 | is not compatible with the type that results after\r | |
66 | application of the default argument promotions, the\r | |
67 | behavior is undefined.\r | |
2aa62f2b | 68 | **/\r |
d7ce7006 | 69 | #if defined(__GNUC__)\r |
70 | #define va_start __builtin_va_start\r | |
71 | #else\r | |
2aa62f2b | 72 | #define va_start VA_START\r |
d7ce7006 | 73 | #endif\r |
2aa62f2b | 74 | \r |
75 | /** The va_arg macro expands to an expression that has the type and value of\r | |
76 | the next argument in the call. The parameter ap shall be the same as the\r | |
77 | va_list ap initialized by va_start. Each invocation of va_arg modifies ap\r | |
78 | so that the values of successive arguments are returned in turn. The\r | |
79 | parameter type is a type name specified such that the type of a pointer to\r | |
80 | an object that has the specified type can be obtained simply by postfixing\r | |
81 | a * to type. If there is no actual next argument, or if type is not\r | |
82 | compatible with the type of the actual next argument (as promoted\r | |
83 | according to the default argument promotions), the behavior is undefined.\r | |
84 | \r | |
85 | Synopsys: type va_arg(va_list ap, type);\r | |
86 | \r | |
87 | @param ap An object of type va_list that was initialized by a prior\r | |
88 | invocation of va_start.\r | |
89 | \r | |
90 | @param type A type name specifying the type of the parameter to be retrieved.\r | |
91 | \r | |
92 | @return The first invocation of the va_arg macro after that of the\r | |
93 | va_start macro returns the value of the argument after that\r | |
94 | specified by paramN. Successive invocations return the values\r | |
95 | of the remaining arguments in succession.\r | |
2aa62f2b | 96 | **/\r |
d7ce7006 | 97 | #if defined(__GNUC__)\r |
98 | #define va_arg __builtin_va_arg\r | |
99 | #else\r | |
2aa62f2b | 100 | #define va_arg VA_ARG\r |
d7ce7006 | 101 | #endif\r |
2aa62f2b | 102 | \r |
103 | /** The va_end macro facillitates a normal return from the function whose\r | |
104 | variable argument list was referred to by the expansion of va_start that\r | |
105 | initialized the va_list ap.\r | |
106 | \r | |
107 | Synopsys: void va_end(va_list ap);\r | |
108 | \r | |
109 | The va_end macro may modify ap so that it is no longer usable (without an\r | |
110 | intervening invocation of va_start). If there is no corresponding\r | |
111 | invocation of the va_start macro, or if the va_end macro is not invoked\r | |
112 | before the return, the behavior is undefined.\r | |
113 | \r | |
114 | @param ap An object of type va_list, initialized by a prior\r | |
115 | invocation of va_start, that will no longer be referenced.\r | |
2aa62f2b | 116 | **/\r |
d7ce7006 | 117 | #if defined(__GNUC__)\r |
118 | #define va_end __builtin_va_end\r | |
119 | #else\r | |
2aa62f2b | 120 | #define va_end VA_END\r |
d7ce7006 | 121 | #endif\r |
2aa62f2b | 122 | \r |
123 | /** For BSD compatibility. **/\r | |
d7ce7006 | 124 | #if defined(__GNUC__)\r |
125 | #define va_copy __builtin_va_copy\r | |
126 | #else\r | |
2aa62f2b | 127 | #define va_copy(s,d) (s) = (d)\r |
d7ce7006 | 128 | #endif\r |
2aa62f2b | 129 | \r |
130 | #endif /* _STDARG_H */\r |