reactos/sdk/lib/crt
Colin Finck bd0a28d1e4 Fix the MSVC version of ldexp filling up the FPU stack and bailing out with #IND after a few calls. Additionally, add it back to libcntpr.
MSVC was previously given a "result" variable to copy the fscale result from st(0). This led to another "fld" FPU stack push at the very end without popping the source value from the FPU stack.
Moreover, this copy isn't even needed: A simple "fstp st(1)" at the end pops an element from the FPU stack while effectively storing the result in st(0), the register used for returning a double value.
This problem didn't affect GCC, as it is only given the "fscale" instruction and does all necessary stack operations itself.

However, looking into the CRT sources, I found many other i386 implementations with inline assembly suffering from the same problem.
Fortunately, they have been replaced by pure assembly implementations a while ago, so it's time to finally remove them.
ldexp would have also been a candidate for a pure assembly implementation, but the required check for NaN and setting errno (verified on Win2003) already outweighs the benefits.
And we cannot just do a NaN check with FUCOMI as this is an i686/pentiumpro instruction while we're still targeting i586/pentium.

I'm also using this opportunity to clean up the ldexp.c header and only put in the remaining contributors as returned by "git blame".

Thanks to NightWolve1975 for reporting the problem! (https://twitter.com/nightwolve1975/status/1099042477531643912)
2019-03-03 16:11:27 +01:00
..
conio Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
direct Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
except [ASM] Fixed ".double" macro in asm.inc. 2018-07-15 23:25:23 +02:00
float Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
include [CRT] Update file descriptor handling to match Wine (3/7). CORE-14504 2018-03-26 13:00:15 +02:00
locale Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
math Fix the MSVC version of ldexp filling up the FPU stack and bailing out with #IND after a few calls. Additionally, add it back to libcntpr. 2019-03-03 16:11:27 +01:00
mbstring [CRT] Fix two obvious typos in _mbbtype(). 2018-10-07 22:56:14 +02:00
mem Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
misc [CRT] Always initialize _[w]pgmptr with a *FULL* path to the current application. 2018-06-05 23:55:46 +02:00
printf [CRT] Implement the missing CRT _sc(w)printf() functions. CORE-14497 2018-03-23 22:30:18 +01:00
process [CRT] spawn: define a unicode environment when needed 2018-10-13 20:30:07 +02:00
search Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
setjmp Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
signal Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
startup [CRT] Implement thread/fiber safe support for MSVC and Clang-CL 2019-02-12 19:31:33 +01:00
stdio [CRT] Fixed _tstat64 which wrongly set executable bits on files. CORE-10904 2018-03-26 13:41:27 +02:00
stdlib [CRT] Use alias names for rot functions when compiling with Clang-CL 2019-02-12 19:31:33 +01:00
string Add .gitattributes and .gitignore files and normalize line endings in the repository (#10) 2017-10-04 20:37:32 +02:00
sys_stat Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
time [CRT] Update file descriptor handling to match Wine (3/7). CORE-14504 2018-03-26 13:00:15 +02:00
wine Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
wstring Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
CMakeLists.txt Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
crt.cmake [CRT] Use alias names for rot functions when compiling with Clang-CL 2019-02-12 19:31:33 +01:00
libcntpr.cmake Fix the MSVC version of ldexp filling up the FPU stack and bailing out with #IND after a few calls. Additionally, add it back to libcntpr. 2019-03-03 16:11:27 +01:00
moldname-msvcrt.def Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
msvcrtex.cmake [CRT] Implement thread/fiber safe support for MSVC and Clang-CL 2019-02-12 19:31:33 +01:00
oldnames-msvcrt.S Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
oldnames.cmake Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
precomp.h Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
README.txt Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00

Big chunks of this CRT library are taken from Wine's msvcrt implementation,
you can find a list of synced files in README.WINE file.

Notes:
1. When syncing, omit MSVCRT_ prefix where possible, Wine has to keep this
because they are linking with *both* original crt, and ms crt implementation.
ReactOS has the only CRT, so no need to make distinct functions.
2. ReactOS compiles two versions of the CRT library, one for usermode
(called just "crt"), and one version for kernelmode usage (called "libcntpr").
In order to separate the code, you can use #ifdef _LIBCNT_ for libcntpr code.