reactos/sdk/lib/crt/except/matherr.c
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

50 lines
1 KiB
C

#include <precomp.h>
#define __USE_ISOC9X 1
#define __USE_ISOC99 1
#include <math.h>
#ifdef HAVE_IEEEFP_H
#include <ieeefp.h>
#endif
#ifndef HAVE_FINITE
#ifndef finite /* Could be a macro */
#ifdef isfinite
#define finite(x) isfinite(x)
#else
#define finite(x) (!isnan(x)) /* At least catch some cases */
#endif
#endif
#endif
#ifndef signbit
#define signbit(x) 0
#endif
typedef int (*MSVCRT_matherr_func)(struct _exception *);
static MSVCRT_matherr_func MSVCRT_default_matherr_func = NULL;
int CDECL _matherr(struct _exception *e)
{
if (e)
TRACE("(%p = %d, %s, %g %g %g)\n",e, e->type, e->name, e->arg1, e->arg2,
e->retval);
else
TRACE("(null)\n");
if (MSVCRT_default_matherr_func)
return MSVCRT_default_matherr_func(e);
ERR(":Unhandled math error!\n");
return 0;
}
/*********************************************************************
* __setusermatherr (MSVCRT.@)
*/
void CDECL __setusermatherr(MSVCRT_matherr_func func)
{
MSVCRT_default_matherr_func = func;
TRACE(":new matherr handler %p\n", func);
}