aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--[-rwxr-xr-x]configure2
-rw-r--r--i386-gen.c28
-rw-r--r--lib/libtcc1.c39
-rw-r--r--tccelf.c4
-rw-r--r--tccpe.c2
-rw-r--r--tcctok.h89
6 files changed, 84 insertions, 80 deletions
diff --git a/configure b/configure
index cc8ca5a..8c44e5c 100755..100644
--- a/configure
+++ b/configure
@@ -273,7 +273,7 @@ Advanced options (experts only):
--strip-binaries strip symbol tables from resulting binaries
--disable-static make libtcc.so instead of libtcc.a
--disable-rpath disable use of -rpath with the above
- --with-libgcc use libgcc_s.so.1 instead of libtcc.a in dynamic link
+ --with-libgcc use libgcc_s.so.1 instead of libtcc1.a in dynamic link
--enable-mingw32 build windows version on linux with mingw32
--enable-cygwin build windows version on windows with cygwin
--enable-cross build cross compilers
diff --git a/i386-gen.c b/i386-gen.c
index 2eb6922..4c4a54b 100644
--- a/i386-gen.c
+++ b/i386-gen.c
@@ -581,14 +581,6 @@ ST_FUNC void gfunc_prolog(CType *func_type)
func_bound_offset = lbounds_section->data_offset;
}
#endif
-
-#ifndef CONFIG_USE_LIBGCC
-#ifndef TCC_TARGET_PE
- if (0 == strcmp(funcname, "main"))
- gen_static_call(TOK___tcc_fpinit);
-#endif
-#endif
-
}
/* generate function epilog */
@@ -988,16 +980,20 @@ ST_FUNC void gen_cvt_itof(int t)
}
/* convert fp to int 't' type */
-/* XXX: handle long long case */
ST_FUNC void gen_cvt_ftoi(int t)
{
- gv(RC_FLOAT);
- save_reg(TREG_EAX);
- save_reg(TREG_EDX);
- gen_static_call(TOK___tcc_cvt_ftol);
- vtop->r = TREG_EAX; /* mark reg as used */
- if (t == VT_LLONG)
- vtop->r2 = TREG_EDX;
+ int bt = vtop->type.t & VT_BTYPE;
+ if (bt == VT_FLOAT)
+ vpush_global_sym(&func_old_type, TOK___fixsfdi);
+ else if (bt == VT_LDOUBLE)
+ vpush_global_sym(&func_old_type, TOK___fixxfdi);
+ else
+ vpush_global_sym(&func_old_type, TOK___fixdfdi);
+ vswap();
+ gfunc_call(1);
+ vpushi(0);
+ vtop->r = REG_IRET;
+ vtop->r2 = REG_LRET;
}
/* convert from one floating point type to another */
diff --git a/lib/libtcc1.c b/lib/libtcc1.c
index 3103691..44208cd 100644
--- a/lib/libtcc1.c
+++ b/lib/libtcc1.c
@@ -478,24 +478,6 @@ long long __ashldi3(long long a, int b)
#endif
}
-#ifndef _WIN32
-void __tcc_fpinit(void)
-{
- unsigned c = 0x137F;
- __asm__ __volatile__ ("fldcw %0" : : "m" (c));
-}
-#endif
-long long __tcc_cvt_ftol(long double x)
-{
- unsigned c0, c1;
- long long ret;
- __asm__ __volatile__ ("fnstcw %0" : "=m" (c0));
- c1 = c0 | 0x0C00;
- __asm__ __volatile__ ("fldcw %0" : : "m" (c1));
- __asm__ __volatile__ ("fistpll %0" : "=m" (ret));
- __asm__ __volatile__ ("fldcw %0" : : "m" (c0));
- return ret;
-}
#endif /* !__x86_64__ */
/* XXX: fix tcc's code generator to do this instead */
@@ -616,6 +598,27 @@ unsigned long long __fixunsxfdi (long double a1)
return 0;
}
+long long __fixsfdi (float a1)
+{
+ long long ret; int s;
+ ret = __fixunssfdi((s = a1 >= 0) ? a1 : -a1);
+ return s ? ret : -ret;
+}
+
+long long __fixdfdi (double a1)
+{
+ long long ret; int s;
+ ret = __fixunsdfdi((s = a1 >= 0) ? a1 : -a1);
+ return s ? ret : -ret;
+}
+
+long long __fixxfdi (long double a1)
+{
+ long long ret; int s;
+ ret = __fixunsxfdi((s = a1 >= 0) ? a1 : -a1);
+ return s ? ret : -ret;
+}
+
#if defined(__x86_64__) && !defined(_WIN64)
#ifndef __TINYC__
diff --git a/tccelf.c b/tccelf.c
index caa8281..aa3daac 100644
--- a/tccelf.c
+++ b/tccelf.c
@@ -178,11 +178,11 @@ LIBTCCAPI void *tcc_get_symbol(TCCState *s, const char *name)
return (void*)(uintptr_t)get_elf_sym_addr(s, name, 0);
}
-#ifdef TCC_IS_NATIVE
+#if defined TCC_IS_NATIVE || defined TCC_TARGET_PE
/* return elf symbol value or error */
ST_FUNC void* tcc_get_symbol_err(TCCState *s, const char *name)
{
- return (void*)get_elf_sym_addr(s, name, 1);
+ return (void*)(uintptr_t)get_elf_sym_addr(s, name, 1);
}
#endif
diff --git a/tccpe.c b/tccpe.c
index bc1545e..62df865 100644
--- a/tccpe.c
+++ b/tccpe.c
@@ -1800,7 +1800,9 @@ static void pe_add_runtime(TCCState *s1, struct pe_info *pe)
if (TCC_OUTPUT_MEMORY == s1->output_type) {
pe_type = PE_RUN;
+#ifdef TCC_IS_NATIVE
s1->runtime_main = start_symbol;
+#endif
} else {
pe->start_addr = (DWORD)tcc_get_symbol_err(s1, start_symbol);
}
diff --git a/tcctok.h b/tcctok.h
index 9b47a60..73b0cf9 100644
--- a/tcctok.h
+++ b/tcctok.h
@@ -143,23 +143,34 @@
#endif
/* builtin functions or variables */
-#ifdef TCC_ARM_EABI
- DEF(TOK_memcpy, "__aeabi_memcpy")
- DEF(TOK_memcpy4, "__aeabi_memcpy4")
- DEF(TOK_memcpy8, "__aeabi_memcpy8")
- DEF(TOK_memset, "__aeabi_memset")
- DEF(TOK___aeabi_ldivmod, "__aeabi_ldivmod")
- DEF(TOK___aeabi_uldivmod, "__aeabi_uldivmod")
-#else
+#ifndef TCC_ARM_EABI
DEF(TOK_memcpy, "memcpy")
DEF(TOK_memset, "memset")
DEF(TOK___divdi3, "__divdi3")
DEF(TOK___moddi3, "__moddi3")
DEF(TOK___udivdi3, "__udivdi3")
DEF(TOK___umoddi3, "__umoddi3")
+ DEF(TOK___ashrdi3, "__ashrdi3")
+ DEF(TOK___lshrdi3, "__lshrdi3")
+ DEF(TOK___ashldi3, "__ashldi3")
+ DEF(TOK___floatundisf, "__floatundisf")
+ DEF(TOK___floatundidf, "__floatundidf")
+# ifndef TCC_ARM_VFP
+ DEF(TOK___floatundixf, "__floatundixf")
+ DEF(TOK___fixunsxfdi, "__fixunsxfdi")
+# endif
+ DEF(TOK___fixunssfdi, "__fixunssfdi")
+ DEF(TOK___fixunsdfdi, "__fixunsdfdi")
#endif
-#if defined(TCC_TARGET_ARM)
-#ifdef TCC_ARM_EABI
+
+#if defined TCC_TARGET_ARM
+# ifdef TCC_ARM_EABI
+ DEF(TOK_memcpy, "__aeabi_memcpy")
+ DEF(TOK_memcpy4, "__aeabi_memcpy4")
+ DEF(TOK_memcpy8, "__aeabi_memcpy8")
+ DEF(TOK_memset, "__aeabi_memset")
+ DEF(TOK___aeabi_ldivmod, "__aeabi_ldivmod")
+ DEF(TOK___aeabi_uldivmod, "__aeabi_uldivmod")
DEF(TOK___aeabi_idivmod, "__aeabi_idivmod")
DEF(TOK___aeabi_uidivmod, "__aeabi_uidivmod")
DEF(TOK___divsi3, "__aeabi_idiv")
@@ -168,24 +179,33 @@
DEF(TOK___floatdidf, "__aeabi_l2d")
DEF(TOK___fixsfdi, "__aeabi_f2lz")
DEF(TOK___fixdfdi, "__aeabi_d2lz")
-#else
+ DEF(TOK___ashrdi3, "__aeabi_lasr")
+ DEF(TOK___lshrdi3, "__aeabi_llsr")
+ DEF(TOK___ashldi3, "__aeabi_llsl")
+ DEF(TOK___floatundisf, "__aeabi_ul2f")
+ DEF(TOK___floatundidf, "__aeabi_ul2d")
+ DEF(TOK___fixunssfdi, "__aeabi_f2ulz")
+ DEF(TOK___fixunsdfdi, "__aeabi_d2ulz")
+# else
DEF(TOK___modsi3, "__modsi3")
DEF(TOK___umodsi3, "__umodsi3")
DEF(TOK___divsi3, "__divsi3")
DEF(TOK___udivsi3, "__udivsi3")
DEF(TOK___floatdisf, "__floatdisf")
DEF(TOK___floatdidf, "__floatdidf")
-#ifndef TCC_ARM_VFP
+# ifndef TCC_ARM_VFP
DEF(TOK___floatdixf, "__floatdixf")
DEF(TOK___fixunssfsi, "__fixunssfsi")
DEF(TOK___fixunsdfsi, "__fixunsdfsi")
DEF(TOK___fixunsxfsi, "__fixunsxfsi")
DEF(TOK___fixxfdi, "__fixxfdi")
-#endif
+# endif
DEF(TOK___fixsfdi, "__fixsfdi")
DEF(TOK___fixdfdi, "__fixdfdi")
+# endif
#endif
-#elif defined(TCC_TARGET_C67)
+
+#if defined TCC_TARGET_C67
DEF(TOK__divi, "_divi")
DEF(TOK__divu, "_divu")
DEF(TOK__divf, "_divf")
@@ -193,32 +213,18 @@
DEF(TOK__remi, "_remi")
DEF(TOK__remu, "_remu")
#endif
-#ifdef TCC_TARGET_I386
- DEF(TOK___tcc_fpinit, "__tcc_fpinit")
- DEF(TOK___tcc_cvt_ftol, "__tcc_cvt_ftol")
-#endif
-#ifdef TCC_ARM_EABI
- DEF(TOK___ashrdi3, "__aeabi_lasr")
- DEF(TOK___lshrdi3, "__aeabi_llsr")
- DEF(TOK___ashldi3, "__aeabi_llsl")
- DEF(TOK___floatundisf, "__aeabi_ul2f")
- DEF(TOK___floatundidf, "__aeabi_ul2d")
- DEF(TOK___fixunssfdi, "__aeabi_f2ulz")
- DEF(TOK___fixunsdfdi, "__aeabi_d2ulz")
-#else
- DEF(TOK___ashrdi3, "__ashrdi3")
- DEF(TOK___lshrdi3, "__lshrdi3")
- DEF(TOK___ashldi3, "__ashldi3")
- DEF(TOK___floatundisf, "__floatundisf")
- DEF(TOK___floatundidf, "__floatundidf")
-#ifndef TCC_ARM_VFP
- DEF(TOK___floatundixf, "__floatundixf")
- DEF(TOK___fixunsxfdi, "__fixunsxfdi")
+
+#if defined TCC_TARGET_I386
+ DEF(TOK___fixsfdi, "__fixsfdi")
+ DEF(TOK___fixdfdi, "__fixdfdi")
+ DEF(TOK___fixxfdi, "__fixxfdi")
#endif
- DEF(TOK___fixunssfdi, "__fixunssfdi")
- DEF(TOK___fixunsdfdi, "__fixunsdfdi")
+
+#if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64
+ DEF(TOK_alloca, "alloca")
#endif
-#ifdef TCC_TARGET_PE
+
+#if defined TCC_TARGET_PE
DEF(TOK___chkstk, "__chkstk")
#endif
@@ -233,20 +239,17 @@
DEF(TOK___bound_ptr_indir16, "__bound_ptr_indir16")
DEF(TOK___bound_local_new, "__bound_local_new")
DEF(TOK___bound_local_delete, "__bound_local_delete")
-#ifdef TCC_TARGET_PE
+# ifdef TCC_TARGET_PE
DEF(TOK_malloc, "malloc")
DEF(TOK_free, "free")
DEF(TOK_realloc, "realloc")
DEF(TOK_memalign, "memalign")
DEF(TOK_calloc, "calloc")
-#endif
+# endif
DEF(TOK_memmove, "memmove")
DEF(TOK_strlen, "strlen")
DEF(TOK_strcpy, "strcpy")
#endif
-#if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64
- DEF(TOK_alloca, "alloca")
-#endif
/* Tiny Assembler */
DEF_ASM(byte)