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