Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
7540 | leency | 1 | #ifndef _STDARG_H |
2 | #define _STDARG_H |
||
3 | |||
4 | #ifdef __x86_64__ |
||
5 | #ifndef _WIN64 |
||
6 | |||
7 | //This should be in sync with the declaration on our lib/libtcc1.c |
||
8 | /* GCC compatible definition of va_list. */ |
||
9 | typedef struct { |
||
10 | unsigned int gp_offset; |
||
11 | unsigned int fp_offset; |
||
12 | union { |
||
13 | unsigned int overflow_offset; |
||
14 | char *overflow_arg_area; |
||
15 | }; |
||
16 | char *reg_save_area; |
||
17 | } __va_list_struct; |
||
18 | |||
19 | typedef __va_list_struct va_list[1]; |
||
20 | |||
21 | void __va_start(__va_list_struct *ap, void *fp); |
||
22 | void *__va_arg(__va_list_struct *ap, int arg_type, int size, int align); |
||
23 | |||
24 | #define va_start(ap, last) __va_start(ap, __builtin_frame_address(0)) |
||
25 | #define va_arg(ap, type) \ |
||
26 | (*(type *)(__va_arg(ap, __builtin_va_arg_types(type), sizeof(type), __alignof__(type)))) |
||
27 | #define va_copy(dest, src) (*(dest) = *(src)) |
||
28 | #define va_end(ap) |
||
29 | |||
30 | #else /* _WIN64 */ |
||
31 | typedef char *va_list; |
||
32 | #define va_start(ap,last) __builtin_va_start(ap,last) |
||
33 | #define va_arg(ap,type) (ap += 8, sizeof(type)<=8 ? *(type*)ap : **(type**)ap) |
||
34 | #define va_copy(dest, src) ((dest) = (src)) |
||
35 | #define va_end(ap) |
||
36 | #endif |
||
37 | |||
38 | #elif __arm__ |
||
39 | typedef char *va_list; |
||
40 | #define _tcc_alignof(type) ((int)&((struct {char c;type x;} *)0)->x) |
||
41 | #define _tcc_align(addr,type) (((unsigned)addr + _tcc_alignof(type) - 1) \ |
||
42 | & ~(_tcc_alignof(type) - 1)) |
||
43 | #define va_start(ap,last) ap = ((char *)&(last)) + ((sizeof(last)+3)&~3) |
||
44 | #define va_arg(ap,type) (ap = (void *) ((_tcc_align(ap,type)+sizeof(type)+3) \ |
||
45 | &~3), *(type *)(ap - ((sizeof(type)+3)&~3))) |
||
46 | #define va_copy(dest, src) (dest) = (src) |
||
47 | #define va_end(ap) |
||
48 | |||
49 | #elif defined(__aarch64__) |
||
50 | typedef struct { |
||
51 | void *__stack; |
||
52 | void *__gr_top; |
||
53 | void *__vr_top; |
||
54 | int __gr_offs; |
||
55 | int __vr_offs; |
||
56 | } va_list; |
||
57 | #define va_start(ap, last) __va_start(ap, last) |
||
58 | #define va_arg(ap, type) __va_arg(ap, type) |
||
59 | #define va_end(ap) |
||
60 | #define va_copy(dest, src) ((dest) = (src)) |
||
61 | |||
62 | #else /* __i386__ */ |
||
63 | typedef char *va_list; |
||
64 | /* only correct for i386 */ |
||
65 | #define va_start(ap,last) ap = ((char *)&(last)) + ((sizeof(last)+3)&~3) |
||
66 | #define va_arg(ap,type) (ap += (sizeof(type)+3)&~3, *(type *)(ap - ((sizeof(type)+3)&~3))) |
||
67 | #define va_copy(dest, src) (dest) = (src) |
||
68 | #define va_end(ap) |
||
69 | #endif |
||
70 | |||
71 | /* fix a buggy dependency on GCC in libio.h */ |
||
72 | typedef va_list __gnuc_va_list; |
||
73 | #define _VA_LIST_DEFINED |
||
74 | |||
75 | #endif /* _STDARG_H */=8> |