varargs.h revision 143063
1272343Sngie/*-
2272343Sngie * Copyright (c) 2002 David E. O'Brien.  All rights reserved.
3272343Sngie * Copyright (c) 1992, 1993
4272343Sngie *	The Regents of the University of California.  All rights reserved.
5272343Sngie * (c) UNIX System Laboratories, Inc.
6272343Sngie * All or some portions of this file are derived from material licensed
7272343Sngie * to the University of California by American Telephone and Telegraph
8272343Sngie * Co. or Unix System Laboratories, Inc. and are reproduced herein with
9272343Sngie * the permission of UNIX System Laboratories, Inc.
10272343Sngie *
11272343Sngie * This software was developed by the Computer Systems Engineering group
12272343Sngie * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
13272343Sngie * contributed to Berkeley.
14272343Sngie *
15272343Sngie * All advertising materials mentioning features or use of this software
16272343Sngie * must display the following acknowledgement:
17272343Sngie *	This product includes software developed by the University of
18272343Sngie *	California, Lawrence Berkeley Laboratory.
19272343Sngie *
20272343Sngie * Redistribution and use in source and binary forms, with or without
21272343Sngie * modification, are permitted provided that the following conditions
22272343Sngie * are met:
23272343Sngie * 1. Redistributions of source code must retain the above copyright
24272343Sngie *    notice, this list of conditions and the following disclaimer.
25272343Sngie * 2. Redistributions in binary form must reproduce the above copyright
26272343Sngie *    notice, this list of conditions and the following disclaimer in the
27272343Sngie *    documentation and/or other materials provided with the distribution.
28272343Sngie * 3. All advertising materials mentioning features or use of this software
29272343Sngie *    must display the following acknowledgement:
30272343Sngie *	This product includes software developed by the University of
31272343Sngie *	California, Berkeley and its contributors.
32272343Sngie * 4. Neither the name of the University nor the names of its contributors
33272343Sngie *    may be used to endorse or promote products derived from this software
34272343Sngie *    without specific prior written permission.
35272343Sngie *
36272343Sngie * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
37272343Sngie * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38272343Sngie * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
39272343Sngie * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
40272343Sngie * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
41272343Sngie * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
42272343Sngie * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
43272343Sngie * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
44272343Sngie * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
45272343Sngie * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
46272343Sngie * SUCH DAMAGE.
47272343Sngie *
48272343Sngie *	@(#)varargs.h	8.3 (Berkeley) 3/22/94
49272343Sngie * $FreeBSD: head/sys/sparc64/include/varargs.h 143063 2005-03-02 21:33:29Z joerg $
50272343Sngie */
51272343Sngie
52272343Sngie#ifndef _MACHINE_VARARGS_H_
53272343Sngie#define	_MACHINE_VARARGS_H_
54272343Sngie
55272343Sngie#ifndef _SYS_CDEFS_H_
56272343Sngie#error this file needs sys/cdefs.h as a prerequisite
57272343Sngie#endif
58272343Sngie
59272343Sngie#ifdef __GNUCLIKE_BUILTIN_VARARGS
60272343Sngie
61272343Sngie#include <sys/_types.h>
62272343Sngie
63272343Sngie#ifndef _VA_LIST_DECLARED
64272343Sngie#define	_VA_LIST_DECLARED
65272343Sngietypedef	__va_list	va_list;
66272343Sngie#endif
67272343Sngie
68272343Sngietypedef int __builtin_va_alist_t __attribute__((__mode__(__word__)));
69272343Sngie
70272343Sngie#define	va_alist		__builtin_va_alist
71272343Sngie#define	va_dcl			__builtin_va_alist_t __builtin_va_alist; ...
72272343Sngie#define	va_start(ap)		__builtin_varargs_start(ap)
73272343Sngie#define	va_arg(ap, type)	__builtin_va_arg((ap), type)
74272343Sngie#define	va_end(ap)		__builtin_va_end(ap)
75272343Sngie
76272343Sngie#else	/* !__GNUCLIKE_BUILTIN_VARARGS */
77272343Sngie
78272343Sngie#include <machine/stdarg.h>
79272343Sngie
80272343Sngie#define	__va_ellipsis	...
81272343Sngie
82272343Sngie#define	va_alist	__builtin_va_alist
83272343Sngie#define	va_dcl		long __builtin_va_alist; __va_ellipsis
84
85#undef va_start
86#define	va_start(ap) \
87	((ap) = (va_list)__builtin_saveregs())
88
89#endif /* __GNUCLIKE_BUILTIN_VARARGS */
90
91#endif /* !_MACHINE_VARARGS_H_ */
92