Commit graph

73 commits

Author SHA1 Message Date
Hervé Poussineau bbf7b5b72a [CRT/x64] Correctly implement fabs for GCC
Note that MSVC does not recognize 'fabs' as a valid label name.
See fee844b6ff and 2f7cf157d8
2021-02-01 19:57:12 +01:00
Hervé Poussineau c345f7f137 [ASM x64] Make UNIMPLEMENTED macro self-suffisant
This fixes link errors with MsgUnimplemented not defined on binaries not linking to CRT.
2021-01-28 20:31:16 +01:00
Jérôme Gardou af3527d4d2 [MSVCRTEX] Do not include _CI* math functions
They are exported by msvcrt
CORE-17423
2021-01-21 09:43:43 +01:00
Mark Jansen 69dffed3f7 [CMAKE] Fix MSVC configuring 2021-01-15 20:43:10 +01:00
Hervé Poussineau 0cce1348c6 [CRT/x64] Make _fpreset/_logb public, as they are exported using the .spec file 2021-01-07 21:12:11 +01:00
Hervé Poussineau a644e7f5fd [CRT/x64] Disable MSVCRT__setjmp function, which references non-existent function __wine_setjmpex
_setjmp is already defined in sdk/lib/crt/setjmp/amd64/setjmp.s
2021-01-07 21:12:11 +01:00
Hervé Poussineau 80b1b0b294 [CRT] Fix hack for GCC x64, when CRT is linking against RosBE libstdc++ 2021-01-05 19:24:23 +01:00
Jérôme Gardou c8d07514c8 [CMAKE] Fix GCC -fstack-protector usage 2021-01-05 13:38:57 +01:00
Jérôme Gardou 8a6d653044 [CRT] Fix _onexit
Avoid calling malloc in CR initialisation code.
Have executables call msvcrt implementation, while the DLLs keep their own function tables

CORE-17362
2020-12-30 19:03:52 +01:00
Jérôme Gardou 6c6d9bee68 [CRT] Do not call atexit at process initialization
There is no guarantee that the underlying APIs are initialized at this point

CORE-17362
2020-12-30 19:03:52 +01:00
Jérôme Gardou 26863538a4 [CRT] Format source a bit.
This is horrendous.
2020-12-30 19:03:52 +01:00
Jérôme Gardou b96e88894a [CMAKE] Turn import libs into regular C static libs
Embed msvcrtex into libmsvcrt

Idea taken from Thomas Faber
2020-12-28 12:13:30 +01:00
Jérôme Gardou 281389b7e7 [CRT] Use ASM aliases for CLang builds 2020-11-16 16:58:10 +01:00
Jérôme Gardou 15c9f63b65 [MSVCRTEX] Add some floating point functions for CLang build
Clang makes optimisations requiring functions not present in msvcrt
2020-11-16 16:58:10 +01:00
Timo Kreuzer 2c791cdde7 [CRT] Remove duplicated atexit/onexit code
This removes the broken wine version of atexit and onexit. It keeps only dllonexit, which is implemented properly. The previous __call_atexit is moved to where the mingw onexit/atexit code is and adjusts it to work with the existing code. A call to __call_atexit is added in __tmainCRTStartup after the main function was called.
2020-11-01 09:33:14 +01:00
Jérôme Gardou 23e04ae1ee [CMAKE] Use an INTERFACE library to perform the msvcrt <-> msvcrtex binding 2020-10-22 18:07:27 +02:00
Jérôme Gardou ab825334dd Apply suggestions from code review
Beautification and clarity

