From c025478d7c03eb8d32022f1aec4537bd0a75a743 Mon Sep 17 00:00:00 2001 From: mingodad Date: Fri, 28 Mar 2014 20:28:19 +0000 Subject: New implementation of va_list/va_start/var_copy that do not use dynamic memory, with this when compiling fossil-scm with tcc on linux X86_64 it works fine. --- include/stdarg.h | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/stdarg.h b/include/stdarg.h index 3c1318e..b6a30f7 100644 --- a/include/stdarg.h +++ b/include/stdarg.h @@ -4,18 +4,28 @@ #ifdef __x86_64__ #ifndef _WIN64 -typedef void *va_list; - -va_list __va_start(void *fp); -void *__va_arg(va_list ap, int arg_type, int size, int align); -va_list __va_copy(va_list src); -void __va_end(va_list ap); - -#define va_start(ap, last) ((ap) = __va_start(__builtin_frame_address(0))) +//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; + +typedef __va_list_struct va_list; + +void __va_start(__va_list_struct *ap, void *fp); +void *__va_arg(__va_list_struct *ap, int arg_type, int size, int align); + +#define va_start(ap, last) __va_start(&ap, __builtin_frame_address(0)) #define va_arg(ap, type) \ - (*(type *)(__va_arg(ap, __builtin_va_arg_types(type), sizeof(type), __alignof__(type)))) -#define va_copy(dest, src) ((dest) = __va_copy(src)) -#define va_end(ap) __va_end(ap) + (*(type *)(__va_arg(&ap, __builtin_va_arg_types(type), sizeof(type), __alignof__(type)))) +#define va_copy(dest, src) ((dest) = (src)) +#define va_end(ap) #else /* _WIN64 */ typedef char *va_list; -- cgit v1.3.1