8 /* GCC compatible definition of va_list. */
9 struct __va_list_struct
{
10 unsigned int gp_offset
;
11 unsigned int fp_offset
;
13 unsigned int overflow_offset
;
14 char *overflow_arg_area
;
19 typedef struct __va_list_struct
*va_list;
21 /* we use __builtin_(malloc|free) to avoid #define malloc tcc_malloc */
22 /* XXX: this lacks the support of aggregated types. */
23 #define va_start(ap, last) \
24 (ap = (va_list)__builtin_malloc(sizeof(struct __va_list_struct)), \
25 *ap = *(struct __va_list_struct*)( \
26 (char*)__builtin_frame_address(0) - 16), \
27 ap->overflow_arg_area = ((char *)__builtin_frame_address(0) + \
28 ap->overflow_offset), \
29 ap->reg_save_area = (char *)__builtin_frame_address(0) - 176 - 16 \
31 #define va_arg(ap, type) \
32 (*(type*)(__builtin_types_compatible_p(type, long double) \
33 ? (ap->overflow_arg_area += 16, \
34 ap->overflow_arg_area - 16) \
35 : __builtin_types_compatible_p(type, double) \
36 ? (ap->fp_offset < 128 + 48 \
37 ? (ap->fp_offset += 16, \
38 ap->reg_save_area + ap->fp_offset - 16) \
39 : (ap->overflow_arg_area += 8, \
40 ap->overflow_arg_area - 8)) \
41 : (ap->gp_offset < 48 \
42 ? (ap->gp_offset += 8, \
43 ap->reg_save_area + ap->gp_offset - 8) \
44 : (ap->overflow_arg_area += 8, \
45 ap->overflow_arg_area - 8)) \
47 #define va_copy(dest, src) \
48 ((dest) = (va_list)malloc(sizeof(struct __va_list_struct)), \
50 #define va_end(ap) __builtin_free(ap)
53 typedef char *va_list;
54 #define va_start(ap,last) ap = ((char *)&(last)) + ((sizeof(last)+7)&~7)
55 #define va_arg(ap,type) (ap += (sizeof(type)+7)&~7, *(type *)(ap - ((sizeof(type)+7)&~7)))
56 #define va_copy(dest, src) (dest) = (src)
61 typedef char *va_list;
62 /* only correct for i386 */
63 #define va_start(ap,last) ap = ((char *)&(last)) + ((sizeof(last)+3)&~3)
64 #define va_arg(ap,type) (ap += (sizeof(type)+3)&~3, *(type *)(ap - ((sizeof(type)+3)&~3)))
65 #define va_copy(dest, src) (dest) = (src)
69 /* fix a buggy dependency on GCC in libio.h */
70 typedef va_list __gnuc_va_list
;
71 #define _VA_LIST_DEFINED
73 #endif /* _STDARG_H */