[CRT] Fix _matherror and _setusermatherror

We previously used 2 different versions: one from wine and one from mingw-w64.
The former was used in msvcrt, the latter was statically compiled into the executable. When using MS libs, there is only one _matherr, which is statically linked into the executable and does nothing (it's not really a function for users to be called).
_setusermatherror should only exist in msvcrt and not statically, which wouldn't work at all.
This commit is contained in:
Timo Kreuzer 2021-07-24 18:13:06 +02:00
parent 486a4d93ed
commit da2a5673e7
8 changed files with 57 additions and 128 deletions

View file

@ -3,6 +3,7 @@ list(APPEND LIBCNTPR_MATH_SOURCE
math/abs.c
math/div.c
math/labs.c
math/usermatherr.c
)
if(ARCH STREQUAL "i386")

View file

@ -0,0 +1,36 @@
/*
* PROJECT: ReactOS CRT library
* LICENSE: MIT (https://spdx.org/licenses/MIT)
* PURPOSE: Implementation of __setusermatherr and _invoke_user_matherr
* COPYRIGHT: Copyright 2021 Timo Kreuzer <timo.kreuzer@reactos.org>
*/
// DO NOT SYNC WITH WINE OR MINGW32
#include <math.h>
/* MS headers have this in corecrt_startup.h */
typedef int (*_UserMathErrorFunctionPointer)(struct _exception *);
static _UserMathErrorFunctionPointer user_matherr = NULL;;
void
__cdecl
__setusermatherr(_UserMathErrorFunctionPointer func)
{
user_matherr = func;
}
int
__cdecl
_invoke_user_matherr(struct _exception *e)
{
if (user_matherr != NULL)
{
return user_matherr(e);
}
else
{
return 0;
}
}