https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3d497ca883370811e83f99d5e6f23782788cc635

commit 3d497ca883370811e83f99d5e6f23782788cc635
Author:     Timo Kreuzer <[email protected]>
AuthorDate: Tue Aug 23 23:36:33 2022 +0200
Commit:     Timo Kreuzer <[email protected]>
CommitDate: Thu Dec 1 15:21:59 2022 +0200

    [CRT] Improve _matherr handling
---
 sdk/lib/crt/math/{usermatherr.c => _invoke_matherr.c} | 19 ++++++++++++++-----
 sdk/lib/crt/math/math.cmake                           |  2 +-
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/sdk/lib/crt/math/usermatherr.c b/sdk/lib/crt/math/_invoke_matherr.c
similarity index 59%
rename from sdk/lib/crt/math/usermatherr.c
rename to sdk/lib/crt/math/_invoke_matherr.c
index 283a42cd5d0..e36b349bcdc 100644
--- a/sdk/lib/crt/math/usermatherr.c
+++ b/sdk/lib/crt/math/_invoke_matherr.c
@@ -1,12 +1,10 @@
 /*
  * PROJECT:     ReactOS CRT library
  * LICENSE:     MIT (https://spdx.org/licenses/MIT)
- * PURPOSE:     Implementation of __setusermatherr and _invoke_user_matherr
+ * PURPOSE:     Implementation of _invoke_matherr and __setusermatherr
  * COPYRIGHT:   Copyright 2021 Timo Kreuzer <[email protected]>
  */
 
-// DO NOT SYNC WITH WINE OR MINGW32
-
 #include <math.h>
 
 /* MS headers have this in corecrt_startup.h */
@@ -23,11 +21,22 @@ __setusermatherr(_UserMathErrorFunctionPointer func)
 
 int
 __cdecl
-_invoke_user_matherr(struct _exception *e)
+_invoke_matherr(
+    int type,
+    char* name,
+    double arg1,
+    double arg2,
+    double retval)
 {
     if (user_matherr != NULL)
     {
-        return user_matherr(e);
+        struct _exception excpt;
+        excpt.type = type;
+        excpt.name = name;
+        excpt.arg1 = arg1;
+        excpt.arg2 = arg2;
+        excpt.retval = retval;
+        return user_matherr(&excpt);
     }
     else
     {
diff --git a/sdk/lib/crt/math/math.cmake b/sdk/lib/crt/math/math.cmake
index e50d2bfa680..42fbc012bbe 100644
--- a/sdk/lib/crt/math/math.cmake
+++ b/sdk/lib/crt/math/math.cmake
@@ -1,9 +1,9 @@
 
 list(APPEND LIBCNTPR_MATH_SOURCE
+    math/_invoke_matherr.c
     math/abs.c
     math/div.c
     math/labs.c
-    math/usermatherr.c
 )
 
 if(ARCH STREQUAL "i386")

Reply via email to