Backed out 3 changesets (bug 1760633) for causing Spidermonkey bustages. CLOSED TREE

Backed out changeset 527f857a91f8 (bug 1760633)
Backed out changeset ee8ecdac4be5 (bug 1760633)
Backed out changeset addec3dc0f80 (bug 1760633)
This commit is contained in:
Stanca Serban 2023-01-06 17:21:52 +02:00
Родитель 43336c5845
Коммит 94f1cf5515
35 изменённых файлов: 40 добавлений и 2984 удалений

Просмотреть файл

@ -17,7 +17,7 @@ origin:
# Revision to pull in
# Must be a long or short commit SHA (long preferred)
revision: bd5e624a861433dee76fe00a8acedc9564425332
revision: 369ea0520a3061c07400d7cd32172efb6af39815
license: "BSD-2-Clause"
license-file: LICENSE

Просмотреть файл

@ -1,7 +1,7 @@
diff --git a/fdlibm.h b/fdlibm.h
--- a/fdlibm.h
+++ b/fdlibm.h
@@ -12,504 +12,66 @@
@@ -12,504 +12,51 @@
/*
* from: @(#)fdlibm.h 5.1 93/09/24
* $FreeBSD$
@ -130,7 +130,7 @@ diff --git a/fdlibm.h b/fdlibm.h
-#define M_LN2 0.69314718055994530942 /* log e2 */
-#define M_LN10 2.30258509299404568402 /* log e10 */
-#define M_PI 3.14159265358979323846 /* pi */
#define M_PI_2 1.57079632679489661923 /* pi/2 */
-#define M_PI_2 1.57079632679489661923 /* pi/2 */
-#define M_PI_4 0.78539816339744830962 /* pi/4 */
-#define M_1_PI 0.31830988618379067154 /* 1/pi */
-#define M_2_PI 0.63661977236758134308 /* 2/pi */
@ -256,7 +256,7 @@ diff --git a/fdlibm.h b/fdlibm.h
double cbrt(double);
-double erf(double);
-double erfc(double);
double exp2(double);
-double exp2(double);
double expm1(double);
-double fma(double, double, double);
double hypot(double, double);
@ -330,20 +330,20 @@ diff --git a/fdlibm.h b/fdlibm.h
-
-/* float versions of ANSI/POSIX functions */
-#if __ISO_C_VISIBLE >= 1999
float acosf(float);
float asinf(float);
float atanf(float);
-float acosf(float);
-float asinf(float);
-float atanf(float);
-float atan2f(float, float);
float cosf(float);
float sinf(float);
float tanf(float);
-float cosf(float);
-float sinf(float);
-float tanf(float);
-
-float coshf(float);
-float sinhf(float);
-float tanhf(float);
-
float exp2f(float);
float expf(float);
-float exp2f(float);
-float expf(float);
-float expm1f(float);
-float frexpf(float, int *); /* fundamentally !__pure2 */
-int ilogbf(float) __pure2;
@ -351,15 +351,14 @@ diff --git a/fdlibm.h b/fdlibm.h
-float log10f(float);
-float log1pf(float);
-float log2f(float);
float logf(float);
-float logf(float);
-float modff(float, float *); /* fundamentally !__pure2 */
-
float powf(float, float);
float sqrtf(float);
-float powf(float, float);
-float sqrtf(float);
float ceilf(float);
-float fabsf(float) __pure2;
+float fabsf(float);
float floorf(float);
-float fmodf(float, float);
-float roundf(float);
@ -387,7 +386,7 @@ diff --git a/fdlibm.h b/fdlibm.h
-float remquof(float, float, int *);
float rintf(float);
-float scalblnf(float, long);
float scalbnf(float, int);
-float scalbnf(float, int);
float truncf(float);
-float fdimf(float, float);

Просмотреть файл

@ -1,6 +1,7 @@
--- a/fdlibm.h 2022-12-13 14:27:29.092805897 -0500
+++ b/fdlibm.h 2022-12-13 14:27:37.444836016 -0500
@@ -9,18 +9,21 @@
diff --git a/fdlibm.h b/fdlibm.h
--- a/fdlibm.h
+++ b/fdlibm.h
@@ -9,18 +9,18 @@
* ====================================================
*/
@ -12,26 +13,23 @@
-#ifndef _MATH_H_
-#define _MATH_H_
+#ifndef mozilla_imported_fdlibm_h
+#define mozilla_imported_fdlibm_h
+#ifndef M_PI_2
#define M_PI_2 1.57079632679489661923 /* pi/2 */
+#endif
+
+#define mozilla_imported_fdlibm_h
double acos(double);
double asin(double);
double atan(double);
double atan2(double, double);
double cos(double);
double sin(double);
@@ -69,9 +72,9 @@
double tan(double);
@@ -54,9 +54,9 @@ double scalbn(double, int);
double trunc(double);
float ceilf(float);
float fabsf(float);
float floorf(float);
float nearbyintf(float);
float rintf(float);
float scalbnf(float, int);
float truncf(float);
-#endif /* !_MATH_H_ */
+#endif /* !mozilla_imported_fdlibm_h */
+#endif /* mozilla_imported_fdlibm_h */

Просмотреть файл

@ -1,20 +1,17 @@
--- a/fdlibm.h 2022-12-13 14:28:36.393051585 -0500
+++ b/fdlibm.h 2022-12-13 14:28:47.533092878 -0500
@@ -12,19 +12,21 @@
diff --git a/fdlibm.h b/fdlibm.h
--- a/fdlibm.h
+++ b/fdlibm.h
@@ -12,16 +12,18 @@
/*
* from: @(#)fdlibm.h 5.1 93/09/24
* $FreeBSD$
*/
#ifndef mozilla_imported_fdlibm_h
#define mozilla_imported_fdlibm_h
#define mozilla_imported_fdlibm_h
+namespace fdlibm {
+
#ifndef M_PI_2
#define M_PI_2 1.57079632679489661923 /* pi/2 */
#endif
double acos(double);
double asin(double);
double atan(double);
@ -22,15 +19,16 @@
double cos(double);
double sin(double);
double tan(double);
@@ -69,9 +71,11 @@
@@ -54,9 +56,11 @@ double scalbn(double, int);
double trunc(double);
float ceilf(float);
float fabsf(float);
float floorf(float);
float nearbyintf(float);
float rintf(float);
float scalbnf(float, int);
float truncf(float);
+} /* namespace fdlibm */
+
#endif /* !mozilla_imported_fdlibm_h */
#endif /* mozilla_imported_fdlibm_h */

Просмотреть файл

