From a72caf1301e7f6cc94bd6cb8010ca9ac12c43c1b Mon Sep 17 00:00:00 2001 From: Akos Kiss Date: Wed, 16 Mar 2016 19:01:31 +0100 Subject: [PATCH] Turn simple constants to preprocessor macros JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu --- third-party/fdlibm/e_rem_pio2.c | 22 ++++++------ third-party/fdlibm/k_cos.c | 15 ++++----- third-party/fdlibm/k_rem_pio2.c | 9 +++-- third-party/fdlibm/k_sin.c | 15 ++++----- third-party/fdlibm/k_tan.c | 48 ++++++++++++--------------- third-party/fdlibm/s_acos.c | 29 ++++++++-------- third-party/fdlibm/s_asin.c | 31 +++++++++-------- third-party/fdlibm/s_atan.c | 33 +++++++++--------- third-party/fdlibm/s_atan2.c | 13 ++++---- third-party/fdlibm/s_ceil.c | 2 +- third-party/fdlibm/s_exp.c | 32 +++++++++--------- third-party/fdlibm/s_floor.c | 2 +- third-party/fdlibm/s_fmod.c | 3 +- third-party/fdlibm/s_log.c | 24 ++++++-------- third-party/fdlibm/s_pow.c | 59 +++++++++++++++++---------------- third-party/fdlibm/s_scalbn.c | 9 +++-- third-party/fdlibm/s_sqrt.c | 7 ++-- 17 files changed, 167 insertions(+), 186 deletions(-) diff --git a/third-party/fdlibm/e_rem_pio2.c b/third-party/fdlibm/e_rem_pio2.c index 46e2a9e96..d3f793516 100644 --- a/third-party/fdlibm/e_rem_pio2.c +++ b/third-party/fdlibm/e_rem_pio2.c @@ -55,18 +55,16 @@ static const int npio2_hw[] = { * pio2_3: third 33 bit of pi/2 * pio2_3t: pi/2 - (pio2_1+pio2_2+pio2_3) */ - -static const double -zero = 0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */ -half = 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */ -two24 = 1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */ -invpio2 = 6.36619772367581382433e-01, /* 0x3FE45F30, 0x6DC9C883 */ -pio2_1 = 1.57079632673412561417e+00, /* 0x3FF921FB, 0x54400000 */ -pio2_1t = 6.07710050650619224932e-11, /* 0x3DD0B461, 0x1A626331 */ -pio2_2 = 6.07710050630396597660e-11, /* 0x3DD0B461, 0x1A600000 */ -pio2_2t = 2.02226624879595063154e-21, /* 0x3BA3198A, 0x2E037073 */ -pio2_3 = 2.02226624871116645580e-21, /* 0x3BA3198A, 0x2E000000 */ -pio2_3t = 8.47842766036889956997e-32; /* 0x397B839A, 0x252049C1 */ +#define zero 0.00000000000000000000e+00 /* 0x00000000, 0x00000000 */ +#define half 5.00000000000000000000e-01 /* 0x3FE00000, 0x00000000 */ +#define two24 1.67772160000000000000e+07 /* 0x41700000, 0x00000000 */ +#define invpio2 6.36619772367581382433e-01 /* 0x3FE45F30, 0x6DC9C883 */ +#define pio2_1 1.57079632673412561417e+00 /* 0x3FF921FB, 0x54400000 */ +#define pio2_1t 6.07710050650619224932e-11 /* 0x3DD0B461, 0x1A626331 */ +#define pio2_2 6.07710050630396597660e-11 /* 0x3DD0B461, 0x1A600000 */ +#define pio2_2t 2.02226624879595063154e-21 /* 0x3BA3198A, 0x2E037073 */ +#define pio2_3 2.02226624871116645580e-21 /* 0x3BA3198A, 0x2E000000 */ +#define pio2_3t 8.47842766036889956997e-32 /* 0x397B839A, 0x252049C1 */ int __ieee754_rem_pio2(double x, double *y) { diff --git a/third-party/fdlibm/k_cos.c b/third-party/fdlibm/k_cos.c index ebf1e4a59..ff284107a 100644 --- a/third-party/fdlibm/k_cos.c +++ b/third-party/fdlibm/k_cos.c @@ -48,14 +48,13 @@ #include "fdlibm.h" -static const double -one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ -C1 = 4.16666666666666019037e-02, /* 0x3FA55555, 0x5555554C */ -C2 = -1.38888888888741095749e-03, /* 0xBF56C16C, 0x16C15177 */ -C3 = 2.48015872894767294178e-05, /* 0x3EFA01A0, 0x19CB1590 */ -C4 = -2.75573143513906633035e-07, /* 0xBE927E4F, 0x809C52AD */ -C5 = 2.08757232129817482790e-09, /* 0x3E21EE9E, 0xBDB4B1C4 */ -C6 = -1.13596475577881948265e-11; /* 0xBDA8FAE9, 0xBE8838D4 */ +#define one 1.00000000000000000000e+00 /* 0x3FF00000, 0x00000000 */ +#define C1 4.16666666666666019037e-02 /* 0x3FA55555, 0x5555554C */ +#define C2 -1.38888888888741095749e-03 /* 0xBF56C16C, 0x16C15177 */ +#define C3 2.48015872894767294178e-05 /* 0x3EFA01A0, 0x19CB1590 */ +#define C4 -2.75573143513906633035e-07 /* 0xBE927E4F, 0x809C52AD */ +#define C5 2.08757232129817482790e-09 /* 0x3E21EE9E, 0xBDB4B1C4 */ +#define C6 -1.13596475577881948265e-11 /* 0xBDA8FAE9, 0xBE8838D4 */ double __kernel_cos(double x, double y) { diff --git a/third-party/fdlibm/k_rem_pio2.c b/third-party/fdlibm/k_rem_pio2.c index 664fd9335..9013b49e4 100644 --- a/third-party/fdlibm/k_rem_pio2.c +++ b/third-party/fdlibm/k_rem_pio2.c @@ -142,11 +142,10 @@ static const double PIo2[] = { 2.16741683877804819444e-51, /* 0x3569F31D, 0x00000000 */ }; -static const double -zero = 0.0, -one = 1.0, -two24 = 1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */ -twon24 = 5.96046447753906250000e-08; /* 0x3E700000, 0x00000000 */ +#define zero 0.0 +#define one 1.0 +#define two24 1.67772160000000000000e+07 /* 0x41700000, 0x00000000 */ +#define twon24 5.96046447753906250000e-08 /* 0x3E700000, 0x00000000 */ int __kernel_rem_pio2(double *x, double *y, int e0, int nx, int prec, const int *ipio2) { diff --git a/third-party/fdlibm/k_sin.c b/third-party/fdlibm/k_sin.c index 959b29942..ad11cb3f3 100644 --- a/third-party/fdlibm/k_sin.c +++ b/third-party/fdlibm/k_sin.c @@ -41,14 +41,13 @@ #include "fdlibm.h" -static const double -half = 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */ -S1 = -1.66666666666666324348e-01, /* 0xBFC55555, 0x55555549 */ -S2 = 8.33333333332248946124e-03, /* 0x3F811111, 0x1110F8A6 */ -S3 = -1.98412698298579493134e-04, /* 0xBF2A01A0, 0x19C161D5 */ -S4 = 2.75573137070700676789e-06, /* 0x3EC71DE3, 0x57B1FE7D */ -S5 = -2.50507602534068634195e-08, /* 0xBE5AE5E6, 0x8A2B9CEB */ -S6 = 1.58969099521155010221e-10; /* 0x3DE5D93A, 0x5ACFD57C */ +#define half 5.00000000000000000000e-01 /* 0x3FE00000, 0x00000000 */ +#define S1 -1.66666666666666324348e-01 /* 0xBFC55555, 0x55555549 */ +#define S2 8.33333333332248946124e-03 /* 0x3F811111, 0x1110F8A6 */ +#define S3 -1.98412698298579493134e-04 /* 0xBF2A01A0, 0x19C161D5 */ +#define S4 2.75573137070700676789e-06 /* 0x3EC71DE3, 0x57B1FE7D */ +#define S5 -2.50507602534068634195e-08 /* 0xBE5AE5E6, 0x8A2B9CEB */ +#define S6 1.58969099521155010221e-10 /* 0x3DE5D93A, 0x5ACFD57C */ double __kernel_sin(double x, double y, int iy) { diff --git a/third-party/fdlibm/k_tan.c b/third-party/fdlibm/k_tan.c index c49762fbd..3008811d0 100644 --- a/third-party/fdlibm/k_tan.c +++ b/third-party/fdlibm/k_tan.c @@ -45,28 +45,22 @@ #include "fdlibm.h" -static const double xxx[] = { - 3.33333333333334091986e-01, /* 3FD55555, 55555563 */ - 1.33333333333201242699e-01, /* 3FC11111, 1110FE7A */ - 5.39682539762260521377e-02, /* 3FABA1BA, 1BB341FE */ - 2.18694882948595424599e-02, /* 3F9664F4, 8406D637 */ - 8.86323982359930005737e-03, /* 3F8226E3, E96E8493 */ - 3.59207910759131235356e-03, /* 3F6D6D22, C9560328 */ - 1.45620945432529025516e-03, /* 3F57DBC8, FEE08315 */ - 5.88041240820264096874e-04, /* 3F4344D8, F2F26501 */ - 2.46463134818469906812e-04, /* 3F3026F7, 1A8D1068 */ - 7.81794442939557092300e-05, /* 3F147E88, A03792A6 */ - 7.14072491382608190305e-05, /* 3F12B80F, 32F0A7E9 */ - -1.85586374855275456654e-05, /* BEF375CB, DB605373 */ - 2.59073051863633712884e-05, /* 3EFB2A70, 74BF7AD4 */ -/* one */ 1.00000000000000000000e+00, /* 3FF00000, 00000000 */ -/* pio4 */ 7.85398163397448278999e-01, /* 3FE921FB, 54442D18 */ -/* pio4lo */ 3.06161699786838301793e-17 /* 3C81A626, 33145C07 */ -}; -#define one xxx[13] -#define pio4 xxx[14] -#define pio4lo xxx[15] -#define T xxx +#define T0 3.33333333333334091986e-01 /* 3FD55555, 55555563 */ +#define T1 1.33333333333201242699e-01 /* 3FC11111, 1110FE7A */ +#define T2 5.39682539762260521377e-02 /* 3FABA1BA, 1BB341FE */ +#define T3 2.18694882948595424599e-02 /* 3F9664F4, 8406D637 */ +#define T4 8.86323982359930005737e-03 /* 3F8226E3, E96E8493 */ +#define T5 3.59207910759131235356e-03 /* 3F6D6D22, C9560328 */ +#define T6 1.45620945432529025516e-03 /* 3F57DBC8, FEE08315 */ +#define T7 5.88041240820264096874e-04 /* 3F4344D8, F2F26501 */ +#define T8 2.46463134818469906812e-04 /* 3F3026F7, 1A8D1068 */ +#define T9 7.81794442939557092300e-05 /* 3F147E88, A03792A6 */ +#define T10 7.14072491382608190305e-05 /* 3F12B80F, 32F0A7E9 */ +#define T11 -1.85586374855275456654e-05 /* BEF375CB, DB605373 */ +#define T12 2.59073051863633712884e-05 /* 3EFB2A70, 74BF7AD4 */ +#define one 1.00000000000000000000e+00 /* 3FF00000, 00000000 */ +#define pio4 7.85398163397448278999e-01 /* 3FE921FB, 54442D18 */ +#define pio4lo 3.06161699786838301793e-17 /* 3C81A626, 33145C07 */ double __kernel_tan(double x, double y, int iy) { @@ -113,13 +107,13 @@ double __kernel_tan(double x, double y, int iy) * x^5(T[1]+x^4*T[3]+...+x^20*T[11]) + * x^5(x^2*(T[2]+x^4*T[4]+...+x^22*[T12])) */ - r = T[1] + w * (T[3] + w * (T[5] + w * (T[7] + w * (T[9] + - w * T[11])))); - v = z * (T[2] + w * (T[4] + w * (T[6] + w * (T[8] + w * (T[10] + - w * T[12]))))); + r = T1 + w * (T3 + w * (T5 + w * (T7 + w * (T9 + + w * T11)))); + v = z * (T2 + w * (T4 + w * (T6 + w * (T8 + w * (T10 + + w * T12))))); s = z * x; r = y + z * (s * (r + v) + y); - r += T[0] * s; + r += T0 * s; w = x + r; if (ix >= 0x3FE59428) { v = (double) iy; diff --git a/third-party/fdlibm/s_acos.c b/third-party/fdlibm/s_acos.c index 4bf4166c6..bd6ec1259 100644 --- a/third-party/fdlibm/s_acos.c +++ b/third-party/fdlibm/s_acos.c @@ -37,21 +37,20 @@ #include "fdlibm.h" -static const double -one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ -pi = 3.14159265358979311600e+00, /* 0x400921FB, 0x54442D18 */ -pio2_hi = 1.57079632679489655800e+00, /* 0x3FF921FB, 0x54442D18 */ -pio2_lo = 6.12323399573676603587e-17, /* 0x3C91A626, 0x33145C07 */ -pS0 = 1.66666666666666657415e-01, /* 0x3FC55555, 0x55555555 */ -pS1 = -3.25565818622400915405e-01, /* 0xBFD4D612, 0x03EB6F7D */ -pS2 = 2.01212532134862925881e-01, /* 0x3FC9C155, 0x0E884455 */ -pS3 = -4.00555345006794114027e-02, /* 0xBFA48228, 0xB5688F3B */ -pS4 = 7.91534994289814532176e-04, /* 0x3F49EFE0, 0x7501B288 */ -pS5 = 3.47933107596021167570e-05, /* 0x3F023DE1, 0x0DFDF709 */ -qS1 = -2.40339491173441421878e+00, /* 0xC0033A27, 0x1C8A2D4B */ -qS2 = 2.02094576023350569471e+00, /* 0x40002AE5, 0x9C598AC8 */ -qS3 = -6.88283971605453293030e-01, /* 0xBFE6066C, 0x1B8D0159 */ -qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */ +#define one 1.00000000000000000000e+00 /* 0x3FF00000, 0x00000000 */ +#define pi 3.14159265358979311600e+00 /* 0x400921FB, 0x54442D18 */ +#define pio2_hi 1.57079632679489655800e+00 /* 0x3FF921FB, 0x54442D18 */ +#define pio2_lo 6.12323399573676603587e-17 /* 0x3C91A626, 0x33145C07 */ +#define pS0 1.66666666666666657415e-01 /* 0x3FC55555, 0x55555555 */ +#define pS1 -3.25565818622400915405e-01 /* 0xBFD4D612, 0x03EB6F7D */ +#define pS2 2.01212532134862925881e-01 /* 0x3FC9C155, 0x0E884455 */ +#define pS3 -4.00555345006794114027e-02 /* 0xBFA48228, 0xB5688F3B */ +#define pS4 7.91534994289814532176e-04 /* 0x3F49EFE0, 0x7501B288 */ +#define pS5 3.47933107596021167570e-05 /* 0x3F023DE1, 0x0DFDF709 */ +#define qS1 -2.40339491173441421878e+00 /* 0xC0033A27, 0x1C8A2D4B */ +#define qS2 2.02094576023350569471e+00 /* 0x40002AE5, 0x9C598AC8 */ +#define qS3 -6.88283971605453293030e-01 /* 0xBFE6066C, 0x1B8D0159 */ +#define qS4 7.70381505559019352791e-02 /* 0x3FB3B8C5, 0xB12E9282 */ double acos(double x) { diff --git a/third-party/fdlibm/s_asin.c b/third-party/fdlibm/s_asin.c index 9a7581460..8f8a83b47 100644 --- a/third-party/fdlibm/s_asin.c +++ b/third-party/fdlibm/s_asin.c @@ -44,23 +44,22 @@ #include "fdlibm.h" -static const double -one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ -huge = 1.000e+300, -pio2_hi = 1.57079632679489655800e+00, /* 0x3FF921FB, 0x54442D18 */ -pio2_lo = 6.12323399573676603587e-17, /* 0x3C91A626, 0x33145C07 */ -pio4_hi = 7.85398163397448278999e-01, /* 0x3FE921FB, 0x54442D18 */ +#define one 1.00000000000000000000e+00 /* 0x3FF00000, 0x00000000 */ +#define huge 1.000e+300 +#define pio2_hi 1.57079632679489655800e+00 /* 0x3FF921FB, 0x54442D18 */ +#define pio2_lo 6.12323399573676603587e-17 /* 0x3C91A626, 0x33145C07 */ +#define pio4_hi 7.85398163397448278999e-01 /* 0x3FE921FB, 0x54442D18 */ /* coefficient for R(x^2) */ -pS0 = 1.66666666666666657415e-01, /* 0x3FC55555, 0x55555555 */ -pS1 = -3.25565818622400915405e-01, /* 0xBFD4D612, 0x03EB6F7D */ -pS2 = 2.01212532134862925881e-01, /* 0x3FC9C155, 0x0E884455 */ -pS3 = -4.00555345006794114027e-02, /* 0xBFA48228, 0xB5688F3B */ -pS4 = 7.91534994289814532176e-04, /* 0x3F49EFE0, 0x7501B288 */ -pS5 = 3.47933107596021167570e-05, /* 0x3F023DE1, 0x0DFDF709 */ -qS1 = -2.40339491173441421878e+00, /* 0xC0033A27, 0x1C8A2D4B */ -qS2 = 2.02094576023350569471e+00, /* 0x40002AE5, 0x9C598AC8 */ -qS3 = -6.88283971605453293030e-01, /* 0xBFE6066C, 0x1B8D0159 */ -qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */ +#define pS0 1.66666666666666657415e-01 /* 0x3FC55555, 0x55555555 */ +#define pS1 -3.25565818622400915405e-01 /* 0xBFD4D612, 0x03EB6F7D */ +#define pS2 2.01212532134862925881e-01 /* 0x3FC9C155, 0x0E884455 */ +#define pS3 -4.00555345006794114027e-02 /* 0xBFA48228, 0xB5688F3B */ +#define pS4 7.91534994289814532176e-04 /* 0x3F49EFE0, 0x7501B288 */ +#define pS5 3.47933107596021167570e-05 /* 0x3F023DE1, 0x0DFDF709 */ +#define qS1 -2.40339491173441421878e+00 /* 0xC0033A27, 0x1C8A2D4B */ +#define qS2 2.02094576023350569471e+00 /* 0x40002AE5, 0x9C598AC8 */ +#define qS3 -6.88283971605453293030e-01 /* 0xBFE6066C, 0x1B8D0159 */ +#define qS4 7.70381505559019352791e-02 /* 0x3FB3B8C5, 0xB12E9282 */ double asin(double x) { diff --git a/third-party/fdlibm/s_atan.c b/third-party/fdlibm/s_atan.c index fecb7fd1e..1af2ab835 100644 --- a/third-party/fdlibm/s_atan.c +++ b/third-party/fdlibm/s_atan.c @@ -48,23 +48,20 @@ static const double atanlo[] = { 6.12323399573676603587e-17, /* atan(inf)lo 0x3C91A626, 0x33145C07 */ }; -static const double aT[] = { - 3.33333333333329318027e-01, /* 0x3FD55555, 0x5555550D */ - -1.99999999998764832476e-01, /* 0xBFC99999, 0x9998EBC4 */ - 1.42857142725034663711e-01, /* 0x3FC24924, 0x920083FF */ - -1.11111104054623557880e-01, /* 0xBFBC71C6, 0xFE231671 */ - 9.09088713343650656196e-02, /* 0x3FB745CD, 0xC54C206E */ - -7.69187620504482999495e-02, /* 0xBFB3B0F2, 0xAF749A6D */ - 6.66107313738753120669e-02, /* 0x3FB10D66, 0xA0D03D51 */ - -5.83357013379057348645e-02, /* 0xBFADDE2D, 0x52DEFD9A */ - 4.97687799461593236017e-02, /* 0x3FA97B4B, 0x24760DEB */ - -3.65315727442169155270e-02, /* 0xBFA2B444, 0x2C6A6C2F */ - 1.62858201153657823623e-02, /* 0x3F90AD3A, 0xE322DA11 */ -}; +#define aT0 3.33333333333329318027e-01 /* 0x3FD55555, 0x5555550D */ +#define aT1 -1.99999999998764832476e-01 /* 0xBFC99999, 0x9998EBC4 */ +#define aT2 1.42857142725034663711e-01 /* 0x3FC24924, 0x920083FF */ +#define aT3 -1.11111104054623557880e-01 /* 0xBFBC71C6, 0xFE231671 */ +#define aT4 9.09088713343650656196e-02 /* 0x3FB745CD, 0xC54C206E */ +#define aT5 -7.69187620504482999495e-02 /* 0xBFB3B0F2, 0xAF749A6D */ +#define aT6 6.66107313738753120669e-02 /* 0x3FB10D66, 0xA0D03D51 */ +#define aT7 -5.83357013379057348645e-02 /* 0xBFADDE2D, 0x52DEFD9A */ +#define aT8 4.97687799461593236017e-02 /* 0x3FA97B4B, 0x24760DEB */ +#define aT9 -3.65315727442169155270e-02 /* 0xBFA2B444, 0x2C6A6C2F */ +#define aT10 1.62858201153657823623e-02 /* 0x3F90AD3A, 0xE322DA11 */ -static const double -one = 1.0, -huge = 1.0e300; +#define one 1.0 +#define huge 1.0e300 double atan(double x) { @@ -103,8 +100,8 @@ double atan(double x) 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]+w*(aT[6]+w*(aT[8]+w*aT[10]))))); - s2 = w*(aT[1]+w*(aT[3]+w*(aT[5]+w*(aT[7]+w*aT[9])))); + s1 = z*(aT0+w*(aT2+w*(aT4+w*(aT6+w*(aT8+w*aT10))))); + s2 = w*(aT1+w*(aT3+w*(aT5+w*(aT7+w*aT9)))); if (id<0) return x - x*(s1+s2); else { z = atanhi[id] - ((x*(s1+s2) - atanlo[id]) - x); diff --git a/third-party/fdlibm/s_atan2.c b/third-party/fdlibm/s_atan2.c index f9445481f..1fd92e8b1 100644 --- a/third-party/fdlibm/s_atan2.c +++ b/third-party/fdlibm/s_atan2.c @@ -41,13 +41,12 @@ #include "fdlibm.h" -static const double -tiny = 1.0e-300, -zero = 0.0, -pi_o_4 = 7.8539816339744827900E-01, /* 0x3FE921FB, 0x54442D18 */ -pi_o_2 = 1.5707963267948965580E+00, /* 0x3FF921FB, 0x54442D18 */ -pi = 3.1415926535897931160E+00, /* 0x400921FB, 0x54442D18 */ -pi_lo = 1.2246467991473531772E-16; /* 0x3CA1A626, 0x33145C07 */ +#define tiny 1.0e-300 +#define zero 0.0 +#define pi_o_4 7.8539816339744827900E-01 /* 0x3FE921FB, 0x54442D18 */ +#define pi_o_2 1.5707963267948965580E+00 /* 0x3FF921FB, 0x54442D18 */ +#define pi 3.1415926535897931160E+00 /* 0x400921FB, 0x54442D18 */ +#define pi_lo 1.2246467991473531772E-16 /* 0x3CA1A626, 0x33145C07 */ double atan2(double y, double x) { diff --git a/third-party/fdlibm/s_ceil.c b/third-party/fdlibm/s_ceil.c index 9500f2ab4..93d0fde87 100644 --- a/third-party/fdlibm/s_ceil.c +++ b/third-party/fdlibm/s_ceil.c @@ -22,7 +22,7 @@ #include "fdlibm.h" -static const double huge = 1.0e300; +#define huge 1.0e300 double ceil(double x) { diff --git a/third-party/fdlibm/s_exp.c b/third-party/fdlibm/s_exp.c index 0e7c8818a..b98baab21 100644 --- a/third-party/fdlibm/s_exp.c +++ b/third-party/fdlibm/s_exp.c @@ -76,23 +76,23 @@ #include "fdlibm.h" static const double -one = 1.0, -halF[2] = {0.5,-0.5,}, -huge = 1.0e+300, -twom1000= 9.33263618503218878990e-302, /* 2**-1000=0x01700000,0*/ -o_threshold= 7.09782712893383973096e+02, /* 0x40862E42, 0xFEFA39EF */ -u_threshold= -7.45133219101941108420e+02, /* 0xc0874910, 0xD52D3051 */ -ln2HI[2] ={ 6.93147180369123816490e-01, /* 0x3fe62e42, 0xfee00000 */ - -6.93147180369123816490e-01,},/* 0xbfe62e42, 0xfee00000 */ -ln2LO[2] ={ 1.90821492927058770002e-10, /* 0x3dea39ef, 0x35793c76 */ - -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 */ +halF[2] = {0.5,-0.5,}, +ln2HI[2] = { 6.93147180369123816490e-01, /* 0x3fe62e42, 0xfee00000 */ + -6.93147180369123816490e-01,}, /* 0xbfe62e42, 0xfee00000 */ +ln2LO[2] = { 1.90821492927058770002e-10, /* 0x3dea39ef, 0x35793c76 */ + -1.90821492927058770002e-10,}; /* 0xbdea39ef, 0x35793c76 */ +#define one 1.0 +#define huge 1.0e+300 +#define twom1000 9.33263618503218878990e-302 /* 2**-1000=0x01700000,0 */ +#define o_threshold 7.09782712893383973096e+02 /* 0x40862E42, 0xFEFA39EF */ +#define u_threshold -7.45133219101941108420e+02 /* 0xc0874910, 0xD52D3051 */ +#define invln2 1.44269504088896338700e+00 /* 0x3ff71547, 0x652b82fe */ +#define P1 1.66666666666666019037e-01 /* 0x3FC55555, 0x5555553E */ +#define P2 -2.77777777770155933842e-03 /* 0xBF66C16C, 0x16BEBD93 */ +#define P3 6.61375632143793436117e-05 /* 0x3F11566A, 0xAF25DE2C */ +#define P4 -1.65339022054652515390e-06 /* 0xBEBBBD41, 0xC5D26BF1 */ +#define P5 4.13813679705723846039e-08 /* 0x3E663769, 0x72BEA4D0 */ double exp(double x) /* default IEEE double exp */ { diff --git a/third-party/fdlibm/s_floor.c b/third-party/fdlibm/s_floor.c index 2d1fb84ce..911dbfb64 100644 --- a/third-party/fdlibm/s_floor.c +++ b/third-party/fdlibm/s_floor.c @@ -22,7 +22,7 @@ #include "fdlibm.h" -static const double huge = 1.0e300; +#define huge 1.0e300 double floor(double x) { diff --git a/third-party/fdlibm/s_fmod.c b/third-party/fdlibm/s_fmod.c index c4bafd4c9..2d6cbc437 100644 --- a/third-party/fdlibm/s_fmod.c +++ b/third-party/fdlibm/s_fmod.c @@ -20,9 +20,10 @@ #include "fdlibm.h" static const double -one = 1.0, Zero[] = {0.0, -0.0,}; +#define one 1.0 + double fmod(double x, double y) { int n,hx,hy,hz,ix,iy,sx,i; diff --git a/third-party/fdlibm/s_log.c b/third-party/fdlibm/s_log.c index a11c1a941..6cf97ca39 100644 --- a/third-party/fdlibm/s_log.c +++ b/third-party/fdlibm/s_log.c @@ -64,19 +64,17 @@ #include "fdlibm.h" -static const double -ln2_hi = 6.93147180369123816490e-01, /* 3fe62e42 fee00000 */ -ln2_lo = 1.90821492927058770002e-10, /* 3dea39ef 35793c76 */ -two54 = 1.80143985094819840000e+16, /* 43500000 00000000 */ -Lg1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */ -Lg2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */ -Lg3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */ -Lg4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */ -Lg5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */ -Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */ -Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */ - -static const double zero = 0.0; +#define zero 0.0 +#define ln2_hi 6.93147180369123816490e-01 /* 3fe62e42 fee00000 */ +#define ln2_lo 1.90821492927058770002e-10 /* 3dea39ef 35793c76 */ +#define two54 1.80143985094819840000e+16 /* 43500000 00000000 */ +#define Lg1 6.666666666666735130e-01 /* 3FE55555 55555593 */ +#define Lg2 3.999999999940941908e-01 /* 3FD99999 9997FA04 */ +#define Lg3 2.857142874366239149e-01 /* 3FD24924 94229359 */ +#define Lg4 2.222219843214978396e-01 /* 3FCC71C5 1D8E78AF */ +#define Lg5 1.818357216161805012e-01 /* 3FC74664 96CB03DE */ +#define Lg6 1.531383769920937332e-01 /* 3FC39A09 D078C69F */ +#define Lg7 1.479819860511658591e-01 /* 3FC2F112 DF3E5244 */ double log(double x) { diff --git a/third-party/fdlibm/s_pow.c b/third-party/fdlibm/s_pow.c index f3981792d..7066eefd3 100644 --- a/third-party/fdlibm/s_pow.c +++ b/third-party/fdlibm/s_pow.c @@ -58,37 +58,38 @@ #include "fdlibm.h" static const double -bp[] = {1.0, 1.5,}, +one = 1.0, +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, -one = 1.0, -two = 2.0, -two53 = 9007199254740992.0, /* 0x43400000, 0x00000000 */ -huge = 1.0e300, -tiny = 1.0e-300, +dp_l[] = { 0.0, 1.35003920212974897128e-08,}; /* 0x3E4CFDEB, 0x43CFD006 */ + +#define zero 0.0 +#define two 2.0 +#define two53 9007199254740992.0 /* 0x43400000, 0x00000000 */ +#define huge 1.0e300 +#define tiny 1.0e-300 /* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */ -L1 = 5.99999999999994648725e-01, /* 0x3FE33333, 0x33333303 */ -L2 = 4.28571428578550184252e-01, /* 0x3FDB6DB6, 0xDB6FABFF */ -L3 = 3.33333329818377432918e-01, /* 0x3FD55555, 0x518F264D */ -L4 = 2.72728123808534006489e-01, /* 0x3FD17460, 0xA91D4101 */ -L5 = 2.30660745775561754067e-01, /* 0x3FCD864A, 0x93C9DB65 */ -L6 = 2.06975017800338417784e-01, /* 0x3FCA7E28, 0x4A454EEF */ -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 */ -lg2 = 6.93147180559945286227e-01, /* 0x3FE62E42, 0xFEFA39EF */ -lg2_h = 6.93147182464599609375e-01, /* 0x3FE62E43, 0x00000000 */ -lg2_l = -1.90465429995776804525e-09, /* 0xBE205C61, 0x0CA86C39 */ -ovt = 8.0085662595372944372e-0017, /* -(1024-log2(ovfl+.5ulp)) */ -cp = 9.61796693925975554329e-01, /* 0x3FEEC709, 0xDC3A03FD =2/(3ln2) */ -cp_h = 9.61796700954437255859e-01, /* 0x3FEEC709, 0xE0000000 =(float)cp */ -cp_l = -7.02846165095275826516e-09, /* 0xBE3E2FE0, 0x145B01F5 =tail of cp_h*/ -ivln2 = 1.44269504088896338700e+00, /* 0x3FF71547, 0x652B82FE =1/ln2 */ -ivln2_h = 1.44269502162933349609e+00, /* 0x3FF71547, 0x60000000 =24b 1/ln2*/ -ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/ +#define L1 5.99999999999994648725e-01 /* 0x3FE33333, 0x33333303 */ +#define L2 4.28571428578550184252e-01 /* 0x3FDB6DB6, 0xDB6FABFF */ +#define L3 3.33333329818377432918e-01 /* 0x3FD55555, 0x518F264D */ +#define L4 2.72728123808534006489e-01 /* 0x3FD17460, 0xA91D4101 */ +#define L5 2.30660745775561754067e-01 /* 0x3FCD864A, 0x93C9DB65 */ +#define L6 2.06975017800338417784e-01 /* 0x3FCA7E28, 0x4A454EEF */ +#define P1 1.66666666666666019037e-01 /* 0x3FC55555, 0x5555553E */ +#define P2 -2.77777777770155933842e-03 /* 0xBF66C16C, 0x16BEBD93 */ +#define P3 6.61375632143793436117e-05 /* 0x3F11566A, 0xAF25DE2C */ +#define P4 -1.65339022054652515390e-06 /* 0xBEBBBD41, 0xC5D26BF1 */ +#define P5 4.13813679705723846039e-08 /* 0x3E663769, 0x72BEA4D0 */ +#define lg2 6.93147180559945286227e-01 /* 0x3FE62E42, 0xFEFA39EF */ +#define lg2_h 6.93147182464599609375e-01 /* 0x3FE62E43, 0x00000000 */ +#define lg2_l -1.90465429995776804525e-09 /* 0xBE205C61, 0x0CA86C39 */ +#define ovt 8.0085662595372944372e-0017 /* -(1024-log2(ovfl+.5ulp)) */ +#define cp 9.61796693925975554329e-01 /* 0x3FEEC709, 0xDC3A03FD =2/(3ln2) */ +#define cp_h 9.61796700954437255859e-01 /* 0x3FEEC709, 0xE0000000 =(float)cp */ +#define cp_l -7.02846165095275826516e-09 /* 0xBE3E2FE0, 0x145B01F5 =tail of cp_h*/ +#define ivln2 1.44269504088896338700e+00 /* 0x3FF71547, 0x652B82FE =1/ln2 */ +#define ivln2_h 1.44269502162933349609e+00 /* 0x3FF71547, 0x60000000 =24b 1/ln2*/ +#define ivln2_l 1.92596299112661746887e-08 /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/ double pow(double x, double y) { diff --git a/third-party/fdlibm/s_scalbn.c b/third-party/fdlibm/s_scalbn.c index 95d51b0ef..1f5dff570 100644 --- a/third-party/fdlibm/s_scalbn.c +++ b/third-party/fdlibm/s_scalbn.c @@ -20,11 +20,10 @@ #include "fdlibm.h" -static const double -two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */ -twom54 = 5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */ -huge = 1.0e+300, -tiny = 1.0e-300; +#define two54 1.80143985094819840000e+16 /* 0x43500000, 0x00000000 */ +#define twom54 5.55111512312578270212e-17 /* 0x3C900000, 0x00000000 */ +#define huge 1.0e+300 +#define tiny 1.0e-300 double scalbn (double x, int n) { diff --git a/third-party/fdlibm/s_sqrt.c b/third-party/fdlibm/s_sqrt.c index 6d096fb9c..2baf9bc58 100644 --- a/third-party/fdlibm/s_sqrt.c +++ b/third-party/fdlibm/s_sqrt.c @@ -83,9 +83,8 @@ #include "fdlibm.h" -static const double -one = 1.0, -tiny = 1.0e-300; +#define one 1.0 +#define tiny 1.0e-300 double sqrt(double x) { @@ -361,7 +360,7 @@ B. sqrt(x) by Reciproot Iteration (3) Final adjustment - By twiddling y's last bit it is possible to force y to be + By twiddling y's last bit it is possible to force y to be correctly rounded according to the prevailing rounding mode as follows. Let r and i be copies of the rounding mode and inexact flag before entering the square root program. Also we