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) \
54 __builtin_saveregs();\
55 (AP = ((__gnuc_va_list) __builtin_next_arg (LASTARG))); \
60 #else /* _VARARGS_H */
62 #define va_alist __builtin_va_alist
63 #define va_dcl int __builtin_va_alist;...
67 #define va_start(AP) \
70 AP.__va_next_fp = (__va_freg *) __builtin_saveregs (); \
71 AP.__va_next_fp_limit = (AP.__va_next_fp + \
72 (__builtin_args_info (1) < 8 ? 8 - __builtin_args_info (1) : 0)); \
73 AP.__va_next_o = (__va_greg *) AP.__va_next_fp_limit; \
74 AP.__va_next_o_limit = (AP.__va_next_o + \
75 (__builtin_args_info (0) < 4 ? 4 - __builtin_args_info (0) : 0)); \
76 AP.__va_next_stack = (__va_greg *) __builtin_next_arg (__builtin_va_alist) \
77 - (__builtin_args_info (0) >= 4 || __builtin_args_info (1) >= 8 ? 1 : 0); \
82 #define va_start(AP) AP=(char *) &__builtin_va_alist
89 void va_end (__gnuc_va_list); /* Defined in libgcc.a */
91 /* Values returned by __builtin_classify_type. */
93 enum __va_type_classes {
98 __enumeral_type_class,
100 __pointer_type_class,
101 __reference_type_class,
104 __complex_type_class,
105 __function_type_class,
117 #define va_end(pvar) ((void)0)
119 #ifdef __LITTLE_ENDIAN__
120 #define __LITTLE_ENDIAN_P 1
122 #define __LITTLE_ENDIAN_P 0
125 #define __SCALAR_TYPE(TYPE) \
126 ((TYPE) == __integer_type_class \
127 || (TYPE) == __char_type_class \
128 || (TYPE) == __enumeral_type_class)
130 /* RECORD_TYPE args passed using the C calling convention are
131 passed by invisible reference. ??? RECORD_TYPE args passed
132 in the stack are made to be word-aligned; for an aggregate that is
133 not word-aligned, we advance the pointer to the first non-reg slot. */
135 /* When this is a smaller-than-int integer, using
136 auto-increment in the promoted (SImode) is fastest;
137 however, there is no way to express that is C. Therefore,
139 We want the MEM_IN_STRUCT_P bit set in the emitted RTL, therefore we
140 use unions even when it would otherwise be unnecessary. */
142 #define __va_arg_sh1(AP, TYPE) __extension__ \
144 ({(sizeof (TYPE) == 1 \
145 ? ({union {TYPE t; char c;} __t; \
148 : "0" ((((union { int i, j; } *) (AP))++)->i)); \
150 : sizeof (TYPE) == 2 \
151 ? ({union {TYPE t; short s;} __t; \
154 : "0" ((((union { int i, j; } *) (AP))++)->i)); \
156 : sizeof (TYPE) >= 4 || __LITTLE_ENDIAN_P \
157 ? (((union { TYPE t; int i;} *) (AP))++)->t \
158 : ((union {TYPE t;TYPE u;}*) ((char *)++(int *)(AP) - sizeof (TYPE)))->t);})
162 #define __PASS_AS_FLOAT(TYPE_CLASS,SIZE) \
163 (TYPE_CLASS == __real_type_class && SIZE == 4)
165 #define va_arg(pvar,TYPE) \
167 ({int __type = __builtin_classify_type (* (TYPE *) 0); \
169 if (__PASS_AS_FLOAT (__type, sizeof(TYPE))) \
171 if (pvar.__va_next_fp < pvar.__va_next_fp_limit) \
173 __result_p = &pvar.__va_next_fp; \
176 __result_p = &pvar.__va_next_stack; \
180 if (pvar.__va_next_o + ((sizeof (TYPE) + 3) / 4) \
181 <= pvar.__va_next_o_limit) \
182 __result_p = &pvar.__va_next_o; \
185 if (sizeof (TYPE) > 4) \
186 pvar.__va_next_o = pvar.__va_next_o_limit; \
188 __result_p = &pvar.__va_next_stack; \
191 __va_arg_sh1(*(void **)__result_p, TYPE);})
195 #define va_arg(AP, TYPE) __va_arg_sh1((AP), TYPE)
199 /* Copy __gnuc_va_list into another variable of this type. */
200 #define __va_copy(dest, src) (dest) = (src)
202 #endif /* defined (_STDARG_H) || defined (_VARARGS_H) */