Co-authored-by: Victor Perevertkin <victor@perevertkin.ru>
Co-authored-by: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>
2020-10-20 21:44:54 +02:00
Jérôme Gardou 00ed72d7e8 [CMAKE] Get rid of add_compile_flags
Use add_compile_options and the like instead
2020-10-20 21:44:54 +02:00
Timo Kreuzer 64d7db506c [CRT] Return from fpreset() 2020-09-20 23:08:17 +02:00
Timo Kreuzer aff33c855d [CRT] Use chkstk_ms.s on x64 builds 2020-09-20 23:08:17 +02:00
Serge Gautherie a04831677e
[PROGMAN][CRT][USER32] Do not use LoadLibraryEx() NT6+ flags (#3152)
CORE-12004
2020-09-13 23:42:09 +02:00
Timo Kreuzer 3c1f6631e6 [MSVCRT] Add vista exports 2020-09-13 15:37:29 +02:00
Timo Kreuzer dfaba507dc [MSVCRT] Fix some architecture specific exports 2020-09-13 15:37:29 +02:00
Timo Kreuzer 2aca4b2795 [ASM] Fix boot with VS 16.7.3 / MSVC 19.27
See https://developercommunity.visualstudio.com/content/problem/1180800/ml-x86-assume-directive-causes-invalid-code-genera.html
2020-09-12 15:01:04 +02:00
Serge Gautherie 0b9cbc5179
[CRT] _onexit(): Fix 'memcpy()' size
Cherry-pick
70bff7377d
2020-06-27 14:38:21 +02:00
Serge Gautherie 4213c70e2e
[CRTDLL][CRT] Remove remnant declaration, silence cppcheck false positive.
* _atexit_cleanup is no longer used
* Fix cppcheck 'pointerSize' warning
2020-06-27 14:35:32 +02:00
Thomas Faber e4066536c2
[CPPRT][CRT] Avoid extern assembly declarations with no type. CORE-17088
Fixes build with ML 14.26.
2020-05-28 14:26:48 +02:00
Bișoc George d8eeb31b8a [SDK][STDLIB][STRING] Wine-sync wcsrtombs_l and _mbstowcs_l
This is a partial sync of the CRT library with wcsrtombs_l and _mbstowcs_l functions from WINE. The _wctomb_s_l implementation of WINE which is used by _wctomb_s, _wctomb_l and wctomb brings failed results of the wctomb unit testcase and at the same time it crashes the whole testcase after.

Therefore I will not address the wctomb function for the moment being.
2020-05-03 15:35:11 +02:00
Bișoc George 8266f62ff6
[CRT][STDLIB] Wine-sync _mbtowc_l function code
The current _mbtowc_l code directly passes the string count size argument to cbMultiByte argument parameter to MultiByteToWideChar(). As the size of lpMultiByteStr expressed in bytes by cbMultiByte is dependent of the actual given string, the size of lpWideCharStr expressed in characters by cchWideChar is always 1.

The resulting parameters to MultiByteToWideChar() will lead to a failure as lpWideCharStr cannot accommodate the converted string if the size pointed by lpMultiByteStr is larger than the buffer wide string to receive the converted output, a Win32 error code of ERROR_INSUFFICIENT_BUFFER in other words. The fact that _mbtowc_l never fails without WINE Gecko package installed is because the codepage pointed by lc_codepage is CP_ACP and the converted output is directly given to the destination wide string parameter thus never calling MultiByteToWideChar(). Installing WINE Gecko merely unhides this problem.

As _mbtowc_l is imported from WINE and that they have updated their code (which at the same time this fixes the aforementioned problem), the following commit syncs the updated code from WINE.

CORE-16885
2020-04-28 22:41:57 +02:00
Mohamed Mediouni fec11747bb [CRT] Implement __chkstk function for ARM (#1595)
Incoming r4 contains the number of dwords to allocate, converting to bytes then return.
This makes ReactOS applications compiled for ARM running on true ARM Windows.

Reference: 2b095beace
2020-04-26 19:58:53 +03:00
Mohamed Mediouni f2f97f9f4c [CRT] ARM & ARM64 Windows do not have initenv in their CRTs (#1597)
Native CRT on ARM & ARM64 Windows doesn't have these functions.
For compatibility, it's mandatory to not have it at all. Otherwise,
ARM executables built for ReactOS do not run on true ARM Windows.

Consider doing full sync with mingw-w64 CRT in future.
2020-04-26 19:56:34 +03:00
Victor Perevertkin 7e069ccdb2
[CMAKE] Replace custom functions to built-in ones
add_target_compile_definitions -> target_compile_definitions
add_target_compile_flags -> target_compile_options
add_target_include_directories -> target_include_directories
2020-04-16 15:59:38 +03:00
Mark Jansen 62c1bb6448
[CRT] Implement _CrtDbgReport and _CrtDbgReportW
Most functionality is working, except output to file
CORE-11835
2020-04-04 19:55:24 +02:00
Mark Jansen 315765ed8b
[MSVCRT] Add _snwscanf 2020-03-15 13:12:20 +01:00
Timo Kreuzer 9efafd640f [CRT] Import wine exception handling code
The code is mostly unchanged. This includes the following changes:
* Move all wine code to crt/wine to keep it separated from our own code
* Add a minimal winternl.h
* Remove the asm macros from wine/config.h
* Include wine/asm.h where required
* Fix the names of the exported functions (GCC uses thiscall now and no wrappers are used anymore)
2020-02-09 15:56:30 +01:00
Thomas Faber d528e63477
[CRT] Only write to the output buffer when necessary in _strlwr. CORE-16667
Like e884290d29, this is also a hack and is missing locale awareness.
2020-02-09 10:23:01 +01:00
Thomas Faber e884290d29
[CRT] Only write to the output buffer when necessary in _strupr. CORE-16667
Fixes crash in msvcrt_winetest:string.

This is a hack and is supposed to be specific to the C locale.
2020-02-08 13:04:12 +01:00
Hervé Poussineau 698e1a3782 [SDK] Use HEX macro, like elsewhere in the file 2020-01-22 20:57:04 +01:00
Victor Perevertkin fdd1d7d60c [MSVCRT] Export __acrt_iob_func to fix GCC build with latest RosBE 2.2 (#1835)
This adds an evil hack to persuade libstdc++, which tries to import __acrt_iob_func from a DLL.
This can only be solved cleanly by adding a GCC-compatible C++ standard library to our tree later.
2019-10-20 12:44:17 +02:00
Timo Kreuzer 99fe069ce6 [CRT][MSVCRT] Add __DestructExceptionObject from wine 2019-09-01 16:29:26 +02:00
Timo Kreuzer 95b3eebf71 [CRT] Use sprintf_s instead of sprintf
Fixes GCC 8 warning:
sdk/lib/crt/misc/i10output.c:83:25: error: '%d' directive writing between 1 and 11 bytes into a region of size 6 [-Werror=format-overflow=]
     sprintf(format, "%%.%dle", prec);
                         ^~
sdk/lib/crt/misc/i10output.c:83:21: note: directive argument in the range [-2147483648, 2147483646]
     sprintf(format, "%%.%dle", prec);
                     ^~~~~~~~~
sdk/lib/crt/misc/i10output.c:83:5: note: 'sprintf' output between 6 and 16 bytes into a destination of size 8
     sprintf(format, "%%.%dle", prec);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2019-07-20 13:56:18 +02:00
Mark Jansen 28a0aa9ae8
[CRT] Remove mingwm10.dll usage in tls support code
CORE-15491
2019-07-06 11:37:30 +02:00
Katayama Hirofumi MZ 6388b91a4d
[CRT][USER32] fix wsprintf additional argument (%*s) (#1470)
Reduce wsprintf function failures ("%*s"). CORE-13955
2019-04-05 16:33:18 +09:00
Hervé Poussineau c8719ee865 [CRT] Correctly share get_ioinfo()/release_ioinfo() functions between code units
This fixes the following compiler errors:

../sdk/lib/crt/stdio/stat64.c:7:13: error: inline function 'release_ioinfo' declared but never defined [-Werror]
 inline void release_ioinfo(ioinfo *info);
             ^~~~~~~~~~~~~~
../sdk/lib/crt/stdio/stat64.c:6:16: error: inline function 'get_ioinfo' declared but never defined [-Werror]
 inline ioinfo* get_ioinfo(int fd);
                ^~~~~~~~~~
../sdk/lib/crt/stdio/file.c:186:5: error: 'init_ioinfo_cs' is static but used in inline function 'get_ioinfo' which is not static [-Werror]
     init_ioinfo_cs(ret);
     ^~~~~~~~~~~~~~
../sdk/lib/crt/stdio/file.c:183:19: error: 'get_ioinfo_nolock' is static but used in inline function 'get_ioinfo' which is not static [-Werror]
     ioinfo *ret = get_ioinfo_nolock(fd);
2019-04-01 11:38:32 +02:00
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
Timo Kreuzer 2a5bf96891 [CRT] Implement thread/fiber safe support for MSVC and Clang-CL
This is the most trivial (but also most efficient) implementation possible. Should be good enough for now.
2019-02-12 19:31:33 +01:00
Timo Kreuzer dc77e7d379 [CRT] Use alias names for rot functions when compiling with Clang-CL
Clang-CL does not support #pragma function like CL. The alternative to this approach is to disable all intrinsics for this single source file, but that is not trivial to do, as it can only be done by removing a compiler switch, which we have no CMake support for. Therefore this solution is simpler and as good.
2019-02-12 19:31:33 +01:00
Timo Kreuzer cfd1647914
[REACTOS] Fix misc 64 bit issues (#783)
* [WIN32K] Fix handle calculation in DbgGdiHTIntegrityCheck
* [NOTEPAD] Fix MSVC warnings
* [PSDK] Simplify *PROC definitions in windef.h
* [VIDEOPRT] Don't try to use NtVdmControl on x64
* [FREELDR] Fix some macros
* [CRT] Make qsort 64 bit compatible
* [NTOS] Use #ifndef _WIN64 instead of #ifdef _M_IX86 around C_ASSERTs
* [FAST486] Fix 64 bit warnings and change DWORD to ULONG, so it can be used in kernel mode
* [APPHELP_APITEST] Fix 64 bit issue
2019-01-05 10:50:11 +01:00
Mark Jansen 2d47c3be29
[CRT] spawn: define a unicode environment when needed
CORE-9182
2018-10-13 20:30:07 +02:00
Eric Kohl bb7292b287 [CRT] Fix two obvious typos in _mbbtype().
Patch by Kudratov Olimjon.

CORE-8545
2018-10-07 22:56:14 +02:00