Projects
Factory:RISC-V:Base
gawk
_service:tar_scm:backport-Fix-negative-NaN-issu...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm:backport-Fix-negative-NaN-issue-on-RiscV.patch of Package gawk
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;
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2