cleanup
[linux-2.4.21-pre4.git] / include / varargs.h
1 /* Record that this is varargs.h; this turns off stdarg.h.  */
2
3 #ifndef _VARARGS_H
4 #define _VARARGS_H
5
6 #ifdef __sparc__
7 #include "va-sparc.h"
8 #else
9 #ifdef __spur__
10 #include "va-spur.h"
11 #else
12 #ifdef __mips__
13 #include "va-mips.h"
14 #else
15 #ifdef __i860__
16 #include "va-i860.h"
17 #else
18 #ifdef __pyr__
19 #include "va-pyr.h"
20 #else
21 #ifdef __clipper__
22 #include "va-clipper.h"
23 #else
24 #ifdef __m88k__
25 #include "va-m88k.h"
26 #else
27 #if defined(__hppa__) || defined(hp800)
28 #include "va-pa.h"
29 #else
30 #ifdef __i960__
31 #include "va-i960.h"
32 #else
33 #ifdef __alpha__
34 #include "va-alpha.h"
35 #else
36 #if defined (__H8300__) || defined (__H8300H__) || defined (__H8300S__)
37 #include "va-h8300.h"
38 #else
39 #if defined (__PPC__) && (defined (_CALL_SYSV) || defined (_WIN32))
40 #include "va-ppc.h"
41 #else
42 #ifdef __arc__
43 #include "va-arc.h"
44 #else
45 #ifdef __M32R__
46 #include "va-m32r.h"
47 #else
48 #ifdef __sh__
49 #include "va-sh.h"
50 #else
51 #ifdef __mn10300__
52 #include "va-mn10300.h"
53 #else
54 #ifdef __mn10200__
55 #include "va-mn10200.h"
56 #else
57 #ifdef __v850__
58 #include "va-v850.h"
59 #else
60 #if defined (_TMS320C4x) || defined (_TMS320C3x)
61 #include <va-c4x.h>
62 #else
63
64 #ifdef __NeXT__
65
66 /* On Next, erase any vestiges of stdarg.h.  */
67
68 #ifdef _ANSI_STDARG_H_
69 #define _VA_LIST_
70 #endif
71 #define _ANSI_STDARG_H_ 
72
73 #undef va_alist
74 #undef va_dcl
75 #undef va_list
76 #undef va_start
77 #undef va_end
78 #undef __va_rounded_size
79 #undef va_arg
80 #endif  /* __NeXT__ */
81
82 /* In GCC version 2, we want an ellipsis at the end of the declaration
83    of the argument list.  GCC version 1 can't parse it.  */
84
85 #if __GNUC__ > 1
86 #define __va_ellipsis ...
87 #else
88 #define __va_ellipsis
89 #endif
90
91 /* These macros implement traditional (non-ANSI) varargs
92    for GNU C.  */
93
94 #define va_alist  __builtin_va_alist
95 /* The ... causes current_function_varargs to be set in cc1.  */
96 /* ??? We don't process attributes correctly in K&R argument context.  */
97 typedef int __builtin_va_alist_t __attribute__((__mode__(__word__)));
98 #define va_dcl  __builtin_va_alist_t __builtin_va_alist; __va_ellipsis
99
100 /* Define __gnuc_va_list, just as in gstdarg.h.  */
101
102 #ifndef __GNUC_VA_LIST
103 #define __GNUC_VA_LIST
104 #if defined(__svr4__) || defined(_AIX) || defined(_M_UNIX)
105 typedef char *__gnuc_va_list;
106 #else
107 typedef void *__gnuc_va_list;
108 #endif
109 #endif
110
111 #define va_start(AP)  AP=(char *) &__builtin_va_alist
112
113 #define va_end(AP)      ((void)0)
114
115 #if defined(sysV68)
116 #define __va_rounded_size(TYPE)  \
117   (((sizeof (TYPE) + sizeof (short) - 1) / sizeof (short)) * sizeof (short))
118 #elif defined(_AIX)
119 #define __va_rounded_size(TYPE)  \
120   (((sizeof (TYPE) + sizeof (long) - 1) / sizeof (long)) * sizeof (long))
121 #else
122 #define __va_rounded_size(TYPE)  \
123   (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
124 #endif
125
126 #if (defined (__arm__) && ! defined (__ARMEB__)) || defined (__i386__) || defined (__i860__) || defined (__ns32000__) || defined (__vax__)
127 /* This is for little-endian machines; small args are padded upward.  */
128 #define va_arg(AP, TYPE)                                                \
129  (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)),     \
130   *((TYPE *) (void *) ((char *) (AP) - __va_rounded_size (TYPE))))
131 #else /* big-endian */
132 /* This is for big-endian machines; small args are padded downward.  */
133 #define va_arg(AP, TYPE)                                                \
134  (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)),     \
135   *((TYPE *) (void *) ((char *) (AP)                                    \
136                        - ((sizeof (TYPE) < __va_rounded_size (char)     \
137                            ? sizeof (TYPE) : __va_rounded_size (TYPE))))))
138 #endif /* big-endian */
139
140 /* Copy __gnuc_va_list into another variable of this type.  */
141 #define __va_copy(dest, src) (dest) = (src)
142
143 #endif /* not TMS320C3x or TMS320C4x */
144 #endif /* not v850 */
145 #endif /* not mn10200 */
146 #endif /* not mn10300 */
147 #endif /* not sh */
148 #endif /* not m32r */
149 #endif /* not arc */
150 #endif /* not powerpc with V.4 calling sequence */
151 #endif /* not h8300 */
152 #endif /* not alpha */
153 #endif /* not i960 */
154 #endif /* not hppa */
155 #endif /* not m88k */
156 #endif /* not clipper */
157 #endif /* not pyr */
158 #endif /* not i860 */
159 #endif /* not mips */
160 #endif /* not spur */
161 #endif /* not sparc */
162 #endif /* not _VARARGS_H */
163
164 /* Define va_list from __gnuc_va_list.  */
165
166 #ifdef _HIDDEN_VA_LIST  /* On OSF1, this means varargs.h is "half-loaded".  */
167 #undef _VA_LIST
168 #endif
169
170 #if defined(__svr4__) || (defined(_SCO_DS) && !defined(__VA_LIST))
171 /* SVR4.2 uses _VA_LIST for an internal alias for va_list,
172    so we must avoid testing it and setting it here.
173    SVR4 uses _VA_LIST as a flag in stdarg.h, but we should
174    have no conflict with that.  */
175 #ifndef _VA_LIST_
176 #define _VA_LIST_
177 #ifdef __i860__
178 #ifndef _VA_LIST
179 #define _VA_LIST va_list
180 #endif
181 #endif /* __i860__ */
182 typedef __gnuc_va_list va_list;
183 #ifdef _SCO_DS
184 #define __VA_LIST
185 #endif
186 #endif /* _VA_LIST_ */
187
188 #else /* not __svr4__  || _SCO_DS */
189
190 /* The macro _VA_LIST_ is the same thing used by this file in Ultrix.
191    But on BSD NET2 we must not test or define or undef it.
192    (Note that the comments in NET 2's ansi.h
193    are incorrect for _VA_LIST_--see stdio.h!)  */
194 /* Michael Eriksson <mer@sics.se> at Thu Sep 30 11:00:57 1993:
195    Sequent defines _VA_LIST_ in <machine/machtypes.h> to be the type to
196    use for va_list (``typedef _VA_LIST_ va_list'') */
197 #if !defined (_VA_LIST_) || defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__) || defined(WINNT)
198 /* The macro _VA_LIST_DEFINED is used in Windows NT 3.5  */
199 #ifndef _VA_LIST_DEFINED
200 /* The macro _VA_LIST is used in SCO Unix 3.2.  */
201 #ifndef _VA_LIST
202 /* The macro _VA_LIST_T_H is used in the Bull dpx2  */
203 #ifndef _VA_LIST_T_H
204 typedef __gnuc_va_list va_list;
205 #endif /* not _VA_LIST_T_H */
206 #endif /* not _VA_LIST */
207 #endif /* not _VA_LIST_DEFINED */
208 #if !(defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__))
209 #define _VA_LIST_
210 #endif
211 #ifndef _VA_LIST
212 #define _VA_LIST
213 #endif
214 #ifndef _VA_LIST_DEFINED
215 #define _VA_LIST_DEFINED
216 #endif
217 #ifndef _VA_LIST_T_H
218 #define _VA_LIST_T_H
219 #endif
220
221 #endif /* not _VA_LIST_, except on certain systems */
222
223 #endif /* not __svr4__ */
224
225 /* The next BSD release (if there is one) wants this symbol to be
226    undefined instead of _VA_LIST_.  */
227 #ifdef _BSD_VA_LIST
228 #undef _BSD_VA_LIST
229 #endif