!27 backport上游补丁修复riscv上测试错误

From: @laokz 
Reviewed-by: @overweight 
Signed-off-by: @overweight
This commit is contained in:
openeuler-ci-bot 2023-01-19 01:20:16 +00:00 committed by Gitee
commit 70eee8d9ca
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 79 additions and 1 deletions

View File

@ -0,0 +1,71 @@
commit a3799ae3f5dd6648040d499224cc6dea61b355dd
Author: Arnold D. Robbins <arnold@skeeve.com>
Date: Mon Sep 19 18:51:28 2022 +0300
Fix negative NaN issue on RiscV.
diff --git a/ChangeLog b/ChangeLog
index 35941d0a..d751baf1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,0 +1,6 @@
+2022-09-19 Arnold D. Robbins <arnold@skeeve.com>
+
+ * eval.c (fix_nan_sign): New function. See bug list citation
+ in the code.
+ * interpret.h (r_interpret): Use it for plus and minus cases.
+
diff --git a/eval.c b/eval.c
index 1069570b..3bfff0ca 100644
--- a/eval.c
+++ b/eval.c
@@ -39,6 +39,8 @@ static int num_exec_hook = 0;
static Func_pre_exec pre_execute[MAX_EXEC_HOOKS];
static Func_post_exec post_execute = NULL;
+static double fix_nan_sign(double left, double right, double result);
+
extern void frame_popped();
int OFSlen;
@@ -1901,3 +1903,20 @@ elem_new_to_scalar(NODE *n)
return n;
}
+
+/* fix_nan_sign --- fix NaN sign on RiscV */
+
+// See the thread starting at
+// https://lists.gnu.org/archive/html/bug-gawk/2022-09/msg00005.html
+// for why we need this function.
+
+static double
+fix_nan_sign(double left, double right, double result)
+{
+ if (isnan(left) && signbit(left))
+ return copysign(result, -1.0);
+ else if (isnan(right) && signbit(right))
+ return copysign(result, -1.0);
+ else
+ return result;
+}
diff --git a/interpret.h b/interpret.h
index 26010ada..955d918f 100644
--- a/interpret.h
+++ b/interpret.h
@@ -583,6 +583,7 @@ uninitialized_scalar:
plus:
t1 = TOP_NUMBER();
r = make_number(t1->numbr + x2);
+ r->numbr = fix_nan_sign(t1->numbr, x2, r->numbr);
DEREF(t1);
REPLACE(r);
break;
@@ -597,6 +598,7 @@ plus:
minus:
t1 = TOP_NUMBER();
r = make_number(t1->numbr - x2);
+ r->numbr = fix_nan_sign(t1->numbr, x2, r->numbr);
DEREF(t1);
REPLACE(r);
break;

View File

@ -4,7 +4,7 @@
egrep -i "gawk_api_minor.*[0-9]+" | egrep -o "[0-9]")
Name: gawk
Version: 5.2.0
Release: 2
Release: 3
License: GPLv3+ and GPLv2+ and LGPLv2+ and BSD
Summary: The GNU version of the AWK text processing utility
URL: https://www.gnu.org/software/gawk/
@ -21,6 +21,7 @@ Patch7: backport-Additional-fix-for-Node_elem_new.patch
Patch8: backport-Yet-another-fix-and-test-for-Node_elem_new.patch
Patch9: backport-Fix-a-memory-leak.patch
Patch10: backport-Code-simplification-in-interpret.h.patch
Patch11: backport-Fix-negative-NaN-issue-on-RiscV.patch
BuildRequires: gcc automake grep
BuildRequires: bison texinfo texinfo-tex ghostscript texlive-ec texlive-cm-super glibc-all-langpacks
@ -116,6 +117,12 @@ install -m 0644 -p doc/gawkinet.{pdf,ps} ${RPM_BUILD_ROOT}%{_docdir}/%{name}
%{_datadir}/locale/*
%changelog
* Thu Jan 19 2023 laokz <zhangkai@iscas.ac.cn> - 5.2.0-3
- Type:bugfix
- ID:NA
- SUG:NA
- DESC: backport 5.2.1 patch to fix -NaN test on riscv
* Thu Jan 12 2023 Jiayi Chen <chenjiayi22@huawei.com> - 5.2.0-2
- Type:bugfix
- ID:NA