|
|
1feee8 |
commit 80b24b86548eee3d96130a48e760d1d6c2e0c587
|
|
|
1feee8 |
Author: H.J. Lu <hjl.tools@gmail.com>
|
|
|
1feee8 |
Date: Mon Dec 20 15:00:24 2021 -0800
|
|
|
1feee8 |
|
|
|
1feee8 |
math: Properly cast X_TLOSS to float [BZ #28713]
|
|
|
1feee8 |
|
|
|
1feee8 |
Add
|
|
|
1feee8 |
|
|
|
1feee8 |
#define AS_FLOAT_CONSTANT_1(x) x##f
|
|
|
1feee8 |
#define AS_FLOAT_CONSTANT(x) AS_FLOAT_CONSTANT_1(x)
|
|
|
1feee8 |
|
|
|
1feee8 |
to cast X_TLOSS to float at compile-time to fix:
|
|
|
1feee8 |
|
|
|
1feee8 |
FAIL: math/test-float-j0
|
|
|
1feee8 |
FAIL: math/test-float-jn
|
|
|
1feee8 |
FAIL: math/test-float-y0
|
|
|
1feee8 |
FAIL: math/test-float-y1
|
|
|
1feee8 |
FAIL: math/test-float-yn
|
|
|
1feee8 |
FAIL: math/test-float32-j0
|
|
|
1feee8 |
FAIL: math/test-float32-jn
|
|
|
1feee8 |
FAIL: math/test-float32-y0
|
|
|
1feee8 |
FAIL: math/test-float32-y1
|
|
|
1feee8 |
FAIL: math/test-float32-yn
|
|
|
1feee8 |
|
|
|
1feee8 |
when compiling with GCC 12.
|
|
|
1feee8 |
|
|
|
1feee8 |
Reviewed-by: Paul Zimmermann <Paul.Zimmermann@inria.fr>
|
|
|
1feee8 |
(cherry picked from commit 6e30181b4a3ab6c56da0378b65f4d60504982300)
|
|
|
1feee8 |
|
|
|
1feee8 |
diff --git a/math/math-svid-compat.h b/math/math-svid-compat.h
|
|
|
1feee8 |
index 5c18cb1b039cb3be..876cadde4084dab0 100644
|
|
|
1feee8 |
--- a/math/math-svid-compat.h
|
|
|
1feee8 |
+++ b/math/math-svid-compat.h
|
|
|
1feee8 |
@@ -49,6 +49,8 @@ extern int matherr (struct exception *__exc);
|
|
|
1feee8 |
extern int __matherr (struct exception *__exc);
|
|
|
1feee8 |
|
|
|
1feee8 |
#define X_TLOSS 1.41484755040568800000e+16
|
|
|
1feee8 |
+#define AS_FLOAT_CONSTANT_1(x) x##f
|
|
|
1feee8 |
+#define AS_FLOAT_CONSTANT(x) AS_FLOAT_CONSTANT_1(x)
|
|
|
1feee8 |
|
|
|
1feee8 |
/* Types of exceptions in the `type' field. */
|
|
|
1feee8 |
#define DOMAIN 1
|
|
|
1feee8 |
diff --git a/math/w_j0f_compat.c b/math/w_j0f_compat.c
|
|
|
1feee8 |
index a4882eadb33853b2..f35a55219f7baa78 100644
|
|
|
1feee8 |
--- a/math/w_j0f_compat.c
|
|
|
1feee8 |
+++ b/math/w_j0f_compat.c
|
|
|
1feee8 |
@@ -28,7 +28,8 @@
|
|
|
1feee8 |
float
|
|
|
1feee8 |
__j0f (float x)
|
|
|
1feee8 |
{
|
|
|
1feee8 |
- if (__builtin_expect (isgreater (fabsf (x), (float) X_TLOSS), 0)
|
|
|
1feee8 |
+ if (__builtin_expect (isgreater (fabsf (x),
|
|
|
1feee8 |
+ AS_FLOAT_CONSTANT (X_TLOSS)), 0)
|
|
|
1feee8 |
&& _LIB_VERSION != _IEEE_ && _LIB_VERSION != _POSIX_)
|
|
|
1feee8 |
/* j0(|x|>X_TLOSS) */
|
|
|
1feee8 |
return __kernel_standard_f (x, x, 134);
|
|
|
1feee8 |
@@ -43,7 +44,7 @@ float
|
|
|
1feee8 |
__y0f (float x)
|
|
|
1feee8 |
{
|
|
|
1feee8 |
if (__builtin_expect (islessequal (x, 0.0f)
|
|
|
1feee8 |
- || isgreater (x, (float) X_TLOSS), 0)
|
|
|
1feee8 |
+ || isgreater (x, AS_FLOAT_CONSTANT (X_TLOSS)), 0)
|
|
|
1feee8 |
&& _LIB_VERSION != _IEEE_)
|
|
|
1feee8 |
{
|
|
|
1feee8 |
if (x < 0.0f)
|
|
|
1feee8 |
diff --git a/math/w_j1f_compat.c b/math/w_j1f_compat.c
|
|
|
1feee8 |
index f2ec7b327d2bc90a..c5e3ccd035031799 100644
|
|
|
1feee8 |
--- a/math/w_j1f_compat.c
|
|
|
1feee8 |
+++ b/math/w_j1f_compat.c
|
|
|
1feee8 |
@@ -28,7 +28,8 @@
|
|
|
1feee8 |
float
|
|
|
1feee8 |
__j1f (float x)
|
|
|
1feee8 |
{
|
|
|
1feee8 |
- if (__builtin_expect (isgreater (fabsf (x), X_TLOSS), 0)
|
|
|
1feee8 |
+ if (__builtin_expect (isgreater (fabsf (x),
|
|
|
1feee8 |
+ AS_FLOAT_CONSTANT (X_TLOSS)), 0)
|
|
|
1feee8 |
&& _LIB_VERSION != _IEEE_ && _LIB_VERSION != _POSIX_)
|
|
|
1feee8 |
/* j1(|x|>X_TLOSS) */
|
|
|
1feee8 |
return __kernel_standard_f (x, x, 136);
|
|
|
1feee8 |
@@ -43,7 +44,7 @@ float
|
|
|
1feee8 |
__y1f (float x)
|
|
|
1feee8 |
{
|
|
|
1feee8 |
if (__builtin_expect (islessequal (x, 0.0f)
|
|
|
1feee8 |
- || isgreater (x, (float) X_TLOSS), 0)
|
|
|
1feee8 |
+ || isgreater (x, AS_FLOAT_CONSTANT (X_TLOSS)), 0)
|
|
|
1feee8 |
&& _LIB_VERSION != _IEEE_)
|
|
|
1feee8 |
{
|
|
|
1feee8 |
if (x < 0.0f)
|
|
|
1feee8 |
diff --git a/math/w_jnf_compat.c b/math/w_jnf_compat.c
|
|
|
1feee8 |
index fb6e5060096fb070..925ccc4cd0988a8f 100644
|
|
|
1feee8 |
--- a/math/w_jnf_compat.c
|
|
|
1feee8 |
+++ b/math/w_jnf_compat.c
|
|
|
1feee8 |
@@ -28,7 +28,8 @@
|
|
|
1feee8 |
float
|
|
|
1feee8 |
__jnf (int n, float x)
|
|
|
1feee8 |
{
|
|
|
1feee8 |
- if (__builtin_expect (isgreater (fabsf (x), (float) X_TLOSS), 0)
|
|
|
1feee8 |
+ if (__builtin_expect (isgreater (fabsf (x),
|
|
|
1feee8 |
+ AS_FLOAT_CONSTANT (X_TLOSS)), 0)
|
|
|
1feee8 |
&& _LIB_VERSION != _IEEE_ && _LIB_VERSION != _POSIX_)
|
|
|
1feee8 |
/* jn(n,|x|>X_TLOSS) */
|
|
|
1feee8 |
return __kernel_standard_f (n, x, 138);
|
|
|
1feee8 |
@@ -43,7 +44,7 @@ float
|
|
|
1feee8 |
__ynf (int n, float x)
|
|
|
1feee8 |
{
|
|
|
1feee8 |
if (__builtin_expect (islessequal (x, 0.0f)
|
|
|
1feee8 |
- || isgreater (x, (float) X_TLOSS), 0)
|
|
|
1feee8 |
+ || isgreater (x, AS_FLOAT_CONSTANT (X_TLOSS)), 0)
|
|
|
1feee8 |
&& _LIB_VERSION != _IEEE_)
|
|
|
1feee8 |
{
|
|
|
1feee8 |
if (x < 0.0f)
|