mirror of
https://github.com/frida/tinycc
synced 2024-12-26 23:09:41 +03:00
4b3c6e74ab
tccgen.c: doubles need to be aligned, on ARM. The section_reserve() in init_putv does not do that. -D ONE_SOURCE: is now the default and not longer needed. Also, tcc.h now sets the default native target. These both make compiling tcc simple as "gcc tcc.c -o tcc -ldl" again. arm-asm.c: enable pseudo asm also for inline asm tests/tests2/Makefile: disable bitfield tests except on windows and x86_64 and don't generate-always tcc.c: fix a loop with -dt on errors configure: print compiler version (as recognized) tccpp.c: actually define symbols for tcc -dt clear static variables (needed for -dt or libtcc usage) 96_nodata_wanted.c: use __label__ instead of asm lib/files: use native symbols (__i386__ etc.) instead of TCC_TARGET_...
66 lines
1.7 KiB
C
66 lines
1.7 KiB
C
/* va_list.c - tinycc support for va_list on X86_64 */
|
|
|
|
#if defined __x86_64__
|
|
|
|
/* Avoid include files, they may not be available when cross compiling */
|
|
extern void *memset(void *s, int c, __SIZE_TYPE__ n);
|
|
extern void abort(void);
|
|
|
|
/* This should be in sync with our include/stdarg.h */
|
|
enum __va_arg_type {
|
|
__va_gen_reg, __va_float_reg, __va_stack
|
|
};
|
|
|
|
/* 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;
|
|
|
|
void __va_start(__va_list_struct *ap, void *fp)
|
|
{
|
|
memset(ap, 0, sizeof(__va_list_struct));
|
|
*ap = *(__va_list_struct *)((char *)fp - 16);
|
|
ap->overflow_arg_area = (char *)fp + ap->overflow_offset;
|
|
ap->reg_save_area = (char *)fp - 176 - 16;
|
|
}
|
|
|
|
void *__va_arg(__va_list_struct *ap,
|
|
enum __va_arg_type arg_type,
|
|
int size, int align)
|
|
{
|
|
size = (size + 7) & ~7;
|
|
align = (align + 7) & ~7;
|
|
switch (arg_type) {
|
|
case __va_gen_reg:
|
|
if (ap->gp_offset + size <= 48) {
|
|
ap->gp_offset += size;
|
|
return ap->reg_save_area + ap->gp_offset - size;
|
|
}
|
|
goto use_overflow_area;
|
|
|
|
case __va_float_reg:
|
|
if (ap->fp_offset < 128 + 48) {
|
|
ap->fp_offset += 16;
|
|
return ap->reg_save_area + ap->fp_offset - 16;
|
|
}
|
|
size = 8;
|
|
goto use_overflow_area;
|
|
|
|
case __va_stack:
|
|
use_overflow_area:
|
|
ap->overflow_arg_area += size;
|
|
ap->overflow_arg_area = (char*)((long long)(ap->overflow_arg_area + align - 1) & -align);
|
|
return ap->overflow_arg_area - size;
|
|
|
|
default: /* should never happen */
|
|
abort();
|
|
}
|
|
}
|
|
#endif
|