]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
6601e61a | 4 | * @APPLE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
6601e61a A |
6 | * The contents of this file constitute Original Code as defined in and |
7 | * are subject to the Apple Public Source License Version 1.1 (the | |
8 | * "License"). You may not use this file except in compliance with the | |
9 | * License. Please obtain a copy of the License at | |
10 | * http://www.apple.com/publicsource and read it before using this file. | |
8f6c56a5 | 11 | * |
6601e61a A |
12 | * This Original Code and all software distributed under the License are |
13 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
8f6c56a5 A |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
6601e61a A |
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the |
17 | * License for the specific language governing rights and limitations | |
18 | * under the License. | |
8f6c56a5 | 19 | * |
6601e61a | 20 | * @APPLE_LICENSE_HEADER_END@ |
1c79356b A |
21 | */ |
22 | /* stdarg.h for GNU. | |
23 | Note that the type used in va_arg is supposed to match the | |
24 | actual type **after default promotions**. | |
25 | Thus, va_arg (..., short) is not valid. */ | |
26 | ||
27 | #ifndef _STDARG_H | |
28 | #ifndef _ANSI_STDARG_H_ | |
29 | #ifndef __need___va_list | |
30 | #define _STDARG_H | |
31 | #define _ANSI_STDARG_H_ | |
32 | #endif /* not __need___va_list */ | |
33 | #undef __need___va_list | |
34 | ||
35 | #ifdef __clipper__ | |
36 | #include <va-clipper.h> | |
37 | #else | |
38 | #ifdef __m88k__ | |
39 | #include <va-m88k.h> | |
40 | #else | |
41 | #ifdef __i860__ | |
42 | #include <va-i860.h> | |
43 | #else | |
44 | #ifdef __hppa__ | |
45 | #include <va-pa.h> | |
46 | #else | |
47 | #ifdef __mips__ | |
48 | #include <va-mips.h> | |
49 | #else | |
50 | #ifdef __sparc__ | |
51 | #include <va-sparc.h> | |
52 | #else | |
53 | #ifdef __i960__ | |
54 | #include <va-i960.h> | |
55 | #else | |
56 | #ifdef __alpha__ | |
57 | #include <va-alpha.h> | |
58 | #else | |
59 | #if defined (__H8300__) || defined (__H8300H__) | |
60 | #include <va-h8300.h> | |
61 | #else | |
62 | #if defined (__PPC__) && defined (_CALL_SYSV) | |
63 | #include <va-ppc.h> | |
64 | #else | |
65 | ||
66 | /* Define __gnuc_va_list. */ | |
67 | ||
68 | #ifndef __GNUC_VA_LIST | |
69 | #define __GNUC_VA_LIST | |
70 | #if defined(__svr4__) || defined(_AIX) || defined(_M_UNIX) || defined(__NetBSD__) || (defined(__APPLE__) && defined(__ppc__)) | |
71 | typedef char *__gnuc_va_list; | |
72 | #else | |
73 | typedef void *__gnuc_va_list; | |
74 | #endif | |
75 | #endif | |
76 | ||
77 | /* Define the standard macros for the user, | |
78 | if this invocation was from the user program. */ | |
79 | #ifdef _STDARG_H | |
80 | ||
81 | /* Amount of space required in an argument list for an arg of type TYPE. | |
82 | TYPE may alternatively be an expression whose type is used. */ | |
83 | ||
84 | #if defined(sysV68) | |
85 | #define __va_rounded_size(TYPE) \ | |
86 | (((sizeof (TYPE) + sizeof (short) - 1) / sizeof (short)) * sizeof (short)) | |
87 | #else | |
88 | #define __va_rounded_size(TYPE) \ | |
89 | (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)) | |
90 | #endif | |
91 | ||
92 | #define va_start(AP, LASTARG) \ | |
93 | (AP = ((__gnuc_va_list) __builtin_next_arg (LASTARG))) | |
94 | ||
95 | #undef va_end | |
96 | void va_end (__gnuc_va_list); /* Defined in libgcc.a */ | |
97 | #define va_end(AP) ((void)0) | |
98 | ||
99 | /* We cast to void * and then to TYPE * because this avoids | |
100 | a warning about increasing the alignment requirement. */ | |
101 | ||
102 | #if defined (__arm__) || defined (__i386__) || defined (__i860__) || defined (__ns32000__) || defined (__vax__) | |
103 | /* This is for little-endian machines; small args are padded upward. */ | |
104 | #define va_arg(AP, TYPE) \ | |
105 | (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)), \ | |
106 | *((TYPE *) (void *) ((char *) (AP) - __va_rounded_size (TYPE)))) | |
107 | #else /* big-endian */ | |
108 | /* This is for big-endian machines; small args are padded downward. */ | |
109 | #define va_arg(AP, TYPE) \ | |
110 | (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)), \ | |
111 | *((TYPE *) (void *) ((char *) (AP) \ | |
112 | - ((sizeof (TYPE) < __va_rounded_size (char) \ | |
113 | ? sizeof (TYPE) : __va_rounded_size (TYPE)))))) | |
114 | #endif /* big-endian */ | |
115 | #endif /* _STDARG_H */ | |
116 | ||
117 | #endif /* not powerpc with V.4 calling sequence */ | |
118 | #endif /* not h8300 */ | |
119 | #endif /* not alpha */ | |
120 | #endif /* not i960 */ | |
121 | #endif /* not sparc */ | |
122 | #endif /* not mips */ | |
123 | #endif /* not hppa */ | |
124 | #endif /* not i860 */ | |
125 | #endif /* not m88k */ | |
126 | #endif /* not clipper */ | |
127 | ||
128 | #ifdef _STDARG_H | |
129 | /* Define va_list, if desired, from __gnuc_va_list. */ | |
130 | /* We deliberately do not define va_list when called from | |
131 | stdio.h, because ANSI C says that stdio.h is not supposed to define | |
132 | va_list. stdio.h needs to have access to that data type, | |
133 | but must not use that name. It should use the name __gnuc_va_list, | |
134 | which is safe because it is reserved for the implementation. */ | |
135 | ||
136 | #ifdef _HIDDEN_VA_LIST /* On OSF1, this means varargs.h is "half-loaded". */ | |
137 | #undef _VA_LIST | |
138 | #endif | |
139 | ||
140 | #ifdef _BSD_VA_LIST | |
141 | #undef _BSD_VA_LIST | |
142 | #endif | |
143 | ||
144 | #ifdef __svr4__ | |
145 | /* SVR4.2 uses _VA_LIST for an internal alias for va_list, | |
146 | so we must avoid testing it and setting it here. | |
147 | SVR4 uses _VA_LIST as a flag in stdarg.h, but we should | |
148 | have no conflict with that. */ | |
149 | #ifndef _VA_LIST_ | |
150 | #define _VA_LIST_ | |
151 | #ifdef __i860__ | |
152 | #ifndef _VA_LIST | |
153 | #define _VA_LIST va_list | |
154 | #endif | |
155 | #endif /* __i860__ */ | |
156 | typedef __gnuc_va_list va_list; | |
157 | #endif /* _VA_LIST_ */ | |
158 | #else /* not __svr4__ */ | |
159 | ||
160 | /* The macro _VA_LIST_ is the same thing used by this file in Ultrix. | |
161 | But on BSD NET2 we must not test or define or undef it. | |
162 | (Note that the comments in NET 2's ansi.h | |
163 | are incorrect for _VA_LIST_--see stdio.h!) */ | |
164 | #if !defined (_VA_LIST_) || defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__) || defined(WINNT) | |
165 | /* The macro _VA_LIST_DEFINED is used in Windows NT 3.5 */ | |
166 | #ifndef _VA_LIST_DEFINED | |
167 | /* The macro _VA_LIST is used in SCO Unix 3.2. */ | |
168 | #ifndef _VA_LIST | |
169 | /* The macro _VA_LIST_T_H is used in the Bull dpx2 */ | |
170 | #ifndef _VA_LIST_T_H | |
171 | typedef __gnuc_va_list va_list; | |
172 | #endif /* not _VA_LIST_T_H */ | |
173 | #endif /* not _VA_LIST */ | |
174 | #endif /* not _VA_LIST_DEFINED */ | |
175 | #if !(defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__)) | |
176 | #define _VA_LIST_ | |
177 | #endif | |
178 | #ifndef _VA_LIST | |
179 | #define _VA_LIST | |
180 | #endif | |
181 | #ifndef _VA_LIST_DEFINED | |
182 | #define _VA_LIST_DEFINED | |
183 | #endif | |
184 | #ifndef _VA_LIST_T_H | |
185 | #define _VA_LIST_T_H | |
186 | #endif | |
187 | ||
188 | #endif /* not _VA_LIST_, except on certain systems */ | |
189 | ||
190 | #endif /* not __svr4__ */ | |
191 | ||
192 | #endif /* _STDARG_H */ | |
193 | ||
194 | #endif /* not _ANSI_STDARG_H_ */ | |
195 | #endif /* not _STDARG_H */ |