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