@ -866,327 +866,3 @@ diff --git a/s_truncf.cpp b/s_truncf.cpp
truncf(float x)
{
int32_t i0,j0;
--- a/e_acosf.cpp 2022-12-11 21:15:50.058431053 -0500
+++ b/e_acosf.cpp_new 2022-12-11 21:13:10.532515637 -0500
@@ -12,15 +12,14 @@
* is preserved.
* ====================================================
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include "math.h"
#include "math_private.h"
static const float
one = 1.0000000000e+00, /* 0x3F800000 */
pi = 3.1415925026e+00, /* 0x40490fda */
pio2_hi = 1.5707962513e+00; /* 0x3fc90fda */
static volatile float
--- a/e_asinf.cpp 2022-12-11 21:15:50.486437124 -0500
+++ b/e_asinf.cpp_new 2022-12-11 21:13:07.876498396 -0500
@@ -12,15 +12,14 @@
* is preserved.
* ====================================================
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include "math.h"
#include "math_private.h"
static const float
one = 1.0000000000e+00, /* 0x3F800000 */
huge = 1.000e+30,
/* coefficient for R(x^2) */
pS0 = 1.6666586697e-01,
--- a/e_expf.cpp 2022-12-11 21:15:51.250447960 -0500
+++ b/e_expf.cpp_new 2022-12-11 21:13:05.212481099 -0500
@@ -14,15 +14,14 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <float.h>
-#include "math.h"
#include "math_private.h"
static const float
one = 1.0,
halF[2] = {0.5,-0.5,},
o_threshold= 8.8721679688e+01, /* 0x42b17180 */
u_threshold= -1.0397208405e+02, /* 0xc2cff1b5 */
--- a/e_logf.cpp 2022-12-11 21:15:51.978458278 -0500
+++ b/e_logf.cpp_new 2022-12-11 21:13:02.644464418 -0500
@@ -12,15 +12,14 @@
* is preserved.
* ====================================================
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include "math.h"
#include "math_private.h"
static const float
ln2_hi = 6.9313812256e-01, /* 0x3f317180 */
ln2_lo = 9.0580006145e-06, /* 0x3717f7d1 */
two25 = 3.355443200e+07, /* 0x4c000000 */
/* |(log(1+s)-log(1-s))/s - Lg(s)| < 2**-34.24 (~[-4.95e-11, 4.97e-11]). */
--- a/e_powf.cpp 2022-12-11 21:15:52.242462016 -0500
+++ b/e_powf.cpp_new 2022-12-11 21:13:00.164448306 -0500
@@ -12,15 +12,14 @@
* is preserved.
* ====================================================
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include "math.h"
#include "math_private.h"
static const float
bp[] = {1.0, 1.5,},
dp_h[] = { 0.0, 5.84960938e-01,}, /* 0x3f15c000 */
dp_l[] = { 0.0, 1.56322085e-06,}, /* 0x35d1cfdc */
zero = 0.0,
--- a/e_rem_pio2f.cpp 2022-12-11 21:15:52.626467454 -0500
+++ b/e_rem_pio2f.cpp_new 2022-12-11 21:12:57.300429693 -0500
@@ -22,15 +22,14 @@
* return the remainder of x rem pi/2 in *y
* use double precision for everything except passing x
* use __kernel_rem_pio2() for large x
*/
#include <float.h>
-#include "math.h"
#include "math_private.h"
/*
* invpio2: 53 bits of 2/pi
* pio2_1: first 25 bits of pi/2
* pio2_1t: pi/2 - pio2_1
*/
--- a/e_sqrtf.cpp 2022-12-11 21:15:52.922471645 -0500
+++ b/e_sqrtf.cpp_new 2022-12-11 21:12:54.596412113 -0500
@@ -13,15 +13,14 @@
* ====================================================
*/
#ifndef lint
static char rcsid[] = "$FreeBSD$";
#endif
-#include "math.h"
#include "math_private.h"
#ifdef USE_BUILTIN_SQRTF
float
__ieee754_sqrtf(float x)
{
return (__builtin_sqrtf(x));
--- a/k_cosf.cpp 2022-12-11 21:15:53.178475268 -0500
+++ b/k_cosf.cpp_new 2022-12-11 21:12:52.012395309 -0500
@@ -15,15 +15,14 @@
*/
#ifndef INLINE_KERNEL_COSDF
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#endif
-#include "math.h"
#include "math_private.h"
/* |cos(x) - c(x)| < 2**-34.1 (~[-5.37e-11, 5.295e-11]). */
static const double
one = 1.0,
C0 = -0x1ffffffd0c5e81.0p-54, /* -0.499999997251031003120 */
C1 = 0x155553e1053a42.0p-57, /* 0.0416666233237390631894 */
--- a/k_expf.cpp 2022-12-11 21:15:53.434478888 -0500
+++ b/k_expf.cpp_new 2022-12-11 21:12:49.012375792 -0500
@@ -27,15 +27,14 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <complex.h>
-#include "math.h"
#include "math_private.h"
static const uint32_t k = 235; /* constant for reduction */
static const float kln2 = 162.88958740F; /* k * ln2 */
/*
* See k_exp.c for details.
--- a/k_sinf.cpp 2022-12-11 21:15:53.946486130 -0500
+++ b/k_sinf.cpp_new 2022-12-11 21:12:46.020356322 -0500
@@ -15,15 +15,14 @@
*/
#ifndef INLINE_KERNEL_SINDF
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#endif
-#include "math.h"
#include "math_private.h"
/* |sin(x)/x - s(x)| < 2**-37.5 (~[-4.89e-12, 4.824e-12]). */
static const double
S1 = -0x15555554cbac77.0p-55, /* -0.166666666416265235595 */
S2 = 0x111110896efbb2.0p-59, /* 0.0083333293858894631756 */
S3 = -0x1a00f9e2cae774.0p-65, /* -0.000198393348360966317347 */
--- a/k_tanf.cpp 2022-12-11 21:15:54.254490484 -0500
+++ b/k_tanf.cpp_new 2022-12-11 21:12:42.972336479 -0500
@@ -14,15 +14,14 @@
*/
#ifndef INLINE_KERNEL_TANDF
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#endif
-#include "math.h"
#include "math_private.h"
/* |tan(x)/x - t(x)| < 2**-25.5 (~[-2e-08, 2e-08]). */
static const double
T[] = {
0x15554d3418c99f.0p-54, /* 0.333331395030791399758 */
0x1112fd38999f72.0p-55, /* 0.133392002712976742718 */
--- a/s_atanf.cpp 2022-12-11 21:15:54.670496364 -0500
+++ b/s_atanf.cpp_new 2022-12-11 21:12:39.940316733 -0500
@@ -12,15 +12,14 @@
* is preserved.
* ====================================================
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include "math.h"
#include "math_private.h"
static const float atanhi[] = {
4.6364760399e-01, /* atan(0.5)hi 0x3eed6338 */
7.8539812565e-01, /* atan(1.0)hi 0x3f490fda */
9.8279368877e-01, /* atan(1.5)hi 0x3f7b985e */
1.5707962513e+00, /* atan(inf)hi 0x3fc90fda */
--- a/s_cosf.cpp 2022-12-11 21:15:55.494508001 -0500
+++ b/s_cosf.cpp_new 2022-12-11 21:12:37.396300160 -0500
@@ -15,15 +15,14 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <float.h>
-#include "math.h"
#define INLINE_KERNEL_COSDF
#define INLINE_KERNEL_SINDF
#define INLINE_REM_PIO2F
#include "math_private.h"
#include "e_rem_pio2f.c"
#include "k_cosf.c"
#include "k_sinf.c"
--- a/s_exp2.cpp 2022-12-11 21:15:55.790512181 -0500
+++ b/s_exp2.cpp_new 2022-12-11 21:12:34.476281131 -0500
@@ -27,15 +27,14 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <float.h>
-#include "math.h"
#include "math_private.h"
#define TBLBITS 8
#define TBLSIZE (1 << TBLBITS)
static const double
redux = 0x1.8p52 / TBLSIZE,
--- a/s_exp2f.cpp 2022-12-11 21:15:55.926514101 -0500
+++ b/s_exp2f.cpp_new 2022-12-11 21:12:30.644256149 -0500
@@ -27,15 +27,14 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <float.h>
-#include "math.h"
#include "math_private.h"
#define TBLBITS 4
#define TBLSIZE (1 << TBLBITS)
static const float
redux = 0x1.8p23f / TBLSIZE,
--- a/s_fabsf.cpp 2022-12-11 21:15:56.202517995 -0500
+++ b/s_fabsf.cpp_new 2022-12-11 21:12:27.244233973 -0500
@@ -16,15 +16,14 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/*
* fabsf(x) returns the absolute value of x.
*/
-#include "math.h"
#include "math_private.h"
float
fabsf(float x)
{
u_int32_t ix;
GET_FLOAT_WORD(ix,x);
--- a/s_sinf.cpp 2022-12-11 21:15:57.618537960 -0500
+++ b/s_sinf.cpp_new 2022-12-11 21:12:24.684217270 -0500
@@ -15,15 +15,14 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <float.h>
-#include "math.h"
#define INLINE_KERNEL_COSDF
#define INLINE_KERNEL_SINDF
#define INLINE_REM_PIO2F
#include "math_private.h"
#include "e_rem_pio2f.c"
#include "k_cosf.c"
#include "k_sinf.c"
--- a/s_tanf.cpp 2022-12-11 21:15:57.930542357 -0500
+++ b/s_tanf.cpp_new 2022-12-11 21:12:20.420189437 -0500
@@ -15,15 +15,14 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <float.h>
-#include "math.h"
#define INLINE_KERNEL_TANDF
#define INLINE_REM_PIO2F
#include "math_private.h"
#include "e_rem_pio2f.c"
#include "k_tanf.c"
/* Small multiples of pi/2 rounded to double precision. */

Просмотреть файл

@ -1,7 +1,7 @@
diff --git a/math_private.h b/math_private.h
--- a/math_private.h
+++ b/math_private.h
@@ -867,16 +867,67 @@ irintl(long double x)
@@ -867,16 +867,53 @@ irintl(long double x)
#define __ieee754_j1f j1f
#define __ieee754_y0f y0f
#define __ieee754_y1f y1f
@ -11,34 +11,22 @@ diff --git a/math_private.h b/math_private.h
#define __ieee754_scalbf scalbf
+#define acos fdlibm::acos
+#define acosf fdlibm::acosf
+#define asin fdlibm::asin
+#define asinf fdlibm::asinf
+#define atan fdlibm::atan
+#define atanf fdlibm::atanf
+#define atan2 fdlibm::atan2
+#define cos fdlibm::cos
+#define cosf fdlibm::cosf
+#define sin fdlibm::sin
+#define sinf fdlibm::sinf
+#define tan fdlibm::tan
+#define tanf fdlibm::tanf
+#define cosh fdlibm::cosh
+#define sinh fdlibm::sinh
+#define tanh fdlibm::tanh
+#define exp fdlibm::exp
+#define expf fdlibm::expf
+#define exp2 fdlibm::exp2
+#define exp2f fdlibm::exp2f
+#define log fdlibm::log
+#define logf fdlibm::logf
+#define log10 fdlibm::log10
+#define pow fdlibm::pow
+#define powf fdlibm::powf
+#define ceil fdlibm::ceil
+#define ceilf fdlibm::ceilf
+#define fabs fdlibm::fabs
+#define fabsf fdlibm::fabsf
+#define floor fdlibm::floor
+#define acosh fdlibm::acosh
+#define asinh fdlibm::asinh
@ -51,7 +39,6 @@ diff --git a/math_private.h b/math_private.h
+#define scalb fdlibm::scalb
+#define copysign fdlibm::copysign
+#define scalbn fdlibm::scalbn
+#define scalbnf fdlibm::scalbnf
+#define trunc fdlibm::trunc
+#define truncf fdlibm::truncf
+#define floorf fdlibm::floorf
@ -59,7 +46,6 @@ diff --git a/math_private.h b/math_private.h
+#define nearbyintf fdlibm::nearbyintf
+#define rint fdlibm::rint
+#define rintf fdlibm::rintf
+#define sqrtf fdlibm::sqrtf
+
/* fdlibm kernel function */
int __kernel_rem_pio2(double*,double*,int,int,int);

Просмотреть файл

@ -431,16 +431,3 @@ diff --git a/s_trunc.cpp b/s_trunc.cpp
-#if LDBL_MANT_DIG == 53
-__weak_reference(trunc, truncl);
-#endif
--- a/s_exp2.cpp 2022-12-11 21:20:40.290068458 -0500
+++ b/s_exp2.cpp_new 2022-12-11 21:20:57.490259247 -0500
@@ -389,10 +389,6 @@
return (r * 2.0 * 0x1p1023);
return (r * twopk);
} else {
return (r * twopkp1000 * twom1000);
}
}
-
-#if (LDBL_MANT_DIG == 53)
-__weak_reference(exp2, exp2l);
-#endif

Просмотреть файл

@ -978,385 +978,3 @@ diff --git a/s_truncf.cpp b/s_truncf.cpp
* Bit twiddling.
* Exception:
* Inexact flag raised if x not equal to truncf(x).
--- a/e_acosf.cpp 2022-12-11 21:20:40.290068458 -0500
+++ b/e_acosf.cpp_new 2022-12-11 21:23:31.863880382 -0500
@@ -9,16 +9,16 @@
* Developed at SunPro, 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$");
#include "math_private.h"
static const float
one = 1.0000000000e+00, /* 0x3F800000 */
pi = 3.1415925026e+00, /* 0x40490fda */
pio2_hi = 1.5707962513e+00; /* 0x3fc90fda */
--- a/e_asinf.cpp 2022-12-11 21:20:40.290068458 -0500
+++ b/e_asinf.cpp_new 2022-12-11 21:23:31.875880502 -0500
@@ -9,16 +9,16 @@
* Developed at SunPro, 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$");
#include "math_private.h"
static const float
one = 1.0000000000e+00, /* 0x3F800000 */
huge = 1.000e+30,
/* coefficient for R(x^2) */
--- a/e_expf.cpp 2022-12-11 21:20:40.290068458 -0500
+++ b/e_expf.cpp_new 2022-12-11 21:23:31.895880703 -0500
@@ -9,16 +9,16 @@
* Developed at SunPro, 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$");
#include <float.h>
#include "math_private.h"
static const float
one = 1.0,
--- a/e_logf.cpp 2022-12-11 21:20:40.290068458 -0500
+++ b/e_logf.cpp_new 2022-12-11 21:23:31.935881104 -0500
@@ -9,16 +9,16 @@
* Developed at SunPro, 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$");
#include "math_private.h"
static const float
ln2_hi = 6.9313812256e-01, /* 0x3f317180 */
ln2_lo = 9.0580006145e-06, /* 0x3717f7d1 */
two25 = 3.355443200e+07, /* 0x4c000000 */
--- a/e_powf.cpp 2022-12-11 21:20:40.290068458 -0500
+++ b/e_powf.cpp_new 2022-12-11 21:23:31.971881465 -0500
@@ -9,16 +9,16 @@
* Developed at SunPro, 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$");
#include "math_private.h"
static const float
bp[] = {1.0, 1.5,},
dp_h[] = { 0.0, 5.84960938e-01,}, /* 0x3f15c000 */
dp_l[] = { 0.0, 1.56322085e-06,}, /* 0x35d1cfdc */
--- a/e_rem_pio2f.cpp 2022-12-11 21:20:40.290068458 -0500
+++ b/e_rem_pio2f.cpp_new 2022-12-11 21:23:32.015881905 -0500
@@ -10,16 +10,16 @@
* Developed at SunPro, 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_rem_pio2f(x,y)
*
* return the remainder of x rem pi/2 in *y
* use double precision for everything except passing x
* use __kernel_rem_pio2() for large x
*/
--- b/k_cosf.cpp 2022-12-11 21:20:40.290068458 -0500
+++ b/k_cosf.cpp_new 2022-12-11 21:23:32.051882266 -0500
@@ -11,16 +11,16 @@
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
#ifndef INLINE_KERNEL_COSDF
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//#include <sys/cdefs.h>
+//__FBSDID("$FreeBSD$");
#endif
#include "math_private.h"
/* |cos(x) - c(x)| < 2**-34.1 (~[-5.37e-11, 5.295e-11]). */
static const double
one = 1.0,
--- b/k_expf.cpp 2022-12-11 21:20:40.290068458 -0500
+++ b/k_expf.cpp_new 2022-12-11 21:23:32.087882627 -0500
@@ -22,16 +22,16 @@
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* 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.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//#include <sys/cdefs.h>
+//__FBSDID("$FreeBSD$");
#include <complex.h>
#include "math_private.h"
static const uint32_t k = 235; /* constant for reduction */
static const float kln2 = 162.88958740F; /* k * ln2 */
--- b/k_sinf.cpp 2022-12-11 21:20:40.290068458 -0500
+++ b/k_sinf.cpp_new 2022-12-11 21:23:32.119882948 -0500
@@ -11,16 +11,16 @@
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
#ifndef INLINE_KERNEL_SINDF
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//#include <sys/cdefs.h>
+//__FBSDID("$FreeBSD$");
#endif
#include "math_private.h"
/* |sin(x)/x - s(x)| < 2**-37.5 (~[-4.89e-12, 4.824e-12]). */
static const double
S1 = -0x15555554cbac77.0p-55, /* -0.166666666416265235595 */
--- b/k_tanf.cpp 2022-12-11 21:20:40.290068458 -0500
+++ b/k_tanf.cpp_new 2022-12-11 21:23:32.155883308 -0500
@@ -10,16 +10,16 @@
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
#ifndef INLINE_KERNEL_TANDF
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//#include <sys/cdefs.h>
+//__FBSDID("$FreeBSD$");
#endif
#include "math_private.h"
/* |tan(x)/x - t(x)| < 2**-25.5 (~[-2e-08, 2e-08]). */
static const double
T[] = {
--- a/s_atanf.cpp 2022-12-11 21:20:40.290068458 -0500
+++ b/s_atanf.cpp_new 2022-12-11 21:23:32.199883749 -0500
@@ -9,16 +9,16 @@
* Developed at SunPro, 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$");
#include "math_private.h"
static const float atanhi[] = {
4.6364760399e-01, /* atan(0.5)hi 0x3eed6338 */
7.8539812565e-01, /* atan(1.0)hi 0x3f490fda */
9.8279368877e-01, /* atan(1.5)hi 0x3f7b985e */
--- a/s_cosf.cpp 2022-12-11 21:20:40.290068458 -0500
+++ b/s_cosf.cpp_new 2022-12-11 21:23:32.235884110 -0500
@@ -10,16 +10,16 @@
* Developed at SunPro, 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$");
#include <float.h>
#define INLINE_KERNEL_COSDF
#define INLINE_KERNEL_SINDF
#define INLINE_REM_PIO2F
#include "math_private.h"
--- a/s_exp2.cpp 2022-12-11 21:20:40.290068458 -0500
+++ b/s_exp2.cpp_new 2022-12-11 21:23:32.275884511 -0500
@@ -22,16 +22,16 @@
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* 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.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//#include <sys/cdefs.h>
+//__FBSDID("$FreeBSD$");
#include <float.h>
#include "math_private.h"
#define TBLBITS 8
#define TBLSIZE (1 << TBLBITS)
--- a/s_exp2f.cpp 2022-12-11 21:20:40.290068458 -0500
+++ b/s_exp2f.cpp_new 2022-12-11 21:23:32.311884872 -0500
@@ -22,16 +22,16 @@
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* 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.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//#include <sys/cdefs.h>
+//__FBSDID("$FreeBSD$");
#include <float.h>
#include "math_private.h"
#define TBLBITS 4
#define TBLSIZE (1 << TBLBITS)
--- a/s_fabsf.cpp 2022-12-11 21:20:40.290068458 -0500
+++ b/s_fabsf.cpp_new 2022-12-11 21:23:32.347885233 -0500
@@ -9,16 +9,16 @@
* Developed at SunPro, 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$");
/*
* fabsf(x) returns the absolute value of x.
*/
#include "math_private.h"
--- a/s_sinf.cpp 2022-12-11 21:20:40.290068458 -0500
+++ b/s_sinf.cpp_new 2022-12-11 21:23:32.383885594 -0500
@@ -10,16 +10,16 @@
* Developed at SunPro, 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$");
#include <float.h>
#define INLINE_KERNEL_COSDF
#define INLINE_KERNEL_SINDF
#define INLINE_REM_PIO2F
#include "math_private.h"
--- a/s_tanf.cpp 2022-12-11 21:20:40.290068458 -0500
+++ b/s_tanf.cpp_new 2022-12-11 21:23:32.419885954 -0500
@@ -10,16 +10,16 @@
* Developed at SunPro, 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$");
#include <float.h>
#define INLINE_KERNEL_TANDF
#define INLINE_REM_PIO2F
#include "math_private.h"
#include "e_rem_pio2f.c"
--- a/e_sqrtf.cpp 2022-12-13 14:30:13.113415455 -0500
+++ b/e_sqrtf.cpp 2022-12-13 14:13:15.302434550 -0500
@@ -8,19 +8,19 @@
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
-#ifndef lint
-static char rcsid[] = "$FreeBSD$";
-#endif
+//#ifndef lint
+//static char rcsid[] = "$FreeBSD$";
+//#endif
#include "math_private.h"
#ifdef USE_BUILTIN_SQRTF
float
__ieee754_sqrtf(float x)
{
return (__builtin_sqrtf(x));

Просмотреть файл

@ -54,54 +54,3 @@ diff --git a/k_exp.cpp b/k_exp.cpp
- return (CMPLX(c * exp_x * scale1 * scale2,
- s * exp_x * scale1 * scale2));
-}
--- a/k_expf.cpp 2022-12-13 14:39:11.791594163 -0500
+++ b/k_expf.cpp 2022-12-13 14:39:18.631622916 -0500
@@ -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.
*/
//#include <sys/cdefs.h>
//__FBSDID("$FreeBSD$");
-#include <complex.h>
-
#include "math_private.h"
static const uint32_t k = 235; /* constant for reduction */
static const float kln2 = 162.88958740F; /* k * ln2 */
/*
* See k_exp.c for details.
*
@@ -61,29 +59,8 @@
float exp_x, scale;
int ex_expt;
exp_x = __frexp_expf(x, &ex_expt);
expt += ex_expt;
SET_FLOAT_WORD(scale, (0x7f + expt) << 23);
return (exp_x * scale);
}
-
-float complex
-__ldexp_cexpf(float complex z, int expt)
-{
- float c, exp_x, s, scale1, scale2, x, y;
- int ex_expt, half_expt;
-
- x = crealf(z);
- y = cimagf(z);
- exp_x = __frexp_expf(x, &ex_expt);
- expt += ex_expt;
-
- half_expt = expt / 2;
- SET_FLOAT_WORD(scale1, (0x7f + half_expt) << 23);
- half_expt = expt - half_expt;
- SET_FLOAT_WORD(scale2, (0x7f + half_expt) << 23);
-
- sincosf(y, &s, &c);
- return (CMPLXF(c * exp_x * scale1 * scale2,
- s * exp_x * scale1 * scale2));
-}

Просмотреть файл

@ -45,24 +45,3 @@ diff --git a/s_expm1.cpp b/s_expm1.cpp
SET_HIGH_WORD(t,0x3ff00000 - (0x200000>>k)); /* t=1-2^-k */
y = t-(e-x);
y = y*twopk;
--- a/s_exp2.cpp 2022-12-11 21:26:36.045643147 -0500
+++ b/s_exp2.cpp_new 2022-12-11 21:28:42.058769925 -0500
@@ -381,14 +381,16 @@
INSERT_WORDS(twopk, 0x3ff00000 + k, 0);
else
INSERT_WORDS(twopkp1000, 0x3ff00000 + k + (1000 << 20), 0);
r = t + t * z * (P1 + z * (P2 + z * (P3 + z * (P4 + z * P5))));
/* Scale by 2**(k>>20). */
if(k >= -(1021 << 20)) {
- if (k == 1024 << 20)
- return (r * 2.0 * 0x1p1023);
+ if (k == 1024 << 20) {
+ double const_0x1p1023 = pow(2, 1023);
+ return (r * 2.0 * const_0x1p1023);
+ }
return (r * twopk);
} else {
return (r * twopkp1000 * twom1000);
}
}

Просмотреть файл

@ -251,39 +251,3 @@ diff --git a/s_asinh.cpp b/s_asinh.cpp
}
if(hx>0) return w; else return -w;
}
--- a/e_asinf.cpp 2022-12-13 14:45:17.953154257 -0500
+++ b/e_asinf.cpp 2022-12-13 14:45:03.425091710 -0500
@@ -11,16 +11,18 @@
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
//#include <sys/cdefs.h>
//__FBSDID("$FreeBSD$");
+#include <cmath>
+
#include "math_private.h"
static const float
one = 1.0000000000e+00, /* 0x3F800000 */
huge = 1.000e+30,
/* coefficient for R(x^2) */
pS0 = 1.6666586697e-01,
pS1 = -4.2743422091e-02,
@@ -52,13 +54,13 @@
w = p/q;
return x+x*w;
}
/* 1> |x|>= 0.5 */
w = one-fabsf(x);
t = w*(float)0.5;
p = t*(pS0+t*(pS1+t*pS2));
q = one+t*qS1;
- s = sqrt(t);
+ s = std::sqrt(t);
w = p/q;
t = pio2-2.0*(s+s*w);
if(hx>0) return t; else return -t;
}

