1129198Scognet/*-
2129198Scognet * Copyright (c) 2002 David E. O'Brien.  All rights reserved.
3129198Scognet * Copyright (c) 1991, 1993
4129198Scognet *	The Regents of the University of California.  All rights reserved.
5129198Scognet *
6129198Scognet * Redistribution and use in source and binary forms, with or without
7129198Scognet * modification, are permitted provided that the following conditions
8129198Scognet * are met:
9129198Scognet * 1. Redistributions of source code must retain the above copyright
10129198Scognet *    notice, this list of conditions and the following disclaimer.
11129198Scognet * 2. Redistributions in binary form must reproduce the above copyright
12129198Scognet *    notice, this list of conditions and the following disclaimer in the
13129198Scognet *    documentation and/or other materials provided with the distribution.
14129198Scognet * 4. Neither the name of the University nor the names of its contributors
15129198Scognet *    may be used to endorse or promote products derived from this software
16129198Scognet *    without specific prior written permission.
17129198Scognet *
18129198Scognet * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19129198Scognet * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20129198Scognet * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21129198Scognet * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22129198Scognet * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23129198Scognet * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24129198Scognet * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25129198Scognet * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26129198Scognet * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27129198Scognet * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28129198Scognet * SUCH DAMAGE.
29129198Scognet *
30129198Scognet *	@(#)stdarg.h	8.1 (Berkeley) 6/10/93
31129198Scognet * $FreeBSD$
32129198Scognet */
33129198Scognet
34129198Scognet#ifndef _MACHINE_STDARG_H_
35129198Scognet#define	_MACHINE_STDARG_H_
36129198Scognet
37129198Scognet#include <sys/cdefs.h>
38129198Scognet#include <sys/_types.h>
39129198Scognet
40129198Scognet#ifndef _VA_LIST_DECLARED
41129198Scognet#define	_VA_LIST_DECLARED
42129198Scognettypedef	__va_list	va_list;
43129198Scognet#endif
44129198Scognet
45143063Sjoerg#ifdef __GNUCLIKE_BUILTIN_STDARG
46129198Scognet
47129198Scognet#define	va_start(ap, last) \
48162487Skan	__builtin_va_start((ap), (last))
49129198Scognet
50129198Scognet#define	va_arg(ap, type) \
51129198Scognet	__builtin_va_arg((ap), type)
52129198Scognet
53129198Scognet#if __ISO_C_VISIBLE >= 1999
54129198Scognet#define	va_copy(dest, src) \
55129198Scognet	__builtin_va_copy((dest), (src))
56129198Scognet#endif
57129198Scognet
58129198Scognet#define	va_end(ap) \
59129198Scognet	__builtin_va_end(ap)
60129198Scognet
61143063Sjoerg#else	/* !__GNUCLIKE_BUILTIN_STDARG */
62129198Scognet
63129198Scognet#define	__va_size(type) \
64129198Scognet	(((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
65129198Scognet
66143063Sjoerg#ifdef __GNUCLIKE_BUILTIN_NEXT_ARG
67129198Scognet#define va_start(ap, last) \
68129198Scognet	((ap) = (va_list)__builtin_next_arg(last))
69143063Sjoerg#else	/* !__GNUCLIKE_BUILTIN_NEXT_ARG */
70129198Scognet#define	va_start(ap, last) \
71129198Scognet	((ap) = (va_list)&(last) + __va_size(last))
72143063Sjoerg#endif	/* __GNUCLIKE_BUILTIN_NEXT_ARG */
73129198Scognet
74129198Scognet#define	va_arg(ap, type) \
75129198Scognet	(*(type *)((ap) += __va_size(type), (ap) - __va_size(type)))
76129198Scognet
77129198Scognet#define	va_end(ap)
78129198Scognet
79143063Sjoerg#endif /* __GNUCLIKE_BUILTIN_STDARG */
80129198Scognet
81129198Scognet#endif /* !_MACHINE_STDARG_H_ */
82