4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2000 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 /* This is just like the default gvarargs.h
27 except for differences described below. */
29 /* Define __gnuc_va_list. */
31 #ifndef __GNUC_VA_LIST
32 #define __GNUC_VA_LIST
34 #pragma ident "%Z%%M% %I% %E% SMI"
37 typedef long long __va_greg
;
38 typedef double __va_freg
;
40 __va_greg
* __va_next_o
; /* next available %o* register */
41 __va_greg
* __va_next_o_limit
; /* past last available %o* register */
42 __va_freg
* __va_next_fp
; /* next available %f* register */
43 __va_freg
* __va_next_fp_limit
; /* last available %f* register */
44 __va_greg
* __va_next_stack
; /* next extended word on stack */
48 /* This has to be a char * to be compatible with Sun.
49 i.e., we have to pass a `va_list' to vsprintf. */
50 typedef char * __gnuc_va_list
;
52 /* This has to be a void * to be compatible with Sun svr4.
53 i.e., we have to pass a `va_list' to vsprintf. */
54 typedef void * __gnuc_va_list
;
56 #endif /* not __sparc_v9__ */
57 #endif /* not __GNUC_VA_LIST */
59 /* If this is for internal libc use, don't define anything but
61 #if defined (_STDARG_H) || defined (_VARARGS_H)
65 * The Solaris kernel stdarg style va_start() even though it includes
75 #define va_start(AP, LASTARG) \
78 AP.__va_next_o = (__va_greg *) __builtin_saveregs (); \
79 AP.__va_next_o_limit = (AP.__va_next_o + \
80 (__builtin_args_info (0) < 6 ? 6 - __builtin_args_info (0) : 0)); \
81 AP.__va_next_fp = (__va_freg *) AP.__va_next_o_limit; \
82 AP.__va_next_fp_limit = (AP.__va_next_fp + \
83 (__builtin_args_info (1) < 16 ? (16 - __builtin_args_info (1) + 1) / 2 : 0)); \
84 AP.__va_next_stack = (__va_greg *) __builtin_next_arg (LASTARG); \
87 /* Call __builtin_next_arg even though we aren't using its value, so that
88 we can verify that LASTARG is correct. */
89 #ifdef __GCC_NEW_VARARGS__
90 #define va_start(AP, LASTARG) \
91 (__builtin_next_arg (LASTARG), AP = (char *) __builtin_saveregs ())
93 #define va_start(AP, LASTARG) \
94 (__builtin_saveregs (), AP = ((char *) __builtin_next_arg (LASTARG)))
96 #endif /* not __sparc_v9__ */
100 #define va_alist __builtin_va_alist
101 #define va_dcl int __builtin_va_alist;...
105 #define va_start(AP) \
108 AP.__va_next_o = (__va_greg *) __builtin_saveregs (); \
109 AP.__va_next_o_limit = (AP.__va_next_o + \
110 (__builtin_args_info (0) < 6 ? 6 - __builtin_args_info (0) : 0)); \
111 AP.__va_next_fp = (__va_freg *) AP.__va_next_o_limit; \
112 AP.__va_next_fp_limit = (AP.__va_next_fp + \
113 (__builtin_args_info (1) < 16 ? (16 - __builtin_args_info (1) + 1) / 2 : 0)); \
114 /* CYGNUS LOCAL dje/sparc64 */ \
115 AP.__va_next_stack = (__va_greg *) __builtin_next_arg (__builtin_va_alist) \
116 - (__builtin_args_info (0) >= 6 || __builtin_args_info (1) >= 16 ? 1 : 0); \
118 #else /* __sparcv9 */
119 #define va_start(AP) \
122 AP.__va_next_o = (__va_greg *) __builtin_saveregs (); \
123 AP.__va_next_o_limit = (AP.__va_next_o + \
124 (__builtin_args_info (0) < 6 ? 6 - __builtin_args_info (0) : 0)); \
125 AP.__va_next_fp = (__va_freg *) AP.__va_next_o_limit; \
126 AP.__va_next_fp_limit = (AP.__va_next_fp + \
127 (__builtin_args_info (1) < 16 ? (16 - __builtin_args_info (1) + 1) / 2 : 0)); \
128 /* CYGNUS LOCAL dje/sparc64 */ \
129 AP.__va_next_stack = (__va_greg *) __builtin_next_arg (__builtin_va_alist) \
130 - (__builtin_args_info (0) >= 6 || __builtin_args_info (1) >= 16 ? 1 : 0); \
132 #endif /* __sparcv9 */
134 #ifdef __GCC_NEW_VARARGS__
135 #define va_start(AP) ((AP) = (char *) __builtin_saveregs ())
137 #define va_start(AP) \
138 (__builtin_saveregs (), (AP) = ((char *) &__builtin_va_alist))
140 #endif /* not __sparc_v9__ */
145 void va_end (__gnuc_va_list
); /* Defined in libgcc.a */
147 /* Values returned by __builtin_classify_type. */
149 enum __va_type_classes
{
150 __no_type_class
= -1,
152 __integer_type_class
,
154 __enumeral_type_class
,
155 __boolean_type_class
,
156 __pointer_type_class
,
157 __reference_type_class
,
160 __complex_type_class
,
161 __function_type_class
,
173 #define va_end(pvar) ((void)0)
175 /* Avoid errors if compiling GCC v2 with GCC v1. */
177 #define __extension__
180 /* RECORD_TYPE args passed using the C calling convention are
181 passed by invisible reference. ??? RECORD_TYPE args passed
182 in the stack are made to be word-aligned; for an aggregate that is
183 not word-aligned, we advance the pointer to the first non-reg slot. */
187 #define va_arg(pvar,TYPE) \
189 (*({int __type = __builtin_classify_type (* (TYPE *) 0); \
191 if (__type == __real_type_class) /* float? */ \
194 /* see PASS_IN_REG_P in gcc's sparc.h */ \
195 if (pvar.__va_next_fp < pvar.__va_next_fp_limit \
196 && ((__r = (__va_freg *) (((__va_greg) pvar.__va_next_fp + sizeof (TYPE) - 1) & ~(__va_greg) (sizeof (TYPE) - 1))) \
197 < pvar.__va_next_fp_limit)) \
199 pvar.__va_next_fp = __r + (sizeof (TYPE) + 7) / 8; \
203 __r = (__va_freg *) pvar.__va_next_stack; \
204 pvar.__va_next_stack += (sizeof (TYPE) + 7) / 8; \
208 else if (__type < __record_type_class) /* integer? */ \
211 if (pvar.__va_next_o < pvar.__va_next_o_limit) \
212 __r = pvar.__va_next_o++; \
214 __r = pvar.__va_next_stack++; \
215 /* adjust for 4 byte ints */ \
216 __result = (char *) __r + 8 - sizeof (TYPE); \
218 else /* aggregate object */ \
221 if (pvar.__va_next_o < pvar.__va_next_o_limit) \
222 __r = (void **) pvar.__va_next_o++; \
224 __r = (void **) pvar.__va_next_stack++; \
227 (TYPE *) __result;}))
229 #else /* not __sparc_v9__ */
231 #define __va_rounded_size(TYPE) \
232 (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
234 /* We don't declare the union member `d' to have type TYPE
235 because that would lose in C++ if TYPE has a constructor. */
236 /* We cast to void * and then to TYPE * because this avoids
237 a warning about increasing the alignment requirement.
238 The casts to char * avoid warnings about invalid pointer arithmetic. */
239 #define va_arg(pvar,TYPE) \
241 (*({((__builtin_classify_type (*(TYPE*) 0) >= __record_type_class \
242 || (__builtin_classify_type (*(TYPE*) 0) == __real_type_class \
243 && sizeof (TYPE) == 16)) \
244 ? ((pvar) = (char *)(pvar) + __va_rounded_size (TYPE *), \
245 *(TYPE **) (void *) ((char *)(pvar) - __va_rounded_size (TYPE *))) \
246 : __va_rounded_size (TYPE) == 8 \
247 ? ({ union {char __d[sizeof (TYPE)]; int __i[2];} __u; \
248 __u.__i[0] = ((int *) (void *) (pvar))[0]; \
249 __u.__i[1] = ((int *) (void *) (pvar))[1]; \
250 (pvar) = (char *)(pvar) + 8; \
251 (TYPE *) (void *) __u.__d; }) \
252 : ((pvar) = (char *)(pvar) + __va_rounded_size (TYPE), \
253 ((TYPE *) (void *) ((char *)(pvar) - __va_rounded_size (TYPE)))));}))
254 #endif /* not __sparc_v9__ */
256 #endif /* defined (_STDARG_H) || defined (_VARARGS_H) */