Move math_narrow_eval to separate math-narrow-eval.h [committed]

Message ID alpine.DEB.2.20.1805090015320.32321@digraph.polyomino.org.uk
State New
Headers show
Series
  • Move math_narrow_eval to separate math-narrow-eval.h [committed]
Related show

Commit Message

Joseph Myers May 9, 2018, 12:15 a.m.
This patch continues cleaning up the math_private.h header, which
contains lots of different definitions many of which are only needed
by a limited subset of files using that header (and some of which are
overridden by architectures that only want to override selected parts
of the header), by moving the math_narrow_eval macro out to a separate
math-narrow-eval.h header, only included by those files that need it.
That header is placed in include/ (since it's used in stdlib/, not
just files built in math/, but no sysdeps variants are needed at
present).

Tested for x86_64, and with build-many-glibcs.py.  (Installed stripped
shared libraries change because of line numbers in assertions in
strtod_l.c.)  Committed.

2018-05-09  Joseph Myers  <joseph@codesourcery.com>

	* include/math-narrow-eval.h: New file.  Contents moved from ....
	* sysdeps/generic/math_private.h: ... here.
	(math_narrow_eval): Remove macro.  Moved to math-narrow-eval.h.
	[FLT_EVAL_METHOD != 0] (excess_precision): Likewise.
	* math/s_fdim_template.c: Include <math-narrow-eval.h>.
	* stdlib/strtod_l.c: Likewise.
	* sysdeps/i386/fpu/s_f32xaddf64.c: Likewise.
	* sysdeps/i386/fpu/s_f32xsubf64.c: Likewise.
	* sysdeps/i386/fpu/s_fdim.c: Likewise.
	* sysdeps/ieee754/dbl-64/e_cosh.c: Likewise.
	* sysdeps/ieee754/dbl-64/e_gamma_r.c: Likewise.
	* sysdeps/ieee754/dbl-64/e_j1.c: Likewise.
	* sysdeps/ieee754/dbl-64/e_jn.c: Likewise.
	* sysdeps/ieee754/dbl-64/e_lgamma_r.c: Likewise.
	* sysdeps/ieee754/dbl-64/e_sinh.c: Likewise.
	* sysdeps/ieee754/dbl-64/gamma_productf.c: Likewise.
	* sysdeps/ieee754/dbl-64/k_rem_pio2.c: Likewise.
	* sysdeps/ieee754/dbl-64/lgamma_neg.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_erf.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_llrint.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_lrint.c: Likewise.
	* sysdeps/ieee754/flt-32/e_coshf.c: Likewise.
	* sysdeps/ieee754/flt-32/e_exp2f.c: Likewise.
	* sysdeps/ieee754/flt-32/e_expf.c: Likewise.
	* sysdeps/ieee754/flt-32/e_gammaf_r.c: Likewise.
	* sysdeps/ieee754/flt-32/e_j1f.c: Likewise.
	* sysdeps/ieee754/flt-32/e_jnf.c: Likewise.
	* sysdeps/ieee754/flt-32/e_lgammaf_r.c: Likewise.
	* sysdeps/ieee754/flt-32/e_sinhf.c: Likewise.
	* sysdeps/ieee754/flt-32/k_rem_pio2f.c: Likewise.
	* sysdeps/ieee754/flt-32/lgamma_negf.c: Likewise.
	* sysdeps/ieee754/flt-32/s_erff.c: Likewise.
	* sysdeps/ieee754/flt-32/s_llrintf.c: Likewise.
	* sysdeps/ieee754/flt-32/s_lrintf.c: Likewise.
	* sysdeps/ieee754/ldbl-96/gamma_product.c: Likewise.

Patch

