11543Srgrimes/*- 296317Sobrien * Copyright (c) 2002 David E. O'Brien. All rights reserved. 31543Srgrimes * Copyright (c) 1990, 1993 41543Srgrimes * The Regents of the University of California. All rights reserved. 51543Srgrimes * (c) UNIX System Laboratories, Inc. 61543Srgrimes * All or some portions of this file are derived from material licensed 71543Srgrimes * to the University of California by American Telephone and Telegraph 81543Srgrimes * Co. or Unix System Laboratories, Inc. and are reproduced herein with 91543Srgrimes * the permission of UNIX System Laboratories, Inc. 101543Srgrimes * 111543Srgrimes * Redistribution and use in source and binary forms, with or without 121543Srgrimes * modification, are permitted provided that the following conditions 131543Srgrimes * are met: 141543Srgrimes * 1. Redistributions of source code must retain the above copyright 151543Srgrimes * notice, this list of conditions and the following disclaimer. 161543Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 171543Srgrimes * notice, this list of conditions and the following disclaimer in the 181543Srgrimes * documentation and/or other materials provided with the distribution. 191543Srgrimes * 3. All advertising materials mentioning features or use of this software 201543Srgrimes * must display the following acknowledgement: 211543Srgrimes * This product includes software developed by the University of 221543Srgrimes * California, Berkeley and its contributors. 231543Srgrimes * 4. Neither the name of the University nor the names of its contributors 241543Srgrimes * may be used to endorse or promote products derived from this software 251543Srgrimes * without specific prior written permission. 261543Srgrimes * 271543Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 281543Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 291543Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 301543Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 311543Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 321543Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 331543Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 341543Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 351543Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 361543Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 371543Srgrimes * SUCH DAMAGE. 381543Srgrimes * 391543Srgrimes * @(#)varargs.h 8.2 (Berkeley) 3/22/94 4050477Speter * $FreeBSD: releng/10.2/sys/amd64/include/varargs.h 143434 2005-03-11 22:16:09Z peter $ 411543Srgrimes */ 421543Srgrimes 43119628Skan#ifndef _MACHINE_VARARGS_H_ 44119628Skan#define _MACHINE_VARARGS_H_ 451543Srgrimes 46143063Sjoerg#ifndef _SYS_CDEFS_H_ 47143063Sjoerg#error this file needs sys/cdefs.h as a prerequisite 48143063Sjoerg#endif 4996317Sobrien 50143063Sjoerg#ifdef __GNUCLIKE_BUILTIN_VARARGS 51143063Sjoerg 52102227Smike#include <sys/_types.h> 5396317Sobrien 54104584Smike#ifndef _VA_LIST_DECLARED 55104584Smike#define _VA_LIST_DECLARED 56102227Smiketypedef __va_list va_list; 57104584Smike#endif 58104584Smike 5996317Sobrientypedef int __builtin_va_alist_t __attribute__((__mode__(__word__))); 6096317Sobrien 6196317Sobrien#define va_alist __builtin_va_alist 6296317Sobrien#define va_dcl __builtin_va_alist_t __builtin_va_alist; ... 6396317Sobrien#define va_start(ap) __builtin_varargs_start(ap) 6496317Sobrien#define va_arg(ap, type) __builtin_va_arg((ap), type) 6596317Sobrien#define va_end(ap) __builtin_va_end(ap) 6696317Sobrien 67143063Sjoerg#else /* !__GNUCLIKE_BUILTIN_VARARGS */ 6896317Sobrien 691543Srgrimestypedef char *va_list; 701543Srgrimes 7126771Sbde#define __va_size(type) \ 7226771Sbde (((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int)) 7326771Sbde 74143434Speter#if defined(__GNUCLIKE_BUILTIN_VAALIST) 7523184Sbde#define va_alist __builtin_va_alist 7623184Sbde#endif 7722415Sphk#define va_dcl int va_alist; ... 781543Srgrimes 791543Srgrimes#define va_start(ap) \ 8026771Sbde ((ap) = (va_list)&va_alist) 811543Srgrimes 821543Srgrimes#define va_arg(ap, type) \ 8326771Sbde (*(type *)((ap) += __va_size(type), (ap) - __va_size(type))) 841543Srgrimes 851543Srgrimes#define va_end(ap) 861543Srgrimes 87143063Sjoerg#endif /* __GNUCLIKE_BUILTIN_VARARGS */ 8896317Sobrien 89119628Skan#endif /* !_MACHINE_VARARGS_H_ */ 90