_matherr may be overridden by an application and as such the default implementation should be in a separated object file.
Signed-off-by: Jacek Caban <ja...@codeweavers.com> --- mingw-w64-crt/Makefile.am | 1 + mingw-w64-crt/crt/merr.c | 26 -------------------------- mingw-w64-crt/crt/usermatherr.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 26 deletions(-) create mode 100644 mingw-w64-crt/crt/usermatherr.c
diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am index 57188d5c..d8a37898 100644 --- a/mingw-w64-crt/Makefile.am +++ b/mingw-w64-crt/Makefile.am @@ -119,6 +119,7 @@ src_libmingw32=include/oscalls.h include/internal.h include/sect_attribs.h \ crt/cinitexe.c crt/crt0_w.c crt/merr.c crt/pesect.c crt/udllargc.c crt/xthdloc.c crt/CRT_fp10.c \ crt/mingw_custom.c crt/mingw_helpers.c \ crt/pseudo-reloc.c crt/udll_argv.c \ + crt/usermatherr.c \ crt/xtxtmode.c crt/crt_handler.c \ crt/tlsthrd.c crt/tlsmthread.c crt/tlsmcrt.c crt/cxa_atexit.c diff --git a/mingw-w64-crt/crt/merr.c b/mingw-w64-crt/crt/merr.c index f3dff580..687aab4a 100644 --- a/mingw-w64-crt/crt/merr.c +++ b/mingw-w64-crt/crt/merr.c @@ -4,35 +4,9 @@ * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ -#include <internal.h> #include <math.h> #include <stdio.h> -typedef int (__cdecl *fUserMathErr)(struct _exception *); -static fUserMathErr stUserMathErr; - -void __mingw_raise_matherr (int typ, const char *name, double a1, double a2, - double rslt) -{ - struct _exception ex; - if (!stUserMathErr) - return; - ex.type = typ; - ex.name = (char*)name; - ex.arg1 = a1; - ex.arg2 = a2; - ex.retval = rslt; - (*stUserMathErr)(&ex); -} - -#undef __setusermatherr - -void __mingw_setusermatherr (int (__cdecl *f)(struct _exception *)) -{ - stUserMathErr = f; - __setusermatherr (f); -} - int __CRTDECL _matherr (struct _exception *pexcept) { diff --git a/mingw-w64-crt/crt/usermatherr.c b/mingw-w64-crt/crt/usermatherr.c new file mode 100644 index 00000000..fce059e1 --- /dev/null +++ b/mingw-w64-crt/crt/usermatherr.c @@ -0,0 +1,32 @@ +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file is part of the mingw-w64 runtime package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. + */ + +#include <math.h> + +typedef int (__cdecl *fUserMathErr)(struct _exception *); +static fUserMathErr stUserMathErr; + +void __mingw_raise_matherr (int typ, const char *name, double a1, double a2, + double rslt) +{ + struct _exception ex; + if (!stUserMathErr) + return; + ex.type = typ; + ex.name = (char*)name; + ex.arg1 = a1; + ex.arg2 = a2; + ex.retval = rslt; + (*stUserMathErr)(&ex); +} + +#undef __setusermatherr + +void __mingw_setusermatherr (int (__cdecl *f)(struct _exception *)) +{ + stUserMathErr = f; + __setusermatherr (f); +}
_______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public