1 /* This is just like the default gvarargs.h
2 except for differences described below. */
4 /* Define __gnuc_va_list. */
11 typedef long __va_greg
;
12 typedef double __va_freg
;
15 __va_greg
* __va_next_o
; /* next available register */
16 __va_greg
* __va_next_o_limit
; /* past last available register */
17 __va_freg
* __va_next_fp
; /* next available fp register */
18 __va_freg
* __va_next_fp_limit
; /* last available fp register */
19 __va_greg
* __va_next_stack
; /* next extended word on stack */
24 typedef void *__gnuc_va_list
;
28 #endif /* __GNUC_VA_LIST */
30 /* If this is for internal libc use, don't define anything but
32 #if defined (_STDARG_H) || defined (_VARARGS_H)
38 #define va_start(AP, LASTARG) \
41 AP.__va_next_fp = (__va_freg *) __builtin_saveregs (); \
42 AP.__va_next_fp_limit = (AP.__va_next_fp + \
43 (__builtin_args_info (1) < 8 ? 8 - __builtin_args_info (1) : 0)); \
44 AP.__va_next_o = (__va_greg *) AP.__va_next_fp_limit; \
45 AP.__va_next_o_limit = (AP.__va_next_o + \
46 (__builtin_args_info (0) < 4 ? 4 - __builtin_args_info (0) : 0)); \
47 AP.__va_next_stack = (__va_greg *) __builtin_next_arg (LASTARG); \
52 #define va_start(AP, LASTARG) \
53 (AP = ((__gnuc_va_list) __builtin_next_arg (LASTARG)))
57 #else /* _VARARGS_H */
59 #define va_alist __builtin_va_alist
60 #define va_dcl int __builtin_va_alist;...
64 #define va_start(AP) \
67 AP.__va_next_fp = (__va_freg *) __builtin_saveregs (); \
68 AP.__va_next_fp_limit = (AP.__va_next_fp + \
69 (__builtin_args_info (1) < 8 ? 8 - __builtin_args_info (1) : 0)); \
70 AP.__va_next_o = (__va_greg *) AP.__va_next_fp_limit; \
71 AP.__va_next_o_limit = (AP.__va_next_o + \
72 (__builtin_args_info (0) < 4 ? 4 - __builtin_args_info (0) : 0)); \
73 AP.__va_next_stack = (__va_greg *) __builtin_next_arg (__builtin_va_alist) \
74 - (__builtin_args_info (0) >= 4 || __builtin_args_info (1) >= 8 ? 1 : 0); \
79 #define va_start(AP) AP=(char *) &__builtin_va_alist
86 void va_end (__gnuc_va_list
); /* Defined in libgcc.a */
88 /* Values returned by __builtin_classify_type. */
90 enum __va_type_classes
{
95 __enumeral_type_class
,
98 __reference_type_class
,
101 __complex_type_class
,
102 __function_type_class
,
114 #define va_end(pvar) ((void)0)
116 #ifdef __LITTLE_ENDIAN__
117 #define __LITTLE_ENDIAN_P 1
119 #define __LITTLE_ENDIAN_P 0
122 #define __SCALAR_TYPE(TYPE) \
123 ((TYPE) == __integer_type_class \
124 || (TYPE) == __char_type_class \
125 || (TYPE) == __enumeral_type_class)
127 /* RECORD_TYPE args passed using the C calling convention are
128 passed by invisible reference. ??? RECORD_TYPE args passed
129 in the stack are made to be word-aligned; for an aggregate that is
130 not word-aligned, we advance the pointer to the first non-reg slot. */
132 /* When this is a smaller-than-int integer, using
133 auto-increment in the promoted (SImode) is fastest;
134 however, there is no way to express that is C. Therefore,
136 We want the MEM_IN_STRUCT_P bit set in the emitted RTL, therefore we
137 use unions even when it would otherwise be unnecessary. */
139 #define __va_arg_sh1(AP, TYPE) __extension__ \
141 ({(sizeof (TYPE) == 1 \
142 ? ({union {TYPE t; char c;} __t; \
145 : "0" ((((union { int i, j; } *) (AP))++)->i)); \
147 : sizeof (TYPE) == 2 \
148 ? ({union {TYPE t; short s;} __t; \
151 : "0" ((((union { int i, j; } *) (AP))++)->i)); \
153 : sizeof (TYPE) >= 4 || __LITTLE_ENDIAN_P \
154 ? (((union { TYPE t; int i;} *) (AP))++)->t \
155 : ((union {TYPE t;TYPE u;}*) ((char *)++(int *)(AP) - sizeof (TYPE)))->t);})
159 #define __PASS_AS_FLOAT(TYPE_CLASS,SIZE) \
160 (TYPE_CLASS == __real_type_class && SIZE == 4)
162 #define va_arg(pvar,TYPE) \
164 ({int __type = __builtin_classify_type (* (TYPE *) 0); \
166 if (__PASS_AS_FLOAT (__type, sizeof(TYPE))) \
168 if (pvar.__va_next_fp < pvar.__va_next_fp_limit) \
170 __result_p = &pvar.__va_next_fp; \
173 __result_p = &pvar.__va_next_stack; \
177 if (pvar.__va_next_o + ((sizeof (TYPE) + 3) / 4) \
178 <= pvar.__va_next_o_limit) \
179 __result_p = &pvar.__va_next_o; \
182 if (sizeof (TYPE) > 4) \
183 pvar.__va_next_o = pvar.__va_next_o_limit; \
185 __result_p = &pvar.__va_next_stack; \
188 __va_arg_sh1(*(void **)__result_p, TYPE);})
192 #define va_arg(AP, TYPE) __va_arg_sh1((AP), TYPE)
196 /* Copy __gnuc_va_list into another variable of this type. */
197 #define __va_copy(dest, src) (dest) = (src)
199 #endif /* defined (_STDARG_H) || defined (_VARARGS_H) */