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