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