mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 20:03:07 +00:00
[CRT] Improve _matherr handling
This commit is contained in:
parent
4d50f81419
commit
3d497ca883
2 changed files with 15 additions and 6 deletions
45
sdk/lib/crt/math/_invoke_matherr.c
Normal file
45
sdk/lib/crt/math/_invoke_matherr.c
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* PROJECT: ReactOS CRT library
|
||||
* LICENSE: MIT (https://spdx.org/licenses/MIT)
|
||||
* PURPOSE: Implementation of _invoke_matherr and __setusermatherr
|
||||
* COPYRIGHT: Copyright 2021 Timo Kreuzer <timo.kreuzer@reactos.org>
|
||||
*/
|
||||
|
||||
#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_matherr(
|
||||
int type,
|
||||
char* name,
|
||||
double arg1,
|
||||
double arg2,
|
||||
double retval)
|
||||
{
|
||||
if (user_matherr != NULL)
|
||||
{
|
||||
struct _exception excpt;
|
||||
excpt.type = type;
|
||||
excpt.name = name;
|
||||
excpt.arg1 = arg1;
|
||||
excpt.arg2 = arg2;
|
||||
excpt.retval = retval;
|
||||
return user_matherr(&excpt);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue