diff options
| author | seyko <seyko2@gmail.com> | 2015-03-04 16:25:51 +0300 |
|---|---|---|
| committer | seyko <seyko2@gmail.com> | 2015-03-04 16:25:51 +0300 |
| commit | 664c19ad5ef16f3463087a33ecfe5d5ac24f81ec (patch) | |
| tree | b80af984089291b8f4dd67b9643af8f7e74e14a5 /lib | |
| parent | bfb7b0d9590d82dfb4f3b142d7d30960567fec43 (diff) | |
| download | tinycc-664c19ad5ef16f3463087a33ecfe5d5ac24f81ec.tar.gz tinycc-664c19ad5ef16f3463087a33ecfe5d5ac24f81ec.tar.bz2 | |
partial revert of the commit 4ad186c5ef61
A test program:
/* result of the new version inroduced in 4ad186c5ef61: t2a = 44100312 */
#include<stdio.h>
int main() {
int t1 = 176401255;
float f = 0.25f;
int t2a = (int)(t1 * f); // must be 44100313
int t2b = (int)(t1 * (float)0.25f);
printf("t2a=%d t2b=%d \n",t2a,t2b);
return 0;
}
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/libtcc1.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/libtcc1.c b/lib/libtcc1.c index d8a5e71..4a923a2 100644 --- a/lib/libtcc1.c +++ b/lib/libtcc1.c @@ -480,6 +480,20 @@ long long __ashldi3(long long a, int b) #endif } +#ifndef COMMIT_4ad186c5ef61_IS_FIXED +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 + #endif /* !__x86_64__ */ /* XXX: fix tcc's code generator to do this instead */ |
