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