lib/msun: Replaced pattern to force exception in _num families
Replaced the old pattern of using a ternary to force addition (raising exceptions for sNaN's) with a new one using a volatile variable. The _mag_num family was already implemented with this pattern PR: 294719 Reviewed by: fuz, kargl MFC after: 1 month
This commit is contained in:
committed by
Robert Clausecker
parent
f62d826a6f
commit
7c20e15592
@@ -53,12 +53,18 @@ fmaximum_num(double x, double y)
|
||||
nan_y = isnan(y);
|
||||
|
||||
if (nan_x || nan_y) {
|
||||
/* These ternary conditionals force (x+y), so that sNaN's raise exceptions */
|
||||
/* If both are NaN, adding returns qNaN */
|
||||
if (nan_x && nan_y)
|
||||
return (x + y);
|
||||
return (x + y);
|
||||
|
||||
/* force_except makes sure sNaN's raise exceptions */
|
||||
volatile double force_except = x + y;
|
||||
force_except;
|
||||
|
||||
if (nan_x)
|
||||
return ((x + y) != 0.0 ? y : y);
|
||||
return ((x + y) != 0.0 ? x : x);
|
||||
return (y);
|
||||
else
|
||||
return (x);
|
||||
}
|
||||
|
||||
/* Handle comparisons of signed zeroes. */
|
||||
|
||||
@@ -52,12 +52,18 @@ fmaximum_numf(float x, float y)
|
||||
nan_y = isnan(y);
|
||||
|
||||
if (nan_x || nan_y) {
|
||||
/* These ternary conditionals force (x+y), so that sNaN's raise exceptions */
|
||||
/* If both are NaN, adding returns qNaN */
|
||||
if (nan_x && nan_y)
|
||||
return (x + y);
|
||||
return (x + y);
|
||||
|
||||
/* force_except makes sure sNaN's raise exceptions */
|
||||
volatile float force_except = x + y;
|
||||
force_except;
|
||||
|
||||
if (nan_x)
|
||||
return ((x + y) != 0.0 ? y : y);
|
||||
return ((x + y) != 0.0 ? x : x);
|
||||
return (y);
|
||||
else
|
||||
return (x);
|
||||
}
|
||||
|
||||
/* Handle comparisons of signed zeroes. */
|
||||
|
||||
@@ -47,12 +47,18 @@ fmaximum_numl(long double x, long double y)
|
||||
nan_y = isnan(y);
|
||||
|
||||
if (nan_x || nan_y) {
|
||||
/* These ternary conditionals force (x+y), so that sNaN's raise exceptions */
|
||||
/* If both are NaN, adding returns qNaN */
|
||||
if (nan_x && nan_y)
|
||||
return (x + y);
|
||||
return (x + y);
|
||||
|
||||
/* force_except makes sure sNaN's raise exceptions */
|
||||
volatile long double force_except = x + y;
|
||||
force_except;
|
||||
|
||||
if (nan_x)
|
||||
return ((x + y) != 0.0 ? y : y);
|
||||
return ((x + y) != 0.0 ? x : x);
|
||||
return (y);
|
||||
else
|
||||
return (x);
|
||||
}
|
||||
|
||||
/* Handle comparisons of signed zeroes. */
|
||||
|
||||
@@ -53,12 +53,18 @@ fminimum_num(double x, double y)
|
||||
nan_y = isnan(y);
|
||||
|
||||
if (nan_x || nan_y) {
|
||||
/* These ternary conditionals force (x+y), so that sNaN's raise exceptions */
|
||||
/* If both are NaN, adding returns qNaN */
|
||||
if (nan_x && nan_y)
|
||||
return (x + y);
|
||||
return (x + y);
|
||||
|
||||
/* force_except makes sure sNaN's raise exceptions */
|
||||
volatile double force_except = x + y;
|
||||
force_except;
|
||||
|
||||
if (nan_x)
|
||||
return ((x + y) != 0.0 ? y : y);
|
||||
return ((x + y) != 0.0 ? x : x);
|
||||
return (y);
|
||||
else
|
||||
return (x);
|
||||
}
|
||||
|
||||
/* Handle comparisons of signed zeroes. */
|
||||
|
||||
@@ -52,12 +52,18 @@ fminimum_numf(float x, float y)
|
||||
nan_y = isnan(y);
|
||||
|
||||
if (nan_x || nan_y) {
|
||||
/* These ternary conditionals force (x+y), so that sNaN's raise exceptions */
|
||||
/* If both are NaN, adding returns qNaN */
|
||||
if (nan_x && nan_y)
|
||||
return (x + y);
|
||||
return (x + y);
|
||||
|
||||
/* force_except makes sure sNaN's raise exceptions */
|
||||
volatile float force_except = x + y;
|
||||
force_except;
|
||||
|
||||
if (nan_x)
|
||||
return ((x + y) != 0.0 ? y : y);
|
||||
return ((x + y) != 0.0 ? x : x);
|
||||
return (y);
|
||||
else
|
||||
return (x);
|
||||
}
|
||||
|
||||
/* Handle comparisons of signed zeroes. */
|
||||
|
||||
@@ -47,12 +47,18 @@ fminimum_numl(long double x, long double y)
|
||||
nan_y = isnan(y);
|
||||
|
||||
if (nan_x || nan_y) {
|
||||
/* These ternary conditionals force (x+y), so that sNaN's raise exceptions */
|
||||
/* If both are NaN, adding returns qNaN */
|
||||
if (nan_x && nan_y)
|
||||
return (x + y);
|
||||
return (x + y);
|
||||
|
||||
/* force_except makes sure sNaN's raise exceptions */
|
||||
volatile long double force_except = x + y;
|
||||
force_except;
|
||||
|
||||
if (nan_x)
|
||||
return ((x + y) != 0.0 ? y : y);
|
||||
return ((x + y) != 0.0 ? x : x);
|
||||
return (y);
|
||||
else
|
||||
return (x);
|
||||
}
|
||||
|
||||
/* Handle comparisons of signed zeroes. */
|
||||
|
||||
Reference in New Issue
Block a user