diff --git a/include/math-narrow-eval.h b/include/math-narrow-eval.h
new file mode 100644
index 0000000..4361aa0
--- /dev/null
+++ b/include/math-narrow-eval.h
@@ -0,0 +1,47 @@ 
+/* Narrow floating-point values to their semantic type.
+   Copyright (C) 2015-2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _MATH_NARROW_EVAL_H
+#define _MATH_NARROW_EVAL_H	1
+
+#include <float.h>
+
+/* math_narrow_eval reduces its floating-point argument to the range
+   and precision of its semantic type.  (The original evaluation may
+   still occur with excess range and precision, so the result may be
+   affected by double rounding.)  */
+#if FLT_EVAL_METHOD == 0
+# define math_narrow_eval(x) (x)
+#else
+# if FLT_EVAL_METHOD == 1
+#  define excess_precision(type) __builtin_types_compatible_p (type, float)
+# else
+#  define excess_precision(type) (__builtin_types_compatible_p (type, float) \
+				  || __builtin_types_compatible_p (type, \
+								   double))
+# endif
+# define math_narrow_eval(x)					\
+  ({								\
+    __typeof (x) math_narrow_eval_tmp = (x);			\
+    if (excess_precision (__typeof (math_narrow_eval_tmp)))	\
+      __asm__ ("" : "+m" (math_narrow_eval_tmp));		\
+    math_narrow_eval_tmp;					\
+   })
+#endif
+
+#endif /* math-narrow-eval.h */
diff --git a/math/s_fdim_template.c b/math/s_fdim_template.c
index d10d2be..c8fa71f 100644
--- a/math/s_fdim_template.c
+++ b/math/s_fdim_template.c
@@ -19,6 +19,7 @@ 
 
 #include <errno.h>
 #include <math.h>
+#include <math-narrow-eval.h>
 #include <math_private.h>
 
 FLOAT
diff --git a/stdlib/strtod_l.c b/stdlib/strtod_l.c
index 98e0b46..09a40ad 100644
--- a/stdlib/strtod_l.c
+++ b/stdlib/strtod_l.c
@@ -66,6 +66,7 @@  extern double ____strtod_l_internal (const char *, char **, int, locale_t);
 #include <float.h>
 #include "../locale/localeinfo.h"
 #include <math.h>
+#include <math-narrow-eval.h>
 #include <math_private.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/sysdeps/generic/math_private.h b/sysdeps/generic/math_private.h
index ecb3739..703f506 100644
--- a/sysdeps/generic/math_private.h
+++ b/sysdeps/generic/math_private.h
@@ -270,29 +270,6 @@  extern void __docos (double __x, double __dx, double __v[]);
 ({ __typeof (x) __x = (x); __asm __volatile__ ("" : : "m" (__x)); })
 #endif
 
-/* math_narrow_eval reduces its floating-point argument to the range
-   and precision of its semantic type.  (The original evaluation may
-   still occur with excess range and precision, so the result may be
-   affected by double rounding.)  */
-#if FLT_EVAL_METHOD == 0
-# define math_narrow_eval(x) (x)
-#else
-# if FLT_EVAL_METHOD == 1
-#  define excess_precision(type) __builtin_types_compatible_p (type, float)
-# else
-#  define excess_precision(type) (__builtin_types_compatible_p (type, float) \
-				  || __builtin_types_compatible_p (type, \
-								   double))
-# endif
-# define math_narrow_eval(x)					\
-  ({								\
-    __typeof (x) math_narrow_eval_tmp = (x);			\
-    if (excess_precision (__typeof (math_narrow_eval_tmp)))	\
-      __asm__ ("" : "+m" (math_narrow_eval_tmp));		\
-    math_narrow_eval_tmp;					\
-   })
-#endif
-
 #define fabs_tg(x) __MATH_TG ((x), (__typeof (x)) __builtin_fabs, (x))
 
 /* These must be function-like macros because some __MATH_TG
diff --git a/sysdeps/i386/fpu/s_f32xaddf64.c b/sysdeps/i386/fpu/s_f32xaddf64.c
index c622a23..9d5e85b 100644
--- a/sysdeps/i386/fpu/s_f32xaddf64.c
+++ b/sysdeps/i386/fpu/s_f32xaddf64.c
@@ -18,6 +18,7 @@ 
 
 #include <math.h>
 #include <fpu_control.h>
+#include <math-narrow-eval.h>
 #include <math_private.h>
 #include <math-narrow.h>
 
diff --git a/sysdeps/i386/fpu/s_f32xsubf64.c b/sysdeps/i386/fpu/s_f32xsubf64.c
index 3a7dbca..3f41acf 100644
--- a/sysdeps/i386/fpu/s_f32xsubf64.c
+++ b/sysdeps/i386/fpu/s_f32xsubf64.c
@@ -18,6 +18,7 @@ 
 
 #include <math.h>
 #include <fpu_control.h>
+#include <math-narrow-eval.h>
 #include <math_private.h>
 #include <math-narrow.h>
 
diff --git a/sysdeps/i386/fpu/s_fdim.c b/sysdeps/i386/fpu/s_fdim.c
index f38bba4..b8fefe7 100644
--- a/sysdeps/i386/fpu/s_fdim.c
+++ b/sysdeps/i386/fpu/s_fdim.c
@@ -19,6 +19,7 @@ 
 #include <errno.h>
 #include <fpu_control.h>
 #include <math.h>
+#include <math-narrow-eval.h>
 #include <math_private.h>
 #include <libm-alias-double.h>
 
diff --git a/sysdeps/ieee754/dbl-64/e_cosh.c b/sysdeps/ieee754/dbl-64/e_cosh.c
index bd940c7..ae2180a 100644
--- a/sysdeps/ieee754/dbl-64/e_cosh.c
+++ b/sysdeps/ieee754/dbl-64/e_cosh.c
@@ -32,6 +32,7 @@ 
  */
 
 #include <math.h>
