(va_arg, va_start): Explicitly cast to __gnuc_va_alist.
[platform/upstream/gcc.git] / gcc / ginclude / stdarg.h
1 /* stdarg.h for GNU.
2    Note that the type used in va_arg is supposed to match the
3    actual type **after default promotions**.
4    Thus, va_arg (..., short) is not valid.  */
5
6 #ifndef _STDARG_H
7 #ifndef __need___va_list
8 #define _STDARG_H
9 #endif
10 #undef __need___va_list
11
12 #ifndef __GNUC__
13 /* Use the system's macros with the system's compiler.  */
14 #include <stdarg.h>
15 #else
16 #ifdef __m88k__
17 #include "va-m88k.h"
18 #else
19 #ifdef __i860__
20 #include "va-i860.h"
21 #else
22 #ifdef __hppa__
23 #include "va-pa.h"
24 #else
25 #ifdef __mips__
26 #include "va-mips.h"
27 #else
28 #ifdef __sparc__
29 #include "va-sparc.h"
30 #else
31 #ifdef __i960__
32 #include "va-i960.h"
33 #else
34 #ifdef __alpha__
35 #include "va-alpha.h"
36 #else
37
38 /* Define __gnuc_va_list.  */
39
40 #ifndef __GNUC_VA_LIST
41 #define __GNUC_VA_LIST
42 #ifdef __svr4__
43 typedef char *__gnuc_va_list;
44 #else
45 typedef void *__gnuc_va_list;
46 #endif
47 #endif
48
49 /* Define the standard macros for the user,
50    if this invocation was from the user program.  */
51 #ifdef _STDARG_H
52
53 /* Amount of space required in an argument list for an arg of type TYPE.
54    TYPE may alternatively be an expression whose type is used.  */
55
56 #define __va_rounded_size(TYPE)  \
57   (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
58
59 #define va_start(AP, LASTARG)                                           \
60  (AP = ((__gnuc_va_list) __builtin_next_arg ()))
61
62 void va_end (__gnuc_va_list);           /* Defined in libgcc.a */
63 #define va_end(AP)
64
65 /* We cast to void * and then to TYPE * because this avoids
66    a warning about increasing the alignment requirement.  */
67 #define va_arg(AP, TYPE)                                                \
68  (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)),     \
69   *((TYPE *) (void *) ((char *) (AP) - __va_rounded_size (TYPE))))
70 #endif /* _STDARG_H */
71
72 #endif /* not alpha */
73 #endif /* not i960 */
74 #endif /* not sparc */
75 #endif /* not mips */
76 #endif /* not hppa */
77 #endif /* not i860 */
78 #endif /* not m88k */
79
80 #ifdef _STDARG_H
81 /* Define va_list, if desired, from __gnuc_va_list. */
82 /* We deliberately do not define va_list when called from
83    stdio.h, because ANSI C says that stdio.h is not supposed to define
84    va_list.  stdio.h needs to have access to that data type, 
85    but must not use that name.  It should use the name __gnuc_va_list,
86    which is safe because it is reserved for the implementation.  */
87
88 #ifdef _HIDDEN_VA_LIST  /* On OSF1, this means varargs.h is "half-loaded".  */
89 #undef _VA_LIST
90 #endif
91
92 #ifdef _BSD_VA_LIST
93 #undef _BSD_VA_LIST
94 #endif
95
96 /* The macro _VA_LIST_ is the same thing used by this file in Ultrix.  */
97 #ifndef _VA_LIST_
98 /* The macro _VA_LIST is used in SCO Unix 3.2.  */
99 #ifndef _VA_LIST
100 #define _VA_LIST_
101 #define _VA_LIST
102 typedef __gnuc_va_list va_list;
103 #endif /* _VA_LIST */
104 #endif /* _VA_LIST_ */
105 #endif /* _STDARG_H */
106
107 #endif /* __GNUC__ */
108 #endif /* not _STDARG_H */