199122Sobrien/*-
299122Sobrien * Copyright (c) 2002 David E. O'Brien.  All rights reserved.
399122Sobrien *
499122Sobrien * Redistribution and use in source and binary forms, with or without
599122Sobrien * modification, are permitted provided that the following conditions
699122Sobrien * are met:
799122Sobrien * 1. Redistributions of source code must retain the above copyright
899122Sobrien *    notice, this list of conditions and the following disclaimer.
999122Sobrien * 2. Redistributions in binary form must reproduce the above copyright
1099122Sobrien *    notice, this list of conditions and the following disclaimer in the
1199122Sobrien *    documentation and/or other materials provided with the distribution.
1299122Sobrien * 3. Neither the name of the University nor the names of its contributors
1399122Sobrien *    may be used to endorse or promote products derived from this software
1499122Sobrien *    without specific prior written permission.
1599122Sobrien *
1699122Sobrien * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1799122Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1899122Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1999122Sobrien * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2099122Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2199122Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2299122Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2399122Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2499122Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2599122Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2699122Sobrien * SUCH DAMAGE.
2799122Sobrien *
2899122Sobrien * $FreeBSD$
2999122Sobrien */
3099122Sobrien
3199122Sobrien#ifndef _MACHINE_STDARG_H_
3299122Sobrien#define	_MACHINE_STDARG_H_
3399122Sobrien
34104583Smike#include <sys/cdefs.h>
35102227Smike#include <sys/_types.h>
3699122Sobrien
37104583Smike#ifndef _VA_LIST_DECLARED
38104583Smike#define	_VA_LIST_DECLARED
39102227Smiketypedef	__va_list	va_list;
40104583Smike#endif
4199122Sobrien
42143434Speter#ifdef __GNUCLIKE_BUILTIN_STDARG
43143434Speter
4499122Sobrien#define	va_start(ap, last) \
45162487Skan	__builtin_va_start((ap), (last))
4699122Sobrien
4799122Sobrien#define	va_arg(ap, type) \
4899122Sobrien	__builtin_va_arg((ap), type)
4999122Sobrien
50121450Speter#define	__va_copy(dest, src) \
51121450Speter	__builtin_va_copy((dest), (src))
52121450Speter
53104583Smike#if __ISO_C_VISIBLE >= 1999
54103526Smike#define	va_copy(dest, src) \
55121450Speter	__va_copy(dest, src)
56104583Smike#endif
57103526Smike
5899122Sobrien#define	va_end(ap) \
5999122Sobrien	__builtin_va_end(ap)
6099122Sobrien
61114870Speter#elif defined(lint)
62114870Speter/* Provide a fake implementation for lint's benefit */
63114870Speter#define	__va_size(type) \
64114870Speter	(((sizeof(type) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))
65114870Speter#define	va_start(ap, last) \
66114870Speter	((ap) = (va_list)&(last) + __va_size(last))
67114870Speter#define	va_arg(ap, type) \
68114870Speter	(*(type *)((ap) += __va_size(type), (ap) - __va_size(type)))
69114870Speter#define	va_end(ap)
70114870Speter
71143063Sjoerg#else
72143063Sjoerg#error this file needs to be ported to your compiler
73114870Speter#endif
74114870Speter
7599122Sobrien#endif /* !_MACHINE_STDARG_H_ */
76