+#include <math-narrow-eval.h>
 #include <math_private.h>
 
 static const double one = 1.0, half = 0.5, huge = 1.0e300;
diff --git a/sysdeps/ieee754/dbl-64/e_gamma_r.c b/sysdeps/ieee754/dbl-64/e_gamma_r.c
index ac7fe2e..a3750f9 100644
--- a/sysdeps/ieee754/dbl-64/e_gamma_r.c
+++ b/sysdeps/ieee754/dbl-64/e_gamma_r.c
@@ -18,6 +18,7 @@ 
    <http://www.gnu.org/licenses/>.  */
 
 #include <math.h>
+#include <math-narrow-eval.h>
 #include <math_private.h>
 #include <float.h>
 
diff --git a/sysdeps/ieee754/dbl-64/e_j1.c b/sysdeps/ieee754/dbl-64/e_j1.c
index b528998..d0e387e 100644
--- a/sysdeps/ieee754/dbl-64/e_j1.c
+++ b/sysdeps/ieee754/dbl-64/e_j1.c
@@ -61,6 +61,7 @@ 
 #include <errno.h>
 #include <float.h>
 #include <math.h>
+#include <math-narrow-eval.h>
 #include <math_private.h>
 
 static double pone (double), qone (double);
diff --git a/sysdeps/ieee754/dbl-64/e_jn.c b/sysdeps/ieee754/dbl-64/e_jn.c
index 12cc0d5..6ef0fbe 100644
--- a/sysdeps/ieee754/dbl-64/e_jn.c
+++ b/sysdeps/ieee754/dbl-64/e_jn.c
@@ -39,6 +39,7 @@ 
 #include <errno.h>
 #include <float.h>
 #include <math.h>
+#include <math-narrow-eval.h>
 #include <math_private.h>
 
 static const double
diff --git a/sysdeps/ieee754/dbl-64/e_lgamma_r.c b/sysdeps/ieee754/dbl-64/e_lgamma_r.c
index 93eda99..17717d9 100644
--- a/sysdeps/ieee754/dbl-64/e_lgamma_r.c
+++ b/sysdeps/ieee754/dbl-64/e_lgamma_r.c
@@ -78,6 +78,7 @@ 
  */
 
 #include <math.h>
+#include <math-narrow-eval.h>
 #include <math_private.h>
 #include <libc-diag.h>
 
diff --git a/sysdeps/ieee754/dbl-64/e_sinh.c b/sysdeps/ieee754/dbl-64/e_sinh.c
index e9371b8..49c24fb 100644
--- a/sysdeps/ieee754/dbl-64/e_sinh.c
+++ b/sysdeps/ieee754/dbl-64/e_sinh.c
@@ -34,6 +34,7 @@  static char rcsid[] = "$NetBSD: e_sinh.c,v 1.7 1995/05/10 20:46:13 jtc Exp $";
 
 #include <float.h>
 #include <math.h>
