OSDN Git Service

Protect va_list definition from SCO headers.
[pf3gnuchains/gcc-fork.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 _ANSI_STDARG_H_
8 #ifndef __need___va_list
9 #define _STDARG_H
10 #define _ANSI_STDARG_H_
11 #endif /* not __need___va_list */
12 #undef __need___va_list
13
14 #ifdef __clipper__
15 #include "va-clipper.h"
16 #else
17 #ifdef __m88k__
18 #include "va-m88k.h"
19 #else
20 #ifdef __i860__
21 #include "va-i860.h"
22 #else
23 #ifdef __hppa__
24 #include "va-pa.h"
25 #else
26 #ifdef __mips__
27 #include "va-mips.h"
28 #else
29 #ifdef __sparc__
30 #include "va-sparc.h"
31 #else
32 #ifdef __i960__
33 #include "va-i960.h"
34 #else
35 #ifdef __alpha__
36 #include "va-alpha.h"
37 #else
38 #if defined (__H8300__) || defined (__H8300H__) || defined (__H8300S__)
39 #include "va-h8300.h"
40 #else
41 #if defined (__PPC__) && (defined (_CALL_SYSV) || defined (_WIN32))
42 #include "va-ppc.h"
43 #else
44 #ifdef __M32R__
45 #include "va-m32r.h"
46 #else
47 #ifdef __sh__
48 #include "va-sh.h"
49 #else
50 #ifdef __mn10300__
51 #include "va-mn10300.h"
52 #else
53
54 /* Define __gnuc_va_list.  */
55
56 #ifndef __GNUC_VA_LIST
57 #define __GNUC_VA_LIST
58 #if defined(__svr4__) || defined(_AIX) || defined(_M_UNIX) || defined(__NetBSD__)
59 typedef char *__gnuc_va_list;
60 #else
61 typedef void *__gnuc_va_list;
62 #endif
63 #endif
64
65 /* Define the standard macros for the user,
66    if this invocation was from the user program.  */
67 #ifdef _STDARG_H
68
69 /* Amount of space required in an argument list for an arg of type TYPE.
70    TYPE may alternatively be an expression whose type is used.  */
71
72 #if defined(sysV68)
73 #define __va_rounded_size(TYPE)  \
74   (((sizeof (TYPE) + sizeof (short) - 1) / sizeof (short)) * sizeof (short))
75 #else
76 #define __va_rounded_size(TYPE)  \
77   (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
78 #endif
79
80 #define va_start(AP, LASTARG)                                           \
81  (AP = ((__gnuc_va_list) __builtin_next_arg (LASTARG)))
82
83 #undef va_end
84 void va_end (__gnuc_va_list);           /* Defined in libgcc.a */
85 #define va_end(AP)      ((void)0)
86
87 /* We cast to void * and then to TYPE * because this avoids
88    a warning about increasing the alignment requirement.  */
89
90 #if defined (__arm__) || defined (__i386__) || defined (__i860__) || defined (__ns32000__) || defined (__vax__)
91 /* This is for little-endian machines; small args are padded upward.  */
92 #define va_arg(AP, TYPE)                                                \
93  (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)),     \
94   *((TYPE *) (void *) ((char *) (AP) - __va_rounded_size (TYPE))))
95 #else /* big-endian */
96 /* This is for big-endian machines; small args are padded downward.  */
97 #define va_arg(AP, TYPE)                                                \
98  (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)),     \
99   *((TYPE *) (void *) ((char *) (AP)                                    \
100                        - ((sizeof (TYPE) < __va_rounded_size (char)     \
101                            ? sizeof (TYPE) : __va_rounded_size (TYPE))))))
102 #endif /* big-endian */
103
104 /* Copy __gnuc_va_list into another variable of this type.  */
105 #define __va_copy(dest, src) (dest) = (src)
106
107 #endif /* _STDARG_H */
108
109 #endif /* not mn10300 */
110 #endif /* not sh */
111 #endif /* not m32r */
112 #endif /* not powerpc with V.4 calling sequence */
113 #endif /* not h8300 */
114 #endif /* not alpha */
115 #endif /* not i960 */
116 #endif /* not sparc */
117 #endif /* not mips */
118 #endif /* not hppa */
119 #endif /* not i860 */
120 #endif /* not m88k */
121 #endif /* not clipper */
122
123 #ifdef _STDARG_H
124 /* Define va_list, if desired, from __gnuc_va_list. */
125 /* We deliberately do not define va_list when called from
126    stdio.h, because ANSI C says that stdio.h is not supposed to define
127    va_list.  stdio.h needs to have access to that data type, 
128    but must not use that name.  It should use the name __gnuc_va_list,
129    which is safe because it is reserved for the implementation.  */
130
131 #ifdef _HIDDEN_VA_LIST  /* On OSF1, this means varargs.h is "half-loaded".  */
132 #undef _VA_LIST
133 #endif
134
135 #ifdef _BSD_VA_LIST
136 #undef _BSD_VA_LIST
137 #endif
138
139 #if defined(__svr4__) || (defined(_SCO_DS) && !defined(__VA_LIST))
140 /* SVR4.2 uses _VA_LIST for an internal alias for va_list,
141    so we must avoid testing it and setting it here.
142    SVR4 uses _VA_LIST as a flag in stdarg.h, but we should
143    have no conflict with that.  */
144 #ifndef _VA_LIST_
145 #define _VA_LIST_
146 #ifdef __i860__
147 #ifndef _VA_LIST
148 #define _VA_LIST va_list
149 #endif
150 #endif /* __i860__ */
151 typedef __gnuc_va_list va_list;
152 #ifdef _SCO_DS
153 #define __VA_LIST
154 #endif
155 #endif /* _VA_LIST_ */
156 #else /* not __svr4__ || _SCO_DS */
157
158 /* The macro _VA_LIST_ is the same thing used by this file in Ultrix.
159    But on BSD NET2 we must not test or define or undef it.
160    (Note that the comments in NET 2's ansi.h
161    are incorrect for _VA_LIST_--see stdio.h!)  */
162 #if !defined (_VA_LIST_) || defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__) || defined(WINNT)
163 /* The macro _VA_LIST_DEFINED is used in Windows NT 3.5  */
164 #ifndef _VA_LIST_DEFINED
165 /* The macro _VA_LIST is used in SCO Unix 3.2.  */
166 #ifndef _VA_LIST
167 /* The macro _VA_LIST_T_H is used in the Bull dpx2  */
168 #ifndef _VA_LIST_T_H
169 typedef __gnuc_va_list va_list;
170 #endif /* not _VA_LIST_T_H */
171 #endif /* not _VA_LIST */
172 #endif /* not _VA_LIST_DEFINED */
173 #if !(defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__))
174 #define _VA_LIST_
175 #endif
176 #ifndef _VA_LIST
177 #define _VA_LIST
178 #endif
179 #ifndef _VA_LIST_DEFINED
180 #define _VA_LIST_DEFINED
181 #endif
182 #ifndef _VA_LIST_T_H
183 #define _VA_LIST_T_H
184 #endif
185
186 #endif /* not _VA_LIST_, except on certain systems */
187
188 #endif /* not __svr4__ */
189
190 #endif /* _STDARG_H */
191
192 #endif /* not _ANSI_STDARG_H_ */
193 #endif /* not _STDARG_H */