2001-11-11 05:54:21 +03:00
|
|
|
#ifndef _STDARG_H
|
|
|
|
#define _STDARG_H
|
|
|
|
|
2008-12-01 21:19:25 +03:00
|
|
|
#ifdef __x86_64__
|
2009-07-19 00:06:37 +04:00
|
|
|
#ifndef _WIN64
|
2008-12-01 21:19:25 +03:00
|
|
|
|
2014-03-29 00:28:19 +04:00
|
|
|
//This should be in sync with the declaration on our lib/libtcc1.c
|
|
|
|
/* GCC compatible definition of va_list. */
|
|
|
|
typedef struct {
|
|
|
|
unsigned int gp_offset;
|
|
|
|
unsigned int fp_offset;
|
|
|
|
union {
|
|
|
|
unsigned int overflow_offset;
|
|
|
|
char *overflow_arg_area;
|
|
|
|
};
|
|
|
|
char *reg_save_area;
|
|
|
|
} __va_list_struct;
|
2008-12-01 21:19:25 +03:00
|
|
|
|
2017-04-20 23:01:50 +03:00
|
|
|
/* Avoid conflicting definition for va_list on musl libc */
|
|
|
|
#ifndef __DEFINED_va_list
|
2014-03-30 03:08:05 +04:00
|
|
|
typedef __va_list_struct va_list[1];
|
2017-04-20 23:01:50 +03:00
|
|
|
#define __DEFINED_va_list
|
|
|
|
#endif
|
2008-12-01 21:19:25 +03:00
|
|
|
|
2014-03-29 00:28:19 +04:00
|
|
|
void __va_start(__va_list_struct *ap, void *fp);
|
|
|
|
void *__va_arg(__va_list_struct *ap, int arg_type, int size, int align);
|
|
|
|
|
2014-03-30 03:08:05 +04:00
|
|
|
#define va_start(ap, last) __va_start(ap, __builtin_frame_address(0))
|
2010-12-28 13:32:40 +03:00
|
|
|
#define va_arg(ap, type) \
|
2014-03-30 03:08:05 +04:00
|
|
|
(*(type *)(__va_arg(ap, __builtin_va_arg_types(type), sizeof(type), __alignof__(type))))
|
|
|
|
#define va_copy(dest, src) (*(dest) = *(src))
|
2014-03-29 00:28:19 +04:00
|
|
|
#define va_end(ap)
|
2008-12-01 21:19:25 +03:00
|
|
|
|
2016-08-04 20:14:52 +03:00
|
|
|
/* avoid conflicting definition for va_list on Macs. */
|
|
|
|
#define _VA_LIST_T
|
|
|
|
|
2009-07-19 00:06:37 +04:00
|
|
|
#else /* _WIN64 */
|
2001-11-11 05:54:21 +03:00
|
|
|
typedef char *va_list;
|
2013-04-24 05:19:15 +04:00
|
|
|
#define va_start(ap,last) __builtin_va_start(ap,last)
|
2016-07-10 21:44:49 +03:00
|
|
|
#define va_arg(ap, t) ((sizeof(t) > 8 || (sizeof(t) & (sizeof(t) - 1))) \
|
|
|
|
? **(t **)((ap += 8) - 8) : *(t *)((ap += 8) - 8))
|
2013-04-24 05:19:15 +04:00
|
|
|
#define va_copy(dest, src) ((dest) = (src))
|
2009-07-19 00:06:37 +04:00
|
|
|
#define va_end(ap)
|
|
|
|
#endif
|
2001-11-11 05:54:21 +03:00
|
|
|
|
2013-11-25 07:24:02 +04:00
|
|
|
#elif __arm__
|
|
|
|
typedef char *va_list;
|
|
|
|
#define _tcc_alignof(type) ((int)&((struct {char c;type x;} *)0)->x)
|
|
|
|
#define _tcc_align(addr,type) (((unsigned)addr + _tcc_alignof(type) - 1) \
|
|
|
|
& ~(_tcc_alignof(type) - 1))
|
|
|
|
#define va_start(ap,last) ap = ((char *)&(last)) + ((sizeof(last)+3)&~3)
|
|
|
|
#define va_arg(ap,type) (ap = (void *) ((_tcc_align(ap,type)+sizeof(type)+3) \
|
|
|
|
&~3), *(type *)(ap - ((sizeof(type)+3)&~3)))
|
|
|
|
#define va_copy(dest, src) (dest) = (src)
|
|
|
|
#define va_end(ap)
|
|
|
|
|
2015-02-13 21:58:31 +03:00
|
|
|
#elif defined(__aarch64__)
|
|
|
|
typedef struct {
|
|
|
|
void *__stack;
|
|
|
|
void *__gr_top;
|
|
|
|
void *__vr_top;
|
|
|
|
int __gr_offs;
|
|
|
|
int __vr_offs;
|
|
|
|
} va_list;
|
|
|
|
#define va_start(ap, last) __va_start(ap, last)
|
|
|
|
#define va_arg(ap, type) __va_arg(ap, type)
|
|
|
|
#define va_end(ap)
|
|
|
|
#define va_copy(dest, src) ((dest) = (src))
|
|
|
|
|
2009-07-19 00:06:37 +04:00
|
|
|
#else /* __i386__ */
|
|
|
|
typedef char *va_list;
|
2001-11-11 05:54:21 +03:00
|
|
|
/* only correct for i386 */
|
2002-08-31 16:43:53 +04:00
|
|
|
#define va_start(ap,last) ap = ((char *)&(last)) + ((sizeof(last)+3)&~3)
|
|
|
|
#define va_arg(ap,type) (ap += (sizeof(type)+3)&~3, *(type *)(ap - ((sizeof(type)+3)&~3)))
|
2006-10-28 23:45:50 +04:00
|
|
|
#define va_copy(dest, src) (dest) = (src)
|
2001-11-11 05:54:21 +03:00
|
|
|
#define va_end(ap)
|
2008-12-01 21:19:25 +03:00
|
|
|
#endif
|
|
|
|
|
2001-11-11 21:01:29 +03:00
|
|
|
/* fix a buggy dependency on GCC in libio.h */
|
|
|
|
typedef va_list __gnuc_va_list;
|
2003-01-06 23:22:23 +03:00
|
|
|
#define _VA_LIST_DEFINED
|
2001-11-11 21:01:29 +03:00
|
|
|
|
2008-12-01 21:19:25 +03:00
|
|
|
#endif /* _STDARG_H */
|