+#include <math-narrow-eval.h>
 #include <math_private.h>
 
 static const double one = 1.0, shuge = 1.0e307;
diff --git a/sysdeps/ieee754/dbl-64/gamma_productf.c b/sysdeps/ieee754/dbl-64/gamma_productf.c
index b93bf55..011c6ff 100644
--- a/sysdeps/ieee754/dbl-64/gamma_productf.c
+++ b/sysdeps/ieee754/dbl-64/gamma_productf.c
@@ -17,6 +17,7 @@ 
    <http://www.gnu.org/licenses/>.  */
 
 #include <math.h>
+#include <math-narrow-eval.h>
 #include <math_private.h>
 #include <float.h>
 
diff --git a/sysdeps/ieee754/dbl-64/k_rem_pio2.c b/sysdeps/ieee754/dbl-64/k_rem_pio2.c
index 2b5add6..820fe77 100644
--- a/sysdeps/ieee754/dbl-64/k_rem_pio2.c
+++ b/sysdeps/ieee754/dbl-64/k_rem_pio2.c
@@ -131,6 +131,7 @@  static char rcsid[] = "$NetBSD: k_rem_pio2.c,v 1.7 1995/05/10 20:46:25 jtc Exp $
  */
 
 #include <math.h>
+#include <math-narrow-eval.h>
 #include <math_private.h>
 #include <libc-diag.h>
 
diff --git a/sysdeps/ieee754/dbl-64/lgamma_neg.c b/sysdeps/ieee754/dbl-64/lgamma_neg.c
index 4255520..5bb2f10 100644
--- a/sysdeps/ieee754/dbl-64/lgamma_neg.c
+++ b/sysdeps/ieee754/dbl-64/lgamma_neg.c
@@ -18,6 +18,7 @@ 
 
 #include <float.h>
 #include <math.h>
+#include <math-narrow-eval.h>
 #include <math_private.h>
 
 static const double lgamma_zeros[][2] =
diff --git a/sysdeps/ieee754/dbl-64/s_erf.c b/sysdeps/ieee754/dbl-64/s_erf.c
index 78287fd..48dfca3 100644
--- a/sysdeps/ieee754/dbl-64/s_erf.c
+++ b/sysdeps/ieee754/dbl-64/s_erf.c
@@ -115,6 +115,7 @@  static char rcsid[] = "$NetBSD: s_erf.c,v 1.8 1995/05/10 20:47:05 jtc Exp $";
 #include <errno.h>
 #include <float.h>
 #include <math.h>
+#include <math-narrow-eval.h>
 #include <math_private.h>
 #include <libm-alias-double.h>
 #include <fix-int-fp-convert-zero.h>
diff --git a/sysdeps/ieee754/dbl-64/s_llrint.c b/sysdeps/ieee754/dbl-64/s_llrint.c
index c6ef055..8159706 100644
--- a/sysdeps/ieee754/dbl-64/s_llrint.c
+++ b/sysdeps/ieee754/dbl-64/s_llrint.c
@@ -22,6 +22,7 @@ 
 #include <limits.h>
 #include <math.h>
 
+#include <math-narrow-eval.h>
 #include <math_private.h>
 #include <libm-alias-double.h>
 #include <fix-fp-int-convert-overflow.h>
diff --git a/sysdeps/ieee754/dbl-64/s_lrint.c b/sysdeps/ieee754/dbl-64/s_lrint.c
index 5df117a..0e64ae1 100644
--- a/sysdeps/ieee754/dbl-64/s_lrint.c
+++ b/sysdeps/ieee754/dbl-64/s_lrint.c
@@ -22,6 +22,7 @@ 
 #include <limits.h>
 #include <math.h>
 
+#include <math-narrow-eval.h>
 #include <math_private.h>
 #include <libm-alias-double.h>
 #include <fix-fp-int-convert-overflow.h>
