Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

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