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