Просмотреть файл

@ -109,97 +109,3 @@ diff --git a/s_tan.cpp b/s_tan.cpp
int32_t n, ix;
/* High word of x. */
--- a/s_cosf.cpp 2022-12-11 21:26:36.041643110 -0500
+++ b/s_cosf.cpp 2022-12-11 21:34:08.197486828 -0500
@@ -18,19 +18,19 @@
//__FBSDID("$FreeBSD$");
#include <float.h>
#define INLINE_KERNEL_COSDF
#define INLINE_KERNEL_SINDF
#define INLINE_REM_PIO2F
#include "math_private.h"
-#include "e_rem_pio2f.c"
-#include "k_cosf.c"
-#include "k_sinf.c"
+#include "e_rem_pio2f.cpp"
+#include "k_cosf.cpp"
+#include "k_sinf.cpp"
/* Small multiples of pi/2 rounded to double precision. */
static const double
c1pio2 = 1*M_PI_2, /* 0x3FF921FB, 0x54442D18 */
c2pio2 = 2*M_PI_2, /* 0x400921FB, 0x54442D18 */
c3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */
c4pio2 = 4*M_PI_2; /* 0x401921FB, 0x54442D18 */
--- a/s_sinf.cpp 2022-12-11 21:26:36.045643147 -0500
+++ b/s_sinf.cpp 2022-12-11 21:33:52.741362926 -0500
@@ -18,19 +18,19 @@
//__FBSDID("$FreeBSD$");
#include <float.h>
#define INLINE_KERNEL_COSDF
#define INLINE_KERNEL_SINDF
#define INLINE_REM_PIO2F
#include "math_private.h"
-#include "e_rem_pio2f.c"
-#include "k_cosf.c"
-#include "k_sinf.c"
+#include "e_rem_pio2f.cpp"
+#include "k_cosf.cpp"
+#include "k_sinf.cpp"
/* Small multiples of pi/2 rounded to double precision. */
static const double
s1pio2 = 1*M_PI_2, /* 0x3FF921FB, 0x54442D18 */
s2pio2 = 2*M_PI_2, /* 0x400921FB, 0x54442D18 */
s3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */
s4pio2 = 4*M_PI_2; /* 0x401921FB, 0x54442D18 */
--- a/s_tanf.cpp 2022-12-11 21:26:36.045643147 -0500
+++ b/s_tanf.cpp 2022-12-11 21:33:45.269302886 -0500
@@ -17,18 +17,18 @@
//#include <sys/cdefs.h>
//__FBSDID("$FreeBSD$");
#include <float.h>
#define INLINE_KERNEL_TANDF
#define INLINE_REM_PIO2F
#include "math_private.h"
-#include "e_rem_pio2f.c"
-#include "k_tanf.c"
+#include "e_rem_pio2f.cpp"
+#include "k_tanf.cpp"
/* Small multiples of pi/2 rounded to double precision. */
static const double
t1pio2 = 1*M_PI_2, /* 0x3FF921FB, 0x54442D18 */
t2pio2 = 2*M_PI_2, /* 0x400921FB, 0x54442D18 */
t3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */
t4pio2 = 4*M_PI_2; /* 0x401921FB, 0x54442D18 */
--- a/e_rem_pio2f.cpp 2022-12-13 14:50:12.582776365 -0500
+++ b/e_rem_pio2f.cpp 2022-12-13 14:51:05.003200166 -0500
@@ -35,17 +35,17 @@
*/
static const double
invpio2 = 6.36619772367581382433e-01, /* 0x3FE45F30, 0x6DC9C883 */
pio2_1 = 1.57079631090164184570e+00, /* 0x3FF921FB, 0x50000000 */
pio2_1t = 1.58932547735281966916e-08; /* 0x3E5110b4, 0x611A6263 */
#ifdef INLINE_REM_PIO2F
-static __inline __always_inline
+static inline
#endif
int
__ieee754_rem_pio2f(float x, double *y)
{
double w,r,fn;
double tx[1],ty[1];
float z;
int32_t e0,n,ix,hx;

Просмотреть файл

@ -19,47 +19,3 @@ diff --git a/math_private.h b/math_private.h
* ix1 = *((1-n0)+(int*)&x); * low word of x *
* to dig two 32 bit words out of the 64 bit IEEE floating point
* value. That is non-ANSI, and, moreover, the gcc instruction
diff --git a/e_rem_pio2f.cpp b/e_rem_pio2f.cpp
--- a/e_rem_pio2f.cpp
+++ b/e_rem_pio2f.cpp
@@ -49,17 +49,17 @@ int
double tx[1],ty[1];
float z;
int32_t e0,n,ix,hx;
GET_FLOAT_WORD(hx,x);
ix = hx&0x7fffffff;
/* 33+53 bit pi is good enough for medium size */
if(ix<0x4dc90fdb) { /* |x| ~< 2^28*(pi/2), medium size */
- fn = rnint((float_t)x*invpio2);
+ fn = rnint((float)x*invpio2);
n = irint(fn);
r = x-fn*pio2_1;
w = fn*pio2_1t;
*y = r-w;
return n;
}
/*
* all other (large) arguments
diff --git a/s_scalbnf.cpp b/s_scalbnf.cpp
--- a/s_scalbnf.cpp
+++ b/s_scalbnf.cpp
@@ -7,17 +7,17 @@
* for all contributors to musl.
*/
#include <math.h>
#include <stdint.h>
float scalbnf(float x, int n)
{
union {float f; uint32_t i;} u;
- float_t y = x;
+ float y = x;
if (n > 127) {
y *= 0x1p127f;
n -= 127;
if (n > 127) {
y *= 0x1p127f;
n -= 127;
if (n > 127)

Просмотреть файл

@ -1,76 +0,0 @@
/* e_acosf.c -- float version of e_acos.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, 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 "math_private.h"
static const float
one = 1.0000000000e+00, /* 0x3F800000 */
pi = 3.1415925026e+00, /* 0x40490fda */
pio2_hi = 1.5707962513e+00; /* 0x3fc90fda */
static volatile float
pio2_lo = 7.5497894159e-08; /* 0x33a22168 */
static const float
pS0 = 1.6666586697e-01,
pS1 = -4.2743422091e-02,
pS2 = -8.6563630030e-03,
qS1 = -7.0662963390e-01;
float
__ieee754_acosf(float x)
{
float z,p,q,r,w,s,c,df;
int32_t hx,ix;
GET_FLOAT_WORD(hx,x);
ix = hx&0x7fffffff;
if(ix>=0x3f800000) { /* |x| >= 1 */
if(ix==0x3f800000) { /* |x| == 1 */
if(hx>0) return 0.0; /* acos(1) = 0 */
else return pi+(float)2.0*pio2_lo; /* acos(-1)= pi */
}
return (x-x)/(x-x); /* acos(|x|>1) is NaN */
}
if(ix<0x3f000000) { /* |x| < 0.5 */
if(ix<=0x32800000) return pio2_hi+pio2_lo;/*if|x|<2**-26*/
z = x*x;
p = z*(pS0+z*(pS1+z*pS2));
q = one+z*qS1;
r = p/q;
return pio2_hi - (x - (pio2_lo-x*r));
} else if (hx<0) { /* x < -0.5 */
z = (one+x)*(float)0.5;
p = z*(pS0+z*(pS1+z*pS2));
q = one+z*qS1;
s = sqrtf(z);
r = p/q;
w = r*s-pio2_lo;
return pi - (float)2.0*(s+w);
} else { /* x > 0.5 */
int32_t idf;
z = (one-x)*(float)0.5;
s = sqrtf(z);
df = s;
GET_FLOAT_WORD(idf,df);
SET_FLOAT_WORD(df,idf&0xfffff000);
c = (z-df*df)/(s+df);
p = z*(pS0+z*(pS1+z*pS2));
q = one+z*qS1;
r = p/q;
w = r*s+c;
return (float)2.0*(df+w);
}
}

Просмотреть файл

@ -1,66 +0,0 @@
/* e_asinf.c -- float version of e_asin.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, 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 <cmath>
#include "math_private.h"
static const float
one = 1.0000000000e+00, /* 0x3F800000 */
huge = 1.000e+30,
/* coefficient for R(x^2) */
pS0 = 1.6666586697e-01,
pS1 = -4.2743422091e-02,
pS2 = -8.6563630030e-03,
qS1 = -7.0662963390e-01;
static const double
pio2 = 1.570796326794896558e+00;
float
__ieee754_asinf(float x)
{
double s;
float t,w,p,q;
int32_t hx,ix;
GET_FLOAT_WORD(hx,x);
ix = hx&0x7fffffff;
if(ix>=0x3f800000) { /* |x| >= 1 */
if(ix==0x3f800000) /* |x| == 1 */
return x*pio2; /* asin(+-1) = +-pi/2 with inexact */
return (x-x)/(x-x); /* asin(|x|>1) is NaN */
} else if (ix<0x3f000000) { /* |x|<0.5 */
if(ix<0x39800000) { /* |x| < 2**-12 */
if(huge+x>one) return x;/* return x with inexact if x!=0*/
}
t = x*x;
p = t*(pS0+t*(pS1+t*pS2));
q = one+t*qS1;
w = p/q;
return x+x*w;
}
/* 1> |x|>= 0.5 */
w = one-fabsf(x);
t = w*(float)0.5;
p = t*(pS0+t*(pS1+t*pS2));
q = one+t*qS1;
s = std::sqrt(t);
w = p/q;
t = pio2-2.0*(s+s*w);
if(hx>0) return t; else return -t;
}

Просмотреть файл

@ -1,97 +0,0 @@
/* e_expf.c -- float version of e_exp.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, 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 <float.h>
#include "math_private.h"
static const float
one = 1.0,
halF[2] = {0.5,-0.5,},
o_threshold= 8.8721679688e+01, /* 0x42b17180 */
u_threshold= -1.0397208405e+02, /* 0xc2cff1b5 */
ln2HI[2] ={ 6.9314575195e-01, /* 0x3f317200 */
-6.9314575195e-01,}, /* 0xbf317200 */
ln2LO[2] ={ 1.4286067653e-06, /* 0x35bfbe8e */
-1.4286067653e-06,}, /* 0xb5bfbe8e */
invln2 = 1.4426950216e+00, /* 0x3fb8aa3b */
/*
* Domain [-0.34568, 0.34568], range ~[-4.278e-9, 4.447e-9]:
* |x*(exp(x)+1)/(exp(x)-1) - p(x)| < 2**-27.74
*/
P1 = 1.6666625440e-1, /* 0xaaaa8f.0p-26 */
P2 = -2.7667332906e-3; /* -0xb55215.0p-32 */
static volatile float
huge = 1.0e+30,
twom100 = 7.8886090522e-31; /* 2**-100=0x0d800000 */
float
__ieee754_expf(float x)
{
float y,hi=0.0,lo=0.0,c,t,twopk;
int32_t k=0,xsb;
u_int32_t hx;
GET_FLOAT_WORD(hx,x);
xsb = (hx>>31)&1; /* sign bit of x */
hx &= 0x7fffffff; /* high word of |x| */
/* filter out non-finite argument */
if(hx >= 0x42b17218) { /* if |x|>=88.721... */
if(hx>0x7f800000)
return x+x; /* NaN */
if(hx==0x7f800000)
return (xsb==0)? x:0.0; /* exp(+-inf)={inf,0} */
if(x > o_threshold) return huge*huge; /* overflow */
if(x < u_threshold) return twom100*twom100; /* underflow */
}
/* argument reduction */
if(hx > 0x3eb17218) { /* if |x| > 0.5 ln2 */
if(hx < 0x3F851592) { /* and |x| < 1.5 ln2 */
hi = x-ln2HI[xsb]; lo=ln2LO[xsb]; k = 1-xsb-xsb;
} else {
k = invln2*x+halF[xsb];
t = k;
hi = x - t*ln2HI[0]; /* t*ln2HI is exact here */
lo = t*ln2LO[0];
}
STRICT_ASSIGN(float, x, hi - lo);
}
else if(hx < 0x39000000) { /* when |x|<2**-14 */
if(huge+x>one) return one+x;/* trigger inexact */
}
else k = 0;
/* x is now in primary range */
t = x*x;
if(k >= -125)
SET_FLOAT_WORD(twopk,((u_int32_t)(0x7f+k))<<23);
else
SET_FLOAT_WORD(twopk,((u_int32_t)(0x7f+(k+100)))<<23);
c = x - t*(P1+t*P2);
if(k==0) return one-((x*c)/(c-(float)2.0)-x);
else y = one-((lo-(x*c)/((float)2.0-c))-hi);
if(k >= -125) {
if(k==128) return y*2.0F*0x1p127F;
return y*twopk;
} else {
return y*twopk*twom100;
}
}

Просмотреть файл

@ -1,88 +0,0 @@
/* e_logf.c -- float version of e_log.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, 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 "math_private.h"
static const float
ln2_hi = 6.9313812256e-01, /* 0x3f317180 */
ln2_lo = 9.0580006145e-06, /* 0x3717f7d1 */
two25 = 3.355443200e+07, /* 0x4c000000 */
/* |(log(1+s)-log(1-s))/s - Lg(s)| < 2**-34.24 (~[-4.95e-11, 4.97e-11]). */
Lg1 = 0xaaaaaa.0p-24, /* 0.66666662693 */
Lg2 = 0xccce13.0p-25, /* 0.40000972152 */
Lg3 = 0x91e9ee.0p-25, /* 0.28498786688 */
Lg4 = 0xf89e26.0p-26; /* 0.24279078841 */
static const float zero = 0.0;
static volatile float vzero = 0.0;
float
__ieee754_logf(float x)
{
float hfsq,f,s,z,R,w,t1,t2,dk;
int32_t k,ix,i,j;
GET_FLOAT_WORD(ix,x);
k=0;
if (ix < 0x00800000) { /* x < 2**-126 */
if ((ix&0x7fffffff)==0)
return -two25/vzero; /* log(+-0)=-inf */
if (ix<0) return (x-x)/zero; /* log(-#) = NaN */
k -= 25; x *= two25; /* subnormal number, scale up x */
GET_FLOAT_WORD(ix,x);
}
if (ix >= 0x7f800000) return x+x;
k += (ix>>23)-127;
ix &= 0x007fffff;
i = (ix+(0x95f64<<3))&0x800000;
SET_FLOAT_WORD(x,ix|(i^0x3f800000)); /* normalize x or x/2 */
k += (i>>23);
f = x-(float)1.0;
if((0x007fffff&(0x8000+ix))<0xc000) { /* -2**-9 <= f < 2**-9 */
if(f==zero) {
if(k==0) {
return zero;
} else {
dk=(float)k;
return dk*ln2_hi+dk*ln2_lo;
}
}
R = f*f*((float)0.5-(float)0.33333333333333333*f);
if(k==0) return f-R; else {dk=(float)k;
return dk*ln2_hi-((R-dk*ln2_lo)-f);}
}
s = f/((float)2.0+f);
dk = (float)k;
z = s*s;
i = ix-(0x6147a<<3);
w = z*z;
j = (0x6b851<<3)-ix;
t1= w*(Lg2+w*Lg4);
t2= z*(Lg1+w*Lg3);
i |= j;
R = t2+t1;
if(i>0) {
hfsq=(float)0.5*f*f;
if(k==0) return f-(hfsq-s*(hfsq+R)); else
return dk*ln2_hi-((hfsq-(s*(hfsq+R)+dk*ln2_lo))-f);
} else {
if(k==0) return f-s*(f-R); else
return dk*ln2_hi-((s*(f-R)-dk*ln2_lo)-f);
}
}

Просмотреть файл

@ -1,251 +0,0 @@
/* e_powf.c -- float version of e_pow.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, 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 "math_private.h"
static const float
bp[] = {1.0, 1.5,},
dp_h[] = { 0.0, 5.84960938e-01,}, /* 0x3f15c000 */
dp_l[] = { 0.0, 1.56322085e-06,}, /* 0x35d1cfdc */
zero = 0.0,
half = 0.5,
qrtr = 0.25,
thrd = 3.33333343e-01, /* 0x3eaaaaab */
one = 1.0,
two = 2.0,
two24 = 16777216.0, /* 0x4b800000 */
huge = 1.0e30,
tiny = 1.0e-30,
/* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */
L1 = 6.0000002384e-01, /* 0x3f19999a */
L2 = 4.2857143283e-01, /* 0x3edb6db7 */
L3 = 3.3333334327e-01, /* 0x3eaaaaab */
L4 = 2.7272811532e-01, /* 0x3e8ba305 */
L5 = 2.3066075146e-01, /* 0x3e6c3255 */
L6 = 2.0697501302e-01, /* 0x3e53f142 */
P1 = 1.6666667163e-01, /* 0x3e2aaaab */
P2 = -2.7777778450e-03, /* 0xbb360b61 */
P3 = 6.6137559770e-05, /* 0x388ab355 */
P4 = -1.6533901999e-06, /* 0xb5ddea0e */
P5 = 4.1381369442e-08, /* 0x3331bb4c */
lg2 = 6.9314718246e-01, /* 0x3f317218 */
lg2_h = 6.93145752e-01, /* 0x3f317200 */
lg2_l = 1.42860654e-06, /* 0x35bfbe8c */
ovt = 4.2995665694e-08, /* -(128-log2(ovfl+.5ulp)) */
cp = 9.6179670095e-01, /* 0x3f76384f =2/(3ln2) */
cp_h = 9.6191406250e-01, /* 0x3f764000 =12b cp */
cp_l = -1.1736857402e-04, /* 0xb8f623c6 =tail of cp_h */
ivln2 = 1.4426950216e+00, /* 0x3fb8aa3b =1/ln2 */
ivln2_h = 1.4426879883e+00, /* 0x3fb8aa00 =16b 1/ln2*/
ivln2_l = 7.0526075433e-06; /* 0x36eca570 =1/ln2 tail*/
float
__ieee754_powf(float x, float y)
{
float z,ax,z_h,z_l,p_h,p_l;
float y1,t1,t2,r,s,sn,t,u,v,w;
int32_t i,j,k,yisint,n;
int32_t hx,hy,ix,iy,is;
GET_FLOAT_WORD(hx,x);
GET_FLOAT_WORD(hy,y);
ix = hx&0x7fffffff; iy = hy&0x7fffffff;
/* y==zero: x**0 = 1 */
if(iy==0) return one;
/* x==1: 1**y = 1, even if y is NaN */
if (hx==0x3f800000) return one;
/* y!=zero: result is NaN if either arg is NaN */
if(ix > 0x7f800000 ||
iy > 0x7f800000)
return nan_mix(x, y);
/* determine if y is an odd int when x < 0
* yisint = 0 ... y is not an integer
* yisint = 1 ... y is an odd int
* yisint = 2 ... y is an even int
*/
yisint = 0;
if(hx<0) {
if(iy>=0x4b800000) yisint = 2; /* even integer y */
else if(iy>=0x3f800000) {
k = (iy>>23)-0x7f; /* exponent */
j = iy>>(23-k);
if((j<<(23-k))==iy) yisint = 2-(j&1);
}
}
/* special value of y */
if (iy==0x7f800000) { /* y is +-inf */
if (ix==0x3f800000)
return one; /* (-1)**+-inf is NaN */
else if (ix > 0x3f800000)/* (|x|>1)**+-inf = inf,0 */
return (hy>=0)? y: zero;
else /* (|x|<1)**-,+inf = inf,0 */
return (hy<0)?-y: zero;
}
if(iy==0x3f800000) { /* y is +-1 */
if(hy<0) return one/x; else return x;
}
if(hy==0x40000000) return x*x; /* y is 2 */
if(hy==0x3f000000) { /* y is 0.5 */
if(hx>=0) /* x >= +0 */
return __ieee754_sqrtf(x);
}
ax = fabsf(x);
/* special value of x */
if(ix==0x7f800000||ix==0||ix==0x3f800000){
z = ax; /*x is +-0,+-inf,+-1*/
if(hy<0) z = one/z; /* z = (1/|x|) */
if(hx<0) {
if(((ix-0x3f800000)|yisint)==0) {
z = (z-z)/(z-z); /* (-1)**non-int is NaN */
} else if(yisint==1)
z = -z; /* (x<0)**odd = -(|x|**odd) */
}
return z;
}
n = ((u_int32_t)hx>>31)-1;
/* (x<0)**(non-int) is NaN */
if((n|yisint)==0) return (x-x)/(x-x);
sn = one; /* s (sign of result -ve**odd) = -1 else = 1 */
if((n|(yisint-1))==0) sn = -one;/* (-ve)**(odd int) */
/* |y| is huge */
if(iy>0x4d000000) { /* if |y| > 2**27 */
/* over/underflow if x is not close to one */
if(ix<0x3f7ffff6) return (hy<0)? sn*huge*huge:sn*tiny*tiny;
if(ix>0x3f800007) return (hy>0)? sn*huge*huge:sn*tiny*tiny;
/* now |1-x| is tiny <= 2**-20, suffice to compute
log(x) by x-x^2/2+x^3/3-x^4/4 */
t = ax-1; /* t has 20 trailing zeros */
w = (t*t)*(half-t*(thrd-t*qrtr));
u = ivln2_h*t; /* ivln2_h has 16 sig. bits */
v = t*ivln2_l-w*ivln2;
t1 = u+v;
GET_FLOAT_WORD(is,t1);
SET_FLOAT_WORD(t1,is&0xfffff000);
t2 = v-(t1-u);
} else {
float s2,s_h,s_l,t_h,t_l;
n = 0;
/* take care subnormal number */
if(ix<0x00800000)
{ax *= two24; n -= 24; GET_FLOAT_WORD(ix,ax); }
n += ((ix)>>23)-0x7f;
j = ix&0x007fffff;
/* determine interval */
ix = j|0x3f800000; /* normalize ix */
if(j<=0x1cc471) k=0; /* |x|<sqrt(3/2) */
else if(j<0x5db3d7) k=1; /* |x|<sqrt(3) */
else {k=0;n+=1;ix -= 0x00800000;}
SET_FLOAT_WORD(ax,ix);
/* compute s = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */
u = ax-bp[k]; /* bp[0]=1.0, bp[1]=1.5 */
v = one/(ax+bp[k]);
s = u*v;
s_h = s;
GET_FLOAT_WORD(is,s_h);
SET_FLOAT_WORD(s_h,is&0xfffff000);
/* t_h=ax+bp[k] High */
is = ((ix>>1)&0xfffff000)|0x20000000;
SET_FLOAT_WORD(t_h,is+0x00400000+(k<<21));
t_l = ax - (t_h-bp[k]);
s_l = v*((u-s_h*t_h)-s_h*t_l);
/* compute log(ax) */
s2 = s*s;
r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6)))));
r += s_l*(s_h+s);
s2 = s_h*s_h;
t_h = 3+s2+r;
GET_FLOAT_WORD(is,t_h);
SET_FLOAT_WORD(t_h,is&0xfffff000);
t_l = r-((t_h-3)-s2);
/* u+v = s*(1+...) */
u = s_h*t_h;
v = s_l*t_h+t_l*s;
/* 2/(3log2)*(s+...) */
p_h = u+v;
GET_FLOAT_WORD(is,p_h);
SET_FLOAT_WORD(p_h,is&0xfffff000);
p_l = v-(p_h-u);
z_h = cp_h*p_h; /* cp_h+cp_l = 2/(3*log2) */
z_l = cp_l*p_h+p_l*cp+dp_l[k];
/* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */
t = n;
t1 = (((z_h+z_l)+dp_h[k])+t);
GET_FLOAT_WORD(is,t1);
SET_FLOAT_WORD(t1,is&0xfffff000);
t2 = z_l-(((t1-t)-dp_h[k])-z_h);
}
/* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */
GET_FLOAT_WORD(is,y);
SET_FLOAT_WORD(y1,is&0xfffff000);
p_l = (y-y1)*t1+y*t2;
p_h = y1*t1;
z = p_l+p_h;
GET_FLOAT_WORD(j,z);
if (j>0x43000000) /* if z > 128 */
return sn*huge*huge; /* overflow */
else if (j==0x43000000) { /* if z == 128 */
if(p_l+ovt>z-p_h) return sn*huge*huge; /* overflow */
}
else if ((j&0x7fffffff)>0x43160000) /* z <= -150 */
return sn*tiny*tiny; /* underflow */
else if (j==0xc3160000){ /* z == -150 */
if(p_l<=z-p_h) return sn*tiny*tiny; /* underflow */
}
/*
* compute 2**(p_h+p_l)
*/
i = j&0x7fffffff;
k = (i>>23)-0x7f;
n = 0;
if(i>0x3f000000) { /* if |z| > 0.5, set n = [z+0.5] */
n = j+(0x00800000>>(k+1));
k = ((n&0x7fffffff)>>23)-0x7f; /* new k for n */
SET_FLOAT_WORD(t,n&~(0x007fffff>>k));
n = ((n&0x007fffff)|0x00800000)>>(23-k);
if(j<0) n = -n;
p_h -= t;
}
t = p_l+p_h;
GET_FLOAT_WORD(is,t);
SET_FLOAT_WORD(t,is&0xffff8000);
u = t*lg2_h;
v = (p_l-(t-p_h))*lg2+t*lg2_l;
z = u+v;
w = v-(z-u);
t = z*z;
t1 = z - t*(P1+t*(P2+t*(P3+t*(P4+t*P5))));
r = (z*t1)/(t1-two)-(w+z*w);
z = one-(r-z);
GET_FLOAT_WORD(j,z);
j += (n<<23);
if((j>>23)<=0) z = scalbnf(z,n); /* subnormal output */
else SET_FLOAT_WORD(z,j);
return sn*z;
}

