OSDN Git Service

(va_arg): Don't assume __va_rounded_size (char) has the value of 4.
[pf3gnuchains/gcc-fork.git] / gcc / ginclude / 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__)
37 #include <va-h8300.h>
38 #else
39
40 #ifdef __NeXT__
41
42 /* On Next, erase any vestiges of stdarg.h.  */
43
44 #ifdef _ANSI_STDARG_H_
45 #define _VA_LIST_
46 #endif
47 #define _ANSI_STDARG_H_ 
48
49 #undef va_alist
50 #undef va_dcl
51 #undef va_list
52 #undef va_start
53 #undef va_end
54 #undef __va_rounded_size
55 #undef va_arg
56 #endif  /* __NeXT__ */
57
58 /* In GCC version 2, we want an ellipsis at the end of the declaration
59    of the argument list.  GCC version 1 can't parse it.  */
60
61 #if __GNUC__ > 1
62 #define __va_ellipsis ...
63 #else
64 #define __va_ellipsis
65 #endif
66
67 /* These macros implement traditional (non-ANSI) varargs
68    for GNU C.  */
69
70 #define va_alist  __builtin_va_alist
71 /* The ... causes current_function_varargs to be set in cc1.  */
72 #define va_dcl    int __builtin_va_alist; __va_ellipsis
73
74 /* Define __gnuc_va_list, just as in gstdarg.h.  */
75
76 #ifndef __GNUC_VA_LIST
77 #define __GNUC_VA_LIST
78 #if defined(__svr4__) || defined(_AIX) || defined(_M_UNIX)
79 typedef char *__gnuc_va_list;
80 #else
81 typedef void *__gnuc_va_list;
82 #endif
83 #endif
84
85 #define va_start(AP)  AP=(char *) &__builtin_va_alist
86
87 #define va_end(AP)      ((void)0)
88
89 #if defined(sysV68)
90 #define __va_rounded_size(TYPE)  \
91   (((sizeof (TYPE) + sizeof (short) - 1) / sizeof (short)) * sizeof (short))
92 #else
93 #define __va_rounded_size(TYPE)  \
94   (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
95 #endif
96
97 #if defined (__arm__) || defined (__i386__) || defined (__i860__) || defined (__ns32000__) || defined (__vax__)
98 /* This is for little-endian machines; small args are padded upward.  */
99 #define va_arg(AP, TYPE)                                                \
100  (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)),     \
101   *((TYPE *) (void *) ((char *) (AP) - __va_rounded_size (TYPE))))
102 #else /* big-endian */
103 /* This is for big-endian machines; small args are padded downward.  */
104 #define va_arg(AP, TYPE)                                                \
105  (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)),     \
106   *((TYPE *) (void *) ((char *) (AP)                                    \
107                        - ((sizeof (TYPE) < __va_rounded_size (char)     \
108                            ? sizeof (TYPE) : __va_rounded_size (TYPE))))))
109 #endif /* big-endian */
110
111 #endif /* not h8300 */
112 #endif /* not alpha */
113 #endif /* not i960 */
114 #endif /* not hppa */
115 #endif /* not m88k */
116 #endif /* not clipper */
117 #endif /* not pyr */
118 #endif /* not i860 */
119 #endif /* not mips */
120 #endif /* not spur */
121 #endif /* not sparc */
122 #endif /* not _VARARGS_H */
123
124 /* Define va_list from __gnuc_va_list.  */
125
126 #ifdef _HIDDEN_VA_LIST  /* On OSF1, this means varargs.h is "half-loaded".  */
127 #undef _VA_LIST
128 #endif
129
130 #ifdef __svr4__
131 /* SVR4.2 uses _VA_LIST for an internal alias for va_list,
132    so we must avoid testing it and setting it here.
133    SVR4 uses _VA_LIST as a flag in stdarg.h, but we should
134    have no conflict with that.  */
135 #ifndef _VA_LIST_
136 #define _VA_LIST_
137 #ifdef __i860__
138 #ifndef _VA_LIST
139 #define _VA_LIST va_list
140 #endif
141 #endif /* __i860__ */
142 typedef __gnuc_va_list va_list;
143 #endif /* _VA_LIST_ */
144
145 #else /* not __svr4__ */
146
147 /* The macro _VA_LIST_ is the same thing used by this file in Ultrix.
148    But on BSD NET2 we must not test or define or undef it.
149    (Note that the comments in NET 2's ansi.h
150    are incorrect for _VA_LIST_--see stdio.h!)  */
151 /* Michael Eriksson <mer@sics.se> at Thu Sep 30 11:00:57 1993:
152    Sequent defines _VA_LIST_ in <machine/machtypes.h> to be the type to
153    use for va_list (``typedef _VA_LIST_ va_list'') */
154 #if !defined (_VA_LIST_) || defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__) || defined(WINNT)
155 /* The macro _VA_LIST_DEFINED is used in Windows NT 3.5  */
156 #ifndef _VA_LIST_DEFINED
157 /* The macro _VA_LIST is used in SCO Unix 3.2.  */
158 #ifndef _VA_LIST
159 /* The macro _VA_LIST_T_H is used in the Bull dpx2  */
160 #ifndef _VA_LIST_T_H
161 typedef __gnuc_va_list va_list;
162 #endif /* not _VA_LIST_T_H */
163 #endif /* not _VA_LIST */
164 #endif /* not _VA_LIST_DEFINED */
165 #if !(defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__))
166 #define _VA_LIST_
167 #endif
168 #ifndef _VA_LIST
169 #define _VA_LIST
170 #endif
171 #ifndef _VA_LIST_DEFINED
172 #define _VA_LIST_DEFINED
173 #endif
174 #ifndef _VA_LIST_T_H
175 #define _VA_LIST_T_H
176 #endif
177
178 #endif /* not _VA_LIST_, except on certain systems */
179
180 #endif /* not __svr4__ */
181
182 /* The next BSD release (if there is one) wants this symbol to be
183    undefined instead of _VA_LIST_.  */
184 #ifdef _BSD_VA_LIST
185 #undef _BSD_VA_LIST
186 #endif