aboutsummaryrefslogtreecommitdiff
path: root/include/stdarg.h
diff options
context:
space:
mode:
authorjiang <30155751@qq.com>2014-04-29 16:05:16 +0800
committerjiang <30155751@qq.com>2014-04-29 16:05:16 +0800
commit2a8905c93b4f67a21e3dbf297c3e93c598831528 (patch)
tree6f7491150cfe01700c9863946906203adad0de13 /include/stdarg.h
parent02e2fe3c260415f4cb1cbcaca9b2403a17f7ff2e (diff)
parente20c1eb99e1003c1e59522c136dbb15c52d7cc7c (diff)
downloadtinycc-2a8905c93b4f67a21e3dbf297c3e93c598831528.tar.gz
tinycc-2a8905c93b4f67a21e3dbf297c3e93c598831528.tar.bz2
So that the generated code, and more short
Diffstat (limited to 'include/stdarg.h')
-rw-r--r--include/stdarg.h37
1 files changed, 29 insertions, 8 deletions
diff --git a/include/stdarg.h b/include/stdarg.h
index efca0e5..5aa9d57 100644
--- a/include/stdarg.h
+++ b/include/stdarg.h
@@ -4,18 +4,28 @@
#ifdef __x86_64__
#ifndef _WIN64
-typedef void *va_list;
+//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;
-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);
+typedef __va_list_struct va_list[1];
-#define va_start(ap, last) ((ap) = __va_start(__builtin_frame_address(0)))
+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)
+#define va_copy(dest, src) (*(dest) = *(src))
+#define va_end(ap)
#else /* _WIN64 */
typedef char *va_list;
@@ -25,6 +35,17 @@ typedef char *va_list;
#define va_end(ap)
#endif
+#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)
+
#else /* __i386__ */
typedef char *va_list;
/* only correct for i386 */