Просмотреть файл

@ -1,77 +0,0 @@
/* e_rem_pio2f.c -- float version of e_rem_pio2.c
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
* Debugged and optimized by Bruce D. Evans.
*/
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, 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$");
/* __ieee754_rem_pio2f(x,y)
*
* return the remainder of x rem pi/2 in *y
* use double precision for everything except passing x
* use __kernel_rem_pio2() for large x
*/
#include <float.h>
#include "math_private.h"
/*
* invpio2: 53 bits of 2/pi
* pio2_1: first 25 bits of pi/2
* pio2_1t: pi/2 - pio2_1
*/
static const double
invpio2 = 6.36619772367581382433e-01, /* 0x3FE45F30, 0x6DC9C883 */
pio2_1 = 1.57079631090164184570e+00, /* 0x3FF921FB, 0x50000000 */
pio2_1t = 1.58932547735281966916e-08; /* 0x3E5110b4, 0x611A6263 */
#ifdef INLINE_REM_PIO2F
static inline
#endif
int
__ieee754_rem_pio2f(float x, double *y)
{
double w,r,fn;
double tx[1],ty[1];
float z;
int32_t e0,n,ix,hx;
GET_FLOAT_WORD(hx,x);
ix = hx&0x7fffffff;
/* 33+53 bit pi is good enough for medium size */
if(ix<0x4dc90fdb) { /* |x| ~< 2^28*(pi/2), medium size */
fn = rnint((float)x*invpio2);
n = irint(fn);
r = x-fn*pio2_1;
w = fn*pio2_1t;
*y = r-w;
return n;
}
/*
* all other (large) arguments
*/
if(ix>=0x7f800000) { /* x is inf or NaN */
*y=x-x; return 0;
}
/* set z = scalbn(|x|,ilogb(|x|)-23) */
e0 = (ix>>23)-150; /* e0 = ilogb(|x|)-23; */
SET_FLOAT_WORD(z, ix - ((int32_t)(e0<<23)));
tx[0] = z;
n = __kernel_rem_pio2(tx,ty,e0,1,0);
if(hx<0) {*y = -ty[0]; return -n;}
*y = ty[0]; return n;
}