diff --git a/sysdeps/ieee754/flt-32/e_coshf.c b/sysdeps/ieee754/flt-32/e_coshf.c
index 7b22375..a2aa838 100644
--- a/sysdeps/ieee754/flt-32/e_coshf.c
+++ b/sysdeps/ieee754/flt-32/e_coshf.c
@@ -15,6 +15,7 @@ 
  */
 
 #include <math.h>
+#include <math-narrow-eval.h>
 #include <math_private.h>
 
 static const float huge = 1.0e30;
diff --git a/sysdeps/ieee754/flt-32/e_exp2f.c b/sysdeps/ieee754/flt-32/e_exp2f.c
index cf078fe..7218e5d 100644
--- a/sysdeps/ieee754/flt-32/e_exp2f.c
+++ b/sysdeps/ieee754/flt-32/e_exp2f.c
@@ -17,6 +17,7 @@ 
    <http://www.gnu.org/licenses/>.  */
 
 #include <math.h>
+#include <math-narrow-eval.h>
 #include <stdint.h>
 #include <shlib-compat.h>
 #include <libm-alias-float.h>
diff --git a/sysdeps/ieee754/flt-32/e_expf.c b/sysdeps/ieee754/flt-32/e_expf.c
index 32ce1b5..f2238bf 100644
--- a/sysdeps/ieee754/flt-32/e_expf.c
+++ b/sysdeps/ieee754/flt-32/e_expf.c
@@ -22,6 +22,7 @@ 
 #endif
 
 #include <math.h>
+#include <math-narrow-eval.h>
 #include <stdint.h>
 #include <shlib-compat.h>
 #include <libm-alias-float.h>
diff --git a/sysdeps/ieee754/flt-32/e_gammaf_r.c b/sysdeps/ieee754/flt-32/e_gammaf_r.c
index efbff02..d640510 100644
--- a/sysdeps/ieee754/flt-32/e_gammaf_r.c
+++ b/sysdeps/ieee754/flt-32/e_gammaf_r.c
@@ -18,6 +18,7 @@ 
    <http://www.gnu.org/licenses/>.  */
 
 #include <math.h>
+#include <math-narrow-eval.h>
 #include <math_private.h>
 #include <float.h>
 
diff --git a/sysdeps/ieee754/flt-32/e_j1f.c b/sysdeps/ieee754/flt-32/e_j1f.c
index 95f03d1..8aadc4c 100644
--- a/sysdeps/ieee754/flt-32/e_j1f.c
+++ b/sysdeps/ieee754/flt-32/e_j1f.c
@@ -16,6 +16,7 @@ 
 #include <errno.h>
 #include <float.h>
 #include <math.h>
+#include <math-narrow-eval.h>
 #include <math_private.h>
 
 static float ponef(float), qonef(float);
diff --git a/sysdeps/ieee754/flt-32/e_jnf.c b/sysdeps/ieee754/flt-32/e_jnf.c
index 4b78ece..a4414ce 100644
--- a/sysdeps/ieee754/flt-32/e_jnf.c
+++ b/sysdeps/ieee754/flt-32/e_jnf.c
@@ -16,6 +16,7 @@ 
 #include <errno.h>
 #include <float.h>
 #include <math.h>
+#include <math-narrow-eval.h>
 #include <math_private.h>
 
 static const float
diff --git a/sysdeps/ieee754/flt-32/e_lgammaf_r.c b/sysdeps/ieee754/flt-32/e_lgammaf_r.c
index b0baad6..8fdf9bb 100644
--- a/sysdeps/ieee754/flt-32/e_lgammaf_r.c
+++ b/sysdeps/ieee754/flt-32/e_lgammaf_r.c
@@ -14,6 +14,7 @@ 
  */
 
 #include <math.h>
+#include <math-narrow-eval.h>
 #include <math_private.h>
 #include <libc-diag.h>
 
