1/* 2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 * 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. 14 * 15 * Please obtain a copy of the License at 16 * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 * 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. 25 * 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 */ 28/* stdarg.h for GNU. 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. */ 32 33#ifndef _STDARG_H 34#ifndef _ANSI_STDARG_H_ 35#ifndef __need___va_list 36#define _STDARG_H 37#define _ANSI_STDARG_H_ 38#endif /* not __need___va_list */ 39#undef __need___va_list 40 41#ifdef __clipper__ 42#include <va-clipper.h> 43#else 44#ifdef __m88k__ 45#include <va-m88k.h> 46#else 47#ifdef __i860__ 48#include <va-i860.h> 49#else 50#ifdef __hppa__ 51#include <va-pa.h> 52#else 53#ifdef __mips__ 54#include <va-mips.h> 55#else 56#ifdef __sparc__ 57#include <va-sparc.h> 58#else 59#ifdef __i960__ 60#include <va-i960.h> 61#else 62#ifdef __alpha__ 63#include <va-alpha.h> 64#else 65#if defined (__H8300__) || defined (__H8300H__) 66#include <va-h8300.h> 67#else 68#if defined (__PPC__) && defined (_CALL_SYSV) 69#include <va-ppc.h> 70#else 71 72/* Define __gnuc_va_list. */ 73 74#ifndef __GNUC_VA_LIST 75#define __GNUC_VA_LIST 76#if defined(__svr4__) || defined(_AIX) || defined(_M_UNIX) || defined(__NetBSD__) 77typedef char *__gnuc_va_list; 78#else 79typedef void *__gnuc_va_list; 80#endif 81#endif 82 83/* Define the standard macros for the user, 84 if this invocation was from the user program. */ 85#ifdef _STDARG_H 86 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. */ 89 90#if defined(sysV68) 91#define __va_rounded_size(TYPE) \ 92 (((sizeof (TYPE) + sizeof (short) - 1) / sizeof (short)) * sizeof (short)) 93#else 94#define __va_rounded_size(TYPE) \ 95 (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)) 96#endif 97 98#define va_start(AP, LASTARG) \ 99 (AP = ((__gnuc_va_list) __builtin_next_arg (LASTARG))) 100 101#undef va_end 102void va_end (__gnuc_va_list); /* Defined in libgcc.a */ 103#define va_end(AP) ((void)0) 104 105/* We cast to void * and then to TYPE * because this avoids 106 a warning about increasing the alignment requirement. */ 107 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 */ 122 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 */ 133 134#ifdef _STDARG_H 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. */ 141 142#ifdef _HIDDEN_VA_LIST /* On OSF1, this means varargs.h is "half-loaded". */ 143#undef _VA_LIST 144#endif 145 146#ifdef _BSD_VA_LIST 147#undef _BSD_VA_LIST 148#endif 149 150#ifdef __svr4__ 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. */ 155#ifndef _VA_LIST_ 156#define _VA_LIST_ 157#ifdef __i860__ 158#ifndef _VA_LIST 159#define _VA_LIST va_list 160#endif 161#endif /* __i860__ */ 162typedef __gnuc_va_list va_list; 163#endif /* _VA_LIST_ */ 164#else /* not __svr4__ */ 165 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. */ 174#ifndef _VA_LIST 175/* The macro _VA_LIST_T_H is used in the Bull dpx2 */ 176#ifndef _VA_LIST_T_H 177typedef __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__)) 182#define _VA_LIST_ 183#endif 184#ifndef _VA_LIST 185#define _VA_LIST 186#endif 187#ifndef _VA_LIST_DEFINED 188#define _VA_LIST_DEFINED 189#endif 190#ifndef _VA_LIST_T_H 191#define _VA_LIST_T_H 192#endif 193 194#endif /* not _VA_LIST_, except on certain systems */ 195 196#endif /* not __svr4__ */ 197 198#endif /* _STDARG_H */ 199 200#endif /* not _ANSI_STDARG_H_ */ 201#endif /* not _STDARG_H */ 202