[Bug 1868] New: ftol function from msvcrt emulation incorporates GNU-C specific artefact
Wine Bugs
wine-bugs at winehq.com
Mon Dec 8 02:58:59 CST 2003
http://bugs.winehq.com/show_bug.cgi?id=1868
Summary: ftol function from msvcrt emulation incorporates GNU-C
specific artefact
Product: Wine
Version: 20030813
Platform: PC
OS/Version: FreeBSD
Status: UNCONFIRMED
Severity: minor
Priority: P2
Component: wine-kernel
AssignedTo: wine-bugs at winehq.com
ReportedBy: cbah at chez.com
There is an feature in way how GNU-C generated code handles double to int
conversion, i.e. the following code:
-----
#include <stdio.h>
int main() {double t[]= {
2777777777.0,
1777777777.0,
};int i;
for(i=0;i<sizeof(t)/sizeof(*t);i++) {
printf("%lf -> %#x\n", t[i], (long)t[i]);
}
return 1;
}
---
When compiled with GCC prints out
2777777777.000000 -> 0x80000000
1777777777.000000 -> 0x69f6bc71
And when compiled with MSVC++ (use /MD and save as ftol.exe for the next test),
prints out something better.
2777777777.000000 -> 0xa5918671
1777777777.000000 -> 0x69f6bc71
Unsuprisingly if ftol.exe launched under wine, it prints out 0x80000000 as
result of first conversion. Using original msvcrt.dll with wine solves the
problem. However problem could be solved in msvcr emulation layer by applying
the following ha^H^Hpatch:
--- ./work/wine-20030813/dlls/ntdll/misc.c.orig Sun Dec 7 21:57:45 2003
+++ ./work/wine-20030813/dlls/ntdll/misc.c Mon Dec 8 00:14:04 2003
@@ -59,8 +59,10 @@
/* don't just do DO_FPU("fistp",retval), because the rounding
* mode must also be set to "round towards zero"... */
double fl;
+ long long r;
POP_FPU(fl);
- return (LONG)fl;
+ r = (long long)fl;
+ return (long)r;
}
#endif /* defined(__GNUC__) && defined(__i386__) */
--
Configure bugmail: http://bugs.winehq.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
More information about the wine-bugs
mailing list