summaryrefslogtreecommitdiffstats
path: root/modules/fdlibm/patches
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-11-15 15:17:37 +0100
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-11-15 15:17:37 +0100
commit59f4de4c45e126f5f20633808ce28548d5879b16 (patch)
tree2db061bafcebcac423ca7deeb152435c44944419 /modules/fdlibm/patches
parent5e902a4a9a25a9e151b5d3945c68517bc0c73139 (diff)
downloadUXP-59f4de4c45e126f5f20633808ce28548d5879b16.tar
UXP-59f4de4c45e126f5f20633808ce28548d5879b16.tar.gz
UXP-59f4de4c45e126f5f20633808ce28548d5879b16.tar.lz
UXP-59f4de4c45e126f5f20633808ce28548d5879b16.tar.xz
UXP-59f4de4c45e126f5f20633808ce28548d5879b16.zip
Issue #1291 - Part 4: Update patch files
Diffstat (limited to 'modules/fdlibm/patches')
-rw-r--r--modules/fdlibm/patches/01_remove_unused_declarations_from_fdlibm_h.patch19
-rw-r--r--modules/fdlibm/patches/02_change_include_guard_in_fdlibm_h.patch2
-rw-r--r--modules/fdlibm/patches/03_put_fdlibm_functions_into_fdlibm_namespace.patch2
-rw-r--r--modules/fdlibm/patches/04_include_fdlibm_h_from_math_private_h.patch53
-rw-r--r--modules/fdlibm/patches/06_use_mfbt_endian_h_in_math_private_h.patch63
-rw-r--r--modules/fdlibm/patches/07_add_fdlibm_namespace_to_functions_defined_and_used_in_fdlibm.patch3
-rw-r--r--modules/fdlibm/patches/08_remove_weak_reference_macro.patch48
-rw-r--r--modules/fdlibm/patches/09_comment_out_rcsid_variable.patch71
-rw-r--r--modules/fdlibm/patches/10_remove_unused_function_from_k_exp_cpp.patch4
-rw-r--r--modules/fdlibm/patches/12_define_u_int32_t_and_u_int64_t_on_windows.patch10
-rw-r--r--modules/fdlibm/patches/13_define_strict_assign_even_if_flt_eval_method_is_not_defined.patch8
-rw-r--r--modules/fdlibm/patches/14_do_not_use_hexadecimal_floating_point_number.patch4
-rw-r--r--modules/fdlibm/patches/15_remove_unused_rintl_function_from_s_nearbyint_cpp.patch2
-rw-r--r--modules/fdlibm/patches/16_use_safer_strict_assign_on_visual_studio.patch (renamed from modules/fdlibm/patches/15_use_safer_strict_assign_on_visual_studio.patch)3
-rw-r--r--modules/fdlibm/patches/17_exp_exact_result_for_positive_one.patch40
-rw-r--r--modules/fdlibm/patches/18_use_stdlib_sqrt.patch255
-rw-r--r--modules/fdlibm/patches/19_remove_unneeded_round_to_integer_helpers.patch130
17 files changed, 562 insertions, 155 deletions
diff --git a/modules/fdlibm/patches/01_remove_unused_declarations_from_fdlibm_h.patch b/modules/fdlibm/patches/01_remove_unused_declarations_from_fdlibm_h.patch
index 2d89d08ef..4e5774ff0 100644
--- a/modules/fdlibm/patches/01_remove_unused_declarations_from_fdlibm_h.patch
+++ b/modules/fdlibm/patches/01_remove_unused_declarations_from_fdlibm_h.patch
@@ -1,7 +1,7 @@
diff --git a/modules/fdlibm/src/fdlibm.h b/modules/fdlibm/src/fdlibm.h
--- a/modules/fdlibm/src/fdlibm.h
+++ b/modules/fdlibm/src/fdlibm.h
-@@ -12,496 +12,50 @@
+@@ -12,499 +12,49 @@
/*
* from: @(#)fdlibm.h 5.1 93/09/24
* $FreeBSD$
@@ -242,15 +242,15 @@ diff --git a/modules/fdlibm/src/fdlibm.h b/modules/fdlibm/src/fdlibm.h
-double modf(double, double *); /* fundamentally !__pure2 */
double pow(double, double);
- double sqrt(double);
+-double sqrt(double);
+double fabs(double);
-+double floor(double);
-+double trunc(double);
- double ceil(double);
+-double ceil(double);
-double fabs(double) __pure2;
--double floor(double);
+ double floor(double);
-double fmod(double, double);
++double trunc(double);
++double ceil(double);
-/*
- * These functions are not in C90.
@@ -368,13 +368,13 @@ diff --git a/modules/fdlibm/src/fdlibm.h b/modules/fdlibm/src/fdlibm.h
float floorf(float);
-float fmodf(float, float);
-float roundf(float);
-
+-
-float erff(float);
-float erfcf(float);
-float hypotf(float, float);
-float lgammaf(float);
-float tgammaf(float);
--
+
-float acoshf(float);
-float asinhf(float);
-float atanhf(float);
@@ -497,6 +497,9 @@ diff --git a/modules/fdlibm/src/fdlibm.h b/modules/fdlibm/src/fdlibm.h
-
-#if __BSD_VISIBLE
-long double lgammal_r(long double, int *);
+-void sincos(double, double *, double *);
+-void sincosf(float, float *, float *);
+-void sincosl(long double, long double *, long double *);
-#endif
-
-__END_DECLS
diff --git a/modules/fdlibm/patches/02_change_include_guard_in_fdlibm_h.patch b/modules/fdlibm/patches/02_change_include_guard_in_fdlibm_h.patch
index e96333bfa..f103af128 100644
--- a/modules/fdlibm/patches/02_change_include_guard_in_fdlibm_h.patch
+++ b/modules/fdlibm/patches/02_change_include_guard_in_fdlibm_h.patch
@@ -22,7 +22,7 @@ diff --git a/modules/fdlibm/src/fdlibm.h b/modules/fdlibm/src/fdlibm.h
double cosh(double);
double sinh(double);
-@@ -53,9 +53,9 @@ double scalbn(double, int);
+@@ -52,9 +52,9 @@ double scalbn(double, int);
float ceilf(float);
float floorf(float);
diff --git a/modules/fdlibm/patches/03_put_fdlibm_functions_into_fdlibm_namespace.patch b/modules/fdlibm/patches/03_put_fdlibm_functions_into_fdlibm_namespace.patch
index 66ae4525f..b6cd7ab7f 100644
--- a/modules/fdlibm/patches/03_put_fdlibm_functions_into_fdlibm_namespace.patch
+++ b/modules/fdlibm/patches/03_put_fdlibm_functions_into_fdlibm_namespace.patch
@@ -20,7 +20,7 @@ diff --git a/modules/fdlibm/src/fdlibm.h b/modules/fdlibm/src/fdlibm.h
double cosh(double);
double sinh(double);
double tanh(double);
-@@ -53,9 +55,11 @@ double scalbn(double, int);
+@@ -52,9 +54,11 @@ double scalbn(double, int);
float ceilf(float);
float floorf(float);
diff --git a/modules/fdlibm/patches/04_include_fdlibm_h_from_math_private_h.patch b/modules/fdlibm/patches/04_include_fdlibm_h_from_math_private_h.patch
index 9c0569e27..153018902 100644
--- a/modules/fdlibm/patches/04_include_fdlibm_h_from_math_private_h.patch
+++ b/modules/fdlibm/patches/04_include_fdlibm_h_from_math_private_h.patch
@@ -232,15 +232,15 @@ diff --git a/modules/fdlibm/src/e_log2.cpp b/modules/fdlibm/src/e_log2.cpp
diff --git a/modules/fdlibm/src/e_pow.cpp b/modules/fdlibm/src/e_pow.cpp
--- a/modules/fdlibm/src/e_pow.cpp
+++ b/modules/fdlibm/src/e_pow.cpp
-@@ -52,17 +52,16 @@
- *
+@@ -53,17 +53,16 @@
* Constants :
- * The hexadecimal values are the intended ones for the following
- * constants. The decimal values may be used, provided that the
- * compiler will convert from decimal to binary accurately enough
+ * The hexadecimal values are the intended ones for the following
+ * constants. The decimal values may be used, provided that the
+ * compiler will convert from decimal to binary accurately enough
* to produce the hexadecimal values shown.
*/
+ #include <float.h>
-#include "math.h"
#include "math_private.h"
@@ -249,7 +249,7 @@ diff --git a/modules/fdlibm/src/e_pow.cpp b/modules/fdlibm/src/e_pow.cpp
dp_h[] = { 0.0, 5.84962487220764160156e-01,}, /* 0x3FE2B803, 0x40000000 */
dp_l[] = { 0.0, 1.35003920212974897128e-08,}, /* 0x3E4CFDEB, 0x43CFD006 */
zero = 0.0,
- one = 1.0,
+ half = 0.5,
diff --git a/modules/fdlibm/src/e_sinh.cpp b/modules/fdlibm/src/e_sinh.cpp
--- a/modules/fdlibm/src/e_sinh.cpp
+++ b/modules/fdlibm/src/e_sinh.cpp
@@ -271,31 +271,10 @@ diff --git a/modules/fdlibm/src/e_sinh.cpp b/modules/fdlibm/src/e_sinh.cpp
__ieee754_sinh(double x)
{
double t,h;
-diff --git a/modules/fdlibm/src/e_sqrt.cpp b/modules/fdlibm/src/e_sqrt.cpp
---- a/modules/fdlibm/src/e_sqrt.cpp
-+++ b/modules/fdlibm/src/e_sqrt.cpp
-@@ -81,17 +81,16 @@
- * sqrt(NaN) = NaN ... with invalid signal for signaling NaN
- *
- * Other methods : see the appended file at the end of the program below.
- *---------------
- */
-
- #include <float.h>
-
--#include "math.h"
- #include "math_private.h"
-
- static const double one = 1.0, tiny=1.0e-300;
-
- double
- __ieee754_sqrt(double x)
- {
- double z;
diff --git a/modules/fdlibm/src/k_exp.cpp b/modules/fdlibm/src/k_exp.cpp
--- a/modules/fdlibm/src/k_exp.cpp
+++ b/modules/fdlibm/src/k_exp.cpp
-@@ -24,17 +24,16 @@
+@@ -26,17 +26,16 @@
* SUCH DAMAGE.
*/
@@ -380,8 +359,7 @@ diff --git a/modules/fdlibm/src/s_atan.cpp b/modules/fdlibm/src/s_atan.cpp
diff --git a/modules/fdlibm/src/s_cbrt.cpp b/modules/fdlibm/src/s_cbrt.cpp
--- a/modules/fdlibm/src/s_cbrt.cpp
+++ b/modules/fdlibm/src/s_cbrt.cpp
-@@ -10,17 +10,16 @@
- * ====================================================
+@@ -11,17 +11,16 @@
*
* Optimized by Bruce D. Evans.
*/
@@ -389,6 +367,7 @@ diff --git a/modules/fdlibm/src/s_cbrt.cpp b/modules/fdlibm/src/s_cbrt.cpp
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+ #include <float.h>
-#include "math.h"
#include "math_private.h"
@@ -485,10 +464,10 @@ diff --git a/modules/fdlibm/src/s_expm1.cpp b/modules/fdlibm/src/s_expm1.cpp
diff --git a/modules/fdlibm/src/s_fabs.cpp b/modules/fdlibm/src/s_fabs.cpp
--- a/modules/fdlibm/src/s_fabs.cpp
+++ b/modules/fdlibm/src/s_fabs.cpp
-@@ -13,17 +13,16 @@
- #ifndef lint
- static char rcsid[] = "$FreeBSD$";
- #endif
+@@ -12,17 +12,16 @@
+
+ #include <sys/cdefs.h>
+ __FBSDID("$FreeBSD$");
/*
* fabs(x) returns the absolute value of x.
@@ -569,7 +548,7 @@ diff --git a/modules/fdlibm/src/s_log1p.cpp b/modules/fdlibm/src/s_log1p.cpp
diff --git a/modules/fdlibm/src/s_nearbyint.cpp b/modules/fdlibm/src/s_nearbyint.cpp
--- a/modules/fdlibm/src/s_nearbyint.cpp
+++ b/modules/fdlibm/src/s_nearbyint.cpp
-@@ -23,17 +23,17 @@
+@@ -25,17 +25,17 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
@@ -633,13 +612,13 @@ diff --git a/modules/fdlibm/src/s_rintf.cpp b/modules/fdlibm/src/s_rintf.cpp
diff --git a/modules/fdlibm/src/s_scalbn.cpp b/modules/fdlibm/src/s_scalbn.cpp
--- a/modules/fdlibm/src/s_scalbn.cpp
+++ b/modules/fdlibm/src/s_scalbn.cpp
-@@ -19,17 +19,16 @@ static char rcsid[] = "$FreeBSD$";
+@@ -17,17 +17,16 @@
+ * scalbn (double x, int n)
* scalbn(x,n) returns x* 2**n computed by exponent
* manipulation rather than by actually performing an
* exponentiation or a multiplication.
*/
- #include <sys/cdefs.h>
#include <float.h>
-#include "math.h"
diff --git a/modules/fdlibm/patches/06_use_mfbt_endian_h_in_math_private_h.patch b/modules/fdlibm/patches/06_use_mfbt_endian_h_in_math_private_h.patch
index c8b30f20e..bd41b919a 100644
--- a/modules/fdlibm/patches/06_use_mfbt_endian_h_in_math_private_h.patch
+++ b/modules/fdlibm/patches/06_use_mfbt_endian_h_in_math_private_h.patch
@@ -1,7 +1,7 @@
diff --git a/modules/fdlibm/src/math_private.h b/modules/fdlibm/src/math_private.h
--- a/modules/fdlibm/src/math_private.h
+++ b/modules/fdlibm/src/math_private.h
-@@ -14,20 +14,21 @@
+@@ -14,52 +14,38 @@
* $FreeBSD$
*/
@@ -24,15 +24,16 @@ diff --git a/modules/fdlibm/src/math_private.h b/modules/fdlibm/src/math_private
* to dig two 32 bit words out of the 64 bit IEEE floating point
* value. That is non-ANSI, and, moreover, the gcc instruction
* scheduler gets it wrong. We instead use the following macros.
-@@ -36,27 +37,17 @@
+ * Unlike the original code, we determine the endianness at compile
+ * time, not at run time; I don't see much benefit to selecting
* endianness at run time.
*/
- /*
- * A union which permits us to convert between a double and two 32 bit
- * ints.
- */
-
+-/*
+- * A union which permits us to convert between a double and two 32 bit
+- * ints.
+- */
+-
-#ifdef __arm__
-#if defined(__VFP_FP__) || defined(__ARM_EABI__)
-#define IEEE_WORD_ORDER BYTE_ORDER
@@ -43,7 +44,53 @@ diff --git a/modules/fdlibm/src/math_private.h b/modules/fdlibm/src/math_private
-#define IEEE_WORD_ORDER BYTE_ORDER
-#endif
-
+ /* A union which permits us to convert between a long double and
+ four 32 bit ints. */
+
+-#if IEEE_WORD_ORDER == BIG_ENDIAN
++#if MOZ_BIG_ENDIAN
+
+ typedef union
+ {
+ long double value;
+ struct {
+ u_int32_t mswhi;
+ u_int32_t mswlo;
+ u_int32_t lswhi;
+@@ -68,17 +54,17 @@ typedef union
+ struct {
+ u_int64_t msw;
+ u_int64_t lsw;
+ } parts64;
+ } ieee_quad_shape_type;
+
+ #endif
+
+-#if IEEE_WORD_ORDER == LITTLE_ENDIAN
++#if MOZ_LITTLE_ENDIAN
+
+ typedef union
+ {
+ long double value;
+ struct {
+ u_int32_t lswlo;
+ u_int32_t lswhi;
+ u_int32_t mswlo;
+@@ -87,17 +73,22 @@ typedef union
+ struct {
+ u_int64_t lsw;
+ u_int64_t msw;
+ } parts64;
+ } ieee_quad_shape_type;
+
+ #endif
+
-#if IEEE_WORD_ORDER == BIG_ENDIAN
++/*
++ * A union which permits us to convert between a double and two 32 bit
++ * ints.
++ */
++
+#if MOZ_BIG_ENDIAN
typedef union
@@ -53,7 +100,7 @@ diff --git a/modules/fdlibm/src/math_private.h b/modules/fdlibm/src/math_private
{
u_int32_t msw;
u_int32_t lsw;
-@@ -64,17 +55,17 @@ typedef union
+@@ -105,17 +96,17 @@ typedef union
struct
{
u_int64_t w;
diff --git a/modules/fdlibm/patches/07_add_fdlibm_namespace_to_functions_defined_and_used_in_fdlibm.patch b/modules/fdlibm/patches/07_add_fdlibm_namespace_to_functions_defined_and_used_in_fdlibm.patch
index b2f95f978..07d3a500a 100644
--- a/modules/fdlibm/patches/07_add_fdlibm_namespace_to_functions_defined_and_used_in_fdlibm.patch
+++ b/modules/fdlibm/patches/07_add_fdlibm_namespace_to_functions_defined_and_used_in_fdlibm.patch
@@ -1,7 +1,7 @@
diff --git a/modules/fdlibm/src/math_private.h b/modules/fdlibm/src/math_private.h
--- a/modules/fdlibm/src/math_private.h
+++ b/modules/fdlibm/src/math_private.h
-@@ -724,16 +724,51 @@ irintl(long double x)
+@@ -872,16 +872,50 @@ irintl(long double x)
#define __ieee754_j1f j1f
#define __ieee754_y0f y0f
#define __ieee754_y1f y1f
@@ -21,7 +21,6 @@ diff --git a/modules/fdlibm/src/math_private.h b/modules/fdlibm/src/math_private
+#define log fdlibm::log
+#define log10 fdlibm::log10
+#define pow fdlibm::pow
-+#define sqrt fdlibm::sqrt
+#define ceil fdlibm::ceil
+#define ceilf fdlibm::ceilf
+#define fabs fdlibm::fabs
diff --git a/modules/fdlibm/patches/08_remove_weak_reference_macro.patch b/modules/fdlibm/patches/08_remove_weak_reference_macro.patch
index 99f14cdfa..0b55bbd84 100644
--- a/modules/fdlibm/patches/08_remove_weak_reference_macro.patch
+++ b/modules/fdlibm/patches/08_remove_weak_reference_macro.patch
@@ -174,6 +174,22 @@ diff --git a/modules/fdlibm/src/e_log2.cpp b/modules/fdlibm/src/e_log2.cpp
-#if (LDBL_MANT_DIG == 53)
-__weak_reference(log2, log2l);
-#endif
+diff --git a/modules/fdlibm/src/e_pow.cpp b/modules/fdlibm/src/e_pow.cpp
+--- a/modules/fdlibm/src/e_pow.cpp
++++ b/modules/fdlibm/src/e_pow.cpp
+@@ -302,12 +302,8 @@ double
+ r = (z*t1)/(t1-two)-(w+z*w);
+ z = one-(r-z);
+ GET_HIGH_WORD(j,z);
+ j += (n<<20);
+ if((j>>20)<=0) z = scalbn(z,n); /* subnormal output */
+ else SET_HIGH_WORD(z,j);
+ return s*z;
+ }
+-
+-#if (LDBL_MANT_DIG == 53)
+-__weak_reference(pow, powl);
+-#endif
diff --git a/modules/fdlibm/src/e_sinh.cpp b/modules/fdlibm/src/e_sinh.cpp
--- a/modules/fdlibm/src/e_sinh.cpp
+++ b/modules/fdlibm/src/e_sinh.cpp
@@ -190,30 +206,6 @@ diff --git a/modules/fdlibm/src/e_sinh.cpp b/modules/fdlibm/src/e_sinh.cpp
-#if (LDBL_MANT_DIG == 53)
-__weak_reference(sinh, sinhl);
-#endif
-diff --git a/modules/fdlibm/src/e_sqrt.cpp b/modules/fdlibm/src/e_sqrt.cpp
---- a/modules/fdlibm/src/e_sqrt.cpp
-+++ b/modules/fdlibm/src/e_sqrt.cpp
-@@ -182,20 +182,16 @@ double
- ix0 = (q>>1)+0x3fe00000;
- ix1 = q1>>1;
- if ((q&1)==1) ix1 |= sign;
- ix0 += (m <<20);
- INSERT_WORDS(z,ix0,ix1);
- return z;
- }
-
--#if (LDBL_MANT_DIG == 53)
--__weak_reference(sqrt, sqrtl);
--#endif
--
- /*
- Other methods (use floating-point arithmetic)
- -------------
- (This is a copy of a drafted paper by Prof W. Kahan
- and K.C. Ng, written in May, 1986)
-
- Two algorithms are given here to implement sqrt(x)
- (IEEE double precision arithmetic) in software.
diff --git a/modules/fdlibm/src/s_asinh.cpp b/modules/fdlibm/src/s_asinh.cpp
--- a/modules/fdlibm/src/s_asinh.cpp
+++ b/modules/fdlibm/src/s_asinh.cpp
@@ -249,7 +241,7 @@ diff --git a/modules/fdlibm/src/s_atan.cpp b/modules/fdlibm/src/s_atan.cpp
diff --git a/modules/fdlibm/src/s_cbrt.cpp b/modules/fdlibm/src/s_cbrt.cpp
--- a/modules/fdlibm/src/s_cbrt.cpp
+++ b/modules/fdlibm/src/s_cbrt.cpp
-@@ -105,12 +105,8 @@ cbrt(double x)
+@@ -106,12 +106,8 @@ cbrt(double x)
s=t*t; /* t*t is exact */
r=x/s; /* error <= 0.5 ulps; |r| < |t| */
w=t+t; /* t+t is exact */
@@ -346,10 +338,10 @@ diff --git a/modules/fdlibm/src/s_scalbn.cpp b/modules/fdlibm/src/s_scalbn.cpp
--- a/modules/fdlibm/src/s_scalbn.cpp
+++ b/modules/fdlibm/src/s_scalbn.cpp
@@ -53,13 +53,8 @@ scalbn (double x, int n)
- if (k <= -54)
- if (n > 50000) /* in case integer overflow in n+k */
return huge*copysign(huge,x); /*overflow*/
- else return tiny*copysign(tiny,x); /*underflow*/
+ else
+ return tiny*copysign(tiny,x); /*underflow*/
+ }
k += 54; /* subnormal result */
SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20));
return x*twom54;
diff --git a/modules/fdlibm/patches/09_comment_out_rcsid_variable.patch b/modules/fdlibm/patches/09_comment_out_rcsid_variable.patch
index 464f2d6fd..d520d9257 100644
--- a/modules/fdlibm/patches/09_comment_out_rcsid_variable.patch
+++ b/modules/fdlibm/patches/09_comment_out_rcsid_variable.patch
@@ -53,7 +53,7 @@ diff --git a/modules/fdlibm/src/e_asin.cpp b/modules/fdlibm/src/e_asin.cpp
*
* Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
@@ -284,7 +284,7 @@ diff --git a/modules/fdlibm/src/e_pow.cpp b/modules/fdlibm/src/e_pow.cpp
* Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
*
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
@@ -325,34 +325,10 @@ diff --git a/modules/fdlibm/src/e_sinh.cpp b/modules/fdlibm/src/e_sinh.cpp
* 2.
* E + E/(E+1)
* 0 <= x <= 22 : sinh(x) := --------------, E=expm1(x)
-diff --git a/modules/fdlibm/src/e_sqrt.cpp b/modules/fdlibm/src/e_sqrt.cpp
---- a/modules/fdlibm/src/e_sqrt.cpp
-+++ b/modules/fdlibm/src/e_sqrt.cpp
-@@ -6,18 +6,18 @@
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
--#include <sys/cdefs.h>
--__FBSDID("$FreeBSD$");
-+//#include <sys/cdefs.h>
-+//__FBSDID("$FreeBSD$");
-
- /* __ieee754_sqrt(x)
- * Return correctly rounded sqrt.
- * ------------------------------------------
- * | Use the hardware sqrt if you have one |
- * ------------------------------------------
- * Method:
- * Bit by bit method using integer arithmetic. (Slow, but portable)
diff --git a/modules/fdlibm/src/k_exp.cpp b/modules/fdlibm/src/k_exp.cpp
--- a/modules/fdlibm/src/k_exp.cpp
+++ b/modules/fdlibm/src/k_exp.cpp
-@@ -19,22 +19,22 @@
+@@ -21,22 +21,22 @@
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
@@ -467,13 +443,13 @@ diff --git a/modules/fdlibm/src/s_cbrt.cpp b/modules/fdlibm/src/s_cbrt.cpp
+//#include <sys/cdefs.h>
+//__FBSDID("$FreeBSD$");
+ #include <float.h>
#include "math_private.h"
/* cbrt(x)
* Return cube root of x
*/
static const u_int32_t
- B1 = 715094163, /* B1 = (1023-1023/3-0.03306235651)*2**20 */
diff --git a/modules/fdlibm/src/s_ceil.cpp b/modules/fdlibm/src/s_ceil.cpp
--- a/modules/fdlibm/src/s_ceil.cpp
+++ b/modules/fdlibm/src/s_ceil.cpp
@@ -573,12 +549,7 @@ diff --git a/modules/fdlibm/src/s_expm1.cpp b/modules/fdlibm/src/s_expm1.cpp
diff --git a/modules/fdlibm/src/s_fabs.cpp b/modules/fdlibm/src/s_fabs.cpp
--- a/modules/fdlibm/src/s_fabs.cpp
+++ b/modules/fdlibm/src/s_fabs.cpp
-@@ -1,22 +1,22 @@
--/* @(#)s_fabs.c 5.1 93/09/24 */
-+ /* @(#)s_fabs.c 5.1 93/09/24 */
- /*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+@@ -5,18 +5,18 @@
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
@@ -587,10 +558,10 @@ diff --git a/modules/fdlibm/src/s_fabs.cpp b/modules/fdlibm/src/s_fabs.cpp
* ====================================================
*/
- #ifndef lint
--static char rcsid[] = "$FreeBSD$";
-+ //static char rcsid[] = "$FreeBSD$";
- #endif
+-#include <sys/cdefs.h>
+-__FBSDID("$FreeBSD$");
++//#include <sys/cdefs.h>
++//__FBSDID("$FreeBSD$");
/*
* fabs(x) returns the absolute value of x.
@@ -598,6 +569,7 @@ diff --git a/modules/fdlibm/src/s_fabs.cpp b/modules/fdlibm/src/s_fabs.cpp
#include "math_private.h"
+ double
diff --git a/modules/fdlibm/src/s_floor.cpp b/modules/fdlibm/src/s_floor.cpp
--- a/modules/fdlibm/src/s_floor.cpp
+++ b/modules/fdlibm/src/s_floor.cpp
@@ -673,7 +645,7 @@ diff --git a/modules/fdlibm/src/s_log1p.cpp b/modules/fdlibm/src/s_log1p.cpp
diff --git a/modules/fdlibm/src/s_nearbyint.cpp b/modules/fdlibm/src/s_nearbyint.cpp
--- a/modules/fdlibm/src/s_nearbyint.cpp
+++ b/modules/fdlibm/src/s_nearbyint.cpp
-@@ -19,18 +19,18 @@
+@@ -21,18 +21,18 @@
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
@@ -745,7 +717,8 @@ diff --git a/modules/fdlibm/src/s_rintf.cpp b/modules/fdlibm/src/s_rintf.cpp
diff --git a/modules/fdlibm/src/s_scalbn.cpp b/modules/fdlibm/src/s_scalbn.cpp
--- a/modules/fdlibm/src/s_scalbn.cpp
+++ b/modules/fdlibm/src/s_scalbn.cpp
-@@ -6,27 +6,27 @@
+@@ -5,18 +5,18 @@
+ *
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
@@ -753,10 +726,10 @@ diff --git a/modules/fdlibm/src/s_scalbn.cpp b/modules/fdlibm/src/s_scalbn.cpp
* ====================================================
*/
- #ifndef lint
--static char rcsid[] = "$FreeBSD$";
-+//static char rcsid[] = "$FreeBSD$";
- #endif
+-#include <sys/cdefs.h>
+-__FBSDID("$FreeBSD$");
++//#include <sys/cdefs.h>
++//__FBSDID("$FreeBSD$");
/*
* scalbn (double x, int n)
@@ -765,16 +738,6 @@ diff --git a/modules/fdlibm/src/s_scalbn.cpp b/modules/fdlibm/src/s_scalbn.cpp
* exponentiation or a multiplication.
*/
--#include <sys/cdefs.h>
-+//#include <sys/cdefs.h>
- #include <float.h>
-
- #include "math_private.h"
-
- static const double
- two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */
- twom54 = 5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */
- huge = 1.0e+300,
diff --git a/modules/fdlibm/src/s_tanh.cpp b/modules/fdlibm/src/s_tanh.cpp
--- a/modules/fdlibm/src/s_tanh.cpp
+++ b/modules/fdlibm/src/s_tanh.cpp
diff --git a/modules/fdlibm/patches/10_remove_unused_function_from_k_exp_cpp.patch b/modules/fdlibm/patches/10_remove_unused_function_from_k_exp_cpp.patch
index 712110dc8..36aee9bb6 100644
--- a/modules/fdlibm/patches/10_remove_unused_function_from_k_exp_cpp.patch
+++ b/modules/fdlibm/patches/10_remove_unused_function_from_k_exp_cpp.patch
@@ -1,7 +1,7 @@
diff --git a/modules/fdlibm/src/k_exp.cpp b/modules/fdlibm/src/k_exp.cpp
--- a/modules/fdlibm/src/k_exp.cpp
+++ b/modules/fdlibm/src/k_exp.cpp
-@@ -22,18 +22,16 @@
+@@ -24,18 +24,16 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
@@ -20,7 +20,7 @@ diff --git a/modules/fdlibm/src/k_exp.cpp b/modules/fdlibm/src/k_exp.cpp
/*
* Compute exp(x), scaled to avoid spurious overflow. An exponent is
* returned separately in 'expt'.
-@@ -76,32 +74,8 @@ double
+@@ -78,32 +76,8 @@ double
double exp_x, scale;
int ex_expt;
diff --git a/modules/fdlibm/patches/12_define_u_int32_t_and_u_int64_t_on_windows.patch b/modules/fdlibm/patches/12_define_u_int32_t_and_u_int64_t_on_windows.patch
index c0e9814aa..106d64dbc 100644
--- a/modules/fdlibm/patches/12_define_u_int32_t_and_u_int64_t_on_windows.patch
+++ b/modules/fdlibm/patches/12_define_u_int32_t_and_u_int64_t_on_windows.patch
@@ -1,7 +1,7 @@
diff --git a/modules/fdlibm/src/math_private.h b/modules/fdlibm/src/math_private.h
--- a/modules/fdlibm/src/math_private.h
+++ b/modules/fdlibm/src/math_private.h
-@@ -33,16 +33,21 @@
+@@ -33,16 +33,23 @@
* to dig two 32 bit words out of the 64 bit IEEE floating point
* value. That is non-ANSI, and, moreover, the gcc instruction
* scheduler gets it wrong. We instead use the following macros.
@@ -17,11 +17,11 @@ diff --git a/modules/fdlibm/src/math_private.h b/modules/fdlibm/src/math_private
+#define u_int64_t uint64_t
+#endif
+
- /*
- * A union which permits us to convert between a double and two 32 bit
- * ints.
- */
+ /* A union which permits us to convert between a long double and
+ four 32 bit ints. */
#if MOZ_BIG_ENDIAN
typedef union
+ {
+ long double value;
diff --git a/modules/fdlibm/patches/13_define_strict_assign_even_if_flt_eval_method_is_not_defined.patch b/modules/fdlibm/patches/13_define_strict_assign_even_if_flt_eval_method_is_not_defined.patch
index 4b2a9541e..a6117e24b 100644
--- a/modules/fdlibm/patches/13_define_strict_assign_even_if_flt_eval_method_is_not_defined.patch
+++ b/modules/fdlibm/patches/13_define_strict_assign_even_if_flt_eval_method_is_not_defined.patch
@@ -1,7 +1,7 @@
diff --git a/modules/fdlibm/src/math_private.h b/modules/fdlibm/src/math_private.h
--- a/modules/fdlibm/src/math_private.h
+++ b/modules/fdlibm/src/math_private.h
-@@ -285,16 +285,27 @@ do { \
+@@ -328,16 +328,27 @@ do { \
if (sizeof(type) >= sizeof(long double)) \
(lval) = (rval); \
else { \
@@ -25,7 +25,7 @@ diff --git a/modules/fdlibm/src/math_private.h b/modules/fdlibm/src/math_private
/* Support switching the mode to FP_PE if necessary. */
#if defined(__i386__) && !defined(NO_FPSETPREC)
- #define ENTERI() \
- long double __retval; \
+ #define ENTERI() ENTERIT(long double)
+ #define ENTERIT(returntype) \
+ returntype __retval; \
fp_prec_t __oprec; \
- \
diff --git a/modules/fdlibm/patches/14_do_not_use_hexadecimal_floating_point_number.patch b/modules/fdlibm/patches/14_do_not_use_hexadecimal_floating_point_number.patch
index 627603448..85f511882 100644
--- a/modules/fdlibm/patches/14_do_not_use_hexadecimal_floating_point_number.patch
+++ b/modules/fdlibm/patches/14_do_not_use_hexadecimal_floating_point_number.patch
@@ -3,9 +3,9 @@ diff --git a/modules/fdlibm/src/e_exp.cpp b/modules/fdlibm/src/e_exp.cpp
+++ b/modules/fdlibm/src/e_exp.cpp
@@ -146,14 +146,17 @@ double
if(k >= -1021)
- INSERT_WORDS(twopk,0x3ff00000+(k<<20), 0);
+ INSERT_WORDS(twopk,((u_int32_t)(0x3ff+k))<<20, 0);
else
- INSERT_WORDS(twopk,0x3ff00000+((k+1000)<<20), 0);
+ INSERT_WORDS(twopk,((u_int32_t)(0x3ff+(k+1000)))<<20, 0);
c = x - t*(P1+t*(P2+t*(P3+t*(P4+t*P5))));
if(k==0) return one-((x*c)/(c-2.0)-x);
else y = one-((lo-(x*c)/(2.0-c))-hi);
diff --git a/modules/fdlibm/patches/15_remove_unused_rintl_function_from_s_nearbyint_cpp.patch b/modules/fdlibm/patches/15_remove_unused_rintl_function_from_s_nearbyint_cpp.patch
index 5648d3096..b64e281aa 100644
--- a/modules/fdlibm/patches/15_remove_unused_rintl_function_from_s_nearbyint_cpp.patch
+++ b/modules/fdlibm/patches/15_remove_unused_rintl_function_from_s_nearbyint_cpp.patch
@@ -1,7 +1,7 @@
diff --git a/modules/fdlibm/src/s_nearbyint.cpp b/modules/fdlibm/src/s_nearbyint.cpp
--- a/modules/fdlibm/src/s_nearbyint.cpp
+++ b/modules/fdlibm/src/s_nearbyint.cpp
-@@ -51,9 +51,8 @@ fn(type x) \
+@@ -53,9 +53,8 @@ fn(type x) \
fegetenv(&env); \
ret = rint(x); \
fesetenv(&env); \
diff --git a/modules/fdlibm/patches/15_use_safer_strict_assign_on_visual_studio.patch b/modules/fdlibm/patches/16_use_safer_strict_assign_on_visual_studio.patch
index 282edbb78..855f91a0d 100644
--- a/modules/fdlibm/patches/15_use_safer_strict_assign_on_visual_studio.patch
+++ b/modules/fdlibm/patches/16_use_safer_strict_assign_on_visual_studio.patch
@@ -1,7 +1,7 @@
diff --git a/modules/fdlibm/src/math_private.h b/modules/fdlibm/src/math_private.h
--- a/modules/fdlibm/src/math_private.h
+++ b/modules/fdlibm/src/math_private.h
-@@ -271,17 +271,17 @@ do { \
+@@ -314,17 +314,17 @@ do { \
/* The above works on non-i386 too, but we use this to check v. */
#define LD80C(m, ex, v) { .e = (v), }
#endif
@@ -20,4 +20,3 @@ diff --git a/modules/fdlibm/src/math_private.h b/modules/fdlibm/src/math_private
if (sizeof(type) >= sizeof(long double)) \
(lval) = (rval); \
else { \
-
diff --git a/modules/fdlibm/patches/17_exp_exact_result_for_positive_one.patch b/modules/fdlibm/patches/17_exp_exact_result_for_positive_one.patch
new file mode 100644
index 000000000..9cda2beef
--- /dev/null
+++ b/modules/fdlibm/patches/17_exp_exact_result_for_positive_one.patch
@@ -0,0 +1,40 @@
+diff --git a/modules/fdlibm/src/e_exp.cpp b/modules/fdlibm/src/e_exp.cpp
+--- a/modules/fdlibm/src/e_exp.cpp
++++ b/modules/fdlibm/src/e_exp.cpp
+@@ -91,16 +91,18 @@ ln2LO[2] ={ 1.90821492927058770002e-10
+ -1.90821492927058770002e-10,},/* 0xbdea39ef, 0x35793c76 */
+ invln2 = 1.44269504088896338700e+00, /* 0x3ff71547, 0x652b82fe */
+ P1 = 1.66666666666666019037e-01, /* 0x3FC55555, 0x5555553E */
+ P2 = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */
+ P3 = 6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */
+ P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */
+ P5 = 4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */
+
++static const double E = 2.7182818284590452354; /* e */
++
+ static volatile double
+ huge = 1.0e+300,
+ twom1000= 9.33263618503218878990e-302; /* 2**-1000=0x01700000,0*/
+
+ double
+ __ieee754_exp(double x) /* default IEEE double exp */
+ {
+ double y,hi=0.0,lo=0.0,c,t,twopk;
+@@ -122,16 +124,17 @@ double
+ }
+ if(x > o_threshold) return huge*huge; /* overflow */
+ if(x < u_threshold) return twom1000*twom1000; /* underflow */
+ }
+
+ /* argument reduction */
+ if(hx > 0x3fd62e42) { /* if |x| > 0.5 ln2 */
+ if(hx < 0x3FF0A2B2) { /* and |x| < 1.5 ln2 */
++ if (x == 1.0) return E;
+ hi = x-ln2HI[xsb]; lo=ln2LO[xsb]; k = 1-xsb-xsb;
+ } else {
+ k = (int)(invln2*x+halF[xsb]);
+ t = k;
+ hi = x - t*ln2HI[0]; /* t*ln2HI is exact here */
+ lo = t*ln2LO[0];
+ }
+ STRICT_ASSIGN(double, x, hi - lo);
diff --git a/modules/fdlibm/patches/18_use_stdlib_sqrt.patch b/modules/fdlibm/patches/18_use_stdlib_sqrt.patch
new file mode 100644
index 000000000..1f87dd73b
--- /dev/null
+++ b/modules/fdlibm/patches/18_use_stdlib_sqrt.patch
@@ -0,0 +1,255 @@
+diff --git a/modules/fdlibm/src/e_acos.cpp b/modules/fdlibm/src/e_acos.cpp
+--- a/modules/fdlibm/src/e_acos.cpp
++++ b/modules/fdlibm/src/e_acos.cpp
+@@ -33,16 +33,17 @@
+ *
+ * Special cases:
+ * if x is NaN, return x itself;
+ * if |x|>1, return NaN with invalid signal.
+ *
+ * Function needed: sqrt
+ */
+
++#include <cmath>
+ #include <float.h>
+
+ #include "math_private.h"
+
+ static const double
+ one= 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
+ pi = 3.14159265358979311600e+00, /* 0x400921FB, 0x54442D18 */
+ pio2_hi = 1.57079632679489655800e+00; /* 0x3FF921FB, 0x54442D18 */
+@@ -82,23 +83,23 @@ double
+ p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
+ q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
+ r = p/q;
+ return pio2_hi - (x - (pio2_lo-x*r));
+ } else if (hx<0) { /* x < -0.5 */
+ z = (one+x)*0.5;
+ p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
+ q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
+- s = sqrt(z);
++ s = std::sqrt(z);
+ r = p/q;
+ w = r*s-pio2_lo;
+ return pi - 2.0*(s+w);
+ } else { /* x > 0.5 */
+ z = (one-x)*0.5;
+- s = sqrt(z);
++ s = std::sqrt(z);
+ df = s;
+ SET_LOW_WORD(df,0);
+ c = (z-df*df)/(s+df);
+ p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
+ q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
+ r = p/q;
+ w = r*s+c;
+ return 2.0*(df+w);
+diff --git a/modules/fdlibm/src/e_acosh.cpp b/modules/fdlibm/src/e_acosh.cpp
+--- a/modules/fdlibm/src/e_acosh.cpp
++++ b/modules/fdlibm/src/e_acosh.cpp
+@@ -24,16 +24,17 @@
+ * acosh(x) := log(2x-1/(sqrt(x*x-1)+x)) if x>2; else
+ * acosh(x) := log1p(t+sqrt(2.0*t+t*t)); where t=x-1.
+ *
+ * Special cases:
+ * acosh(x) is NaN with signal if x<1.
+ * acosh(NaN) is NaN without signal.
+ */
+
++#include <cmath>
+ #include <float.h>
+
+ #include "math_private.h"
+
+ static const double
+ one = 1.0,
+ ln2 = 6.93147180559945286227e-01; /* 0x3FE62E42, 0xFEFA39EF */
+
+@@ -50,14 +51,14 @@ double
+ if(hx >=0x7ff00000) { /* x is inf of NaN */
+ return x+x;
+ } else
+ return __ieee754_log(x)+ln2; /* acosh(huge)=log(2x) */
+ } else if(((hx-0x3ff00000)|lx)==0) {
+ return 0.0; /* acosh(1) = 0 */
+ } else if (hx > 0x40000000) { /* 2**28 > x > 2 */
+ t=x*x;
+- return __ieee754_log(2.0*x-one/(x+sqrt(t-one)));
++ return __ieee754_log(2.0*x-one/(x+std::sqrt(t-one)));
+ } else { /* 1<x<2 */
+ t = x-one;
+- return log1p(t+sqrt(2.0*t+t*t));
++ return log1p(t+std::sqrt(2.0*t+t*t));
+ }
+ }
+diff --git a/modules/fdlibm/src/e_asin.cpp b/modules/fdlibm/src/e_asin.cpp
+--- a/modules/fdlibm/src/e_asin.cpp
++++ b/modules/fdlibm/src/e_asin.cpp
+@@ -39,16 +39,17 @@
+ * = pio4_hi+(pio4-2f)-(2s*z*R(z)-(pio2_lo+2c))
+ *
+ * Special cases:
+ * if x is NaN, return x itself;
+ * if |x|>1, return NaN with invalid signal.
+ *
+ */
+
++#include <cmath>
+ #include <float.h>
+
+ #include "math_private.h"
+
+ static const double
+ one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
+ huge = 1.000e+300,
+ pio2_hi = 1.57079632679489655800e+00, /* 0x3FF921FB, 0x54442D18 */
+@@ -90,17 +91,17 @@ double
+ w = p/q;
+ return x+x*w;
+ }
+ /* 1> |x|>= 0.5 */
+ w = one-fabs(x);
+ t = w*0.5;
+ p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5)))));
+ q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4)));
+- s = sqrt(t);
++ s = std::sqrt(t);
+ if(ix>=0x3FEF3333) { /* if |x| > 0.975 */
+ w = p/q;
+ t = pio2_hi-(2.0*(s+s*w)-pio2_lo);
+ } else {
+ w = s;
+ SET_LOW_WORD(w,0);
+ c = (t-w*w)/(s+w);
+ r = p/q;
+diff --git a/modules/fdlibm/src/e_hypot.cpp b/modules/fdlibm/src/e_hypot.cpp
+--- a/modules/fdlibm/src/e_hypot.cpp
++++ b/modules/fdlibm/src/e_hypot.cpp
+@@ -41,16 +41,17 @@
+ * hypot(x,y) is INF if x or y is +INF or -INF; else
+ * hypot(x,y) is NAN if x or y is NAN.
+ *
+ * Accuracy:
+ * hypot(x,y) returns sqrt(x^2+y^2) with error less
+ * than 1 ulps (units in the last place)
+ */
+
++#include <cmath>
+ #include <float.h>
+
+ #include "math_private.h"
+
+ double
+ __ieee754_hypot(double x, double y)
+ {
+ double a,b,t1,t2,y1,y2,w;
+@@ -100,26 +101,26 @@ double
+ }
+ }
+ /* medium size a and b */
+ w = a-b;
+ if (w>b) {
+ t1 = 0;
+ SET_HIGH_WORD(t1,ha);
+ t2 = a-t1;
+- w = sqrt(t1*t1-(b*(-b)-t2*(a+t1)));
++ w = std::sqrt(t1*t1-(b*(-b)-t2*(a+t1)));
+ } else {
+ a = a+a;
+ y1 = 0;
+ SET_HIGH_WORD(y1,hb);
+ y2 = b - y1;
+ t1 = 0;
+ SET_HIGH_WORD(t1,ha+0x00100000);
+ t2 = a - t1;
+- w = sqrt(t1*y1-(w*(-w)-(t1*y2+t2*b)));
++ w = std::sqrt(t1*y1-(w*(-w)-(t1*y2+t2*b)));
+ }
+ if(k!=0) {
+ u_int32_t high;
+ t1 = 1.0;
+ GET_HIGH_WORD(high,t1);
+ SET_HIGH_WORD(t1,high+(k<<20));
+ return t1*w;
+ } else return w;
+diff --git a/modules/fdlibm/src/e_pow.cpp b/modules/fdlibm/src/e_pow.cpp
+--- a/modules/fdlibm/src/e_pow.cpp
++++ b/modules/fdlibm/src/e_pow.cpp
+@@ -52,16 +52,18 @@
+ *
+ * Constants :
+ * The hexadecimal values are the intended ones for the following
+ * constants. The decimal values may be used, provided that the
+ * compiler will convert from decimal to binary accurately enough
+ * to produce the hexadecimal values shown.
+ */
+
++#include <cmath>
++
+ #include <float.h>
+ #include "math_private.h"
+
+ static const double
+ bp[] = {1.0, 1.5,},
+ dp_h[] = { 0.0, 5.84962487220764160156e-01,}, /* 0x3FE2B803, 0x40000000 */
+ dp_l[] = { 0.0, 1.35003920212974897128e-08,}, /* 0x3E4CFDEB, 0x43CFD006 */
+ zero = 0.0,
+@@ -151,17 +153,17 @@ double
+ return (hy<0)?-y: zero;
+ }
+ if(iy==0x3ff00000) { /* y is +-1 */
+ if(hy<0) return one/x; else return x;
+ }
+ if(hy==0x40000000) return x*x; /* y is 2 */
+ if(hy==0x3fe00000) { /* y is 0.5 */
+ if(hx>=0) /* x >= +0 */
+- return sqrt(x);
++ return std::sqrt(x);
+ }
+ }
+
+ ax = fabs(x);
+ /* special value of x */
+ if(lx==0) {
+ if(ix==0x7ff00000||ix==0||ix==0x3ff00000){
+ z = ax; /*x is +-0,+-inf,+-1*/
+diff --git a/modules/fdlibm/src/s_asinh.cpp b/modules/fdlibm/src/s_asinh.cpp
+--- a/modules/fdlibm/src/s_asinh.cpp
++++ b/modules/fdlibm/src/s_asinh.cpp
+@@ -19,16 +19,17 @@
+ * asinh(x) = sign(x) * log [ |x| + sqrt(x*x+1) ]
+ * we have
+ * asinh(x) := x if 1+x*x=1,
+ * := sign(x)*(log(x)+ln2)) for large |x|, else
+ * := sign(x)*log(2|x|+1/(|x|+sqrt(x*x+1))) if|x|>2, else
+ * := sign(x)*log1p(|x| + x^2/(1 + sqrt(1+x^2)))
+ */
+
++#include <cmath>
+ #include <float.h>
+
+ #include "math_private.h"
+
+ static const double
+ one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
+ ln2 = 6.93147180559945286227e-01, /* 0x3FE62E42, 0xFEFA39EF */
+ huge= 1.00000000000000000000e+300;
+@@ -43,15 +44,15 @@ asinh(double x)
+ if(ix>=0x7ff00000) return x+x; /* x is inf or NaN */
+ if(ix< 0x3e300000) { /* |x|<2**-28 */
+ if(huge+x>one) return x; /* return x inexact except 0 */
+ }
+ if(ix>0x41b00000) { /* |x| > 2**28 */
+ w = __ieee754_log(fabs(x))+ln2;
+ } else if (ix>0x40000000) { /* 2**28 > |x| > 2.0 */
+ t = fabs(x);
+- w = __ieee754_log(2.0*t+one/(__ieee754_sqrt(x*x+one)+t));
++ w = __ieee754_log(2.0*t+one/(std::sqrt(x*x+one)+t));
+ } else { /* 2.0 > |x| > 2**-28 */
+ t = x*x;
+- w =log1p(fabs(x)+t/(one+__ieee754_sqrt(one+t)));
++ w =log1p(fabs(x)+t/(one+std::sqrt(one+t)));
+ }
+ if(hx>0) return w; else return -w;
+ }
diff --git a/modules/fdlibm/patches/19_remove_unneeded_round_to_integer_helpers.patch b/modules/fdlibm/patches/19_remove_unneeded_round_to_integer_helpers.patch
new file mode 100644
index 000000000..6d1baa23a
--- /dev/null
+++ b/modules/fdlibm/patches/19_remove_unneeded_round_to_integer_helpers.patch
@@ -0,0 +1,130 @@
+diff --git a/modules/fdlibm/src/math_private.h b/modules/fdlibm/src/math_private.h
+--- a/modules/fdlibm/src/math_private.h
++++ b/modules/fdlibm/src/math_private.h
+@@ -586,126 +586,16 @@ CMPLXL(long double x, long double y)
+ REALPART(z) = x;
+ IMAGPART(z) = y;
+ return (z.f);
+ }
+ #endif
+
+ #endif /* _COMPLEX_H */
+
+-/*
+- * The rnint() family rounds to the nearest integer for a restricted range
+- * range of args (up to about 2**MANT_DIG). We assume that the current
+- * rounding mode is FE_TONEAREST so that this can be done efficiently.
+- * Extra precision causes more problems in practice, and we only centralize
+- * this here to reduce those problems, and have not solved the efficiency
+- * problems. The exp2() family uses a more delicate version of this that
+- * requires extracting bits from the intermediate value, so it is not
+- * centralized here and should copy any solution of the efficiency problems.
+- */
+-
+-static inline double
+-rnint(__double_t x)
+-{
+- /*
+- * This casts to double to kill any extra precision. This depends
+- * on the cast being applied to a double_t to avoid compiler bugs
+- * (this is a cleaner version of STRICT_ASSIGN()). This is
+- * inefficient if there actually is extra precision, but is hard
+- * to improve on. We use double_t in the API to minimise conversions
+- * for just calling here. Note that we cannot easily change the
+- * magic number to the one that works directly with double_t, since
+- * the rounding precision is variable at runtime on x86 so the
+- * magic number would need to be variable. Assuming that the
+- * rounding precision is always the default is too fragile. This
+- * and many other complications will move when the default is
+- * changed to FP_PE.
+- */
+- return ((double)(x + 0x1.8p52) - 0x1.8p52);
+-}
+-
+-static inline float
+-rnintf(__float_t x)
+-{
+- /*
+- * As for rnint(), except we could just call that to handle the
+- * extra precision case, usually without losing efficiency.
+- */
+- return ((float)(x + 0x1.8p23F) - 0x1.8p23F);
+-}
+-
+-#ifdef LDBL_MANT_DIG
+-/*
+- * The complications for extra precision are smaller for rnintl() since it
+- * can safely assume that the rounding precision has been increased from
+- * its default to FP_PE on x86. We don't exploit that here to get small
+- * optimizations from limiting the rangle to double. We just need it for
+- * the magic number to work with long doubles. ld128 callers should use
+- * rnint() instead of this if possible. ld80 callers should prefer
+- * rnintl() since for amd64 this avoids swapping the register set, while
+- * for i386 it makes no difference (assuming FP_PE), and for other arches
+- * it makes little difference.
+- */
+-static inline long double
+-rnintl(long double x)
+-{
+- return (x + __CONCAT(0x1.8p, LDBL_MANT_DIG) / 2 -
+- __CONCAT(0x1.8p, LDBL_MANT_DIG) / 2);
+-}
+-#endif /* LDBL_MANT_DIG */
+-
+-/*
+- * irint() and i64rint() give the same result as casting to their integer
+- * return type provided their arg is a floating point integer. They can
+- * sometimes be more efficient because no rounding is required.
+- */
+-#if (defined(amd64) || defined(__i386__)) && defined(__GNUCLIKE_ASM)
+-#define irint(x) \
+- (sizeof(x) == sizeof(float) && \
+- sizeof(__float_t) == sizeof(long double) ? irintf(x) : \
+- sizeof(x) == sizeof(double) && \
+- sizeof(__double_t) == sizeof(long double) ? irintd(x) : \
+- sizeof(x) == sizeof(long double) ? irintl(x) : (int)(x))
+-#else
+-#define irint(x) ((int)(x))
+-#endif
+-
+-#define i64rint(x) ((int64_t)(x)) /* only needed for ld128 so not opt. */
+-
+-#if defined(__i386__) && defined(__GNUCLIKE_ASM)
+-static __inline int
+-irintf(float x)
+-{
+- int n;
+-
+- __asm("fistl %0" : "=m" (n) : "t" (x));
+- return (n);
+-}
+-
+-static __inline int
+-irintd(double x)
+-{
+- int n;
+-
+- __asm("fistl %0" : "=m" (n) : "t" (x));
+- return (n);
+-}
+-#endif
+-
+-#if (defined(__amd64__) || defined(__i386__)) && defined(__GNUCLIKE_ASM)
+-static __inline int
+-irintl(long double x)
+-{
+- int n;
+-
+- __asm("fistl %0" : "=m" (n) : "t" (x));
+- return (n);
+-}
+-#endif
+-
+ #ifdef DEBUG
+ #if defined(__amd64__) || defined(__i386__)
+ #define breakpoint() asm("int $3")
+ #else
+ #include <signal.h>
+
+ #define breakpoint() raise(SIGTRAP)
+ #endif