stdarg.h revision 52212
1218885Sdim/* stdarg.h for GNU. 2218885Sdim Note that the type used in va_arg is supposed to match the 3218885Sdim actual type **after default promotions**. 4218885Sdim Thus, va_arg (..., short) is not valid. */ 5218885Sdim 6218885Sdim/* $FreeBSD: head/contrib/gcc/ginclude/stdarg.h 52212 1999-10-13 15:55:31Z obrien $ */ 7218885Sdim 8218885Sdim#ifndef _STDARG_H 9218885Sdim#ifndef _ANSI_STDARG_H_ 10218885Sdim#ifndef __need___va_list 11218885Sdim#define _STDARG_H 12218885Sdim#define _ANSI_STDARG_H_ 13218885Sdim#endif /* not __need___va_list */ 14218885Sdim#undef __need___va_list 15218885Sdim 16218885Sdim#ifdef __clipper__ 17218885Sdim#include "va-clipper.h" 18218885Sdim#else 19218885Sdim#ifdef __m88k__ 20218885Sdim#include "va-m88k.h" 21218885Sdim#else 22218885Sdim#ifdef __i860__ 23218885Sdim#include "va-i860.h" 24218885Sdim#else 25218885Sdim#ifdef __hppa__ 26218885Sdim#include "va-pa.h" 27218885Sdim#else 28218885Sdim#ifdef __mips__ 29218885Sdim#include "va-mips.h" 30218885Sdim#else 31218885Sdim#ifdef __sparc__ 32218885Sdim#include "va-sparc.h" 33218885Sdim#else 34218885Sdim#ifdef __i960__ 35218885Sdim#include "va-i960.h" 36218885Sdim#else 37218885Sdim#ifdef __alpha__ 38218885Sdim#include "va-alpha.h" 39218885Sdim#else 40239462Sdim#if defined (__H8300__) || defined (__H8300H__) || defined (__H8300S__) 41239462Sdim#include "va-h8300.h" 42218885Sdim#else 43218885Sdim#if defined (__PPC__) && (defined (_CALL_SYSV) || defined (_WIN32)) 44218885Sdim#include "va-ppc.h" 45218885Sdim#else 46218885Sdim#ifdef __arc__ 47218885Sdim#include "va-arc.h" 48218885Sdim#else 49218885Sdim#ifdef __M32R__ 50239462Sdim#include "va-m32r.h" 51218885Sdim#else 52218885Sdim#ifdef __sh__ 53218885Sdim#include "va-sh.h" 54218885Sdim#else 55218885Sdim#ifdef __mn10300__ 56218885Sdim#include "va-mn10300.h" 57219077Sdim#else 58219077Sdim#ifdef __mn10200__ 59218885Sdim#include "va-mn10200.h" 60234353Sdim#else 61218885Sdim#ifdef __v850__ 62218885Sdim#include "va-v850.h" 63218885Sdim#else 64218885Sdim 65239462Sdim/* Define __gnuc_va_list. */ 66223017Sdim 67218885Sdim#ifndef __GNUC_VA_LIST 68239462Sdim#define __GNUC_VA_LIST 69218885Sdim#if defined(__svr4__) || defined(_AIX) || defined(_M_UNIX) || defined(__NetBSD__) 70218885Sdimtypedef char *__gnuc_va_list; 71218885Sdim#else 72218885Sdimtypedef void *__gnuc_va_list; 73239462Sdim#endif 74218885Sdim#endif 75218885Sdim 76218885Sdim/* Define the standard macros for the user, 77218885Sdim if this invocation was from the user program. */ 78218885Sdim#ifdef _STDARG_H 79218885Sdim 80218885Sdim/* Amount of space required in an argument list for an arg of type TYPE. 81218885Sdim TYPE may alternatively be an expression whose type is used. */ 82219077Sdim 83219077Sdim#if defined(sysV68) 84218885Sdim#define __va_rounded_size(TYPE) \ 85219077Sdim (((sizeof (TYPE) + sizeof (short) - 1) / sizeof (short)) * sizeof (short)) 86219077Sdim#else 87219077Sdim#define __va_rounded_size(TYPE) \ 88218885Sdim (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)) 89218885Sdim#endif 90218885Sdim 91218885Sdim#define va_start(AP, LASTARG) \ 92218885Sdim (AP = ((__gnuc_va_list) __builtin_next_arg (LASTARG))) 93218885Sdim 94218885Sdim#undef va_end 95218885Sdimvoid va_end (__gnuc_va_list); /* Defined in libgcc.a */ 96218885Sdim#define va_end(AP) ((void)0) 97218885Sdim 98218885Sdim/* We cast to void * and then to TYPE * because this avoids 99218885Sdim a warning about increasing the alignment requirement. */ 100218885Sdim 101218885Sdim#if (defined (__arm__) && ! defined (__ARMEB__)) || defined (__i386__) || defined (__i860__) || defined (__ns32000__) || defined (__vax__) 102218885Sdim/* This is for little-endian machines; small args are padded upward. */ 103219077Sdim#define va_arg(AP, TYPE) \ 104218885Sdim (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)), \ 105218885Sdim *((TYPE *) (void *) ((char *) (AP) - __va_rounded_size (TYPE)))) 106218885Sdim#else /* big-endian */ 107218885Sdim/* This is for big-endian machines; small args are padded downward. */ 108218885Sdim#define va_arg(AP, TYPE) \ 109 (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)), \ 110 *((TYPE *) (void *) ((char *) (AP) \ 111 - ((sizeof (TYPE) < __va_rounded_size (char) \ 112 ? sizeof (TYPE) : __va_rounded_size (TYPE)))))) 113#endif /* big-endian */ 114 115/* Copy __gnuc_va_list into another variable of this type. */ 116#define __va_copy(dest, src) (dest) = (src) 117 118#endif /* _STDARG_H */ 119 120#endif /* not v850 */ 121#endif /* not mn10200 */ 122#endif /* not mn10300 */ 123#endif /* not sh */ 124#endif /* not m32r */ 125#endif /* not arc */ 126#endif /* not powerpc with V.4 calling sequence */ 127#endif /* not h8300 */ 128#endif /* not alpha */ 129#endif /* not i960 */ 130#endif /* not sparc */ 131#endif /* not mips */ 132#endif /* not hppa */ 133#endif /* not i860 */ 134#endif /* not m88k */ 135#endif /* not clipper */ 136 137#ifdef _STDARG_H 138/* Define va_list, if desired, from __gnuc_va_list. */ 139/* We deliberately do not define va_list when called from 140 stdio.h, because ANSI C says that stdio.h is not supposed to define 141 va_list. stdio.h needs to have access to that data type, 142 but must not use that name. It should use the name __gnuc_va_list, 143 which is safe because it is reserved for the implementation. */ 144 145#ifdef _HIDDEN_VA_LIST /* On OSF1, this means varargs.h is "half-loaded". */ 146#undef _VA_LIST 147#endif 148 149#ifdef _BSD_VA_LIST 150#undef _BSD_VA_LIST 151#endif 152 153#if defined(__svr4__) || (defined(_SCO_DS) && !defined(__VA_LIST)) 154/* SVR4.2 uses _VA_LIST for an internal alias for va_list, 155 so we must avoid testing it and setting it here. 156 SVR4 uses _VA_LIST as a flag in stdarg.h, but we should 157 have no conflict with that. */ 158#ifndef _VA_LIST_ 159#define _VA_LIST_ 160#ifdef __i860__ 161#ifndef _VA_LIST 162#define _VA_LIST va_list 163#endif 164#endif /* __i860__ */ 165typedef __gnuc_va_list va_list; 166#ifdef _SCO_DS 167#define __VA_LIST 168#endif 169#endif /* _VA_LIST_ */ 170#else /* not __svr4__ || _SCO_DS */ 171 172/* The macro _VA_LIST_ is the same thing used by this file in Ultrix. 173 But on BSD NET2 we must not test or define or undef it. 174 (Note that the comments in NET 2's ansi.h 175 are incorrect for _VA_LIST_--see stdio.h!) */ 176#if !defined (_VA_LIST_) || defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__) || defined(WINNT) 177/* The macro _VA_LIST_DEFINED is used in Windows NT 3.5 */ 178#ifndef _VA_LIST_DEFINED 179/* The macro _VA_LIST is used in SCO Unix 3.2. */ 180#ifndef _VA_LIST 181/* The macro _VA_LIST_T_H is used in the Bull dpx2 */ 182#ifndef _VA_LIST_T_H 183typedef __gnuc_va_list va_list; 184#endif /* not _VA_LIST_T_H */ 185#endif /* not _VA_LIST */ 186#endif /* not _VA_LIST_DEFINED */ 187#if !(defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__)) 188#define _VA_LIST_ 189#endif 190#ifndef _VA_LIST 191#define _VA_LIST 192#endif 193#ifndef _VA_LIST_DEFINED 194#define _VA_LIST_DEFINED 195#endif 196#ifndef _VA_LIST_T_H 197#define _VA_LIST_T_H 198#endif 199 200#endif /* not _VA_LIST_, except on certain systems */ 201 202#endif /* not __svr4__ */ 203 204#endif /* _STDARG_H */ 205 206#endif /* not _ANSI_STDARG_H_ */ 207#endif /* not _STDARG_H */ 208