Просмотреть файл

@ -1,96 +0,0 @@
/* e_sqrtf.c -- float version of e_sqrt.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
//#ifndef lint
//static char rcsid[] = "$FreeBSD$";
//#endif
#include "math_private.h"
#ifdef USE_BUILTIN_SQRTF
float
__ieee754_sqrtf(float x)
{
return (__builtin_sqrtf(x));
}
#else
static const float one = 1.0, tiny=1.0e-30;
float
__ieee754_sqrtf(float x)
{
float z;
int32_t sign = (int)0x80000000;
int32_t ix,s,q,m,t,i;
u_int32_t r;
GET_FLOAT_WORD(ix,x);
/* take care of Inf and NaN */
if((ix&0x7f800000)==0x7f800000) {
return x*x+x; /* sqrt(NaN)=NaN, sqrt(+inf)=+inf
sqrt(-inf)=sNaN */
}
/* take care of zero */
if(ix<=0) {
if((ix&(~sign))==0) return x;/* sqrt(+-0) = +-0 */
else if(ix<0)
return (x-x)/(x-x); /* sqrt(-ve) = sNaN */
}
/* normalize x */
m = (ix>>23);
if(m==0) { /* subnormal x */
for(i=0;(ix&0x00800000)==0;i++) ix<<=1;
m -= i-1;
}
m -= 127; /* unbias exponent */
ix = (ix&0x007fffff)|0x00800000;
if(m&1) /* odd m, double x to make it even */
ix += ix;
m >>= 1; /* m = [m/2] */
/* generate sqrt(x) bit by bit */
ix += ix;
q = s = 0; /* q = sqrt(x) */
r = 0x01000000; /* r = moving bit from right to left */
while(r!=0) {
t = s+r;
if(t<=ix) {
s = t+r;
ix -= t;
q += r;
}
ix += ix;
r>>=1;
}
/* use floating add to find out rounding direction */
if(ix!=0) {
z = one-tiny; /* trigger inexact flag */
if (z>=one) {
z = one+tiny;
if (z>one)
q += 2;
else
q += (q&1);
}
}
ix = (q>>1)+0x3f000000;
ix += (m <<23);
SET_FLOAT_WORD(z,ix);
return z;
}
#endif

Просмотреть файл

@ -15,14 +15,10 @@
*/
#ifndef mozilla_imported_fdlibm_h
#define mozilla_imported_fdlibm_h
#define mozilla_imported_fdlibm_h
namespace fdlibm {
#ifndef M_PI_2
#define M_PI_2 1.57079632679489661923 /* pi/2 */
#endif
double acos(double);
double asin(double);
double atan(double);
@ -49,7 +45,6 @@ double acosh(double);
double asinh(double);
double atanh(double);
double cbrt(double);
double exp2(double);
double expm1(double);
double hypot(double, double);
double log1p(double);
@ -59,26 +54,13 @@ double copysign(double, double);
double nearbyint(double);
double scalbn(double, int);
double trunc(double);
float acosf(float);
float asinf(float);
float atanf(float);
float cosf(float);
float sinf(float);
float tanf(float);
float exp2f(float);
float expf(float);
float logf(float);
float powf(float, float);
float sqrtf(float);
float ceilf(float);
float fabsf(float);
float floorf(float);
float nearbyintf(float);
float rintf(float);
float scalbnf(float, int);
float truncf(float);
} /* namespace fdlibm */
#endif /* !mozilla_imported_fdlibm_h */
#endif /* mozilla_imported_fdlibm_h */

Просмотреть файл

@ -1,45 +0,0 @@
/* k_cosf.c -- float version of k_cos.c
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
* Debugged and optimized by Bruce D. Evans.
*/
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
#ifndef INLINE_KERNEL_COSDF
//#include <sys/cdefs.h>
//__FBSDID("$FreeBSD$");
#endif
#include "math_private.h"
/* |cos(x) - c(x)| < 2**-34.1 (~[-5.37e-11, 5.295e-11]). */
static const double
one = 1.0,
C0 = -0x1ffffffd0c5e81.0p-54, /* -0.499999997251031003120 */
C1 = 0x155553e1053a42.0p-57, /* 0.0416666233237390631894 */
C2 = -0x16c087e80f1e27.0p-62, /* -0.00138867637746099294692 */
C3 = 0x199342e0ee5069.0p-68; /* 0.0000243904487962774090654 */
#ifdef INLINE_KERNEL_COSDF
static __inline
#endif
float
__kernel_cosdf(double x)
{
double r, w, z;
/* Try to optimize for parallel evaluation as in k_tanf.c. */
z = x*x;
w = z*z;
r = C2+z*C3;
return ((one+z*C0) + w*C1) + (w*z)*r;
}

Просмотреть файл

@ -1,66 +0,0 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2011 David Schultz <das@FreeBSD.ORG>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* 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
* 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.
*/
//#include <sys/cdefs.h>
//__FBSDID("$FreeBSD$");
#include "math_private.h"
static const uint32_t k = 235; /* constant for reduction */
static const float kln2 = 162.88958740F; /* k * ln2 */
/*
* See k_exp.c for details.
*
* Input: ln(FLT_MAX) <= x < ln(2 * FLT_MAX / FLT_MIN_DENORM) ~= 192.7
* Output: 2**127 <= y < 2**128
*/
static float
__frexp_expf(float x, int *expt)
{
float exp_x;
uint32_t hx;
exp_x = expf(x - kln2);
GET_FLOAT_WORD(hx, exp_x);
*expt = (hx >> 23) - (0x7f + 127) + k;
SET_FLOAT_WORD(exp_x, (hx & 0x7fffff) | ((0x7f + 127) << 23));
return (exp_x);
}
float
__ldexp_expf(float x, int expt)
{
float exp_x, scale;
int ex_expt;
exp_x = __frexp_expf(x, &ex_expt);
expt += ex_expt;
SET_FLOAT_WORD(scale, (0x7f + expt) << 23);
return (exp_x * scale);
}

Просмотреть файл

@ -1,45 +0,0 @@
/* k_sinf.c -- float version of k_sin.c
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
* Optimized by Bruce D. Evans.
*/
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
#ifndef INLINE_KERNEL_SINDF
//#include <sys/cdefs.h>
//__FBSDID("$FreeBSD$");
#endif
#include "math_private.h"
/* |sin(x)/x - s(x)| < 2**-37.5 (~[-4.89e-12, 4.824e-12]). */
static const double
S1 = -0x15555554cbac77.0p-55, /* -0.166666666416265235595 */
S2 = 0x111110896efbb2.0p-59, /* 0.0083333293858894631756 */
S3 = -0x1a00f9e2cae774.0p-65, /* -0.000198393348360966317347 */
S4 = 0x16cd878c3b46a7.0p-71; /* 0.0000027183114939898219064 */
#ifdef INLINE_KERNEL_SINDF
static __inline
#endif
float
__kernel_sindf(double x)
{
double r, s, w, z;
/* Try to optimize for parallel evaluation as in k_tanf.c. */
z = x*x;
w = z*z;
r = S3+z*S4;
s = z*x;
return (x + s*(S1+z*S2)) + s*w*r;
}

Просмотреть файл

@ -1,65 +0,0 @@
/* k_tanf.c -- float version of k_tan.c
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
* Optimized by Bruce D. Evans.
*/
/*
* ====================================================
* Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
*
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
#ifndef INLINE_KERNEL_TANDF
//#include <sys/cdefs.h>
//__FBSDID("$FreeBSD$");
#endif
#include "math_private.h"
/* |tan(x)/x - t(x)| < 2**-25.5 (~[-2e-08, 2e-08]). */
static const double
T[] = {
0x15554d3418c99f.0p-54, /* 0.333331395030791399758 */
0x1112fd38999f72.0p-55, /* 0.133392002712976742718 */
0x1b54c91d865afe.0p-57, /* 0.0533812378445670393523 */
0x191df3908c33ce.0p-58, /* 0.0245283181166547278873 */
0x185dadfcecf44e.0p-61, /* 0.00297435743359967304927 */
0x1362b9bf971bcd.0p-59, /* 0.00946564784943673166728 */
};
#ifdef INLINE_KERNEL_TANDF
static __inline
#endif
float
__kernel_tandf(double x, int iy)
{
double z,r,w,s,t,u;
z = x*x;
/*
* Split up the polynomial into small independent terms to give
* opportunities for parallel evaluation. The chosen splitting is
* micro-optimized for Athlons (XP, X64). It costs 2 multiplications
* relative to Horner's method on sequential machines.
*
* We add the small terms from lowest degree up for efficiency on
* non-sequential machines (the lowest degree terms tend to be ready
* earlier). Apart from this, we don't care about order of
* operations, and don't need to care since we have precision to
* spare. However, the chosen splitting is good for accuracy too,
* and would give results as accurate as Horner's method if the
* small terms were added from highest degree down.
*/
r = T[4]+z*T[5];
t = T[2]+z*T[3];
w = z*z;
s = z*x;
u = T[0]+z*T[1];
r = (x+s*u)+(s*w)*(t+w*r);
if(iy==1) return r;
else return -1.0/r;
}

