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