Deleted Added
full compact
stdarg.h (143063) stdarg.h (162487)
1/*-
2 * Copyright (c) 2002 David E. O'Brien. All rights reserved.
3 * Copyright (c) 1992, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * This software was developed by the Computer Systems Engineering group
7 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
8 * contributed to Berkeley.
9 *
10 * All advertising materials mentioning features or use of this software
11 * must display the following acknowledgement:
12 * This product includes software developed by the University of
13 * California, Lawrence Berkeley Laboratory.
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * @(#)stdarg.h 8.2 (Berkeley) 9/27/93
37 * $NetBSD: stdarg.h,v 1.11 2000/07/23 21:36:56 mycroft Exp $
1/*-
2 * Copyright (c) 2002 David E. O'Brien. All rights reserved.
3 * Copyright (c) 1992, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * This software was developed by the Computer Systems Engineering group
7 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
8 * contributed to Berkeley.
9 *
10 * All advertising materials mentioning features or use of this software
11 * must display the following acknowledgement:
12 * This product includes software developed by the University of
13 * California, Lawrence Berkeley Laboratory.
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * @(#)stdarg.h 8.2 (Berkeley) 9/27/93
37 * $NetBSD: stdarg.h,v 1.11 2000/07/23 21:36:56 mycroft Exp $
38 * $FreeBSD: head/sys/sparc64/include/stdarg.h 143063 2005-03-02 21:33:29Z joerg $
38 * $FreeBSD: head/sys/sparc64/include/stdarg.h 162487 2006-09-21 01:37:02Z kan $
39 */
40
41#ifndef _MACHINE_STDARG_H_
42#define _MACHINE_STDARG_H_
43
44#include <sys/cdefs.h>
45#include <sys/_types.h>
46
47#ifndef _VA_LIST_DECLARED
48#define _VA_LIST_DECLARED
49typedef __va_list va_list;
50#endif
51
52#ifdef __GNUCLIKE_BUILTIN_STDARG
53
54#define va_start(ap, last) \
39 */
40
41#ifndef _MACHINE_STDARG_H_
42#define _MACHINE_STDARG_H_
43
44#include <sys/cdefs.h>
45#include <sys/_types.h>
46
47#ifndef _VA_LIST_DECLARED
48#define _VA_LIST_DECLARED
49typedef __va_list va_list;
50#endif
51
52#ifdef __GNUCLIKE_BUILTIN_STDARG
53
54#define va_start(ap, last) \
55 __builtin_stdarg_start((ap), (last))
55 __builtin_va_start((ap), (last))
56
57#define va_arg(ap, type) \
58 __builtin_va_arg((ap), type)
59
60#if __ISO_C_VISIBLE >= 1999
61#define va_copy(dest, src) \
62 __builtin_va_copy((dest), (src))
63#endif
64
65#define va_end(ap) \
66 __builtin_va_end(ap)
67
68#else /* ! __GNUCLIKE_BUILTIN_STDARG */
69
70#if !defined(__GNUCLIKE_BUILTIN_NEXT_ARG) && !defined(lint)
71#error no support for your compiler
72#endif
73
74#define va_start(ap, last) \
75 (__builtin_next_arg(last), (ap) = (va_list)__builtin_saveregs())
76
77#define va_end(ap)
78
79#define __va_arg8(ap, type) \
80 (*(type *)(void *)((ap) += 8, (ap) - 8))
81#define __va_arg16(ap, type) \
82 (*(type *)(void *)((ap) = (va_list)(((unsigned long)(ap) + 31) & -16),\
83 (ap) - 16))
84#define __va_int(ap, type) \
85 (*(type *)(void *)((ap) += 8, (ap) - sizeof(type)))
86
87#define __REAL_TYPE_CLASS 8
88#define __RECORD_TYPE_CLASS 12
89#define va_arg(ap, type) \
90 (__builtin_classify_type(*(type *)0) == __REAL_TYPE_CLASS ? \
91 (__alignof__(type) == 16 ? __va_arg16(ap, type) : \
92 __va_arg8(ap, type)) : \
93 (__builtin_classify_type(*(type *)0) < __RECORD_TYPE_CLASS ? \
94 __va_int(ap, type) : \
95 (sizeof(type) <= 8 ? __va_arg8(ap, type) : \
96 (sizeof(type) <= 16 ? __va_arg16(ap, type) : \
97 *__va_arg8(ap, type *)))))
98
99#endif /* __GNUCLIKE_BUILTIN_STDARG */
100
101#endif /* !_MACHINE_STDARG_H_ */
56
57#define va_arg(ap, type) \
58 __builtin_va_arg((ap), type)
59
60#if __ISO_C_VISIBLE >= 1999
61#define va_copy(dest, src) \
62 __builtin_va_copy((dest), (src))
63#endif
64
65#define va_end(ap) \
66 __builtin_va_end(ap)
67
68#else /* ! __GNUCLIKE_BUILTIN_STDARG */
69
70#if !defined(__GNUCLIKE_BUILTIN_NEXT_ARG) && !defined(lint)
71#error no support for your compiler
72#endif
73
74#define va_start(ap, last) \
75 (__builtin_next_arg(last), (ap) = (va_list)__builtin_saveregs())
76
77#define va_end(ap)
78
79#define __va_arg8(ap, type) \
80 (*(type *)(void *)((ap) += 8, (ap) - 8))
81#define __va_arg16(ap, type) \
82 (*(type *)(void *)((ap) = (va_list)(((unsigned long)(ap) + 31) & -16),\
83 (ap) - 16))
84#define __va_int(ap, type) \
85 (*(type *)(void *)((ap) += 8, (ap) - sizeof(type)))
86
87#define __REAL_TYPE_CLASS 8
88#define __RECORD_TYPE_CLASS 12
89#define va_arg(ap, type) \
90 (__builtin_classify_type(*(type *)0) == __REAL_TYPE_CLASS ? \
91 (__alignof__(type) == 16 ? __va_arg16(ap, type) : \
92 __va_arg8(ap, type)) : \
93 (__builtin_classify_type(*(type *)0) < __RECORD_TYPE_CLASS ? \
94 __va_int(ap, type) : \
95 (sizeof(type) <= 8 ? __va_arg8(ap, type) : \
96 (sizeof(type) <= 16 ? __va_arg16(ap, type) : \
97 *__va_arg8(ap, type *)))))
98
99#endif /* __GNUCLIKE_BUILTIN_STDARG */
100
101#endif /* !_MACHINE_STDARG_H_ */