4 * Provides facilities for stepping through a list of function arguments of
5 * an unknown number and type.
7 * NOTE: Gcc should provide stdarg.h, and I believe their version will work
8 * with crtdll. If necessary I think you can replace this with the GCC
9 * stdarg.h (or is it vararg.h).
11 * Note that the type used in va_arg is supposed to match the actual type
12 * *after default promotions*. Thus, va_arg (..., short) is not valid.
14 * This file is part of the Mingw32 package.
17 * Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
19 * THIS SOFTWARE IS NOT COPYRIGHTED
21 * This source code is offered for use in the public domain. You may
22 * use, modify or distribute it freely.
24 * This code is distributed in the hope that it will be useful but
25 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
26 * DISCLAIMED. This includes but is not limited to warranties of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
31 * $Date: 2002/11/24 18:06:00 $
34 /* Appropriated for Reactos Crtdll by Ariadne */
40 * Don't do any of this stuff for the resource compiler.
45 * I was told that Win NT likes this.
47 #ifndef _VA_LIST_DEFINED
48 #define _VA_LIST_DEFINED
53 typedef char* va_list;
58 * Amount of space required in an argument list (ie. the stack) for an
61 #define __va_argsiz(t) \
62 (((sizeof(t) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
66 * Start variable argument list processing by setting AP to point to the
71 * In GNU the stack is not necessarily arranged very neatly in order to
72 * pack shorts and such into a smaller argument list. Fortunately a
73 * neatly arranged version is available through the use of __builtin_next_arg.
76 #define va_start(ap, pN) \
77 ((ap) = ((va_list) __builtin_next_arg(pN)))
81 * For a simple minded compiler this should work (it works in GNU too for
82 * vararg lists that don't follow shorts and such).
85 #define va_start(ap, pN) \
86 ((ap) = ((va_list) (&pN) + __va_argsiz(pN)))
92 * End processing of variable argument list. In this case we do nothing.
95 #define va_end(ap) ((void)0)
100 * Increment ap to the next argument in the list while returing a
101 * pointer to what ap pointed to first, which is of type t.
103 * We cast to void* and then to t* because this avoids a warning about
104 * increasing the alignment requirement.
108 #define va_arg(ap, t) \
109 (((ap) = (ap) + __va_argsiz(t)), \
110 *((t*) (void*) ((ap) - __va_argsiz(t))))
113 #endif /* Not RC_INVOKED */
115 #endif /* not _STDARG_H_ */