From 4ad186c5ef61477030ca37372f9d6c6d03681015 Mon Sep 17 00:00:00 2001 From: grischka Date: Mon, 6 Jan 2014 19:07:08 +0100 Subject: i386: use __fixdfdi instead of __tcc_cvt_ftol Variants __fixsfdi/__fixxfdi are not needed for now because the value is converted to double always. Also: - remove __tcc_fpinit for unix as it seems redundant by the __setfpucw call in the startup code - avoid reference to s->runtime_main in cross compilers - configure: fix --with-libgcc help - tcctok.h: cleanup --- lib/libtcc1.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'lib') 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__ -- cgit v1.3.1