Просмотреть файл

@ -871,34 +871,22 @@ irintl(long double x)
#define __ieee754_scalbf scalbf
#define acos fdlibm::acos
#define acosf fdlibm::acosf
#define asin fdlibm::asin
#define asinf fdlibm::asinf
#define atan fdlibm::atan
#define atanf fdlibm::atanf
#define atan2 fdlibm::atan2
#define cos fdlibm::cos
#define cosf fdlibm::cosf
#define sin fdlibm::sin
#define sinf fdlibm::sinf
#define tan fdlibm::tan
#define tanf fdlibm::tanf
#define cosh fdlibm::cosh
#define sinh fdlibm::sinh
#define tanh fdlibm::tanh
#define exp fdlibm::exp
#define expf fdlibm::expf
#define exp2 fdlibm::exp2
#define exp2f fdlibm::exp2f
#define log fdlibm::log
#define logf fdlibm::logf
#define log10 fdlibm::log10
#define pow fdlibm::pow
#define powf fdlibm::powf
#define ceil fdlibm::ceil
#define ceilf fdlibm::ceilf
#define fabs fdlibm::fabs
#define fabsf fdlibm::fabsf
#define floor fdlibm::floor
#define acosh fdlibm::acosh
#define asinh fdlibm::asinh
@ -911,7 +899,6 @@ irintl(long double x)
#define scalb fdlibm::scalb
#define copysign fdlibm::copysign
#define scalbn fdlibm::scalbn
#define scalbnf fdlibm::scalbnf
#define trunc fdlibm::trunc
#define truncf fdlibm::truncf
#define floorf fdlibm::floorf
@ -919,7 +906,6 @@ irintl(long double x)
#define nearbyintf fdlibm::nearbyintf
#define rint fdlibm::rint
#define rintf fdlibm::rintf
#define sqrtf fdlibm::sqrtf
/* fdlibm kernel function */
int __kernel_rem_pio2(double*,double*,int,int,int);

Просмотреть файл

