]>
git.saurik.com Git - apple/xnu.git/blob - EXTERNAL_HEADERS/stdarg.h
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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 License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 Note that the type used in va_arg is supposed to match the
30 actual type **after default promotions**.
31 Thus, va_arg (..., short) is not valid. */
34 #ifndef _ANSI_STDARG_H_
35 #ifndef __need___va_list
37 #define _ANSI_STDARG_H_
38 #endif /* not __need___va_list */
39 #undef __need___va_list
42 #include <va-clipper.h>
65 #if defined (__H8300__) || defined (__H8300H__)
68 #if defined (__PPC__) && defined (_CALL_SYSV)
72 /* Define __gnuc_va_list. */
74 #ifndef __GNUC_VA_LIST
75 #define __GNUC_VA_LIST
76 #if defined(__svr4__) || defined(_AIX) || defined(_M_UNIX) || defined(__NetBSD__) || (defined(__APPLE__) && defined(__ppc__))
77 typedef char * __gnuc_va_list
;
79 typedef void * __gnuc_va_list
;
83 /* Define the standard macros for the user,
84 if this invocation was from the user program. */
87 /* Amount of space required in an argument list for an arg of type TYPE.
88 TYPE may alternatively be an expression whose type is used. */
91 #define __va_rounded_size(TYPE) \
92 (((sizeof (TYPE) + sizeof (short) - 1) / sizeof (short)) * sizeof (short))
94 #define __va_rounded_size(TYPE) \
95 (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
98 #define va_start(AP, LASTARG) \
99 (AP = ((__gnuc_va_list) __builtin_next_arg (LASTARG)))
102 void va_end ( __gnuc_va_list
); /* Defined in libgcc.a */
103 #define va_end(AP) ((void)0)
105 /* We cast to void * and then to TYPE * because this avoids
106 a warning about increasing the alignment requirement. */
108 #if defined (__arm__) || defined (__i386__) || defined (__i860__) || defined (__ns32000__) || defined (__vax__)
109 /* This is for little-endian machines; small args are padded upward. */
110 #define va_arg(AP, TYPE) \
111 (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)), \
112 *((TYPE *) (void *) ((char *) (AP) - __va_rounded_size (TYPE))))
113 #else /* big-endian */
114 /* This is for big-endian machines; small args are padded downward. */
115 #define va_arg(AP, TYPE) \
116 (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)), \
117 *((TYPE *) (void *) ((char *) (AP) \
118 - ((sizeof (TYPE) < __va_rounded_size (char) \
119 ? sizeof (TYPE) : __va_rounded_size (TYPE))))))
120 #endif /* big-endian */
121 #endif /* _STDARG_H */
123 #endif /* not powerpc with V.4 calling sequence */
124 #endif /* not h8300 */
125 #endif /* not alpha */
126 #endif /* not i960 */
127 #endif /* not sparc */
128 #endif /* not mips */
129 #endif /* not hppa */
130 #endif /* not i860 */
131 #endif /* not m88k */
132 #endif /* not clipper */
135 /* Define va_list, if desired, from __gnuc_va_list. */
136 /* We deliberately do not define va_list when called from
137 stdio.h, because ANSI C says that stdio.h is not supposed to define
138 va_list. stdio.h needs to have access to that data type,
139 but must not use that name. It should use the name __gnuc_va_list,
140 which is safe because it is reserved for the implementation. */
142 #ifdef _HIDDEN_VA_LIST /* On OSF1, this means varargs.h is "half-loaded". */
151 /* SVR4.2 uses _VA_LIST for an internal alias for va_list,
152 so we must avoid testing it and setting it here.
153 SVR4 uses _VA_LIST as a flag in stdarg.h, but we should
154 have no conflict with that. */
159 #define _VA_LIST va_list
161 #endif /* __i860__ */
162 typedef __gnuc_va_list
va_list ;
163 #endif /* _VA_LIST_ */
164 #else /* not __svr4__ */
166 /* The macro _VA_LIST_ is the same thing used by this file in Ultrix.
167 But on BSD NET2 we must not test or define or undef it.
168 (Note that the comments in NET 2's ansi.h
169 are incorrect for _VA_LIST_--see stdio.h!) */
170 #if !defined (_VA_LIST_) || defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__) || defined(WINNT)
171 /* The macro _VA_LIST_DEFINED is used in Windows NT 3.5 */
172 #ifndef _VA_LIST_DEFINED
173 /* The macro _VA_LIST is used in SCO Unix 3.2. */
175 /* The macro _VA_LIST_T_H is used in the Bull dpx2 */
177 typedef __gnuc_va_list
va_list ;
178 #endif /* not _VA_LIST_T_H */
179 #endif /* not _VA_LIST */
180 #endif /* not _VA_LIST_DEFINED */
181 #if !(defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__))
187 #ifndef _VA_LIST_DEFINED
188 #define _VA_LIST_DEFINED
194 #endif /* not _VA_LIST_, except on certain systems */
196 #endif /* not __svr4__ */
198 #endif /* _STDARG_H */
200 #endif /* not _ANSI_STDARG_H_ */
201 #endif /* not _STDARG_H */