https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f71940efb17014a4cb7e5…
commit f71940efb17014a4cb7e5c112cf7e7ae5a5f7011
Author: Timo Kreuzer <timo.kreuzer(a)reactos.org>
AuthorDate: Mon Aug 8 10:33:02 2022 +0300
Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org>
CommitDate: Thu Dec 1 20:17:40 2022 +0200
[CRT_APITEST] Restore direction flag to avoid false RTC break
With set direction flag the variables will not be initialized properly.
---
modules/rostests/apitests/crt/strlen.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/modules/rostests/apitests/crt/strlen.c b/modules/rostests/apitests/crt/strlen.c
index 182dcf68ccf..7f0c9d7e6fe 100644
--- a/modules/rostests/apitests/crt/strlen.c
+++ b/modules/rostests/apitests/crt/strlen.c
@@ -48,8 +48,8 @@ Test_strlen(PFN_STRLEN pstrlen)
eflags = __readeflags();
__writeeflags(eflags | EFLAGS_DF);
len = pstrlen(teststr + 4);
- eflags = __readeflags();
- ok((eflags & EFLAGS_DF) != 0, "Direction flag in ELFAGS was changed.");
+ ok((__readeflags() & EFLAGS_DF) != 0, "Direction flag in ELFAGS was changed.");
+ __writeeflags(eflags);
/* Only test this for the exported versions, intrinsics might do it
differently. It's up to us to not do fishy stuff! Also crtdll does
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1ad4106b84adb448bd95e…
commit 1ad4106b84adb448bd95eeb651d8c3dad486e5c4
Author: Timo Kreuzer <timo.kreuzer(a)reactos.org>
AuthorDate: Sat Jun 18 10:19:18 2022 +0200
Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org>
CommitDate: Thu Dec 1 15:21:59 2022 +0200
[CRT] Add basic version of handle_error
---
sdk/lib/crt/math/libm_sse2/_handle_error.c | 72 ++++++++++++++++++++++++++++++
1 file changed, 72 insertions(+)
diff --git a/sdk/lib/crt/math/libm_sse2/_handle_error.c b/sdk/lib/crt/math/libm_sse2/_handle_error.c
new file mode 100644
index 00000000000..4d679a292ea
--- /dev/null
+++ b/sdk/lib/crt/math/libm_sse2/_handle_error.c
@@ -0,0 +1,72 @@
+/*
+ * PROJECT: ReactOS CRT library
+ * LICENSE: MIT (https://spdx.org/licenses/MIT)
+ * PURPOSE: Implementation of _handle_error / _handle_errorf for libm
+ * COPYRIGHT: Copyright 2022 Timo Kreuzer <timo.kreuzer(a)reactos.org>
+ */
+
+#include <math.h>
+
+int
+__cdecl
+_invoke_matherr(
+ int type,
+ char* name,
+ double arg1,
+ double arg2,
+ double retval);
+
+/*!
+ * @brief Handles an error condition.
+ * @param fname - The name of the function that caused the error.
+ * @param opcode - Opcode of the function that cause the error (see OP_* consants in fpieee.h).
+ * @param value - The value to be returned, encoded as uint64_t.
+ * @param type - The type of error (see _DOMAIN, ... in math.h)
+ * @param flags - Exception flags (see AMD_F_* constants).
+ * @param error - Specifies the CRT error code (EDOM, ...).
+ * @param arg1 - First parameter to the function that cause the error.
+ * @param arg2 - Second parameter to the function that cause the error.
+ * @param nargs - Number of parameters to the function that cause the error.
+ * @return The value to be returned.
+ */
+double
+__cdecl
+_handle_error(
+ char *fname,
+ int opcode,
+ unsigned long long value,
+ int type,
+ int flags,
+ int error,
+ double arg1,
+ double arg2,
+ int nargs)
+{
+ float retval = *(double*)&value;
+
+ _invoke_matherr(type, fname, arg1, arg2, retval);
+
+ return retval;
+}
+
+
+
+float
+__cdecl
+_handle_errorf(
+ char *fname,
+ int opcode,
+ unsigned long long value,
+ int type,
+ int flags,
+ int error,
+ float arg1,
+ float arg2,
+ int nargs)
+{
+ float retval = *(float*)&value;
+
+ _invoke_matherr(type, fname, arg1, arg2, retval);
+
+ return retval;
+}