xref: /freebsd/sys/x86/include/stdarg.h (revision 5b2a5decd1e6b61fc8080209ded10a7781eac828)
1*5b2a5decSTijl Coosemans /*-
2*5b2a5decSTijl Coosemans  * Copyright (c) 2002 David E. O'Brien.  All rights reserved.
3*5b2a5decSTijl Coosemans  *
4*5b2a5decSTijl Coosemans  * Redistribution and use in source and binary forms, with or without
5*5b2a5decSTijl Coosemans  * modification, are permitted provided that the following conditions
6*5b2a5decSTijl Coosemans  * are met:
7*5b2a5decSTijl Coosemans  * 1. Redistributions of source code must retain the above copyright
8*5b2a5decSTijl Coosemans  *    notice, this list of conditions and the following disclaimer.
9*5b2a5decSTijl Coosemans  * 2. Redistributions in binary form must reproduce the above copyright
10*5b2a5decSTijl Coosemans  *    notice, this list of conditions and the following disclaimer in the
11*5b2a5decSTijl Coosemans  *    documentation and/or other materials provided with the distribution.
12*5b2a5decSTijl Coosemans  * 3. Neither the name of the University nor the names of its contributors
13*5b2a5decSTijl Coosemans  *    may be used to endorse or promote products derived from this software
14*5b2a5decSTijl Coosemans  *    without specific prior written permission.
15*5b2a5decSTijl Coosemans  *
16*5b2a5decSTijl Coosemans  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17*5b2a5decSTijl Coosemans  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18*5b2a5decSTijl Coosemans  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19*5b2a5decSTijl Coosemans  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20*5b2a5decSTijl Coosemans  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21*5b2a5decSTijl Coosemans  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22*5b2a5decSTijl Coosemans  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23*5b2a5decSTijl Coosemans  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24*5b2a5decSTijl Coosemans  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25*5b2a5decSTijl Coosemans  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26*5b2a5decSTijl Coosemans  * SUCH DAMAGE.
27*5b2a5decSTijl Coosemans  *
28*5b2a5decSTijl Coosemans  * $FreeBSD$
29*5b2a5decSTijl Coosemans  */
30*5b2a5decSTijl Coosemans 
31*5b2a5decSTijl Coosemans #ifndef _MACHINE_STDARG_H_
32*5b2a5decSTijl Coosemans #define	_MACHINE_STDARG_H_
33*5b2a5decSTijl Coosemans 
34*5b2a5decSTijl Coosemans #include <sys/cdefs.h>
35*5b2a5decSTijl Coosemans #include <sys/_types.h>
36*5b2a5decSTijl Coosemans 
37*5b2a5decSTijl Coosemans #ifndef _VA_LIST_DECLARED
38*5b2a5decSTijl Coosemans #define	_VA_LIST_DECLARED
39*5b2a5decSTijl Coosemans typedef	__va_list	va_list;
40*5b2a5decSTijl Coosemans #endif
41*5b2a5decSTijl Coosemans 
42*5b2a5decSTijl Coosemans #ifdef __GNUCLIKE_BUILTIN_STDARG
43*5b2a5decSTijl Coosemans 
44*5b2a5decSTijl Coosemans #define	va_start(ap, last) \
45*5b2a5decSTijl Coosemans 	__builtin_va_start((ap), (last))
46*5b2a5decSTijl Coosemans 
47*5b2a5decSTijl Coosemans #define	va_arg(ap, type) \
48*5b2a5decSTijl Coosemans 	__builtin_va_arg((ap), type)
49*5b2a5decSTijl Coosemans 
50*5b2a5decSTijl Coosemans #define	__va_copy(dest, src) \
51*5b2a5decSTijl Coosemans 	__builtin_va_copy((dest), (src))
52*5b2a5decSTijl Coosemans 
53*5b2a5decSTijl Coosemans #if __ISO_C_VISIBLE >= 1999
54*5b2a5decSTijl Coosemans #define	va_copy(dest, src) \
55*5b2a5decSTijl Coosemans 	__va_copy(dest, src)
56*5b2a5decSTijl Coosemans #endif
57*5b2a5decSTijl Coosemans 
58*5b2a5decSTijl Coosemans #define	va_end(ap) \
59*5b2a5decSTijl Coosemans 	__builtin_va_end(ap)
60*5b2a5decSTijl Coosemans 
61*5b2a5decSTijl Coosemans #elif defined(lint)
62*5b2a5decSTijl Coosemans /* Provide a fake implementation for lint's benefit */
63*5b2a5decSTijl Coosemans #define	__va_size(type) \
64*5b2a5decSTijl Coosemans 	(((sizeof(type) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))
65*5b2a5decSTijl Coosemans #define	va_start(ap, last) \
66*5b2a5decSTijl Coosemans 	((ap) = (va_list)&(last) + __va_size(last))
67*5b2a5decSTijl Coosemans #define	va_arg(ap, type) \
68*5b2a5decSTijl Coosemans 	(*(type *)((ap) += __va_size(type), (ap) - __va_size(type)))
69*5b2a5decSTijl Coosemans #define	va_end(ap)
70*5b2a5decSTijl Coosemans 
71*5b2a5decSTijl Coosemans #else
72*5b2a5decSTijl Coosemans #error this file needs to be ported to your compiler
73*5b2a5decSTijl Coosemans #endif
74*5b2a5decSTijl Coosemans 
75*5b2a5decSTijl Coosemans #endif /* !_MACHINE_STDARG_H_ */
76