varargs.h revision 26771
11543Srgrimes/*-
21543Srgrimes * Copyright (c) 1990, 1993
31543Srgrimes *	The Regents of the University of California.  All rights reserved.
41543Srgrimes * (c) UNIX System Laboratories, Inc.
51543Srgrimes * All or some portions of this file are derived from material licensed
61543Srgrimes * to the University of California by American Telephone and Telegraph
71543Srgrimes * Co. or Unix System Laboratories, Inc. and are reproduced herein with
81543Srgrimes * the permission of UNIX System Laboratories, Inc.
91543Srgrimes *
101543Srgrimes * Redistribution and use in source and binary forms, with or without
111543Srgrimes * modification, are permitted provided that the following conditions
121543Srgrimes * are met:
131543Srgrimes * 1. Redistributions of source code must retain the above copyright
141543Srgrimes *    notice, this list of conditions and the following disclaimer.
151543Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
161543Srgrimes *    notice, this list of conditions and the following disclaimer in the
171543Srgrimes *    documentation and/or other materials provided with the distribution.
181543Srgrimes * 3. All advertising materials mentioning features or use of this software
191543Srgrimes *    must display the following acknowledgement:
201543Srgrimes *	This product includes software developed by the University of
211543Srgrimes *	California, Berkeley and its contributors.
221543Srgrimes * 4. Neither the name of the University nor the names of its contributors
231543Srgrimes *    may be used to endorse or promote products derived from this software
241543Srgrimes *    without specific prior written permission.
251543Srgrimes *
261543Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
271543Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
281543Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
291543Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
301543Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
311543Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
321543Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
331543Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
341543Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
351543Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
361543Srgrimes * SUCH DAMAGE.
371543Srgrimes *
381543Srgrimes *	@(#)varargs.h	8.2 (Berkeley) 3/22/94
3926771Sbde * $Id: varargs.h,v 1.6 1997/02/28 07:12:34 bde Exp $
401543Srgrimes */
411543Srgrimes
421543Srgrimes#ifndef _VARARGS_H_
431543Srgrimes#define	_VARARGS_H_
441543Srgrimes
451543Srgrimestypedef char *va_list;
461543Srgrimes
4726771Sbde#define	__va_size(type) \
4826771Sbde	(((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
4926771Sbde
5022415Sphk#ifdef __GNUC__
5123184Sbde#define	va_alist	__builtin_va_alist
5223184Sbde#endif
5323184Sbde#if __GNUC__ > 1
5422415Sphk#define	va_dcl	int va_alist; ...
5523184Sbde#else
5622415Sphk#define	va_dcl	int va_alist;
5722415Sphk#endif
581543Srgrimes
591543Srgrimes#define	va_start(ap) \
6026771Sbde	((ap) = (va_list)&va_alist)
611543Srgrimes
621543Srgrimes#define	va_arg(ap, type) \
6326771Sbde	(*(type *)((ap) += __va_size(type), (ap) - __va_size(type)))
641543Srgrimes
651543Srgrimes#define	va_end(ap)
661543Srgrimes
671543Srgrimes#endif /* !_VARARGS_H_ */
68