stdarg.h revision 114870
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: head/sys/amd64/include/stdarg.h 114870 2003-05-10 00:55:15Z peter $
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
42114870Speter#if defined(__GNUC__)
4399122Sobrien#define	va_start(ap, last) \
4499122Sobrien	__builtin_stdarg_start((ap), (last))
4599122Sobrien
4699122Sobrien#define	va_arg(ap, type) \
4799122Sobrien	__builtin_va_arg((ap), type)
4899122Sobrien
49104583Smike#if __ISO_C_VISIBLE >= 1999
50103526Smike#define	va_copy(dest, src) \
51103526Smike	__builtin_va_copy((dest), (src))
52104583Smike#endif
53103526Smike
5499122Sobrien#define	va_end(ap) \
5599122Sobrien	__builtin_va_end(ap)
5699122Sobrien
57114870Speter#elif defined(lint)
58114870Speter/* Provide a fake implementation for lint's benefit */
59114870Speter#define	__va_size(type) \
60114870Speter	(((sizeof(type) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))
61114870Speter#define	va_start(ap, last) \
62114870Speter	((ap) = (va_list)&(last) + __va_size(last))
63114870Speter#define	va_arg(ap, type) \
64114870Speter	(*(type *)((ap) += __va_size(type), (ap) - __va_size(type)))
65114870Speter#define	va_end(ap)
66114870Speter
67114870Speter#endif
68114870Speter
6999122Sobrien#endif /* !_MACHINE_STDARG_H_ */
70