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