]>
git.saurik.com Git - apple/xnu.git/blob - EXTERNAL_HEADERS/stdarg.h
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
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. */
28 #ifndef _ANSI_STDARG_H_
29 #ifndef __need___va_list
31 #define _ANSI_STDARG_H_
32 #endif /* not __need___va_list */
33 #undef __need___va_list
36 #include <va-clipper.h>
59 #if defined (__H8300__) || defined (__H8300H__)
62 #if defined (__PPC__) && defined (_CALL_SYSV)
66 /* Define __gnuc_va_list. */
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
;
73 typedef void * __gnuc_va_list
;
77 /* Define the standard macros for the user,
78 if this invocation was from the user program. */
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. */
85 #define __va_rounded_size(TYPE) \
86 (((sizeof (TYPE) + sizeof (short) - 1) / sizeof (short)) * sizeof (short))
88 #define __va_rounded_size(TYPE) \
89 (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
92 #define va_start(AP, LASTARG) \
93 (AP = ((__gnuc_va_list) __builtin_next_arg (LASTARG)))
96 void va_end ( __gnuc_va_list
); /* Defined in libgcc.a */
97 #define va_end(AP) ((void)0)
99 /* We cast to void * and then to TYPE * because this avoids
100 a warning about increasing the alignment requirement. */
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 */
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 */
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. */
136 #ifdef _HIDDEN_VA_LIST /* On OSF1, this means varargs.h is "half-loaded". */
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. */
153 #define _VA_LIST va_list
155 #endif /* __i860__ */
156 typedef __gnuc_va_list
va_list ;
157 #endif /* _VA_LIST_ */
158 #else /* not __svr4__ */
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. */
169 /* The macro _VA_LIST_T_H is used in the Bull dpx2 */
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__))
181 #ifndef _VA_LIST_DEFINED
182 #define _VA_LIST_DEFINED
188 #endif /* not _VA_LIST_, except on certain systems */
190 #endif /* not __svr4__ */
192 #endif /* _STDARG_H */
194 #endif /* not _ANSI_STDARG_H_ */
195 #endif /* not _STDARG_H */