diff --git a/sysdeps/ieee754/flt-32/e_sinhf.c b/sysdeps/ieee754/flt-32/e_sinhf.c
index 6100d95..17b3663 100644
--- a/sysdeps/ieee754/flt-32/e_sinhf.c
+++ b/sysdeps/ieee754/flt-32/e_sinhf.c
@@ -15,6 +15,7 @@ 
 
 #include <float.h>
 #include <math.h>
+#include <math-narrow-eval.h>
 #include <math_private.h>
 
 static const float one = 1.0, shuge = 1.0e37;
diff --git a/sysdeps/ieee754/flt-32/k_rem_pio2f.c b/sysdeps/ieee754/flt-32/k_rem_pio2f.c
index a8d5b21..fdf2b5d 100644
--- a/sysdeps/ieee754/flt-32/k_rem_pio2f.c
+++ b/sysdeps/ieee754/flt-32/k_rem_pio2f.c
@@ -18,6 +18,7 @@  static char rcsid[] = "$NetBSD: k_rem_pio2f.c,v 1.4 1995/05/10 20:46:28 jtc Exp
 #endif
 
 #include <math.h>
+#include <math-narrow-eval.h>
 #include <math_private.h>
 #include <libc-diag.h>
 
diff --git a/sysdeps/ieee754/flt-32/lgamma_negf.c b/sysdeps/ieee754/flt-32/lgamma_negf.c
index c60f6ca..01edb0b 100644
--- a/sysdeps/ieee754/flt-32/lgamma_negf.c
+++ b/sysdeps/ieee754/flt-32/lgamma_negf.c
@@ -18,6 +18,7 @@ 
 
 #include <float.h>
 #include <math.h>
+#include <math-narrow-eval.h>
 #include <math_private.h>
 
 static const float lgamma_zeros[][2] =
diff --git a/sysdeps/ieee754/flt-32/s_erff.c b/sysdeps/ieee754/flt-32/s_erff.c
index 6eacf0f..1d00abd 100644
--- a/sysdeps/ieee754/flt-32/s_erff.c
+++ b/sysdeps/ieee754/flt-32/s_erff.c
@@ -20,6 +20,7 @@  static char rcsid[] = "$NetBSD: s_erff.c,v 1.4 1995/05/10 20:47:07 jtc Exp $";
 #include <errno.h>
 #include <float.h>
 #include <math.h>
+#include <math-narrow-eval.h>
 #include <math_private.h>
 #include <libm-alias-float.h>
 #include <fix-int-fp-convert-zero.h>
diff --git a/sysdeps/ieee754/flt-32/s_llrintf.c b/sysdeps/ieee754/flt-32/s_llrintf.c
index 974214c..7c64bb2 100644
--- a/sysdeps/ieee754/flt-32/s_llrintf.c
+++ b/sysdeps/ieee754/flt-32/s_llrintf.c
@@ -22,6 +22,7 @@ 
 #include <limits.h>
 #include <math.h>
 
+#include <math-narrow-eval.h>
 #include <math_private.h>
 #include <libm-alias-float.h>
 #include <fix-fp-int-convert-overflow.h>
diff --git a/sysdeps/ieee754/flt-32/s_lrintf.c b/sysdeps/ieee754/flt-32/s_lrintf.c
index 8bdc1ca..5171377 100644
--- a/sysdeps/ieee754/flt-32/s_lrintf.c
+++ b/sysdeps/ieee754/flt-32/s_lrintf.c
@@ -22,6 +22,7 @@ 
 #include <limits.h>
 #include <math.h>
 
+#include <math-narrow-eval.h>
 #include <math_private.h>
 #include <libm-alias-float.h>
 #include <fix-fp-int-convert-overflow.h>
diff --git a/sysdeps/ieee754/ldbl-96/gamma_product.c b/sysdeps/ieee754/ldbl-96/gamma_product.c
index 9276dd5..f1b65e1 100644
--- a/sysdeps/ieee754/ldbl-96/gamma_product.c
+++ b/sysdeps/ieee754/ldbl-96/gamma_product.c
@@ -17,6 +17,7 @@ 
    <http://www.gnu.org/licenses/>.  */
 
 #include <math.h>
+#include <math-narrow-eval.h>
 #include <math_private.h>
 #include <float.h>