aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/float.h2
-rw-r--r--include/stdarg.h37
-rw-r--r--include/stdbool.h1
-rw-r--r--include/stddef.h15
4 files changed, 46 insertions, 9 deletions
diff --git a/include/float.h b/include/float.h
index 5f1c6f7..f16f1f0 100644
--- a/include/float.h
+++ b/include/float.h
@@ -27,7 +27,7 @@
#define DBL_MAX_10_EXP 308
/* horrible intel long double */
-#ifdef __i386__
+#if defined __i386__ || defined __x86_64__
#define LDBL_MANT_DIG 64
#define LDBL_DIG 18
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 */
diff --git a/include/stdbool.h b/include/stdbool.h
index 6ed13a6..d2ee446 100644
--- a/include/stdbool.h
+++ b/include/stdbool.h
@@ -6,5 +6,6 @@
#define bool _Bool
#define true 1
#define false 0
+#define __bool_true_false_are_defined 1
#endif /* _STDBOOL_H */
diff --git a/include/stddef.h b/include/stddef.h
index fbc61fc..9e43de9 100644
--- a/include/stddef.h
+++ b/include/stddef.h
@@ -26,3 +26,18 @@ typedef unsigned long long int uint64_t;
void *alloca(size_t size);
#endif
+
+/* Older glibc require a wint_t from <stddef.h> (when requested
+ by __need_wint_t, as otherwise stddef.h isn't allowed to
+ define this type). Note that this must be outside the normal
+ _STDDEF_H guard, so that it works even when we've included the file
+ already (without requiring wint_t). Some other libs define _WINT_T
+ if they've already provided that type, so we can use that as guard.
+ TCC defines __WINT_TYPE__ for us. */
+#if defined (__need_wint_t)
+#ifndef _WINT_T
+#define _WINT_T
+typedef __WINT_TYPE__ wint_t;
+#endif
+#undef __need_wint_t
+#endif