]>
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 | |
ea0ad163 | 14 | #ifndef __GNUC__ |
b3fab01d RS |
15 | /* Use the system's macros with the system's compiler. |
16 | This is relevant only when building GCC with some other compiler. */ | |
ea0ad163 RS |
17 | #include <stdarg.h> |
18 | #else | |
0dbbbb09 | 19 | #ifdef __m88k__ |
b3fab01d | 20 | #include <va-m88k.h> |
0dbbbb09 RS |
21 | #else |
22 | #ifdef __i860__ | |
b3fab01d | 23 | #include <va-i860.h> |
0dbbbb09 | 24 | #else |
d9b694cb | 25 | #ifdef __hppa__ |
b3fab01d | 26 | #include <va-pa.h> |
43b0eb42 RS |
27 | #else |
28 | #ifdef __mips__ | |
b3fab01d | 29 | #include <va-mips.h> |
43b0eb42 | 30 | #else |
5840cf94 | 31 | #ifdef __sparc__ |
b3fab01d | 32 | #include <va-sparc.h> |
5840cf94 | 33 | #else |
6f90e075 | 34 | #ifdef __i960__ |
b3fab01d | 35 | #include <va-i960.h> |
6f90e075 | 36 | #else |
e318a72a | 37 | #ifdef __alpha__ |
b3fab01d | 38 | #include <va-alpha.h> |
e318a72a | 39 | #else |
0dbbbb09 | 40 | |
0a85964e | 41 | /* Define __gnuc_va_list. */ |
373b5e3b | 42 | |
0a85964e RS |
43 | #ifndef __GNUC_VA_LIST |
44 | #define __GNUC_VA_LIST | |
b394f631 | 45 | #if defined(__svr4__) || defined(_AIX) || defined(_M_UNIX) |
0a85964e | 46 | typedef char *__gnuc_va_list; |
69d6c854 | 47 | #else |
0a85964e | 48 | typedef void *__gnuc_va_list; |
69d6c854 | 49 | #endif |
0a85964e RS |
50 | #endif |
51 | ||
52 | /* Define the standard macros for the user, | |
53 | if this invocation was from the user program. */ | |
a5a9fc56 | 54 | #ifdef _STDARG_H |
0dbbbb09 RS |
55 | |
56 | /* Amount of space required in an argument list for an arg of type TYPE. | |
57 | TYPE may alternatively be an expression whose type is used. */ | |
58 | ||
59 | #define __va_rounded_size(TYPE) \ | |
60 | (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)) | |
61 | ||
0dbbbb09 | 62 | #define va_start(AP, LASTARG) \ |
339ae22d | 63 | (AP = ((__gnuc_va_list) __builtin_next_arg ())) |
0dbbbb09 | 64 | |
0a85964e | 65 | void va_end (__gnuc_va_list); /* Defined in libgcc.a */ |
0dbbbb09 RS |
66 | #define va_end(AP) |
67 | ||
7436f435 RS |
68 | /* We cast to void * and then to TYPE * because this avoids |
69 | a warning about increasing the alignment requirement. */ | |
0dbbbb09 | 70 | #define va_arg(AP, TYPE) \ |
339ae22d | 71 | (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)), \ |
7436f435 | 72 | *((TYPE *) (void *) ((char *) (AP) - __va_rounded_size (TYPE)))) |
0a85964e | 73 | #endif /* _STDARG_H */ |
0dbbbb09 | 74 | |
e318a72a | 75 | #endif /* not alpha */ |
6f90e075 | 76 | #endif /* not i960 */ |
5840cf94 | 77 | #endif /* not sparc */ |
43b0eb42 | 78 | #endif /* not mips */ |
d9b694cb | 79 | #endif /* not hppa */ |
0dbbbb09 RS |
80 | #endif /* not i860 */ |
81 | #endif /* not m88k */ | |
0a85964e RS |
82 | |
83 | #ifdef _STDARG_H | |
84 | /* Define va_list, if desired, from __gnuc_va_list. */ | |
da86800a RS |
85 | /* We deliberately do not define va_list when called from |
86 | stdio.h, because ANSI C says that stdio.h is not supposed to define | |
87 | va_list. stdio.h needs to have access to that data type, | |
88 | but must not use that name. It should use the name __gnuc_va_list, | |
89 | which is safe because it is reserved for the implementation. */ | |
0a85964e RS |
90 | |
91 | #ifdef _HIDDEN_VA_LIST /* On OSF1, this means varargs.h is "half-loaded". */ | |
92 | #undef _VA_LIST | |
93 | #endif | |
94 | ||
eaec9d17 RS |
95 | #ifdef _BSD_VA_LIST |
96 | #undef _BSD_VA_LIST | |
97 | #endif | |
98 | ||
eae92d82 RS |
99 | #ifdef __SVR4_2__ |
100 | /* SVR4.2 uses _VA_LIST for an internal alias for va_list, | |
101 | so we must avoid testing it and setting it here. */ | |
102 | #ifndef _VA_LIST_ | |
103 | #define _VA_LIST_ | |
104 | typedef __gnuc_va_list va_list; | |
105 | #endif /* _VA_LIST_ */ | |
106 | #else /* not __SVR4_2__ */ | |
107 | ||
d9832c78 RS |
108 | /* On 4.3bsd-net2, make sure ansi.h is included, so we have |
109 | one less case to deal with in the following. */ | |
110 | #if defined (__BSD_NET2__) || defined (____386BSD____) | |
111 | #include <ansi.h> | |
112 | #endif | |
113 | ||
114 | /* In 4.3bsd-net2, machine/ansi.h defines these symbols, which remain | |
115 | defined as long as the corresponding type is *not* defined. */ | |
116 | #ifdef _ANSI_H_ | |
117 | #ifndef _VA_LIST_ | |
118 | #define _VA_LIST | |
119 | #endif | |
120 | #undef _VA_LIST_ | |
121 | #endif /* _ANSI_H_ */ | |
122 | ||
0a85964e | 123 | /* The macro _VA_LIST_ is the same thing used by this file in Ultrix. */ |
d9832c78 | 124 | #ifndef _VA_LIST_ |
0a85964e RS |
125 | /* The macro _VA_LIST is used in SCO Unix 3.2. */ |
126 | #ifndef _VA_LIST | |
127 | #define _VA_LIST_ | |
128 | #define _VA_LIST | |
129 | typedef __gnuc_va_list va_list; | |
36228d08 | 130 | #endif /* not _VA_LIST */ |
d9832c78 RS |
131 | #endif /* not _VA_LIST_ */ |
132 | ||
133 | /* On 4.3bsd-net2, leave _VA_LIST_ undef to indicate va_list is defined. */ | |
134 | #ifdef _ANSI_H_ | |
135 | #undef _VA_LIST_ | |
136 | #endif | |
eae92d82 RS |
137 | |
138 | #endif /* not __SVR4_2__ */ | |
139 | ||
0dbbbb09 | 140 | #endif /* _STDARG_H */ |
0a85964e RS |
141 | |
142 | #endif /* __GNUC__ */ | |
36228d08 | 143 | #endif /* not _ANSI_STDARG_H_ */ |
0a85964e | 144 | #endif /* not _STDARG_H */ |