@ -34,47 +34,32 @@ if CONFIG['CC_TYPE'] == 'clang-cl':
# variables (e.g. almost every source file defines a `one` and a `huge`).
SOURCES += [
'e_acos.cpp',
'e_acosf.cpp',
'e_acosh.cpp',
'e_asin.cpp',
'e_asinf.cpp',
'e_atan2.cpp',
'e_atanh.cpp',
'e_cosh.cpp',
'e_exp.cpp',
'e_expf.cpp',
'e_hypot.cpp',
'e_log.cpp',
'e_log10.cpp',
'e_log2.cpp',
'e_logf.cpp',
'e_pow.cpp',
'e_powf.cpp',
'e_sinh.cpp',
'e_sqrtf.cpp',
'k_cos.cpp',
'k_cosf.cpp',
'k_exp.cpp',
'k_expf.cpp',
'k_rem_pio2.cpp',
'k_sin.cpp',
'k_sinf.cpp',
'k_tan.cpp',
'k_tanf.cpp',
's_asinh.cpp',
's_atan.cpp',
's_atanf.cpp',
's_cbrt.cpp',
's_ceil.cpp',
's_ceilf.cpp',
# 's_copysign.cpp', # Unused file.
's_cos.cpp',
's_cosf.cpp',
's_exp2.cpp',
's_exp2f.cpp',
's_expm1.cpp',
's_fabs.cpp',
's_fabsf.cpp',
's_floor.cpp',
's_floorf.cpp',
's_log1p.cpp',
@ -83,9 +68,7 @@ SOURCES += [
's_rintf.cpp',
's_scalbn.cpp',
's_sin.cpp',
's_sinf.cpp',
's_tan.cpp',
's_tanf.cpp',
's_tanh.cpp',
's_trunc.cpp',
's_truncf.cpp',

Просмотреть файл

@ -1,91 +0,0 @@
/* s_atanf.c -- float version of s_atan.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, 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 "math_private.h"
static const float atanhi[] = {
4.6364760399e-01, /* atan(0.5)hi 0x3eed6338 */
7.8539812565e-01, /* atan(1.0)hi 0x3f490fda */
9.8279368877e-01, /* atan(1.5)hi 0x3f7b985e */
1.5707962513e+00, /* atan(inf)hi 0x3fc90fda */
};
static const float atanlo[] = {
5.0121582440e-09, /* atan(0.5)lo 0x31ac3769 */
3.7748947079e-08, /* atan(1.0)lo 0x33222168 */
3.4473217170e-08, /* atan(1.5)lo 0x33140fb4 */
7.5497894159e-08, /* atan(inf)lo 0x33a22168 */
};
static const float aT[] = {
3.3333328366e-01,
-1.9999158382e-01,
1.4253635705e-01,
-1.0648017377e-01,
6.1687607318e-02,
};
static const float
one = 1.0,
huge = 1.0e30;
float
atanf(float x)
{
float w,s1,s2,z;
int32_t ix,hx,id;
GET_FLOAT_WORD(hx,x);
ix = hx&0x7fffffff;
if(ix>=0x4c800000) { /* if |x| >= 2**26 */
if(ix>0x7f800000)
return x+x; /* NaN */
if(hx>0) return atanhi[3]+*(volatile float *)&atanlo[3];
else return -atanhi[3]-*(volatile float *)&atanlo[3];
} if (ix < 0x3ee00000) { /* |x| < 0.4375 */
if (ix < 0x39800000) { /* |x| < 2**-12 */
if(huge+x>one) return x; /* raise inexact */
}
id = -1;
} else {
x = fabsf(x);
if (ix < 0x3f980000) { /* |x| < 1.1875 */
if (ix < 0x3f300000) { /* 7/16 <=|x|<11/16 */
id = 0; x = ((float)2.0*x-one)/((float)2.0+x);
} else { /* 11/16<=|x|< 19/16 */
id = 1; x = (x-one)/(x+one);
}
} else {
if (ix < 0x401c0000) { /* |x| < 2.4375 */
id = 2; x = (x-(float)1.5)/(one+(float)1.5*x);
} else { /* 2.4375 <= |x| < 2**26 */
id = 3; x = -(float)1.0/x;
}
}}
/* end of argument reduction */
z = x*x;
w = z*z;
/* break sum from i=0 to 10 aT[i]z**(i+1) into odd and even poly */
s1 = z*(aT[0]+w*(aT[2]+w*aT[4]));
s2 = w*(aT[1]+w*aT[3]);
if (id<0) return x - x*(s1+s2);
else {
z = atanhi[id] - ((x*(s1+s2) - atanlo[id]) - x);
return (hx<0)? -z:z;
}
}

Просмотреть файл

@ -1,86 +0,0 @@
/* s_cosf.c -- float version of s_cos.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
* Optimized by Bruce D. Evans.
*/
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, 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 <float.h>
#define INLINE_KERNEL_COSDF
#define INLINE_KERNEL_SINDF
#define INLINE_REM_PIO2F
#include "math_private.h"
#include "e_rem_pio2f.cpp"
#include "k_cosf.cpp"
#include "k_sinf.cpp"
/* Small multiples of pi/2 rounded to double precision. */
static const double
c1pio2 = 1*M_PI_2, /* 0x3FF921FB, 0x54442D18 */
c2pio2 = 2*M_PI_2, /* 0x400921FB, 0x54442D18 */
c3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */
c4pio2 = 4*M_PI_2; /* 0x401921FB, 0x54442D18 */
float
cosf(float x)
{
double y;
int32_t n, hx, ix;
GET_FLOAT_WORD(hx,x);
ix = hx & 0x7fffffff;
if(ix <= 0x3f490fda) { /* |x| ~<= pi/4 */
if(ix<0x39800000) /* |x| < 2**-12 */
if(((int)x)==0) return 1.0; /* 1 with inexact if x != 0 */
return __kernel_cosdf(x);
}
if(ix<=0x407b53d1) { /* |x| ~<= 5*pi/4 */
if(ix>0x4016cbe3) /* |x| ~> 3*pi/4 */
return -__kernel_cosdf(x + (hx > 0 ? -c2pio2 : c2pio2));
else {
if(hx>0)
return __kernel_sindf(c1pio2 - x);
else
return __kernel_sindf(x + c1pio2);
}
}
if(ix<=0x40e231d5) { /* |x| ~<= 9*pi/4 */
if(ix>0x40afeddf) /* |x| ~> 7*pi/4 */
return __kernel_cosdf(x + (hx > 0 ? -c4pio2 : c4pio2));
else {
if(hx>0)
return __kernel_sindf(x - c3pio2);
else
return __kernel_sindf(-c3pio2 - x);
}
}
/* cos(Inf or NaN) is NaN */
else if (ix>=0x7f800000) return x-x;
/* general argument reduction needed */
else {
n = __ieee754_rem_pio2f(x,&y);
switch(n&3) {
case 0: return __kernel_cosdf(y);
case 1: return __kernel_sindf(-y);
case 2: return -__kernel_cosdf(y);
default:
return __kernel_sindf(y);
}
}
}

Просмотреть файл

@ -1,396 +0,0 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* 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
* 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.
*/
//#include <sys/cdefs.h>
//__FBSDID("$FreeBSD$");
#include <float.h>
#include "math_private.h"
#define TBLBITS 8
#define TBLSIZE (1 << TBLBITS)
static const double
redux = 0x1.8p52 / TBLSIZE,
P1 = 0x1.62e42fefa39efp-1,
P2 = 0x1.ebfbdff82c575p-3,
P3 = 0x1.c6b08d704a0a6p-5,
P4 = 0x1.3b2ab88f70400p-7,
P5 = 0x1.5d88003875c74p-10;
static volatile double
huge = 0x1p1000,
twom1000 = 0x1p-1000;
static const double tbl[TBLSIZE * 2] = {
/* exp2(z + eps) eps */
0x1.6a09e667f3d5dp-1, 0x1.9880p-44,
0x1.6b052fa751744p-1, 0x1.8000p-50,
0x1.6c012750bd9fep-1, -0x1.8780p-45,
0x1.6cfdcddd476bfp-1, 0x1.ec00p-46,
0x1.6dfb23c651a29p-1, -0x1.8000p-50,
0x1.6ef9298593ae3p-1, -0x1.c000p-52,
0x1.6ff7df9519386p-1, -0x1.fd80p-45,
0x1.70f7466f42da3p-1, -0x1.c880p-45,
0x1.71f75e8ec5fc3p-1, 0x1.3c00p-46,
0x1.72f8286eacf05p-1, -0x1.8300p-44,
0x1.73f9a48a58152p-1, -0x1.0c00p-47,
0x1.74fbd35d7ccfcp-1, 0x1.f880p-45,
0x1.75feb564267f1p-1, 0x1.3e00p-47,
0x1.77024b1ab6d48p-1, -0x1.7d00p-45,
0x1.780694fde5d38p-1, -0x1.d000p-50,
0x1.790b938ac1d00p-1, 0x1.3000p-49,
0x1.7a11473eb0178p-1, -0x1.d000p-49,
0x1.7b17b0976d060p-1, 0x1.0400p-45,
0x1.7c1ed0130c133p-1, 0x1.0000p-53,
0x1.7d26a62ff8636p-1, -0x1.6900p-45,
0x1.7e2f336cf4e3bp-1, -0x1.2e00p-47,
0x1.7f3878491c3e8p-1, -0x1.4580p-45,
0x1.80427543e1b4ep-1, 0x1.3000p-44,
0x1.814d2add1071ap-1, 0x1.f000p-47,
0x1.82589994ccd7ep-1, -0x1.1c00p-45,
0x1.8364c1eb942d0p-1, 0x1.9d00p-45,
0x1.8471a4623cab5p-1, 0x1.7100p-43,
0x1.857f4179f5bbcp-1, 0x1.2600p-45,
0x1.868d99b4491afp-1, -0x1.2c40p-44,
0x1.879cad931a395p-1, -0x1.3000p-45,
0x1.88ac7d98a65b8p-1, -0x1.a800p-45,
0x1.89bd0a4785800p-1, -0x1.d000p-49,
0x1.8ace5422aa223p-1, 0x1.3280p-44,
0x1.8be05bad619fap-1, 0x1.2b40p-43,
0x1.8cf3216b54383p-1, -0x1.ed00p-45,
0x1.8e06a5e08664cp-1, -0x1.0500p-45,
0x1.8f1ae99157807p-1, 0x1.8280p-45,
0x1.902fed0282c0ep-1, -0x1.cb00p-46,
0x1.9145b0b91ff96p-1, -0x1.5e00p-47,
0x1.925c353aa2ff9p-1, 0x1.5400p-48,
0x1.93737b0cdc64ap-1, 0x1.7200p-46,
0x1.948b82b5f98aep-1, -0x1.9000p-47,
0x1.95a44cbc852cbp-1, 0x1.5680p-45,
0x1.96bdd9a766f21p-1, -0x1.6d00p-44,
0x1.97d829fde4e2ap-1, -0x1.1000p-47,
0x1.98f33e47a23a3p-1, 0x1.d000p-45,
0x1.9a0f170ca0604p-1, -0x1.8a40p-44,
0x1.9b2bb4d53ff89p-1, 0x1.55c0p-44,
0x1.9c49182a3f15bp-1, 0x1.6b80p-45,
0x1.9d674194bb8c5p-1, -0x1.c000p-49,
0x1.9e86319e3238ep-1, 0x1.7d00p-46,
0x1.9fa5e8d07f302p-1, 0x1.6400p-46,
0x1.a0c667b5de54dp-1, -0x1.5000p-48,
0x1.a1e7aed8eb8f6p-1, 0x1.9e00p-47,
0x1.a309bec4a2e27p-1, 0x1.ad80p-45,
0x1.a42c980460a5dp-1, -0x1.af00p-46,
0x1.a5503b23e259bp-1, 0x1.b600p-47,
0x1.a674a8af46213p-1, 0x1.8880p-44,
0x1.a799e1330b3a7p-1, 0x1.1200p-46,
0x1.a8bfe53c12e8dp-1, 0x1.6c00p-47,
0x1.a9e6b5579fcd2p-1, -0x1.9b80p-45,
0x1.ab0e521356fb8p-1, 0x1.b700p-45,
0x1.ac36bbfd3f381p-1, 0x1.9000p-50,
0x1.ad5ff3a3c2780p-1, 0x1.4000p-49,
0x1.ae89f995ad2a3p-1, -0x1.c900p-45,
0x1.afb4ce622f367p-1, 0x1.6500p-46,
0x1.b0e07298db790p-1, 0x1.fd40p-45,
0x1.b20ce6c9a89a9p-1, 0x1.2700p-46,
0x1.b33a2b84f1a4bp-1, 0x1.d470p-43,
0x1.b468415b747e7p-1, -0x1.8380p-44,
0x1.b59728de5593ap-1, 0x1.8000p-54,
0x1.b6c6e29f1c56ap-1, 0x1.ad00p-47,
0x1.b7f76f2fb5e50p-1, 0x1.e800p-50,
0x1.b928cf22749b2p-1, -0x1.4c00p-47,
0x1.ba5b030a10603p-1, -0x1.d700p-47,
0x1.bb8e0b79a6f66p-1, 0x1.d900p-47,
0x1.bcc1e904bc1ffp-1, 0x1.2a00p-47,
0x1.bdf69c3f3a16fp-1, -0x1.f780p-46,
0x1.bf2c25bd71db8p-1, -0x1.0a00p-46,
0x1.c06286141b2e9p-1, -0x1.1400p-46,
0x1.c199bdd8552e0p-1, 0x1.be00p-47,
0x1.c2d1cd9fa64eep-1, -0x1.9400p-47,
0x1.c40ab5fffd02fp-1, -0x1.ed00p-47,
0x1.c544778fafd15p-1, 0x1.9660p-44,
0x1.c67f12e57d0cbp-1, -0x1.a100p-46,
0x1.c7ba88988c1b6p-1, -0x1.8458p-42,
0x1.c8f6d9406e733p-1, -0x1.a480p-46,
0x1.ca3405751c4dfp-1, 0x1.b000p-51,
0x1.cb720dcef9094p-1, 0x1.1400p-47,
0x1.ccb0f2e6d1689p-1, 0x1.0200p-48,
0x1.cdf0b555dc412p-1, 0x1.3600p-48,
0x1.cf3155b5bab3bp-1, -0x1.6900p-47,
0x1.d072d4a0789bcp-1, 0x1.9a00p-47,
0x1.d1b532b08c8fap-1, -0x1.5e00p-46,
0x1.d2f87080d8a85p-1, 0x1.d280p-46,
0x1.d43c8eacaa203p-1, 0x1.1a00p-47,
0x1.d5818dcfba491p-1, 0x1.f000p-50,
0x1.d6c76e862e6a1p-1, -0x1.3a00p-47,
0x1.d80e316c9834ep-1, -0x1.cd80p-47,
0x1.d955d71ff6090p-1, 0x1.4c00p-48,
0x1.da9e603db32aep-1, 0x1.f900p-48,
0x1.dbe7cd63a8325p-1, 0x1.9800p-49,
0x1.dd321f301b445p-1, -0x1.5200p-48,
0x1.de7d5641c05bfp-1, -0x1.d700p-46,
0x1.dfc97337b9aecp-1, -0x1.6140p-46,
0x1.e11676b197d5ep-1, 0x1.b480p-47,
0x1.e264614f5a3e7p-1, 0x1.0ce0p-43,
0x1.e3b333b16ee5cp-1, 0x1.c680p-47,
0x1.e502ee78b3fb4p-1, -0x1.9300p-47,
0x1.e653924676d68p-1, -0x1.5000p-49,
0x1.e7a51fbc74c44p-1, -0x1.7f80p-47,
0x1.e8f7977cdb726p-1, -0x1.3700p-48,
0x1.ea4afa2a490e8p-1, 0x1.5d00p-49,
0x1.eb9f4867ccae4p-1, 0x1.61a0p-46,
0x1.ecf482d8e680dp-1, 0x1.5500p-48,
0x1.ee4aaa2188514p-1, 0x1.6400p-51,
0x1.efa1bee615a13p-1, -0x1.e800p-49,
0x1.f0f9c1cb64106p-1, -0x1.a880p-48,
0x1.f252b376bb963p-1, -0x1.c900p-45,
0x1.f3ac948dd7275p-1, 0x1.a000p-53,
0x1.f50765b6e4524p-1, -0x1.4f00p-48,
0x1.f6632798844fdp-1, 0x1.a800p-51,
0x1.f7bfdad9cbe38p-1, 0x1.abc0p-48,
0x1.f91d802243c82p-1, -0x1.4600p-50,
0x1.fa7c1819e908ep-1, -0x1.b0c0p-47,
0x1.fbdba3692d511p-1, -0x1.0e00p-51,
0x1.fd3c22b8f7194p-1, -0x1.0de8p-46,
0x1.fe9d96b2a23eep-1, 0x1.e430p-49,
0x1.0000000000000p+0, 0x0.0000p+0,
0x1.00b1afa5abcbep+0, -0x1.3400p-52,
0x1.0163da9fb3303p+0, -0x1.2170p-46,
0x1.02168143b0282p+0, 0x1.a400p-52,
0x1.02c9a3e77806cp+0, 0x1.f980p-49,
0x1.037d42e11bbcap+0, -0x1.7400p-51,
0x1.04315e86e7f89p+0, 0x1.8300p-50,
0x1.04e5f72f65467p+0, -0x1.a3f0p-46,
0x1.059b0d315855ap+0, -0x1.2840p-47,
0x1.0650a0e3c1f95p+0, 0x1.1600p-48,
0x1.0706b29ddf71ap+0, 0x1.5240p-46,
0x1.07bd42b72a82dp+0, -0x1.9a00p-49,
0x1.0874518759bd0p+0, 0x1.6400p-49,
0x1.092bdf66607c8p+0, -0x1.0780p-47,
0x1.09e3ecac6f383p+0, -0x1.8000p-54,
0x1.0a9c79b1f3930p+0, 0x1.fa00p-48,
0x1.0b5586cf988fcp+0, -0x1.ac80p-48,
0x1.0c0f145e46c8ap+0, 0x1.9c00p-50,
0x1.0cc922b724816p+0, 0x1.5200p-47,
0x1.0d83b23395dd8p+0, -0x1.ad00p-48,
0x1.0e3ec32d3d1f3p+0, 0x1.bac0p-46,
0x1.0efa55fdfa9a6p+0, -0x1.4e80p-47,
0x1.0fb66affed2f0p+0, -0x1.d300p-47,
0x1.1073028d7234bp+0, 0x1.1500p-48,
0x1.11301d0125b5bp+0, 0x1.c000p-49,
0x1.11edbab5e2af9p+0, 0x1.6bc0p-46,
0x1.12abdc06c31d5p+0, 0x1.8400p-49,
0x1.136a814f2047dp+0, -0x1.ed00p-47,
0x1.1429aaea92de9p+0, 0x1.8e00p-49,
0x1.14e95934f3138p+0, 0x1.b400p-49,
0x1.15a98c8a58e71p+0, 0x1.5300p-47,
0x1.166a45471c3dfp+0, 0x1.3380p-47,
0x1.172b83c7d5211p+0, 0x1.8d40p-45,
0x1.17ed48695bb9fp+0, -0x1.5d00p-47,
0x1.18af9388c8d93p+0, -0x1.c880p-46,
0x1.1972658375d66p+0, 0x1.1f00p-46,
0x1.1a35beb6fcba7p+0, 0x1.0480p-46,
0x1.1af99f81387e3p+0, -0x1.7390p-43,
0x1.1bbe084045d54p+0, 0x1.4e40p-45,
0x1.1c82f95281c43p+0, -0x1.a200p-47,
0x1.1d4873168b9b2p+0, 0x1.3800p-49,
0x1.1e0e75eb44031p+0, 0x1.ac00p-49,
0x1.1ed5022fcd938p+0, 0x1.1900p-47,
0x1.1f9c18438cdf7p+0, -0x1.b780p-46,
0x1.2063b88628d8fp+0, 0x1.d940p-45,
0x1.212be3578a81ep+0, 0x1.8000p-50,
0x1.21f49917ddd41p+0, 0x1.b340p-45,
0x1.22bdda2791323p+0, 0x1.9f80p-46,
0x1.2387a6e7561e7p+0, -0x1.9c80p-46,
0x1.2451ffb821427p+0, 0x1.2300p-47,
0x1.251ce4fb2a602p+0, -0x1.3480p-46,
0x1.25e85711eceb0p+0, 0x1.2700p-46,
0x1.26b4565e27d16p+0, 0x1.1d00p-46,
0x1.2780e341de00fp+0, 0x1.1ee0p-44,
0x1.284dfe1f5633ep+0, -0x1.4c00p-46,
0x1.291ba7591bb30p+0, -0x1.3d80p-46,
0x1.29e9df51fdf09p+0, 0x1.8b00p-47,
0x1.2ab8a66d10e9bp+0, -0x1.27c0p-45,
0x1.2b87fd0dada3ap+0, 0x1.a340p-45,
0x1.2c57e39771af9p+0, -0x1.0800p-46,
0x1.2d285a6e402d9p+0, -0x1.ed00p-47,
0x1.2df961f641579p+0, -0x1.4200p-48,
0x1.2ecafa93e2ecfp+0, -0x1.4980p-45,
0x1.2f9d24abd8822p+0, -0x1.6300p-46,
0x1.306fe0a31b625p+0, -0x1.2360p-44,
0x1.31432edeea50bp+0, -0x1.0df8p-40,
0x1.32170fc4cd7b8p+0, -0x1.2480p-45,
0x1.32eb83ba8e9a2p+0, -0x1.5980p-45,
0x1.33c08b2641766p+0, 0x1.ed00p-46,
0x1.3496266e3fa27p+0, -0x1.c000p-50,
0x1.356c55f929f0fp+0, -0x1.0d80p-44,
0x1.36431a2de88b9p+0, 0x1.2c80p-45,
0x1.371a7373aaa39p+0, 0x1.0600p-45,
0x1.37f26231e74fep+0, -0x1.6600p-46,
0x1.38cae6d05d838p+0, -0x1.ae00p-47,
0x1.39a401b713ec3p+0, -0x1.4720p-43,
0x1.3a7db34e5a020p+0, 0x1.8200p-47,
0x1.3b57fbfec6e95p+0, 0x1.e800p-44,
0x1.3c32dc313a8f2p+0, 0x1.f800p-49,
0x1.3d0e544ede122p+0, -0x1.7a00p-46,
0x1.3dea64c1234bbp+0, 0x1.6300p-45,
0x1.3ec70df1c4eccp+0, -0x1.8a60p-43,
0x1.3fa4504ac7e8cp+0, -0x1.cdc0p-44,
0x1.40822c367a0bbp+0, 0x1.5b80p-45,
0x1.4160a21f72e95p+0, 0x1.ec00p-46,
0x1.423fb27094646p+0, -0x1.3600p-46,
0x1.431f5d950a920p+0, 0x1.3980p-45,
0x1.43ffa3f84b9ebp+0, 0x1.a000p-48,
0x1.44e0860618919p+0, -0x1.6c00p-48,
0x1.45c2042a7d201p+0, -0x1.bc00p-47,
0x1.46a41ed1d0016p+0, -0x1.2800p-46,
0x1.4786d668b3326p+0, 0x1.0e00p-44,
0x1.486a2b5c13c00p+0, -0x1.d400p-45,
0x1.494e1e192af04p+0, 0x1.c200p-47,
0x1.4a32af0d7d372p+0, -0x1.e500p-46,
0x1.4b17dea6db801p+0, 0x1.7800p-47,
0x1.4bfdad53629e1p+0, -0x1.3800p-46,
0x1.4ce41b817c132p+0, 0x1.0800p-47,
0x1.4dcb299fddddbp+0, 0x1.c700p-45,
0x1.4eb2d81d8ab96p+0, -0x1.ce00p-46,
0x1.4f9b2769d2d02p+0, 0x1.9200p-46,
0x1.508417f4531c1p+0, -0x1.8c00p-47,
0x1.516daa2cf662ap+0, -0x1.a000p-48,
0x1.5257de83f51eap+0, 0x1.a080p-43,
0x1.5342b569d4edap+0, -0x1.6d80p-45,
0x1.542e2f4f6ac1ap+0, -0x1.2440p-44,
0x1.551a4ca5d94dbp+0, 0x1.83c0p-43,
0x1.56070dde9116bp+0, 0x1.4b00p-45,
0x1.56f4736b529dep+0, 0x1.15a0p-43,
0x1.57e27dbe2c40ep+0, -0x1.9e00p-45,
0x1.58d12d497c76fp+0, -0x1.3080p-45,
0x1.59c0827ff0b4cp+0, 0x1.dec0p-43,
0x1.5ab07dd485427p+0, -0x1.4000p-51,
0x1.5ba11fba87af4p+0, 0x1.0080p-44,
0x1.5c9268a59460bp+0, -0x1.6c80p-45,
0x1.5d84590998e3fp+0, 0x1.69a0p-43,
0x1.5e76f15ad20e1p+0, -0x1.b400p-46,
0x1.5f6a320dcebcap+0, 0x1.7700p-46,
0x1.605e1b976dcb8p+0, 0x1.6f80p-45,
0x1.6152ae6cdf715p+0, 0x1.1000p-47,
0x1.6247eb03a5531p+0, -0x1.5d00p-46,
0x1.633dd1d1929b5p+0, -0x1.2d00p-46,
0x1.6434634ccc313p+0, -0x1.a800p-49,
0x1.652b9febc8efap+0, -0x1.8600p-45,
0x1.6623882553397p+0, 0x1.1fe0p-40,
0x1.671c1c708328ep+0, -0x1.7200p-44,
0x1.68155d44ca97ep+0, 0x1.6800p-49,
0x1.690f4b19e9471p+0, -0x1.9780p-45,
};
/*
* exp2(x): compute the base 2 exponential of x
*
* Accuracy: Peak error < 0.503 ulp for normalized results.
*
* Method: (accurate tables)
*
* Reduce x:
* x = 2**k + y, for integer k and |y| <= 1/2.
* Thus we have exp2(x) = 2**k * exp2(y).
*
* Reduce y:
* y = i/TBLSIZE + z - eps[i] for integer i near y * TBLSIZE.
* Thus we have exp2(y) = exp2(i/TBLSIZE) * exp2(z - eps[i]),
* with |z - eps[i]| <= 2**-9 + 2**-39 for the table used.
*
* We compute exp2(i/TBLSIZE) via table lookup and exp2(z - eps[i]) via
* a degree-5 minimax polynomial with maximum error under 1.3 * 2**-61.
* The values in exp2t[] and eps[] are chosen such that
* exp2t[i] = exp2(i/TBLSIZE + eps[i]), and eps[i] is a small offset such
* that exp2t[i] is accurate to 2**-64.
*
* Note that the range of i is +-TBLSIZE/2, so we actually index the tables
* by i0 = i + TBLSIZE/2. For cache efficiency, exp2t[] and eps[] are
* virtual tables, interleaved in the real table tbl[].
*
* This method is due to Gal, with many details due to Gal and Bachelis:
*
* Gal, S. and Bachelis, B. An Accurate Elementary Mathematical Library
* for the IEEE Floating Point Standard. TOMS 17(1), 26-46 (1991).
*/
double
exp2(double x)
{
double r, t, twopk, twopkp1000, z;
uint32_t hx, ix, lx, i0;
int k;
/* Filter out exceptional cases. */
GET_HIGH_WORD(hx,x);
ix = hx & 0x7fffffff; /* high word of |x| */
if(ix >= 0x40900000) { /* |x| >= 1024 */
if(ix >= 0x7ff00000) {
GET_LOW_WORD(lx,x);
if(((ix & 0xfffff) | lx) != 0 || (hx & 0x80000000) == 0)
return (x + x); /* x is NaN or +Inf */
else
return (0.0); /* x is -Inf */
}
if(x >= 0x1.0p10)
return (huge * huge); /* overflow */
if(x <= -0x1.0ccp10)
return (twom1000 * twom1000); /* underflow */
} else if (ix < 0x3c900000) { /* |x| < 0x1p-54 */
return (1.0 + x);
}
/* Reduce x, computing z, i0, and k. */
STRICT_ASSIGN(double, t, x + redux);
GET_LOW_WORD(i0, t);
i0 += TBLSIZE / 2;
k = (i0 >> TBLBITS) << 20;
i0 = (i0 & (TBLSIZE - 1)) << 1;
t -= redux;
z = x - t;
/* Compute r = exp2(y) = exp2t[i0] * p(z - eps[i]). */
t = tbl[i0]; /* exp2t[i0] */
z -= tbl[i0 + 1]; /* eps[i0] */
if (k >= -(1021 << 20))
INSERT_WORDS(twopk, 0x3ff00000 + k, 0);
else
INSERT_WORDS(twopkp1000, 0x3ff00000 + k + (1000 << 20), 0);
r = t + t * z * (P1 + z * (P2 + z * (P3 + z * (P4 + z * P5))));
/* Scale by 2**(k>>20). */
if(k >= -(1021 << 20)) {
if (k == 1024 << 20) {
double const_0x1p1023 = pow(2, 1023);
return (r * 2.0 * const_0x1p1023);
}
return (r * twopk);
} else {
return (r * twopkp1000 * twom1000);
}
}

Просмотреть файл

@ -1,138 +0,0 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* 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
* 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.
*/
//#include <sys/cdefs.h>
//__FBSDID("$FreeBSD$");
#include <float.h>
#include "math_private.h"
#define TBLBITS 4
#define TBLSIZE (1 << TBLBITS)
static const float
redux = 0x1.8p23f / TBLSIZE,
P1 = 0x1.62e430p-1f,
P2 = 0x1.ebfbe0p-3f,
P3 = 0x1.c6b348p-5f,
P4 = 0x1.3b2c9cp-7f;
static volatile float
huge = 0x1p100f,
twom100 = 0x1p-100f;
static const double exp2ft[TBLSIZE] = {
0x1.6a09e667f3bcdp-1,
0x1.7a11473eb0187p-1,
0x1.8ace5422aa0dbp-1,
0x1.9c49182a3f090p-1,
0x1.ae89f995ad3adp-1,
0x1.c199bdd85529cp-1,
0x1.d5818dcfba487p-1,
0x1.ea4afa2a490dap-1,
0x1.0000000000000p+0,
0x1.0b5586cf9890fp+0,
0x1.172b83c7d517bp+0,
0x1.2387a6e756238p+0,
0x1.306fe0a31b715p+0,
0x1.3dea64c123422p+0,
0x1.4bfdad5362a27p+0,
0x1.5ab07dd485429p+0,
};
/*
* exp2f(x): compute the base 2 exponential of x
*
* Accuracy: Peak error < 0.501 ulp; location of peak: -0.030110927.
*
* Method: (equally-spaced tables)
*
* Reduce x:
* x = 2**k + y, for integer k and |y| <= 1/2.
* Thus we have exp2f(x) = 2**k * exp2(y).
*
* Reduce y:
* y = i/TBLSIZE + z for integer i near y * TBLSIZE.
* Thus we have exp2(y) = exp2(i/TBLSIZE) * exp2(z),
* with |z| <= 2**-(TBLSIZE+1).
*
* We compute exp2(i/TBLSIZE) via table lookup and exp2(z) via a
* degree-4 minimax polynomial with maximum error under 1.4 * 2**-33.
* Using double precision for everything except the reduction makes
* roundoff error insignificant and simplifies the scaling step.
*
* This method is due to Tang, but I do not use his suggested parameters:
*
* Tang, P. Table-driven Implementation of the Exponential Function
* in IEEE Floating-Point Arithmetic. TOMS 15(2), 144-157 (1989).
*/
float
exp2f(float x)
{
double tv, twopk, u, z;
float t;
uint32_t hx, ix, i0;
int32_t k;
/* Filter out exceptional cases. */
GET_FLOAT_WORD(hx, x);
ix = hx & 0x7fffffff; /* high word of |x| */
if(ix >= 0x43000000) { /* |x| >= 128 */
if(ix >= 0x7f800000) {
if ((ix & 0x7fffff) != 0 || (hx & 0x80000000) == 0)
return (x + x); /* x is NaN or +Inf */
else
return (0.0); /* x is -Inf */
}
if(x >= 0x1.0p7f)
return (huge * huge); /* overflow */
if(x <= -0x1.2cp7f)
return (twom100 * twom100); /* underflow */
} else if (ix <= 0x33000000) { /* |x| <= 0x1p-25 */
return (1.0f + x);
}
/* Reduce x, computing z, i0, and k. */
STRICT_ASSIGN(float, t, x + redux);
GET_FLOAT_WORD(i0, t);
i0 += TBLSIZE / 2;
k = (i0 >> TBLBITS) << 20;
i0 &= TBLSIZE - 1;
t -= redux;
z = x - t;
INSERT_WORDS(twopk, 0x3ff00000 + k, 0);
/* Compute r = exp2(y) = exp2ft[i0] * p(z). */
tv = exp2ft[i0];
u = tv * z;
tv = tv + u * (P1 + z * P2) + u * (z * z) * (P3 + z * P4);
/* Scale by 2**(k>>20). */
return (tv * twopk);
}

Просмотреть файл

@ -1,32 +0,0 @@
/* s_fabsf.c -- float version of s_fabs.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, 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$");
/*
* fabsf(x) returns the absolute value of x.
*/
#include "math_private.h"
float
fabsf(float x)
{
u_int32_t ix;
GET_FLOAT_WORD(ix,x);
SET_FLOAT_WORD(x,ix&0x7fffffff);
return x;
}

Просмотреть файл

@ -1,41 +0,0 @@
/*
* Copyright (c) 2005-2020 Rich Felker, et al.
*
* SPDX-License-Identifier: MIT
*
* Please see https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT
* for all contributors to musl.
*/
#include <math.h>
#include <stdint.h>
float scalbnf(float x, int n)
{
union {float f; uint32_t i;} u;
float y = x;
if (n > 127) {
y *= 0x1p127f;
n -= 127;
if (n > 127) {
y *= 0x1p127f;
n -= 127;
if (n > 127)
n = 127;
}
} else if (n < -126) {
y *= 0x1p-126f * 0x1p24f;
n += 126 - 24;
if (n < -126) {
y *= 0x1p-126f * 0x1p24f;
n += 126 - 24;
if (n < -126)
n = -126;
}
}
u.i = (uint32_t)(0x7f+n)<<23;
x = y * u.f;
return x;
}
__strong_reference(scalbnf, ldexpf);

Просмотреть файл

@ -1,84 +0,0 @@
/* s_sinf.c -- float version of s_sin.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
* Optimized by Bruce D. Evans.
*/
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, 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 <float.h>
#define INLINE_KERNEL_COSDF
#define INLINE_KERNEL_SINDF
#define INLINE_REM_PIO2F
#include "math_private.h"
#include "e_rem_pio2f.cpp"
#include "k_cosf.cpp"
#include "k_sinf.cpp"
/* Small multiples of pi/2 rounded to double precision. */
static const double
s1pio2 = 1*M_PI_2, /* 0x3FF921FB, 0x54442D18 */
s2pio2 = 2*M_PI_2, /* 0x400921FB, 0x54442D18 */
s3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */
s4pio2 = 4*M_PI_2; /* 0x401921FB, 0x54442D18 */
float
sinf(float x)
{
double y;
int32_t n, hx, ix;
GET_FLOAT_WORD(hx,x);
ix = hx & 0x7fffffff;
if(ix <= 0x3f490fda) { /* |x| ~<= pi/4 */
if(ix<0x39800000) /* |x| < 2**-12 */
if(((int)x)==0) return x; /* x with inexact if x != 0 */
return __kernel_sindf(x);
}
if(ix<=0x407b53d1) { /* |x| ~<= 5*pi/4 */
if(ix<=0x4016cbe3) { /* |x| ~<= 3pi/4 */
if(hx>0)
return __kernel_cosdf(x - s1pio2);
else
return -__kernel_cosdf(x + s1pio2);
} else
return __kernel_sindf((hx > 0 ? s2pio2 : -s2pio2) - x);
}
if(ix<=0x40e231d5) { /* |x| ~<= 9*pi/4 */
if(ix<=0x40afeddf) { /* |x| ~<= 7*pi/4 */
if(hx>0)
return -__kernel_cosdf(x - s3pio2);
else
return __kernel_cosdf(x + s3pio2);
} else
return __kernel_sindf(x + (hx > 0 ? -s4pio2 : s4pio2));
}
/* sin(Inf or NaN) is NaN */
else if (ix>=0x7f800000) return x-x;
/* general argument reduction needed */
else {
n = __ieee754_rem_pio2f(x,&y);
switch(n&3) {
case 0: return __kernel_sindf(y);
case 1: return __kernel_cosdf(y);
case 2: return __kernel_sindf(-y);
default:
return -__kernel_cosdf(y);
}
}
}

Просмотреть файл

@ -1,71 +0,0 @@
/* s_tanf.c -- float version of s_tan.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
* Optimized by Bruce D. Evans.
*/
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, 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 <float.h>
#define INLINE_KERNEL_TANDF
#define INLINE_REM_PIO2F
#include "math_private.h"
#include "e_rem_pio2f.cpp"
#include "k_tanf.cpp"
/* Small multiples of pi/2 rounded to double precision. */
static const double
t1pio2 = 1*M_PI_2, /* 0x3FF921FB, 0x54442D18 */
t2pio2 = 2*M_PI_2, /* 0x400921FB, 0x54442D18 */
t3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */
t4pio2 = 4*M_PI_2; /* 0x401921FB, 0x54442D18 */
float
tanf(float x)
{
double y;
int32_t n, hx, ix;
GET_FLOAT_WORD(hx,x);
ix = hx & 0x7fffffff;
if(ix <= 0x3f490fda) { /* |x| ~<= pi/4 */
if(ix<0x39800000) /* |x| < 2**-12 */
if(((int)x)==0) return x; /* x with inexact if x != 0 */
return __kernel_tandf(x,1);
}
if(ix<=0x407b53d1) { /* |x| ~<= 5*pi/4 */
if(ix<=0x4016cbe3) /* |x| ~<= 3pi/4 */
return __kernel_tandf(x + (hx>0 ? -t1pio2 : t1pio2), -1);
else
return __kernel_tandf(x + (hx>0 ? -t2pio2 : t2pio2), 1);
}
if(ix<=0x40e231d5) { /* |x| ~<= 9*pi/4 */
if(ix<=0x40afeddf) /* |x| ~<= 7*pi/4 */
return __kernel_tandf(x + (hx>0 ? -t3pio2 : t3pio2), -1);
else
return __kernel_tandf(x + (hx>0 ? -t4pio2 : t4pio2), 1);
}
/* tan(Inf or NaN) is NaN */
else if (ix>=0x7f800000) return x-x;
/* general argument reduction needed */
else {
n = __ieee754_rem_pio2f(x,&y);
/* integer parameter: 1 -- n even; -1 -- n odd */
return __kernel_tandf(y,1-((n&1)<<1));
}
}