1199767fToomas Soome/*-
2199767fToomas Soome * Copyright (c) 2002 David E. O'Brien.  All rights reserved.
3199767fToomas Soome *
4199767fToomas Soome * Redistribution and use in source and binary forms, with or without
5199767fToomas Soome * modification, are permitted provided that the following conditions
6199767fToomas Soome * are met:
7199767fToomas Soome * 1. Redistributions of source code must retain the above copyright
8199767fToomas Soome *    notice, this list of conditions and the following disclaimer.
9199767fToomas Soome * 2. Redistributions in binary form must reproduce the above copyright
10199767fToomas Soome *    notice, this list of conditions and the following disclaimer in the
11199767fToomas Soome *    documentation and/or other materials provided with the distribution.
12199767fToomas Soome * 3. Neither the name of the University nor the names of its contributors
13199767fToomas Soome *    may be used to endorse or promote products derived from this software
14199767fToomas Soome *    without specific prior written permission.
15199767fToomas Soome *
16199767fToomas Soome * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17199767fToomas Soome * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18199767fToomas Soome * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19199767fToomas Soome * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20199767fToomas Soome * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21199767fToomas Soome * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22199767fToomas Soome * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23199767fToomas Soome * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24199767fToomas Soome * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25199767fToomas Soome * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26199767fToomas Soome * SUCH DAMAGE.
27199767fToomas Soome *
28199767fToomas Soome * $FreeBSD$
29199767fToomas Soome */
30199767fToomas Soome
31199767fToomas Soome#ifndef _MACHINE_STDARG_H_
32199767fToomas Soome#define	_MACHINE_STDARG_H_
33199767fToomas Soome
34199767fToomas Soome#include <sys/cdefs.h>
35199767fToomas Soome#include <sys/_types.h>
36199767fToomas Soome
37199767fToomas Soome#ifndef _VA_LIST_DECLARED
38199767fToomas Soome#define	_VA_LIST_DECLARED
39199767fToomas Soometypedef	__va_list	va_list;
40199767fToomas Soome#endif
41199767fToomas Soome
42199767fToomas Soome#ifdef __GNUCLIKE_BUILTIN_STDARG
43199767fToomas Soome
44199767fToomas Soome#define	va_start(ap, last) \
45199767fToomas Soome	__builtin_va_start((ap), (last))
46199767fToomas Soome
47199767fToomas Soome#define	va_arg(ap, type) \
48199767fToomas Soome	__builtin_va_arg((ap), type)
49199767fToomas Soome
50199767fToomas Soome#define	__va_copy(dest, src) \
51199767fToomas Soome	__builtin_va_copy((dest), (src))
52199767fToomas Soome
53199767fToomas Soome#if __ISO_C_VISIBLE >= 1999
54199767fToomas Soome#define	va_copy(dest, src) \
55199767fToomas Soome	__va_copy(dest, src)
56199767fToomas Soome#endif
57199767fToomas Soome
58199767fToomas Soome#define	va_end(ap) \
59199767fToomas Soome	__builtin_va_end(ap)
60199767fToomas Soome
61199767fToomas Soome#elif defined(lint)
62199767fToomas Soome/* Provide a fake implementation for lint's benefit */
63199767fToomas Soome#define	__va_size(type) \
64199767fToomas Soome	(((sizeof(type) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))
65199767fToomas Soome#define	va_start(ap, last) \
66199767fToomas Soome	((ap) = (va_list)&(last) + __va_size(last))
67199767fToomas Soome#define va_copy(dst, src) \
68199767fToomas Soome	((dst) = (src))
69199767fToomas Soome#define	va_arg(ap, type) \
70199767fToomas Soome	(*(type *)((ap) += __va_size(type), (ap) - __va_size(type)))
71199767fToomas Soome#define	va_end(ap)
72199767fToomas Soome
73199767fToomas Soome#else
74199767fToomas Soome#error this file needs to be ported to your compiler
75199767fToomas Soome#endif
76199767fToomas Soome
77199767fToomas Soome#endif /* !_MACHINE_STDARG_H_ */
78