1/*-
2 * Copyright (c) 2002 David E. O'Brien.  All rights reserved.
3 * Copyright (c) 2000 Tsubai Masanari.  All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 *    derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27 *	$NetBSD: varargs.h,v 1.5 2000/02/27 17:50:22 tsubai Exp $
28 * $FreeBSD$
29 */
30
31#ifndef _MACHINE_VARARGS_H_
32#define	_MACHINE_VARARGS_H_
33
34#ifndef _SYS_CDEFS_H_
35#error this file needs sys/cdefs.h as a prerequisite
36#endif
37
38#if defined(__GNUCLIKE_BUILTIN_VARARGS)
39
40#include <sys/_types.h>
41
42#ifndef _VA_LIST_DECLARED
43#define	_VA_LIST_DECLARED
44typedef	__va_list	va_list;
45#endif
46
47typedef int __builtin_va_alist_t __attribute__((__mode__(__word__)));
48
49#define	va_alist		__builtin_va_alist
50#define	va_dcl			__builtin_va_alist_t __builtin_va_alist; ...
51#define	va_start(ap)		__builtin_varargs_start(ap)
52#define	va_arg(ap, type)	__builtin_va_arg((ap), type)
53#define	va_end(ap)		__builtin_va_end(ap)
54
55#else	/* !  __GNUCLIKE_BUILTIN_VARARGS */
56
57#include <machine/stdarg.h>
58
59#ifdef __GNUCLIKE_BUILTIN_VAALIST
60#define	va_alist	__builtin_va_alist
61#define	va_dcl		int __builtin_va_alist; ...
62#else
63#error this file needs to be ported to your compiler
64#endif
65
66#undef va_start
67
68#ifdef __lint__
69#define	va_start(ap)	((ap) = *(va_list *)0)
70#else
71#define	va_start(ap)							\
72	((ap).__stack = __va_stack_args,				\
73	 (ap).__base = __va_reg_args,					\
74	 (ap).__gpr = __va_first_gpr,					\
75	 (ap).__fpr = __va_first_fpr)
76#endif
77
78#endif /* __GNUCLIKE_BUILTIN_VARARGS */
79
80#endif /* _MACHINE_VARARGS_H_ */
81