OSDN Git Service

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