[Midnightbsd-cvs] src [10591] trunk/lib/msun/src: sync src
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sat Jun 9 11:08:31 EDT 2018
Revision: 10591
http://svnweb.midnightbsd.org/src/?rev=10591
Author: laffer1
Date: 2018-06-09 11:08:31 -0400 (Sat, 09 Jun 2018)
Log Message:
-----------
sync src
Modified Paths:
--------------
trunk/lib/msun/src/e_acos.c
trunk/lib/msun/src/e_acosf.c
trunk/lib/msun/src/e_acosh.c
trunk/lib/msun/src/e_acoshf.c
trunk/lib/msun/src/e_acosl.c
trunk/lib/msun/src/e_asin.c
trunk/lib/msun/src/e_asinf.c
trunk/lib/msun/src/e_asinl.c
trunk/lib/msun/src/e_atan2.c
trunk/lib/msun/src/e_atan2f.c
trunk/lib/msun/src/e_atan2l.c
trunk/lib/msun/src/e_atanh.c
trunk/lib/msun/src/e_atanhf.c
trunk/lib/msun/src/e_cosh.c
trunk/lib/msun/src/e_coshf.c
trunk/lib/msun/src/e_exp.c
trunk/lib/msun/src/e_expf.c
trunk/lib/msun/src/e_fmod.c
trunk/lib/msun/src/e_fmodf.c
trunk/lib/msun/src/e_fmodl.c
trunk/lib/msun/src/e_gamma.c
trunk/lib/msun/src/e_gamma_r.c
trunk/lib/msun/src/e_gammaf.c
trunk/lib/msun/src/e_gammaf_r.c
trunk/lib/msun/src/e_hypot.c
trunk/lib/msun/src/e_hypotf.c
trunk/lib/msun/src/e_hypotl.c
trunk/lib/msun/src/e_j0.c
trunk/lib/msun/src/e_j0f.c
trunk/lib/msun/src/e_j1.c
trunk/lib/msun/src/e_j1f.c
trunk/lib/msun/src/e_jn.c
trunk/lib/msun/src/e_jnf.c
trunk/lib/msun/src/e_lgamma.c
trunk/lib/msun/src/e_lgamma_r.c
trunk/lib/msun/src/e_lgammaf.c
trunk/lib/msun/src/e_lgammaf_r.c
trunk/lib/msun/src/e_log.c
trunk/lib/msun/src/e_log10.c
trunk/lib/msun/src/e_log10f.c
trunk/lib/msun/src/e_log2.c
trunk/lib/msun/src/e_log2f.c
trunk/lib/msun/src/e_logf.c
trunk/lib/msun/src/e_pow.c
trunk/lib/msun/src/e_powf.c
trunk/lib/msun/src/e_rem_pio2.c
trunk/lib/msun/src/e_rem_pio2f.c
trunk/lib/msun/src/e_remainder.c
trunk/lib/msun/src/e_remainderf.c
trunk/lib/msun/src/e_remainderl.c
trunk/lib/msun/src/e_scalb.c
trunk/lib/msun/src/e_scalbf.c
trunk/lib/msun/src/e_sinh.c
trunk/lib/msun/src/e_sinhf.c
trunk/lib/msun/src/e_sqrt.c
trunk/lib/msun/src/e_sqrtf.c
trunk/lib/msun/src/e_sqrtl.c
trunk/lib/msun/src/k_cos.c
trunk/lib/msun/src/k_cosf.c
trunk/lib/msun/src/k_log.h
trunk/lib/msun/src/k_logf.h
trunk/lib/msun/src/k_rem_pio2.c
trunk/lib/msun/src/k_rem_pio2f.c
trunk/lib/msun/src/k_sin.c
trunk/lib/msun/src/k_sinf.c
trunk/lib/msun/src/k_tan.c
trunk/lib/msun/src/k_tanf.c
trunk/lib/msun/src/math.h
trunk/lib/msun/src/math_private.h
trunk/lib/msun/src/s_asinh.c
trunk/lib/msun/src/s_asinhf.c
trunk/lib/msun/src/s_atan.c
trunk/lib/msun/src/s_atanf.c
trunk/lib/msun/src/s_atanl.c
trunk/lib/msun/src/s_carg.c
trunk/lib/msun/src/s_cargf.c
trunk/lib/msun/src/s_cargl.c
trunk/lib/msun/src/s_cbrt.c
trunk/lib/msun/src/s_cbrtf.c
trunk/lib/msun/src/s_cbrtl.c
trunk/lib/msun/src/s_ceil.c
trunk/lib/msun/src/s_ceilf.c
trunk/lib/msun/src/s_ceill.c
trunk/lib/msun/src/s_cexp.c
trunk/lib/msun/src/s_cexpf.c
trunk/lib/msun/src/s_cimag.c
trunk/lib/msun/src/s_cimagf.c
trunk/lib/msun/src/s_cimagl.c
trunk/lib/msun/src/s_conj.c
trunk/lib/msun/src/s_conjf.c
trunk/lib/msun/src/s_conjl.c
trunk/lib/msun/src/s_copysign.c
trunk/lib/msun/src/s_copysignf.c
trunk/lib/msun/src/s_copysignl.c
trunk/lib/msun/src/s_cos.c
trunk/lib/msun/src/s_cosf.c
trunk/lib/msun/src/s_cosl.c
trunk/lib/msun/src/s_cproj.c
trunk/lib/msun/src/s_cprojf.c
trunk/lib/msun/src/s_cprojl.c
trunk/lib/msun/src/s_creal.c
trunk/lib/msun/src/s_crealf.c
trunk/lib/msun/src/s_creall.c
trunk/lib/msun/src/s_csqrt.c
trunk/lib/msun/src/s_csqrtf.c
trunk/lib/msun/src/s_csqrtl.c
trunk/lib/msun/src/s_erf.c
trunk/lib/msun/src/s_erff.c
trunk/lib/msun/src/s_exp2.c
trunk/lib/msun/src/s_exp2f.c
trunk/lib/msun/src/s_expm1.c
trunk/lib/msun/src/s_expm1f.c
trunk/lib/msun/src/s_fabs.c
trunk/lib/msun/src/s_fabsf.c
trunk/lib/msun/src/s_fabsl.c
trunk/lib/msun/src/s_fdim.c
trunk/lib/msun/src/s_finite.c
trunk/lib/msun/src/s_finitef.c
trunk/lib/msun/src/s_floor.c
trunk/lib/msun/src/s_floorf.c
trunk/lib/msun/src/s_floorl.c
trunk/lib/msun/src/s_fma.c
trunk/lib/msun/src/s_fmaf.c
trunk/lib/msun/src/s_fmal.c
trunk/lib/msun/src/s_fmax.c
trunk/lib/msun/src/s_fmaxf.c
trunk/lib/msun/src/s_fmaxl.c
trunk/lib/msun/src/s_fmin.c
trunk/lib/msun/src/s_fminf.c
trunk/lib/msun/src/s_fminl.c
trunk/lib/msun/src/s_frexp.c
trunk/lib/msun/src/s_frexpf.c
trunk/lib/msun/src/s_frexpl.c
trunk/lib/msun/src/s_ilogb.c
trunk/lib/msun/src/s_ilogbf.c
trunk/lib/msun/src/s_ilogbl.c
trunk/lib/msun/src/s_isfinite.c
trunk/lib/msun/src/s_isnan.c
trunk/lib/msun/src/s_isnormal.c
trunk/lib/msun/src/s_llrint.c
trunk/lib/msun/src/s_llrintf.c
trunk/lib/msun/src/s_llrintl.c
trunk/lib/msun/src/s_llround.c
trunk/lib/msun/src/s_llroundf.c
trunk/lib/msun/src/s_llroundl.c
trunk/lib/msun/src/s_log1p.c
trunk/lib/msun/src/s_log1pf.c
trunk/lib/msun/src/s_logb.c
trunk/lib/msun/src/s_logbf.c
trunk/lib/msun/src/s_logbl.c
trunk/lib/msun/src/s_lrint.c
trunk/lib/msun/src/s_lrintf.c
trunk/lib/msun/src/s_lrintl.c
trunk/lib/msun/src/s_lround.c
trunk/lib/msun/src/s_lroundf.c
trunk/lib/msun/src/s_lroundl.c
trunk/lib/msun/src/s_modf.c
trunk/lib/msun/src/s_modff.c
trunk/lib/msun/src/s_modfl.c
trunk/lib/msun/src/s_nan.c
trunk/lib/msun/src/s_nearbyint.c
trunk/lib/msun/src/s_nextafter.c
trunk/lib/msun/src/s_nextafterf.c
trunk/lib/msun/src/s_nextafterl.c
trunk/lib/msun/src/s_nexttoward.c
trunk/lib/msun/src/s_nexttowardf.c
trunk/lib/msun/src/s_remquo.c
trunk/lib/msun/src/s_remquof.c
trunk/lib/msun/src/s_remquol.c
trunk/lib/msun/src/s_rint.c
trunk/lib/msun/src/s_rintf.c
trunk/lib/msun/src/s_rintl.c
trunk/lib/msun/src/s_round.c
trunk/lib/msun/src/s_roundf.c
trunk/lib/msun/src/s_roundl.c
trunk/lib/msun/src/s_scalbln.c
trunk/lib/msun/src/s_scalbn.c
trunk/lib/msun/src/s_scalbnf.c
trunk/lib/msun/src/s_scalbnl.c
trunk/lib/msun/src/s_signbit.c
trunk/lib/msun/src/s_signgam.c
trunk/lib/msun/src/s_significand.c
trunk/lib/msun/src/s_significandf.c
trunk/lib/msun/src/s_sin.c
trunk/lib/msun/src/s_sinf.c
trunk/lib/msun/src/s_sinl.c
trunk/lib/msun/src/s_tan.c
trunk/lib/msun/src/s_tanf.c
trunk/lib/msun/src/s_tanh.c
trunk/lib/msun/src/s_tanhf.c
trunk/lib/msun/src/s_tanl.c
trunk/lib/msun/src/s_tgammaf.c
trunk/lib/msun/src/s_trunc.c
trunk/lib/msun/src/s_truncf.c
trunk/lib/msun/src/s_truncl.c
trunk/lib/msun/src/w_cabs.c
trunk/lib/msun/src/w_cabsf.c
trunk/lib/msun/src/w_cabsl.c
trunk/lib/msun/src/w_drem.c
trunk/lib/msun/src/w_dremf.c
Added Paths:
-----------
trunk/lib/msun/src/catrig.c
trunk/lib/msun/src/catrigf.c
trunk/lib/msun/src/e_acoshl.c
trunk/lib/msun/src/e_atanhl.c
trunk/lib/msun/src/e_coshl.c
trunk/lib/msun/src/e_lgammal.c
trunk/lib/msun/src/e_sinhl.c
trunk/lib/msun/src/fenv-softfloat.h
trunk/lib/msun/src/imprecise.c
trunk/lib/msun/src/k_exp.c
trunk/lib/msun/src/k_expf.c
trunk/lib/msun/src/s_asinhl.c
trunk/lib/msun/src/s_ccosh.c
trunk/lib/msun/src/s_ccoshf.c
trunk/lib/msun/src/s_csinh.c
trunk/lib/msun/src/s_csinhf.c
trunk/lib/msun/src/s_ctanh.c
trunk/lib/msun/src/s_ctanhf.c
trunk/lib/msun/src/s_tanhl.c
Added: trunk/lib/msun/src/catrig.c
===================================================================
--- trunk/lib/msun/src/catrig.c (rev 0)
+++ trunk/lib/msun/src/catrig.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -0,0 +1,640 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2012 Stephen Montgomery-Smith <stephen at 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: stable/10/lib/msun/src/catrig.c 318365 2017-05-16 18:54:25Z dim $");
+
+#include <complex.h>
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+#undef isinf
+#define isinf(x) (fabs(x) == INFINITY)
+#undef isnan
+#define isnan(x) ((x) != (x))
+#define raise_inexact() do { volatile float junk __unused = 1 + tiny; } while(0)
+#undef signbit
+#define signbit(x) (__builtin_signbit(x))
+
+/* We need that DBL_EPSILON^2/128 is larger than FOUR_SQRT_MIN. */
+static const double
+A_crossover = 10, /* Hull et al suggest 1.5, but 10 works better */
+B_crossover = 0.6417, /* suggested by Hull et al */
+FOUR_SQRT_MIN = 0x1p-509, /* >= 4 * sqrt(DBL_MIN) */
+QUARTER_SQRT_MAX = 0x1p509, /* <= sqrt(DBL_MAX) / 4 */
+m_e = 2.7182818284590452e0, /* 0x15bf0a8b145769.0p-51 */
+m_ln2 = 6.9314718055994531e-1, /* 0x162e42fefa39ef.0p-53 */
+pio2_hi = 1.5707963267948966e0, /* 0x1921fb54442d18.0p-52 */
+RECIP_EPSILON = 1 / DBL_EPSILON,
+SQRT_3_EPSILON = 2.5809568279517849e-8, /* 0x1bb67ae8584caa.0p-78 */
+SQRT_6_EPSILON = 3.6500241499888571e-8, /* 0x13988e1409212e.0p-77 */
+SQRT_MIN = 0x1p-511; /* >= sqrt(DBL_MIN) */
+
+static const volatile double
+pio2_lo = 6.1232339957367659e-17; /* 0x11a62633145c07.0p-106 */
+static const volatile float
+tiny = 0x1p-100;
+
+static double complex clog_for_large_values(double complex z);
+
+/*
+ * Testing indicates that all these functions are accurate up to 4 ULP.
+ * The functions casin(h) and cacos(h) are about 2.5 times slower than asinh.
+ * The functions catan(h) are a little under 2 times slower than atanh.
+ *
+ * The code for casinh, casin, cacos, and cacosh comes first. The code is
+ * rather complicated, and the four functions are highly interdependent.
+ *
+ * The code for catanh and catan comes at the end. It is much simpler than
+ * the other functions, and the code for these can be disconnected from the
+ * rest of the code.
+ */
+
+/*
+ * ================================
+ * | casinh, casin, cacos, cacosh |
+ * ================================
+ */
+
+/*
+ * The algorithm is very close to that in "Implementing the complex arcsine
+ * and arccosine functions using exception handling" by T. E. Hull, Thomas F.
+ * Fairgrieve, and Ping Tak Peter Tang, published in ACM Transactions on
+ * Mathematical Software, Volume 23 Issue 3, 1997, Pages 299-335,
+ * http://dl.acm.org/citation.cfm?id=275324.
+ *
+ * Throughout we use the convention z = x + I*y.
+ *
+ * casinh(z) = sign(x)*log(A+sqrt(A*A-1)) + I*asin(B)
+ * where
+ * A = (|z+I| + |z-I|) / 2
+ * B = (|z+I| - |z-I|) / 2 = y/A
+ *
+ * These formulas become numerically unstable:
+ * (a) for Re(casinh(z)) when z is close to the line segment [-I, I] (that
+ * is, Re(casinh(z)) is close to 0);
+ * (b) for Im(casinh(z)) when z is close to either of the intervals
+ * [I, I*infinity) or (-I*infinity, -I] (that is, |Im(casinh(z))| is
+ * close to PI/2).
+ *
+ * These numerical problems are overcome by defining
+ * f(a, b) = (hypot(a, b) - b) / 2 = a*a / (hypot(a, b) + b) / 2
+ * Then if A < A_crossover, we use
+ * log(A + sqrt(A*A-1)) = log1p((A-1) + sqrt((A-1)*(A+1)))
+ * A-1 = f(x, 1+y) + f(x, 1-y)
+ * and if B > B_crossover, we use
+ * asin(B) = atan2(y, sqrt(A*A - y*y)) = atan2(y, sqrt((A+y)*(A-y)))
+ * A-y = f(x, y+1) + f(x, y-1)
+ * where without loss of generality we have assumed that x and y are
+ * non-negative.
+ *
+ * Much of the difficulty comes because the intermediate computations may
+ * produce overflows or underflows. This is dealt with in the paper by Hull
+ * et al by using exception handling. We do this by detecting when
+ * computations risk underflow or overflow. The hardest part is handling the
+ * underflows when computing f(a, b).
+ *
+ * Note that the function f(a, b) does not appear explicitly in the paper by
+ * Hull et al, but the idea may be found on pages 308 and 309. Introducing the
+ * function f(a, b) allows us to concentrate many of the clever tricks in this
+ * paper into one function.
+ */
+
+/*
+ * Function f(a, b, hypot_a_b) = (hypot(a, b) - b) / 2.
+ * Pass hypot(a, b) as the third argument.
+ */
+static inline double
+f(double a, double b, double hypot_a_b)
+{
+ if (b < 0)
+ return ((hypot_a_b - b) / 2);
+ if (b == 0)
+ return (a / 2);
+ return (a * a / (hypot_a_b + b) / 2);
+}
+
+/*
+ * All the hard work is contained in this function.
+ * x and y are assumed positive or zero, and less than RECIP_EPSILON.
+ * Upon return:
+ * rx = Re(casinh(z)) = -Im(cacos(y + I*x)).
+ * B_is_usable is set to 1 if the value of B is usable.
+ * If B_is_usable is set to 0, sqrt_A2my2 = sqrt(A*A - y*y), and new_y = y.
+ * If returning sqrt_A2my2 has potential to result in an underflow, it is
+ * rescaled, and new_y is similarly rescaled.
+ */
+static inline void
+do_hard_work(double x, double y, double *rx, int *B_is_usable, double *B,
+ double *sqrt_A2my2, double *new_y)
+{
+ double R, S, A; /* A, B, R, and S are as in Hull et al. */
+ double Am1, Amy; /* A-1, A-y. */
+
+ R = hypot(x, y + 1); /* |z+I| */
+ S = hypot(x, y - 1); /* |z-I| */
+
+ /* A = (|z+I| + |z-I|) / 2 */
+ A = (R + S) / 2;
+ /*
+ * Mathematically A >= 1. There is a small chance that this will not
+ * be so because of rounding errors. So we will make certain it is
+ * so.
+ */
+ if (A < 1)
+ A = 1;
+
+ if (A < A_crossover) {
+ /*
+ * Am1 = fp + fm, where fp = f(x, 1+y), and fm = f(x, 1-y).
+ * rx = log1p(Am1 + sqrt(Am1*(A+1)))
+ */
+ if (y == 1 && x < DBL_EPSILON * DBL_EPSILON / 128) {
+ /*
+ * fp is of order x^2, and fm = x/2.
+ * A = 1 (inexactly).
+ */
+ *rx = sqrt(x);
+ } else if (x >= DBL_EPSILON * fabs(y - 1)) {
+ /*
+ * Underflow will not occur because
+ * x >= DBL_EPSILON^2/128 >= FOUR_SQRT_MIN
+ */
+ Am1 = f(x, 1 + y, R) + f(x, 1 - y, S);
+ *rx = log1p(Am1 + sqrt(Am1 * (A + 1)));
+ } else if (y < 1) {
+ /*
+ * fp = x*x/(1+y)/4, fm = x*x/(1-y)/4, and
+ * A = 1 (inexactly).
+ */
+ *rx = x / sqrt((1 - y) * (1 + y));
+ } else { /* if (y > 1) */
+ /*
+ * A-1 = y-1 (inexactly).
+ */
+ *rx = log1p((y - 1) + sqrt((y - 1) * (y + 1)));
+ }
+ } else {
+ *rx = log(A + sqrt(A * A - 1));
+ }
+
+ *new_y = y;
+
+ if (y < FOUR_SQRT_MIN) {
+ /*
+ * Avoid a possible underflow caused by y/A. For casinh this
+ * would be legitimate, but will be picked up by invoking atan2
+ * later on. For cacos this would not be legitimate.
+ */
+ *B_is_usable = 0;
+ *sqrt_A2my2 = A * (2 / DBL_EPSILON);
+ *new_y = y * (2 / DBL_EPSILON);
+ return;
+ }
+
+ /* B = (|z+I| - |z-I|) / 2 = y/A */
+ *B = y / A;
+ *B_is_usable = 1;
+
+ if (*B > B_crossover) {
+ *B_is_usable = 0;
+ /*
+ * Amy = fp + fm, where fp = f(x, y+1), and fm = f(x, y-1).
+ * sqrt_A2my2 = sqrt(Amy*(A+y))
+ */
+ if (y == 1 && x < DBL_EPSILON / 128) {
+ /*
+ * fp is of order x^2, and fm = x/2.
+ * A = 1 (inexactly).
+ */
+ *sqrt_A2my2 = sqrt(x) * sqrt((A + y) / 2);
+ } else if (x >= DBL_EPSILON * fabs(y - 1)) {
+ /*
+ * Underflow will not occur because
+ * x >= DBL_EPSILON/128 >= FOUR_SQRT_MIN
+ * and
+ * x >= DBL_EPSILON^2 >= FOUR_SQRT_MIN
+ */
+ Amy = f(x, y + 1, R) + f(x, y - 1, S);
+ *sqrt_A2my2 = sqrt(Amy * (A + y));
+ } else if (y > 1) {
+ /*
+ * fp = x*x/(y+1)/4, fm = x*x/(y-1)/4, and
+ * A = y (inexactly).
+ *
+ * y < RECIP_EPSILON. So the following
+ * scaling should avoid any underflow problems.
+ */
+ *sqrt_A2my2 = x * (4 / DBL_EPSILON / DBL_EPSILON) * y /
+ sqrt((y + 1) * (y - 1));
+ *new_y = y * (4 / DBL_EPSILON / DBL_EPSILON);
+ } else { /* if (y < 1) */
+ /*
+ * fm = 1-y >= DBL_EPSILON, fp is of order x^2, and
+ * A = 1 (inexactly).
+ */
+ *sqrt_A2my2 = sqrt((1 - y) * (1 + y));
+ }
+ }
+}
+
+/*
+ * casinh(z) = z + O(z^3) as z -> 0
+ *
+ * casinh(z) = sign(x)*clog(sign(x)*z) + O(1/z^2) as z -> infinity
+ * The above formula works for the imaginary part as well, because
+ * Im(casinh(z)) = sign(x)*atan2(sign(x)*y, fabs(x)) + O(y/z^3)
+ * as z -> infinity, uniformly in y
+ */
+double complex
+casinh(double complex z)
+{
+ double x, y, ax, ay, rx, ry, B, sqrt_A2my2, new_y;
+ int B_is_usable;
+ double complex w;
+
+ x = creal(z);
+ y = cimag(z);
+ ax = fabs(x);
+ ay = fabs(y);
+
+ if (isnan(x) || isnan(y)) {
+ /* casinh(+-Inf + I*NaN) = +-Inf + I*NaN */
+ if (isinf(x))
+ return (CMPLX(x, y + y));
+ /* casinh(NaN + I*+-Inf) = opt(+-)Inf + I*NaN */
+ if (isinf(y))
+ return (CMPLX(y, x + x));
+ /* casinh(NaN + I*0) = NaN + I*0 */
+ if (y == 0)
+ return (CMPLX(x + x, y));
+ /*
+ * All other cases involving NaN return NaN + I*NaN.
+ * C99 leaves it optional whether to raise invalid if one of
+ * the arguments is not NaN, so we opt not to raise it.
+ */
+ return (CMPLX(x + 0.0L + (y + 0), x + 0.0L + (y + 0)));
+ }
+
+ if (ax > RECIP_EPSILON || ay > RECIP_EPSILON) {
+ /* clog...() will raise inexact unless x or y is infinite. */
+ if (signbit(x) == 0)
+ w = clog_for_large_values(z) + m_ln2;
+ else
+ w = clog_for_large_values(-z) + m_ln2;
+ return (CMPLX(copysign(creal(w), x), copysign(cimag(w), y)));
+ }
+
+ /* Avoid spuriously raising inexact for z = 0. */
+ if (x == 0 && y == 0)
+ return (z);
+
+ /* All remaining cases are inexact. */
+ raise_inexact();
+
+ if (ax < SQRT_6_EPSILON / 4 && ay < SQRT_6_EPSILON / 4)
+ return (z);
+
+ do_hard_work(ax, ay, &rx, &B_is_usable, &B, &sqrt_A2my2, &new_y);
+ if (B_is_usable)
+ ry = asin(B);
+ else
+ ry = atan2(new_y, sqrt_A2my2);
+ return (CMPLX(copysign(rx, x), copysign(ry, y)));
+}
+
+/*
+ * casin(z) = reverse(casinh(reverse(z)))
+ * where reverse(x + I*y) = y + I*x = I*conj(z).
+ */
+double complex
+casin(double complex z)
+{
+ double complex w = casinh(CMPLX(cimag(z), creal(z)));
+
+ return (CMPLX(cimag(w), creal(w)));
+}
+
+/*
+ * cacos(z) = PI/2 - casin(z)
+ * but do the computation carefully so cacos(z) is accurate when z is
+ * close to 1.
+ *
+ * cacos(z) = PI/2 - z + O(z^3) as z -> 0
+ *
+ * cacos(z) = -sign(y)*I*clog(z) + O(1/z^2) as z -> infinity
+ * The above formula works for the real part as well, because
+ * Re(cacos(z)) = atan2(fabs(y), x) + O(y/z^3)
+ * as z -> infinity, uniformly in y
+ */
+double complex
+cacos(double complex z)
+{
+ double x, y, ax, ay, rx, ry, B, sqrt_A2mx2, new_x;
+ int sx, sy;
+ int B_is_usable;
+ double complex w;
+
+ x = creal(z);
+ y = cimag(z);
+ sx = signbit(x);
+ sy = signbit(y);
+ ax = fabs(x);
+ ay = fabs(y);
+
+ if (isnan(x) || isnan(y)) {
+ /* cacos(+-Inf + I*NaN) = NaN + I*opt(-)Inf */
+ if (isinf(x))
+ return (CMPLX(y + y, -INFINITY));
+ /* cacos(NaN + I*+-Inf) = NaN + I*-+Inf */
+ if (isinf(y))
+ return (CMPLX(x + x, -y));
+ /* cacos(0 + I*NaN) = PI/2 + I*NaN with inexact */
+ if (x == 0)
+ return (CMPLX(pio2_hi + pio2_lo, y + y));
+ /*
+ * All other cases involving NaN return NaN + I*NaN.
+ * C99 leaves it optional whether to raise invalid if one of
+ * the arguments is not NaN, so we opt not to raise it.
+ */
+ return (CMPLX(x + 0.0L + (y + 0), x + 0.0L + (y + 0)));
+ }
+
+ if (ax > RECIP_EPSILON || ay > RECIP_EPSILON) {
+ /* clog...() will raise inexact unless x or y is infinite. */
+ w = clog_for_large_values(z);
+ rx = fabs(cimag(w));
+ ry = creal(w) + m_ln2;
+ if (sy == 0)
+ ry = -ry;
+ return (CMPLX(rx, ry));
+ }
+
+ /* Avoid spuriously raising inexact for z = 1. */
+ if (x == 1 && y == 0)
+ return (CMPLX(0, -y));
+
+ /* All remaining cases are inexact. */
+ raise_inexact();
+
+ if (ax < SQRT_6_EPSILON / 4 && ay < SQRT_6_EPSILON / 4)
+ return (CMPLX(pio2_hi - (x - pio2_lo), -y));
+
+ do_hard_work(ay, ax, &ry, &B_is_usable, &B, &sqrt_A2mx2, &new_x);
+ if (B_is_usable) {
+ if (sx == 0)
+ rx = acos(B);
+ else
+ rx = acos(-B);
+ } else {
+ if (sx == 0)
+ rx = atan2(sqrt_A2mx2, new_x);
+ else
+ rx = atan2(sqrt_A2mx2, -new_x);
+ }
+ if (sy == 0)
+ ry = -ry;
+ return (CMPLX(rx, ry));
+}
+
+/*
+ * cacosh(z) = I*cacos(z) or -I*cacos(z)
+ * where the sign is chosen so Re(cacosh(z)) >= 0.
+ */
+double complex
+cacosh(double complex z)
+{
+ double complex w;
+ double rx, ry;
+
+ w = cacos(z);
+ rx = creal(w);
+ ry = cimag(w);
+ /* cacosh(NaN + I*NaN) = NaN + I*NaN */
+ if (isnan(rx) && isnan(ry))
+ return (CMPLX(ry, rx));
+ /* cacosh(NaN + I*+-Inf) = +Inf + I*NaN */
+ /* cacosh(+-Inf + I*NaN) = +Inf + I*NaN */
+ if (isnan(rx))
+ return (CMPLX(fabs(ry), rx));
+ /* cacosh(0 + I*NaN) = NaN + I*NaN */
+ if (isnan(ry))
+ return (CMPLX(ry, ry));
+ return (CMPLX(fabs(ry), copysign(rx, cimag(z))));
+}
+
+/*
+ * Optimized version of clog() for |z| finite and larger than ~RECIP_EPSILON.
+ */
+static double complex
+clog_for_large_values(double complex z)
+{
+ double x, y;
+ double ax, ay, t;
+
+ x = creal(z);
+ y = cimag(z);
+ ax = fabs(x);
+ ay = fabs(y);
+ if (ax < ay) {
+ t = ax;
+ ax = ay;
+ ay = t;
+ }
+
+ /*
+ * Avoid overflow in hypot() when x and y are both very large.
+ * Divide x and y by E, and then add 1 to the logarithm. This depends
+ * on E being larger than sqrt(2).
+ * Dividing by E causes an insignificant loss of accuracy; however
+ * this method is still poor since it is uneccessarily slow.
+ */
+ if (ax > DBL_MAX / 2)
+ return (CMPLX(log(hypot(x / m_e, y / m_e)) + 1, atan2(y, x)));
+
+ /*
+ * Avoid overflow when x or y is large. Avoid underflow when x or
+ * y is small.
+ */
+ if (ax > QUARTER_SQRT_MAX || ay < SQRT_MIN)
+ return (CMPLX(log(hypot(x, y)), atan2(y, x)));
+
+ return (CMPLX(log(ax * ax + ay * ay) / 2, atan2(y, x)));
+}
+
+/*
+ * =================
+ * | catanh, catan |
+ * =================
+ */
+
+/*
+ * sum_squares(x,y) = x*x + y*y (or just x*x if y*y would underflow).
+ * Assumes x*x and y*y will not overflow.
+ * Assumes x and y are finite.
+ * Assumes y is non-negative.
+ * Assumes fabs(x) >= DBL_EPSILON.
+ */
+static inline double
+sum_squares(double x, double y)
+{
+
+ /* Avoid underflow when y is small. */
+ if (y < SQRT_MIN)
+ return (x * x);
+
+ return (x * x + y * y);
+}
+
+/*
+ * real_part_reciprocal(x, y) = Re(1/(x+I*y)) = x/(x*x + y*y).
+ * Assumes x and y are not NaN, and one of x and y is larger than
+ * RECIP_EPSILON. We avoid unwarranted underflow. It is important to not use
+ * the code creal(1/z), because the imaginary part may produce an unwanted
+ * underflow.
+ * This is only called in a context where inexact is always raised before
+ * the call, so no effort is made to avoid or force inexact.
+ */
+static inline double
+real_part_reciprocal(double x, double y)
+{
+ double scale;
+ uint32_t hx, hy;
+ int32_t ix, iy;
+
+ /*
+ * This code is inspired by the C99 document n1124.pdf, Section G.5.1,
+ * example 2.
+ */
+ GET_HIGH_WORD(hx, x);
+ ix = hx & 0x7ff00000;
+ GET_HIGH_WORD(hy, y);
+ iy = hy & 0x7ff00000;
+#define BIAS (DBL_MAX_EXP - 1)
+/* XXX more guard digits are useful iff there is extra precision. */
+#define CUTOFF (DBL_MANT_DIG / 2 + 1) /* just half or 1 guard digit */
+ if (ix - iy >= CUTOFF << 20 || isinf(x))
+ return (1 / x); /* +-Inf -> +-0 is special */
+ if (iy - ix >= CUTOFF << 20)
+ return (x / y / y); /* should avoid double div, but hard */
+ if (ix <= (BIAS + DBL_MAX_EXP / 2 - CUTOFF) << 20)
+ return (x / (x * x + y * y));
+ scale = 1;
+ SET_HIGH_WORD(scale, 0x7ff00000 - ix); /* 2**(1-ilogb(x)) */
+ x *= scale;
+ y *= scale;
+ return (x / (x * x + y * y) * scale);
+}
+
+/*
+ * catanh(z) = log((1+z)/(1-z)) / 2
+ * = log1p(4*x / |z-1|^2) / 4
+ * + I * atan2(2*y, (1-x)*(1+x)-y*y) / 2
+ *
+ * catanh(z) = z + O(z^3) as z -> 0
+ *
+ * catanh(z) = 1/z + sign(y)*I*PI/2 + O(1/z^3) as z -> infinity
+ * The above formula works for the real part as well, because
+ * Re(catanh(z)) = x/|z|^2 + O(x/z^4)
+ * as z -> infinity, uniformly in x
+ */
+double complex
+catanh(double complex z)
+{
+ double x, y, ax, ay, rx, ry;
+
+ x = creal(z);
+ y = cimag(z);
+ ax = fabs(x);
+ ay = fabs(y);
+
+ /* This helps handle many cases. */
+ if (y == 0 && ax <= 1)
+ return (CMPLX(atanh(x), y));
+
+ /* To ensure the same accuracy as atan(), and to filter out z = 0. */
+ if (x == 0)
+ return (CMPLX(x, atan(y)));
+
+ if (isnan(x) || isnan(y)) {
+ /* catanh(+-Inf + I*NaN) = +-0 + I*NaN */
+ if (isinf(x))
+ return (CMPLX(copysign(0, x), y + y));
+ /* catanh(NaN + I*+-Inf) = sign(NaN)0 + I*+-PI/2 */
+ if (isinf(y))
+ return (CMPLX(copysign(0, x),
+ copysign(pio2_hi + pio2_lo, y)));
+ /*
+ * All other cases involving NaN return NaN + I*NaN.
+ * C99 leaves it optional whether to raise invalid if one of
+ * the arguments is not NaN, so we opt not to raise it.
+ */
+ return (CMPLX(x + 0.0L + (y + 0), x + 0.0L + (y + 0)));
+ }
+
+ if (ax > RECIP_EPSILON || ay > RECIP_EPSILON)
+ return (CMPLX(real_part_reciprocal(x, y),
+ copysign(pio2_hi + pio2_lo, y)));
+
+ if (ax < SQRT_3_EPSILON / 2 && ay < SQRT_3_EPSILON / 2) {
+ /*
+ * z = 0 was filtered out above. All other cases must raise
+ * inexact, but this is the only only that needs to do it
+ * explicitly.
+ */
+ raise_inexact();
+ return (z);
+ }
+
+ if (ax == 1 && ay < DBL_EPSILON)
+ rx = (m_ln2 - log(ay)) / 2;
+ else
+ rx = log1p(4 * ax / sum_squares(ax - 1, ay)) / 4;
+
+ if (ax == 1)
+ ry = atan2(2, -ay) / 2;
+ else if (ay < DBL_EPSILON)
+ ry = atan2(2 * ay, (1 - ax) * (1 + ax)) / 2;
+ else
+ ry = atan2(2 * ay, (1 - ax) * (1 + ax) - ay * ay) / 2;
+
+ return (CMPLX(copysign(rx, x), copysign(ry, y)));
+}
+
+/*
+ * catan(z) = reverse(catanh(reverse(z)))
+ * where reverse(x + I*y) = y + I*x = I*conj(z).
+ */
+double complex
+catan(double complex z)
+{
+ double complex w = catanh(CMPLX(cimag(z), creal(z)));
+
+ return (CMPLX(cimag(w), creal(w)));
+}
Property changes on: trunk/lib/msun/src/catrig.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/lib/msun/src/catrigf.c
===================================================================
--- trunk/lib/msun/src/catrigf.c (rev 0)
+++ trunk/lib/msun/src/catrigf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -0,0 +1,394 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2012 Stephen Montgomery-Smith <stephen at 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.
+ */
+
+/*
+ * The algorithm is very close to that in "Implementing the complex arcsine
+ * and arccosine functions using exception handling" by T. E. Hull, Thomas F.
+ * Fairgrieve, and Ping Tak Peter Tang, published in ACM Transactions on
+ * Mathematical Software, Volume 23 Issue 3, 1997, Pages 299-335,
+ * http://dl.acm.org/citation.cfm?id=275324.
+ *
+ * See catrig.c for complete comments.
+ *
+ * XXX comments were removed automatically, and even short ones on the right
+ * of statements were removed (all of them), contrary to normal style. Only
+ * a few comments on the right of declarations remain.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/catrigf.c 318365 2017-05-16 18:54:25Z dim $");
+
+#include <complex.h>
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+#undef isinf
+#define isinf(x) (fabsf(x) == INFINITY)
+#undef isnan
+#define isnan(x) ((x) != (x))
+#define raise_inexact() do { volatile float junk __unused = 1 + tiny; } while(0)
+#undef signbit
+#define signbit(x) (__builtin_signbitf(x))
+
+static const float
+A_crossover = 10,
+B_crossover = 0.6417,
+FOUR_SQRT_MIN = 0x1p-61,
+QUARTER_SQRT_MAX = 0x1p61,
+m_e = 2.7182818285e0, /* 0xadf854.0p-22 */
+m_ln2 = 6.9314718056e-1, /* 0xb17218.0p-24 */
+pio2_hi = 1.5707962513e0, /* 0xc90fda.0p-23 */
+RECIP_EPSILON = 1 / FLT_EPSILON,
+SQRT_3_EPSILON = 5.9801995673e-4, /* 0x9cc471.0p-34 */
+SQRT_6_EPSILON = 8.4572793338e-4, /* 0xddb3d7.0p-34 */
+SQRT_MIN = 0x1p-63;
+
+static const volatile float
+pio2_lo = 7.5497899549e-8, /* 0xa22169.0p-47 */
+tiny = 0x1p-100;
+
+static float complex clog_for_large_values(float complex z);
+
+static inline float
+f(float a, float b, float hypot_a_b)
+{
+ if (b < 0)
+ return ((hypot_a_b - b) / 2);
+ if (b == 0)
+ return (a / 2);
+ return (a * a / (hypot_a_b + b) / 2);
+}
+
+static inline void
+do_hard_work(float x, float y, float *rx, int *B_is_usable, float *B,
+ float *sqrt_A2my2, float *new_y)
+{
+ float R, S, A;
+ float Am1, Amy;
+
+ R = hypotf(x, y + 1);
+ S = hypotf(x, y - 1);
+
+ A = (R + S) / 2;
+ if (A < 1)
+ A = 1;
+
+ if (A < A_crossover) {
+ if (y == 1 && x < FLT_EPSILON * FLT_EPSILON / 128) {
+ *rx = sqrtf(x);
+ } else if (x >= FLT_EPSILON * fabsf(y - 1)) {
+ Am1 = f(x, 1 + y, R) + f(x, 1 - y, S);
+ *rx = log1pf(Am1 + sqrtf(Am1 * (A + 1)));
+ } else if (y < 1) {
+ *rx = x / sqrtf((1 - y) * (1 + y));
+ } else {
+ *rx = log1pf((y - 1) + sqrtf((y - 1) * (y + 1)));
+ }
+ } else {
+ *rx = logf(A + sqrtf(A * A - 1));
+ }
+
+ *new_y = y;
+
+ if (y < FOUR_SQRT_MIN) {
+ *B_is_usable = 0;
+ *sqrt_A2my2 = A * (2 / FLT_EPSILON);
+ *new_y = y * (2 / FLT_EPSILON);
+ return;
+ }
+
+ *B = y / A;
+ *B_is_usable = 1;
+
+ if (*B > B_crossover) {
+ *B_is_usable = 0;
+ if (y == 1 && x < FLT_EPSILON / 128) {
+ *sqrt_A2my2 = sqrtf(x) * sqrtf((A + y) / 2);
+ } else if (x >= FLT_EPSILON * fabsf(y - 1)) {
+ Amy = f(x, y + 1, R) + f(x, y - 1, S);
+ *sqrt_A2my2 = sqrtf(Amy * (A + y));
+ } else if (y > 1) {
+ *sqrt_A2my2 = x * (4 / FLT_EPSILON / FLT_EPSILON) * y /
+ sqrtf((y + 1) * (y - 1));
+ *new_y = y * (4 / FLT_EPSILON / FLT_EPSILON);
+ } else {
+ *sqrt_A2my2 = sqrtf((1 - y) * (1 + y));
+ }
+ }
+}
+
+float complex
+casinhf(float complex z)
+{
+ float x, y, ax, ay, rx, ry, B, sqrt_A2my2, new_y;
+ int B_is_usable;
+ float complex w;
+
+ x = crealf(z);
+ y = cimagf(z);
+ ax = fabsf(x);
+ ay = fabsf(y);
+
+ if (isnan(x) || isnan(y)) {
+ if (isinf(x))
+ return (CMPLXF(x, y + y));
+ if (isinf(y))
+ return (CMPLXF(y, x + x));
+ if (y == 0)
+ return (CMPLXF(x + x, y));
+ return (CMPLXF(x + 0.0L + (y + 0), x + 0.0L + (y + 0)));
+ }
+
+ if (ax > RECIP_EPSILON || ay > RECIP_EPSILON) {
+ if (signbit(x) == 0)
+ w = clog_for_large_values(z) + m_ln2;
+ else
+ w = clog_for_large_values(-z) + m_ln2;
+ return (CMPLXF(copysignf(crealf(w), x),
+ copysignf(cimagf(w), y)));
+ }
+
+ if (x == 0 && y == 0)
+ return (z);
+
+ raise_inexact();
+
+ if (ax < SQRT_6_EPSILON / 4 && ay < SQRT_6_EPSILON / 4)
+ return (z);
+
+ do_hard_work(ax, ay, &rx, &B_is_usable, &B, &sqrt_A2my2, &new_y);
+ if (B_is_usable)
+ ry = asinf(B);
+ else
+ ry = atan2f(new_y, sqrt_A2my2);
+ return (CMPLXF(copysignf(rx, x), copysignf(ry, y)));
+}
+
+float complex
+casinf(float complex z)
+{
+ float complex w = casinhf(CMPLXF(cimagf(z), crealf(z)));
+
+ return (CMPLXF(cimagf(w), crealf(w)));
+}
+
+float complex
+cacosf(float complex z)
+{
+ float x, y, ax, ay, rx, ry, B, sqrt_A2mx2, new_x;
+ int sx, sy;
+ int B_is_usable;
+ float complex w;
+
+ x = crealf(z);
+ y = cimagf(z);
+ sx = signbit(x);
+ sy = signbit(y);
+ ax = fabsf(x);
+ ay = fabsf(y);
+
+ if (isnan(x) || isnan(y)) {
+ if (isinf(x))
+ return (CMPLXF(y + y, -INFINITY));
+ if (isinf(y))
+ return (CMPLXF(x + x, -y));
+ if (x == 0)
+ return (CMPLXF(pio2_hi + pio2_lo, y + y));
+ return (CMPLXF(x + 0.0L + (y + 0), x + 0.0L + (y + 0)));
+ }
+
+ if (ax > RECIP_EPSILON || ay > RECIP_EPSILON) {
+ w = clog_for_large_values(z);
+ rx = fabsf(cimagf(w));
+ ry = crealf(w) + m_ln2;
+ if (sy == 0)
+ ry = -ry;
+ return (CMPLXF(rx, ry));
+ }
+
+ if (x == 1 && y == 0)
+ return (CMPLXF(0, -y));
+
+ raise_inexact();
+
+ if (ax < SQRT_6_EPSILON / 4 && ay < SQRT_6_EPSILON / 4)
+ return (CMPLXF(pio2_hi - (x - pio2_lo), -y));
+
+ do_hard_work(ay, ax, &ry, &B_is_usable, &B, &sqrt_A2mx2, &new_x);
+ if (B_is_usable) {
+ if (sx == 0)
+ rx = acosf(B);
+ else
+ rx = acosf(-B);
+ } else {
+ if (sx == 0)
+ rx = atan2f(sqrt_A2mx2, new_x);
+ else
+ rx = atan2f(sqrt_A2mx2, -new_x);
+ }
+ if (sy == 0)
+ ry = -ry;
+ return (CMPLXF(rx, ry));
+}
+
+float complex
+cacoshf(float complex z)
+{
+ float complex w;
+ float rx, ry;
+
+ w = cacosf(z);
+ rx = crealf(w);
+ ry = cimagf(w);
+ if (isnan(rx) && isnan(ry))
+ return (CMPLXF(ry, rx));
+ if (isnan(rx))
+ return (CMPLXF(fabsf(ry), rx));
+ if (isnan(ry))
+ return (CMPLXF(ry, ry));
+ return (CMPLXF(fabsf(ry), copysignf(rx, cimagf(z))));
+}
+
+static float complex
+clog_for_large_values(float complex z)
+{
+ float x, y;
+ float ax, ay, t;
+
+ x = crealf(z);
+ y = cimagf(z);
+ ax = fabsf(x);
+ ay = fabsf(y);
+ if (ax < ay) {
+ t = ax;
+ ax = ay;
+ ay = t;
+ }
+
+ if (ax > FLT_MAX / 2)
+ return (CMPLXF(logf(hypotf(x / m_e, y / m_e)) + 1,
+ atan2f(y, x)));
+
+ if (ax > QUARTER_SQRT_MAX || ay < SQRT_MIN)
+ return (CMPLXF(logf(hypotf(x, y)), atan2f(y, x)));
+
+ return (CMPLXF(logf(ax * ax + ay * ay) / 2, atan2f(y, x)));
+}
+
+static inline float
+sum_squares(float x, float y)
+{
+
+ if (y < SQRT_MIN)
+ return (x * x);
+
+ return (x * x + y * y);
+}
+
+static inline float
+real_part_reciprocal(float x, float y)
+{
+ float scale;
+ uint32_t hx, hy;
+ int32_t ix, iy;
+
+ GET_FLOAT_WORD(hx, x);
+ ix = hx & 0x7f800000;
+ GET_FLOAT_WORD(hy, y);
+ iy = hy & 0x7f800000;
+#define BIAS (FLT_MAX_EXP - 1)
+#define CUTOFF (FLT_MANT_DIG / 2 + 1)
+ if (ix - iy >= CUTOFF << 23 || isinf(x))
+ return (1 / x);
+ if (iy - ix >= CUTOFF << 23)
+ return (x / y / y);
+ if (ix <= (BIAS + FLT_MAX_EXP / 2 - CUTOFF) << 23)
+ return (x / (x * x + y * y));
+ SET_FLOAT_WORD(scale, 0x7f800000 - ix);
+ x *= scale;
+ y *= scale;
+ return (x / (x * x + y * y) * scale);
+}
+
+float complex
+catanhf(float complex z)
+{
+ float x, y, ax, ay, rx, ry;
+
+ x = crealf(z);
+ y = cimagf(z);
+ ax = fabsf(x);
+ ay = fabsf(y);
+
+ if (y == 0 && ax <= 1)
+ return (CMPLXF(atanhf(x), y));
+
+ if (x == 0)
+ return (CMPLXF(x, atanf(y)));
+
+ if (isnan(x) || isnan(y)) {
+ if (isinf(x))
+ return (CMPLXF(copysignf(0, x), y + y));
+ if (isinf(y))
+ return (CMPLXF(copysignf(0, x),
+ copysignf(pio2_hi + pio2_lo, y)));
+ return (CMPLXF(x + 0.0L + (y + 0), x + 0.0L + (y + 0)));
+ }
+
+ if (ax > RECIP_EPSILON || ay > RECIP_EPSILON)
+ return (CMPLXF(real_part_reciprocal(x, y),
+ copysignf(pio2_hi + pio2_lo, y)));
+
+ if (ax < SQRT_3_EPSILON / 2 && ay < SQRT_3_EPSILON / 2) {
+ raise_inexact();
+ return (z);
+ }
+
+ if (ax == 1 && ay < FLT_EPSILON)
+ rx = (m_ln2 - logf(ay)) / 2;
+ else
+ rx = log1pf(4 * ax / sum_squares(ax - 1, ay)) / 4;
+
+ if (ax == 1)
+ ry = atan2f(2, -ay) / 2;
+ else if (ay < FLT_EPSILON)
+ ry = atan2f(2 * ay, (1 - ax) * (1 + ax)) / 2;
+ else
+ ry = atan2f(2 * ay, (1 - ax) * (1 + ax) - ay * ay) / 2;
+
+ return (CMPLXF(copysignf(rx, x), copysignf(ry, y)));
+}
+
+float complex
+catanf(float complex z)
+{
+ float complex w = catanhf(CMPLXF(cimagf(z), crealf(z)));
+
+ return (CMPLXF(cimagf(w), crealf(w)));
+}
Property changes on: trunk/lib/msun/src/catrigf.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/lib/msun/src/e_acos.c
===================================================================
--- trunk/lib/msun/src/e_acos.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_acos.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_acos.c 1.3 95/01/18 */
/*
@@ -12,7 +13,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_acos.c 181074 2008-07-31 22:41:26Z das $");
/* __ieee754_acos(x)
* Method :
Modified: trunk/lib/msun/src/e_acosf.c
===================================================================
--- trunk/lib/msun/src/e_acosf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_acosf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* e_acosf.c -- float version of e_acos.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_acosf.c 181257 2008-08-03 17:39:54Z das $");
#include "math.h"
#include "math_private.h"
Modified: trunk/lib/msun/src/e_acosh.c
===================================================================
--- trunk/lib/msun/src/e_acosh.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_acosh.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_acosh.c 1.3 95/01/18 */
/*
@@ -13,7 +14,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_acosh.c 251599 2013-06-10 06:04:58Z das $");
/* __ieee754_acosh(x)
* Method :
@@ -29,6 +30,8 @@
* acosh(NaN) is NaN without signal.
*/
+#include <float.h>
+
#include "math.h"
#include "math_private.h"
@@ -60,3 +63,7 @@
return log1p(t+sqrt(2.0*t+t*t));
}
}
+
+#if LDBL_MANT_DIG == 53
+__weak_reference(acosh, acoshl);
+#endif
Modified: trunk/lib/msun/src/e_acoshf.c
===================================================================
--- trunk/lib/msun/src/e_acoshf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_acoshf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* e_acoshf.c -- float version of e_acosh.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_acoshf.c 176451 2008-02-22 02:30:36Z das $");
#include "math.h"
#include "math_private.h"
Added: trunk/lib/msun/src/e_acoshl.c
===================================================================
--- trunk/lib/msun/src/e_acoshl.c (rev 0)
+++ trunk/lib/msun/src/e_acoshl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -0,0 +1,90 @@
+/* $MidnightBSD$ */
+/* from: FreeBSD: head/lib/msun/src/e_acosh.c 176451 2008-02-22 02:30:36Z das */
+
+/* @(#)e_acosh.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ *
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_acoshl.c 251599 2013-06-10 06:04:58Z das $");
+
+/*
+ * See e_acosh.c for complete comments.
+ *
+ * Converted to long double by David Schultz <das at FreeBSD.ORG> and
+ * Bruce D. Evans.
+ */
+
+#include <float.h>
+#ifdef __i386__
+#include <ieeefp.h>
+#endif
+
+#include "fpmath.h"
+#include "math.h"
+#include "math_private.h"
+
+/* EXP_LARGE is the threshold above which we use acosh(x) ~= log(2x). */
+#if LDBL_MANT_DIG == 64
+#define EXP_LARGE 34
+#elif LDBL_MANT_DIG == 113
+#define EXP_LARGE 58
+#else
+#error "Unsupported long double format"
+#endif
+
+#if LDBL_MAX_EXP != 0x4000
+/* We also require the usual expsign encoding. */
+#error "Unsupported long double format"
+#endif
+
+#define BIAS (LDBL_MAX_EXP - 1)
+
+static const double
+one = 1.0;
+
+#if LDBL_MANT_DIG == 64
+static const union IEEEl2bits
+u_ln2 = LD80C(0xb17217f7d1cf79ac, -1, 6.93147180559945309417e-1L);
+#define ln2 u_ln2.e
+#elif LDBL_MANT_DIG == 113
+static const long double
+ln2 = 6.93147180559945309417232121458176568e-1L; /* 0x162e42fefa39ef35793c7673007e6.0p-113 */
+#else
+#error "Unsupported long double format"
+#endif
+
+long double
+acoshl(long double x)
+{
+ long double t;
+ int16_t hx;
+
+ ENTERI();
+ GET_LDBL_EXPSIGN(hx, x);
+ if (hx < 0x3fff) { /* x < 1, or misnormal */
+ RETURNI((x-x)/(x-x));
+ } else if (hx >= BIAS + EXP_LARGE) { /* x >= LARGE */
+ if (hx >= 0x7fff) { /* x is inf, NaN or misnormal */
+ RETURNI(x+x);
+ } else
+ RETURNI(logl(x)+ln2); /* acosh(huge)=log(2x), or misnormal */
+ } else if (hx == 0x3fff && x == 1) {
+ RETURNI(0.0); /* acosh(1) = 0 */
+ } else if (hx >= 0x4000) { /* LARGE > x >= 2, or misnormal */
+ t=x*x;
+ RETURNI(logl(2.0*x-one/(x+sqrtl(t-one))));
+ } else { /* 1<x<2 */
+ t = x-one;
+ RETURNI(log1pl(t+sqrtl(2.0*t+t*t)));
+ }
+}
Property changes on: trunk/lib/msun/src/e_acoshl.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/lib/msun/src/e_acosl.c
===================================================================
--- trunk/lib/msun/src/e_acosl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_acosl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_acos.c 1.3 95/01/18 */
/* FreeBSD: head/lib/msun/src/e_acos.c 176451 2008-02-22 02:30:36Z das */
@@ -13,7 +14,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_acosl.c 181152 2008-08-02 03:56:22Z das $");
/*
* See comments in e_acos.c.
Modified: trunk/lib/msun/src/e_asin.c
===================================================================
--- trunk/lib/msun/src/e_asin.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_asin.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_asin.c 1.3 95/01/18 */
/*
@@ -12,7 +13,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_asin.c 218509 2011-02-10 07:37:50Z das $");
/* __ieee754_asin(x)
* Method :
Modified: trunk/lib/msun/src/e_asinf.c
===================================================================
--- trunk/lib/msun/src/e_asinf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_asinf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* e_asinf.c -- float version of e_asin.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_asinf.c 181405 2008-08-08 00:21:27Z das $");
#include "math.h"
#include "math_private.h"
Modified: trunk/lib/msun/src/e_asinl.c
===================================================================
--- trunk/lib/msun/src/e_asinl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_asinl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_asin.c 1.3 95/01/18 */
/* FreeBSD: head/lib/msun/src/e_asin.c 176451 2008-02-22 02:30:36Z das */
@@ -13,7 +14,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_asinl.c 181258 2008-08-03 17:49:05Z das $");
/*
* See comments in e_asin.c.
Modified: trunk/lib/msun/src/e_atan2.c
===================================================================
--- trunk/lib/msun/src/e_atan2.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_atan2.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_atan2.c 1.3 95/01/18 */
/*
@@ -13,7 +14,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_atan2.c 181204 2008-08-02 19:17:00Z das $");
/* __ieee754_atan2(y,x)
* Method :
Modified: trunk/lib/msun/src/e_atan2f.c
===================================================================
--- trunk/lib/msun/src/e_atan2f.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_atan2f.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* e_atan2f.c -- float version of e_atan2.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_atan2f.c 181257 2008-08-03 17:39:54Z das $");
#include "math.h"
#include "math_private.h"
Modified: trunk/lib/msun/src/e_atan2l.c
===================================================================
--- trunk/lib/msun/src/e_atan2l.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_atan2l.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_atan2.c 1.3 95/01/18 */
/* FreeBSD: head/lib/msun/src/e_atan2.c 176451 2008-02-22 02:30:36Z das */
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_atan2l.c 181204 2008-08-02 19:17:00Z das $");
/*
* See comments in e_atan2.c.
Modified: trunk/lib/msun/src/e_atanh.c
===================================================================
--- trunk/lib/msun/src/e_atanh.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_atanh.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_atanh.c 1.3 95/01/18 */
/*
@@ -13,7 +14,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_atanh.c 251599 2013-06-10 06:04:58Z das $");
/* __ieee754_atanh(x)
* Method :
@@ -33,6 +34,8 @@
*
*/
+#include <float.h>
+
#include "math.h"
#include "math_private.h"
@@ -60,3 +63,7 @@
t = 0.5*log1p((x+x)/(one-x));
if(hx>=0) return t; else return -t;
}
+
+#if LDBL_MANT_DIG == 53
+__weak_reference(atanh, atanhl);
+#endif
Modified: trunk/lib/msun/src/e_atanhf.c
===================================================================
--- trunk/lib/msun/src/e_atanhf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_atanhf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* e_atanhf.c -- float version of e_atanh.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_atanhf.c 176451 2008-02-22 02:30:36Z das $");
#include "math.h"
#include "math_private.h"
Added: trunk/lib/msun/src/e_atanhl.c
===================================================================
--- trunk/lib/msun/src/e_atanhl.c (rev 0)
+++ trunk/lib/msun/src/e_atanhl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -0,0 +1,75 @@
+/* $MidnightBSD$ */
+/* from: FreeBSD: head/lib/msun/src/e_atanh.c 176451 2008-02-22 02:30:36Z das */
+
+/* @(#)e_atanh.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ *
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_atanhl.c 251599 2013-06-10 06:04:58Z das $");
+
+/*
+ * See e_atanh.c for complete comments.
+ *
+ * Converted to long double by David Schultz <das at FreeBSD.ORG> and
+ * Bruce D. Evans.
+ */
+
+#include <float.h>
+#ifdef __i386__
+#include <ieeefp.h>
+#endif
+
+#include "fpmath.h"
+#include "math.h"
+#include "math_private.h"
+
+/* EXP_TINY is the threshold below which we use atanh(x) ~= x. */
+#if LDBL_MANT_DIG == 64
+#define EXP_TINY -34
+#elif LDBL_MANT_DIG == 113
+#define EXP_TINY -58
+#else
+#error "Unsupported long double format"
+#endif
+
+#if LDBL_MAX_EXP != 0x4000
+/* We also require the usual expsign encoding. */
+#error "Unsupported long double format"
+#endif
+
+#define BIAS (LDBL_MAX_EXP - 1)
+
+static const double one = 1.0, huge = 1e300;
+static const double zero = 0.0;
+
+long double
+atanhl(long double x)
+{
+ long double t;
+ uint16_t hx, ix;
+
+ ENTERI();
+ GET_LDBL_EXPSIGN(hx, x);
+ ix = hx & 0x7fff;
+ if (ix >= 0x3fff) /* |x| >= 1, or NaN or misnormal */
+ RETURNI(fabsl(x) == 1 ? x / zero : (x - x) / (x - x));
+ if (ix < BIAS + EXP_TINY && (huge + x) > zero)
+ RETURNI(x); /* x is tiny */
+ SET_LDBL_EXPSIGN(x, ix);
+ if (ix < 0x3ffe) { /* |x| < 0.5, or misnormal */
+ t = x+x;
+ t = 0.5*log1pl(t+t*x/(one-x));
+ } else
+ t = 0.5*log1pl((x+x)/(one-x));
+ RETURNI((hx & 0x8000) == 0 ? t : -t);
+}
Property changes on: trunk/lib/msun/src/e_atanhl.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/lib/msun/src/e_cosh.c
===================================================================
--- trunk/lib/msun/src/e_cosh.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_cosh.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_cosh.c 1.3 95/01/18 */
/*
@@ -12,7 +13,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_cosh.c 271779 2014-09-18 15:10:22Z tijl $");
/* __ieee754_cosh(x)
* Method :
@@ -35,6 +36,8 @@
* only cosh(0)=1 is exact for finite x.
*/
+#include <float.h>
+
#include "math.h"
#include "math_private.h"
@@ -45,7 +48,6 @@
{
double t,w;
int32_t ix;
- u_int32_t lx;
/* High word of |x|. */
GET_HIGH_WORD(ix,x);
@@ -72,14 +74,13 @@
if (ix < 0x40862E42) return half*__ieee754_exp(fabs(x));
/* |x| in [log(maxdouble), overflowthresold] */
- GET_LOW_WORD(lx,x);
- if (ix<0x408633CE ||
- ((ix==0x408633ce)&&(lx<=(u_int32_t)0x8fb9f87d))) {
- w = __ieee754_exp(half*fabs(x));
- t = half*w;
- return t*w;
- }
+ if (ix<=0x408633CE)
+ return __ldexp_exp(fabs(x), -1);
/* |x| > overflowthresold, cosh(x) overflow */
return huge*huge;
}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(cosh, coshl);
+#endif
Modified: trunk/lib/msun/src/e_coshf.c
===================================================================
--- trunk/lib/msun/src/e_coshf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_coshf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* e_coshf.c -- float version of e_cosh.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_coshf.c 226598 2011-10-21 06:28:47Z das $");
#include "math.h"
#include "math_private.h"
@@ -51,11 +52,8 @@
if (ix < 0x42b17217) return half*__ieee754_expf(fabsf(x));
/* |x| in [log(maxfloat), overflowthresold] */
- if (ix<=0x42b2d4fc) {
- w = __ieee754_expf(half*fabsf(x));
- t = half*w;
- return t*w;
- }
+ if (ix<=0x42b2d4fc)
+ return __ldexp_expf(fabsf(x), -1);
/* |x| > overflowthresold, cosh(x) overflow */
return huge*huge;
Added: trunk/lib/msun/src/e_coshl.c
===================================================================
--- trunk/lib/msun/src/e_coshl.c (rev 0)
+++ trunk/lib/msun/src/e_coshl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -0,0 +1,131 @@
+/* $MidnightBSD$ */
+/* from: FreeBSD: head/lib/msun/src/e_coshl.c XXX */
+
+/*
+ * ====================================================
+ * 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: stable/10/lib/msun/src/e_coshl.c 271779 2014-09-18 15:10:22Z tijl $");
+
+/*
+ * See e_cosh.c for complete comments.
+ *
+ * Converted to long double by Bruce D. Evans.
+ */
+
+#include <float.h>
+#ifdef __i386__
+#include <ieeefp.h>
+#endif
+
+#include "fpmath.h"
+#include "math.h"
+#include "math_private.h"
+#include "k_expl.h"
+
+#if LDBL_MAX_EXP != 0x4000
+/* We also require the usual expsign encoding. */
+#error "Unsupported long double format"
+#endif
+
+#define BIAS (LDBL_MAX_EXP - 1)
+
+static const volatile long double huge = 0x1p10000L, tiny = 0x1p-10000L;
+#if LDBL_MANT_DIG == 64
+/*
+ * Domain [-1, 1], range ~[-1.8211e-21, 1.8211e-21]:
+ * |cosh(x) - c(x)| < 2**-68.8
+ */
+static const union IEEEl2bits
+C4u = LD80C(0xaaaaaaaaaaaaac78, -5, 4.16666666666666682297e-2L);
+#define C4 C4u.e
+static const double
+C2 = 0.5,
+C6 = 1.3888888888888616e-3, /* 0x16c16c16c16b99.0p-62 */
+C8 = 2.4801587301767953e-5, /* 0x1a01a01a027061.0p-68 */
+C10 = 2.7557319163300398e-7, /* 0x127e4fb6c9b55f.0p-74 */
+C12 = 2.0876768371393075e-9, /* 0x11eed99406a3f4.0p-81 */
+C14 = 1.1469537039374480e-11, /* 0x1938c67cd18c48.0p-89 */
+C16 = 4.8473490896852041e-14; /* 0x1b49c429701e45.0p-97 */
+#elif LDBL_MANT_DIG == 113
+/*
+ * Domain [-1, 1], range ~[-2.3194e-37, 2.3194e-37]:
+ * |cosh(x) - c(x)| < 2**-121.69
+ */
+static const long double
+C4 = 4.16666666666666666666666666666666225e-2L, /* 0x1555555555555555555555555554e.0p-117L */
+C6 = 1.38888888888888888888888888889434831e-3L, /* 0x16c16c16c16c16c16c16c16c1dd7a.0p-122L */
+C8 = 2.48015873015873015873015871870962089e-5L, /* 0x1a01a01a01a01a01a01a017af2756.0p-128L */
+C10 = 2.75573192239858906525574318600800201e-7L, /* 0x127e4fb7789f5c72ef01c8a040640.0p-134L */
+C12 = 2.08767569878680989791444691755468269e-9L, /* 0x11eed8eff8d897b543d0679607399.0p-141L */
+C14= 1.14707455977297247387801189650495351e-11L, /* 0x193974a8c07c9d24ae169a7fa9b54.0p-149L */
+C16 = 4.77947733238737883626416876486279985e-14L; /* 0x1ae7f3e733b814d4e1b90f5727fe4.0p-157L */
+static const double
+C2 = 0.5,
+C18 = 1.5619206968597871e-16, /* 0x16827863b9900b.0p-105 */
+C20 = 4.1103176218528049e-19, /* 0x1e542ba3d3c269.0p-114 */
+C22 = 8.8967926401641701e-22, /* 0x10ce399542a014.0p-122 */
+C24 = 1.6116681626523904e-24, /* 0x1f2c981d1f0cb7.0p-132 */
+C26 = 2.5022374732804632e-27; /* 0x18c7ecf8b2c4a0.0p-141 */
+#else
+#error "Unsupported long double format"
+#endif /* LDBL_MANT_DIG == 64 */
+
+/* log(2**16385 - 0.5) rounded up: */
+static const float
+o_threshold = 1.13572168e4; /* 0xb174de.0p-10 */
+
+long double
+coshl(long double x)
+{
+ long double hi,lo,x2,x4;
+ double dx2;
+ uint16_t ix;
+
+ GET_LDBL_EXPSIGN(ix,x);
+ ix &= 0x7fff;
+
+ /* x is INF or NaN */
+ if(ix>=0x7fff) return x*x;
+
+ ENTERI();
+
+ /* |x| < 1, return 1 or c(x) */
+ if(ix<0x3fff) {
+ if (ix<BIAS-(LDBL_MANT_DIG+1)/2) /* |x| < TINY */
+ RETURNI(1+tiny); /* cosh(tiny) = 1(+) with inexact */
+ x2 = x*x;
+#if LDBL_MANT_DIG == 64
+ x4 = x2*x2;
+ RETURNI(((C16*x2 + C14)*x4 + (C12*x2 + C10))*(x4*x4*x2) +
+ ((C8*x2 + C6)*x2 + C4)*x4 + C2*x2 + 1);
+#elif LDBL_MANT_DIG == 113
+ dx2 = x2;
+ RETURNI((((((((((((C26*dx2 + C24)*dx2 + C22)*dx2 +
+ C20)*x2 + C18)*x2 +
+ C16)*x2 + C14)*x2 + C12)*x2 + C10)*x2 + C8)*x2 + C6)*x2 +
+ C4)*(x2*x2) + C2*x2 + 1);
+#endif
+ }
+
+ /* |x| in [1, 64), return accurate exp(|x|)/2+1/exp(|x|)/2 */
+ if (ix < 0x4005) {
+ k_hexpl(fabsl(x), &hi, &lo);
+ RETURNI(lo + 0.25/(hi + lo) + hi);
+ }
+
+ /* |x| in [64, o_threshold], return correctly-overflowing exp(|x|)/2 */
+ if (fabsl(x) <= o_threshold)
+ RETURNI(hexpl(fabsl(x)));
+
+ /* |x| > o_threshold, cosh(x) overflow */
+ RETURNI(huge*huge);
+}
Property changes on: trunk/lib/msun/src/e_coshl.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/lib/msun/src/e_exp.c
===================================================================
--- trunk/lib/msun/src/e_exp.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_exp.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_exp.c 1.6 04/04/22 */
/*
@@ -11,7 +12,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_exp.c 251024 2013-05-27 08:50:10Z das $");
/* __ieee754_exp(x)
* Returns the exponential of x.
@@ -76,6 +77,8 @@
* to produce the hexadecimal values shown.
*/
+#include <float.h>
+
#include "math.h"
#include "math_private.h"
@@ -82,7 +85,6 @@
static const double
one = 1.0,
halF[2] = {0.5,-0.5,},
-huge = 1.0e+300,
o_threshold= 7.09782712893383973096e+02, /* 0x40862E42, 0xFEFA39EF */
u_threshold= -7.45133219101941108420e+02, /* 0xc0874910, 0xD52D3051 */
ln2HI[2] ={ 6.93147180369123816490e-01, /* 0x3fe62e42, 0xfee00000 */
@@ -97,6 +99,7 @@
P5 = 4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */
static volatile double
+huge = 1.0e+300,
twom1000= 9.33263618503218878990e-302; /* 2**-1000=0x01700000,0*/
double
@@ -133,7 +136,7 @@
hi = x - t*ln2HI[0]; /* t*ln2HI is exact here */
lo = t*ln2LO[0];
}
- x = hi - lo;
+ STRICT_ASSIGN(double, x, hi - lo);
}
else if(hx < 0x3e300000) { /* when |x|<2**-28 */
if(huge+x>one) return one+x;/* trigger inexact */
@@ -156,3 +159,7 @@
return y*twopk*twom1000;
}
}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(exp, expl);
+#endif
Modified: trunk/lib/msun/src/e_expf.c
===================================================================
--- trunk/lib/msun/src/e_expf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_expf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* e_expf.c -- float version of e_exp.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,8 +15,10 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_expf.c 251024 2013-05-27 08:50:10Z das $");
+#include <float.h>
+
#include "math.h"
#include "math_private.h"
@@ -22,7 +25,6 @@
static const float
one = 1.0,
halF[2] = {0.5,-0.5,},
-huge = 1.0e+30,
o_threshold= 8.8721679688e+01, /* 0x42b17180 */
u_threshold= -1.0397208405e+02, /* 0xc2cff1b5 */
ln2HI[2] ={ 6.9314575195e-01, /* 0x3f317200 */
@@ -37,10 +39,12 @@
P1 = 1.6666625440e-1, /* 0xaaaa8f.0p-26 */
P2 = -2.7667332906e-3; /* -0xb55215.0p-32 */
-static volatile float twom100 = 7.8886090522e-31; /* 2**-100=0x0d800000 */
+static volatile float
+huge = 1.0e+30,
+twom100 = 7.8886090522e-31; /* 2**-100=0x0d800000 */
float
-__ieee754_expf(float x) /* default IEEE double exp */
+__ieee754_expf(float x)
{
float y,hi=0.0,lo=0.0,c,t,twopk;
int32_t k=0,xsb;
@@ -70,7 +74,7 @@
hi = x - t*ln2HI[0]; /* t*ln2HI is exact here */
lo = t*ln2LO[0];
}
- x = hi - lo;
+ STRICT_ASSIGN(float, x, hi - lo);
}
else if(hx < 0x39000000) { /* when |x|<2**-14 */
if(huge+x>one) return one+x;/* trigger inexact */
Modified: trunk/lib/msun/src/e_fmod.c
===================================================================
--- trunk/lib/msun/src/e_fmod.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_fmod.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_fmod.c 1.3 95/01/18 */
/*
@@ -12,7 +13,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_fmod.c 176451 2008-02-22 02:30:36Z das $");
/*
* __ieee754_fmod(x,y)
Modified: trunk/lib/msun/src/e_fmodf.c
===================================================================
--- trunk/lib/msun/src/e_fmodf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_fmodf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* e_fmodf.c -- float version of e_fmod.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_fmodf.c 176451 2008-02-22 02:30:36Z das $");
/*
* __ieee754_fmodf(x,y)
Modified: trunk/lib/msun/src/e_fmodl.c
===================================================================
--- trunk/lib/msun/src/e_fmodl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_fmodl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_fmod.c 1.3 95/01/18 */
/*-
* ====================================================
@@ -11,7 +12,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_fmodl.c 181063 2008-07-31 20:09:47Z das $");
#include <float.h>
#include <stdint.h>
Modified: trunk/lib/msun/src/e_gamma.c
===================================================================
--- trunk/lib/msun/src/e_gamma.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_gamma.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_gamma.c 1.3 95/01/18 */
/*
@@ -13,7 +14,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_gamma.c 176451 2008-02-22 02:30:36Z das $");
/* __ieee754_gamma(x)
* Return the logarithm of the Gamma function of x.
Modified: trunk/lib/msun/src/e_gamma_r.c
===================================================================
--- trunk/lib/msun/src/e_gamma_r.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_gamma_r.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_gamma_r.c 1.3 95/01/18 */
/*
@@ -13,7 +14,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_gamma_r.c 176451 2008-02-22 02:30:36Z das $");
/* __ieee754_gamma_r(x, signgamp)
* Reentrant version of the logarithm of the Gamma function
Modified: trunk/lib/msun/src/e_gammaf.c
===================================================================
--- trunk/lib/msun/src/e_gammaf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_gammaf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* e_gammaf.c -- float version of e_gamma.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_gammaf.c 176451 2008-02-22 02:30:36Z das $");
/* __ieee754_gammaf(x)
* Return the logarithm of the Gamma function of x.
Modified: trunk/lib/msun/src/e_gammaf_r.c
===================================================================
--- trunk/lib/msun/src/e_gammaf_r.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_gammaf_r.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* e_gammaf_r.c -- float version of e_gamma_r.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_gammaf_r.c 176451 2008-02-22 02:30:36Z das $");
/* __ieee754_gammaf_r(x, signgamp)
* Reentrant version of the logarithm of the Gamma function
Modified: trunk/lib/msun/src/e_hypot.c
===================================================================
--- trunk/lib/msun/src/e_hypot.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_hypot.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_hypot.c 1.3 95/01/18 */
/*
@@ -12,7 +13,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_hypot.c 226380 2011-10-15 07:00:28Z das $");
/* __ieee754_hypot(x,y)
*
@@ -54,7 +55,7 @@
double
__ieee754_hypot(double x, double y)
{
- double a=x,b=y,t1,t2,y1,y2,w;
+ double a,b,t1,t2,y1,y2,w;
int32_t j,k,ha,hb;
GET_HIGH_WORD(ha,x);
Modified: trunk/lib/msun/src/e_hypotf.c
===================================================================
--- trunk/lib/msun/src/e_hypotf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_hypotf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* e_hypotf.c -- float version of e_hypot.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_hypotf.c 226380 2011-10-15 07:00:28Z das $");
#include "math.h"
#include "math_private.h"
@@ -22,7 +23,7 @@
float
__ieee754_hypotf(float x, float y)
{
- float a=x,b=y,t1,t2,y1,y2,w;
+ float a,b,t1,t2,y1,y2,w;
int32_t j,k,ha,hb;
GET_FLOAT_WORD(ha,x);
Modified: trunk/lib/msun/src/e_hypotl.c
===================================================================
--- trunk/lib/msun/src/e_hypotl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_hypotl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* From: @(#)e_hypot.c 1.3 95/01/18 */
/*
* ====================================================
@@ -11,7 +12,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_hypotl.c 226412 2011-10-16 05:36:39Z das $");
/* long double version of hypot(). See e_hypot.c for most comments. */
@@ -21,13 +22,6 @@
#include "math.h"
#include "math_private.h"
-#define GET_LDBL_EXPSIGN(i, v) do { \
- union IEEEl2bits uv; \
- \
- uv.e = v; \
- i = uv.xbits.expsign; \
-} while (0)
-
#define GET_LDBL_MAN(h, l, v) do { \
union IEEEl2bits uv; \
\
@@ -36,14 +30,6 @@
l = uv.bits.manl; \
} while (0)
-#define SET_LDBL_EXPSIGN(v, i) do { \
- union IEEEl2bits uv; \
- \
- uv.e = v; \
- uv.xbits.expsign = i; \
- v = uv.e; \
-} while (0)
-
#undef GET_HIGH_WORD
#define GET_HIGH_WORD(i, v) GET_LDBL_EXPSIGN(i, v)
#undef SET_HIGH_WORD
Modified: trunk/lib/msun/src/e_j0.c
===================================================================
--- trunk/lib/msun/src/e_j0.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_j0.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_j0.c 1.3 95/01/18 */
/*
@@ -12,7 +13,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_j0.c 284810 2015-06-25 13:01:10Z tijl $");
/* __ieee754_j0(x), __ieee754_y0(x)
* Bessel function of the first and second kinds of order zero.
@@ -62,8 +63,10 @@
#include "math.h"
#include "math_private.h"
-static double pzero(double), qzero(double);
+static __inline double pzero(double), qzero(double);
+static const volatile double vone = 1, vzero = 0;
+
static const double
huge = 1e300,
one = 1.0,
@@ -115,7 +118,7 @@
if(ix<0x3f200000) { /* |x| < 2**-13 */
if(huge+x>one) { /* raise inexact if x != 0 */
if(ix<0x3e400000) return one; /* |x|<2**-27 */
- else return one - 0.25*x*x;
+ else return one - x*x/4;
}
}
z = x*x;
@@ -150,10 +153,16 @@
EXTRACT_WORDS(hx,lx,x);
ix = 0x7fffffff&hx;
- /* Y0(NaN) is NaN, y0(-inf) is Nan, y0(inf) is 0 */
- if(ix>=0x7ff00000) return one/(x+x*x);
- if((ix|lx)==0) return -one/zero;
- if(hx<0) return zero/zero;
+ /*
+ * y0(NaN) = NaN.
+ * y0(Inf) = 0.
+ * y0(-Inf) = NaN and raise invalid exception.
+ */
+ if(ix>=0x7ff00000) return vone/(x+x*x);
+ /* y0(+-0) = -inf and raise divide-by-zero exception. */
+ if((ix|lx)==0) return -one/vzero;
+ /* y0(x<0) = NaN and raise invalid exception. */
+ if(hx<0) return vzero/vzero;
if(ix >= 0x40000000) { /* |x| >= 2.0 */
/* y0(x) = sqrt(2/(pi*x))*(p0(x)*sin(x0)+q0(x)*cos(x0))
* where x0 = x-pi/4
@@ -268,7 +277,8 @@
1.46576176948256193810e+01, /* 0x402D50B3, 0x44391809 */
};
- static double pzero(double x)
+static __inline double
+pzero(double x)
{
const double *p,*q;
double z,r,s;
@@ -278,7 +288,7 @@
if(ix>=0x40200000) {p = pR8; q= pS8;}
else if(ix>=0x40122E8B){p = pR5; q= pS5;}
else if(ix>=0x4006DB6D){p = pR3; q= pS3;}
- else if(ix>=0x40000000){p = pR2; q= pS2;}
+ else {p = pR2; q= pS2;} /* ix>=0x40000000 */
z = one/(x*x);
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
@@ -363,7 +373,8 @@
-5.31095493882666946917e+00, /* 0xC0153E6A, 0xF8B32931 */
};
- static double qzero(double x)
+static __inline double
+qzero(double x)
{
const double *p,*q;
double s,r,z;
@@ -373,7 +384,7 @@
if(ix>=0x40200000) {p = qR8; q= qS8;}
else if(ix>=0x40122E8B){p = qR5; q= qS5;}
else if(ix>=0x4006DB6D){p = qR3; q= qS3;}
- else if(ix>=0x40000000){p = qR2; q= qS2;}
+ else {p = qR2; q= qS2;} /* ix>=0x40000000 */
z = one/(x*x);
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
Modified: trunk/lib/msun/src/e_j0f.c
===================================================================
--- trunk/lib/msun/src/e_j0f.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_j0f.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* e_j0f.c -- float version of e_j0.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,13 +15,19 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_j0f.c 284810 2015-06-25 13:01:10Z tijl $");
+/*
+ * See e_j0.c for complete comments.
+ */
+
#include "math.h"
#include "math_private.h"
-static float pzerof(float), qzerof(float);
+static __inline float pzerof(float), qzerof(float);
+static const volatile float vone = 1, vzero = 0;
+
static const float
huge = 1e30,
one = 1.0,
@@ -62,7 +69,7 @@
* j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x)
* y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x)
*/
- if(ix>0x80000000) z = (invsqrtpi*cc)/sqrtf(x);
+ if(ix>0x58000000) z = (invsqrtpi*cc)/sqrtf(x); /* |x|>2**49 */
else {
u = pzerof(x); v = qzerof(x);
z = invsqrtpi*(u*cc-v*ss)/sqrtf(x);
@@ -69,10 +76,10 @@
}
return z;
}
- if(ix<0x39000000) { /* |x| < 2**-13 */
+ if(ix<0x3b000000) { /* |x| < 2**-9 */
if(huge+x>one) { /* raise inexact if x != 0 */
- if(ix<0x32000000) return one; /* |x|<2**-27 */
- else return one - (float)0.25*x*x;
+ if(ix<0x39800000) return one; /* |x|<2**-12 */
+ else return one - x*x/4;
}
}
z = x*x;
@@ -107,10 +114,9 @@
GET_FLOAT_WORD(hx,x);
ix = 0x7fffffff&hx;
- /* Y0(NaN) is NaN, y0(-inf) is Nan, y0(inf) is 0 */
- if(ix>=0x7f800000) return one/(x+x*x);
- if(ix==0) return -one/zero;
- if(hx<0) return zero/zero;
+ if(ix>=0x7f800000) return vone/(x+x*x);
+ if(ix==0) return -one/vzero;
+ if(hx<0) return vzero/vzero;
if(ix >= 0x40000000) { /* |x| >= 2.0 */
/* y0(x) = sqrt(2/(pi*x))*(p0(x)*sin(x0)+q0(x)*cos(x0))
* where x0 = x-pi/4
@@ -136,7 +142,7 @@
if ((s*c)<zero) cc = z/ss;
else ss = z/cc;
}
- if(ix>0x80000000) z = (invsqrtpi*ss)/sqrtf(x);
+ if(ix>0x58000000) z = (invsqrtpi*ss)/sqrtf(x); /* |x|>2**49 */
else {
u = pzerof(x); v = qzerof(x);
z = invsqrtpi*(u*ss+v*cc)/sqrtf(x);
@@ -143,7 +149,7 @@
}
return z;
}
- if(ix<=0x32000000) { /* x < 2**-27 */
+ if(ix<=0x39000000) { /* x < 2**-13 */
return(u00 + tpi*__ieee754_logf(x));
}
z = x*x;
@@ -224,7 +230,8 @@
1.4657617569e+01, /* 0x416a859a */
};
- static float pzerof(float x)
+static __inline float
+pzerof(float x)
{
const float *p,*q;
float z,r,s;
@@ -232,9 +239,9 @@
GET_FLOAT_WORD(ix,x);
ix &= 0x7fffffff;
if(ix>=0x41000000) {p = pR8; q= pS8;}
- else if(ix>=0x40f71c58){p = pR5; q= pS5;}
- else if(ix>=0x4036db68){p = pR3; q= pS3;}
- else if(ix>=0x40000000){p = pR2; q= pS2;}
+ else if(ix>=0x409173eb){p = pR5; q= pS5;}
+ else if(ix>=0x4036d917){p = pR3; q= pS3;}
+ else {p = pR2; q= pS2;} /* ix>=0x40000000 */
z = one/(x*x);
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
@@ -319,7 +326,8 @@
-5.3109550476e+00, /* 0xc0a9f358 */
};
- static float qzerof(float x)
+static __inline float
+qzerof(float x)
{
const float *p,*q;
float s,r,z;
@@ -327,9 +335,9 @@
GET_FLOAT_WORD(ix,x);
ix &= 0x7fffffff;
if(ix>=0x41000000) {p = qR8; q= qS8;}
- else if(ix>=0x40f71c58){p = qR5; q= qS5;}
- else if(ix>=0x4036db68){p = qR3; q= qS3;}
- else if(ix>=0x40000000){p = qR2; q= qS2;}
+ else if(ix>=0x409173eb){p = qR5; q= qS5;}
+ else if(ix>=0x4036d917){p = qR3; q= qS3;}
+ else {p = qR2; q= qS2;} /* ix>=0x40000000 */
z = one/(x*x);
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
Modified: trunk/lib/msun/src/e_j1.c
===================================================================
--- trunk/lib/msun/src/e_j1.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_j1.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_j1.c 1.3 95/01/18 */
/*
@@ -12,7 +13,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_j1.c 284810 2015-06-25 13:01:10Z tijl $");
/* __ieee754_j1(x), __ieee754_y1(x)
* Bessel function of the first and second kinds of order zero.
@@ -62,8 +63,10 @@
#include "math.h"
#include "math_private.h"
-static double pone(double), qone(double);
+static __inline double pone(double), qone(double);
+static const volatile double vone = 1, vzero = 0;
+
static const double
huge = 1e300,
one = 1.0,
@@ -147,10 +150,16 @@
EXTRACT_WORDS(hx,lx,x);
ix = 0x7fffffff&hx;
- /* if Y1(NaN) is NaN, Y1(-inf) is NaN, Y1(inf) is 0 */
- if(ix>=0x7ff00000) return one/(x+x*x);
- if((ix|lx)==0) return -one/zero;
- if(hx<0) return zero/zero;
+ /*
+ * y1(NaN) = NaN.
+ * y1(Inf) = 0.
+ * y1(-Inf) = NaN and raise invalid exception.
+ */
+ if(ix>=0x7ff00000) return vone/(x+x*x);
+ /* y1(+-0) = -inf and raise divide-by-zero exception. */
+ if((ix|lx)==0) return -one/vzero;
+ /* y1(x<0) = NaN and raise invalid exception. */
+ if(hx<0) return vzero/vzero;
if(ix >= 0x40000000) { /* |x| >= 2.0 */
s = sin(x);
c = cos(x);
@@ -262,7 +271,8 @@
8.36463893371618283368e+00, /* 0x4020BAB1, 0xF44E5192 */
};
- static double pone(double x)
+static __inline double
+pone(double x)
{
const double *p,*q;
double z,r,s;
@@ -272,7 +282,7 @@
if(ix>=0x40200000) {p = pr8; q= ps8;}
else if(ix>=0x40122E8B){p = pr5; q= ps5;}
else if(ix>=0x4006DB6D){p = pr3; q= ps3;}
- else if(ix>=0x40000000){p = pr2; q= ps2;}
+ else {p = pr2; q= ps2;} /* ix>=0x40000000 */
z = one/(x*x);
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
@@ -358,7 +368,8 @@
-4.95949898822628210127e+00, /* 0xC013D686, 0xE71BE86B */
};
- static double qone(double x)
+static __inline double
+qone(double x)
{
const double *p,*q;
double s,r,z;
@@ -368,7 +379,7 @@
if(ix>=0x40200000) {p = qr8; q= qs8;}
else if(ix>=0x40122E8B){p = qr5; q= qs5;}
else if(ix>=0x4006DB6D){p = qr3; q= qs3;}
- else if(ix>=0x40000000){p = qr2; q= qs2;}
+ else {p = qr2; q= qs2;} /* ix>=0x40000000 */
z = one/(x*x);
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
Modified: trunk/lib/msun/src/e_j1f.c
===================================================================
--- trunk/lib/msun/src/e_j1f.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_j1f.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* e_j1f.c -- float version of e_j1.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,13 +15,19 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_j1f.c 284810 2015-06-25 13:01:10Z tijl $");
+/*
+ * See e_j1.c for complete comments.
+ */
+
#include "math.h"
#include "math_private.h"
-static float ponef(float), qonef(float);
+static __inline float ponef(float), qonef(float);
+static const volatile float vone = 1, vzero = 0;
+
static const float
huge = 1e30,
one = 1.0,
@@ -63,7 +70,7 @@
* j1(x) = 1/sqrt(pi) * (P(1,x)*cc - Q(1,x)*ss) / sqrt(x)
* y1(x) = 1/sqrt(pi) * (P(1,x)*ss + Q(1,x)*cc) / sqrt(x)
*/
- if(ix>0x80000000) z = (invsqrtpi*cc)/sqrtf(y);
+ if(ix>0x58000000) z = (invsqrtpi*cc)/sqrtf(y); /* |x|>2**49 */
else {
u = ponef(y); v = qonef(y);
z = invsqrtpi*(u*cc-v*ss)/sqrtf(y);
@@ -71,7 +78,7 @@
if(hx<0) return -z;
else return z;
}
- if(ix<0x32000000) { /* |x|<2**-27 */
+ if(ix<0x39000000) { /* |x|<2**-13 */
if(huge+x>one) return (float)0.5*x;/* inexact if x!=0 necessary */
}
z = x*x;
@@ -104,10 +111,9 @@
GET_FLOAT_WORD(hx,x);
ix = 0x7fffffff&hx;
- /* if Y1(NaN) is NaN, Y1(-inf) is NaN, Y1(inf) is 0 */
- if(ix>=0x7f800000) return one/(x+x*x);
- if(ix==0) return -one/zero;
- if(hx<0) return zero/zero;
+ if(ix>=0x7f800000) return vone/(x+x*x);
+ if(ix==0) return -one/vzero;
+ if(hx<0) return vzero/vzero;
if(ix >= 0x40000000) { /* |x| >= 2.0 */
s = sinf(x);
c = cosf(x);
@@ -129,7 +135,7 @@
* sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
* to compute the worse one.
*/
- if(ix>0x48000000) z = (invsqrtpi*ss)/sqrtf(x);
+ if(ix>0x58000000) z = (invsqrtpi*ss)/sqrtf(x); /* |x|>2**49 */
else {
u = ponef(x); v = qonef(x);
z = invsqrtpi*(u*ss+v*cc)/sqrtf(x);
@@ -136,7 +142,7 @@
}
return z;
}
- if(ix<=0x24800000) { /* x < 2**-54 */
+ if(ix<=0x33000000) { /* x < 2**-25 */
return(-tpi/x);
}
z = x*x;
@@ -219,7 +225,8 @@
8.3646392822e+00, /* 0x4105d590 */
};
- static float ponef(float x)
+static __inline float
+ponef(float x)
{
const float *p,*q;
float z,r,s;
@@ -227,9 +234,9 @@
GET_FLOAT_WORD(ix,x);
ix &= 0x7fffffff;
if(ix>=0x41000000) {p = pr8; q= ps8;}
- else if(ix>=0x40f71c58){p = pr5; q= ps5;}
- else if(ix>=0x4036db68){p = pr3; q= ps3;}
- else if(ix>=0x40000000){p = pr2; q= ps2;}
+ else if(ix>=0x409173eb){p = pr5; q= ps5;}
+ else if(ix>=0x4036d917){p = pr3; q= ps3;}
+ else {p = pr2; q= ps2;} /* ix>=0x40000000 */
z = one/(x*x);
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
@@ -315,7 +322,8 @@
-4.9594988823e+00, /* 0xc09eb437 */
};
- static float qonef(float x)
+static __inline float
+qonef(float x)
{
const float *p,*q;
float s,r,z;
@@ -322,10 +330,10 @@
int32_t ix;
GET_FLOAT_WORD(ix,x);
ix &= 0x7fffffff;
- if(ix>=0x40200000) {p = qr8; q= qs8;}
- else if(ix>=0x40f71c58){p = qr5; q= qs5;}
- else if(ix>=0x4036db68){p = qr3; q= qs3;}
- else if(ix>=0x40000000){p = qr2; q= qs2;}
+ if(ix>=0x41000000) {p = qr8; q= qs8;}
+ else if(ix>=0x409173eb){p = qr5; q= qs5;}
+ else if(ix>=0x4036d917){p = qr3; q= qs3;}
+ else {p = qr2; q= qs2;} /* ix>=0x40000000 */
z = one/(x*x);
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
Modified: trunk/lib/msun/src/e_jn.c
===================================================================
--- trunk/lib/msun/src/e_jn.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_jn.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_jn.c 1.4 95/01/18 */
/*
@@ -12,7 +13,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_jn.c 284810 2015-06-25 13:01:10Z tijl $");
/*
* __ieee754_jn(n, x), __ieee754_yn(n, x)
@@ -43,6 +44,8 @@
#include "math.h"
#include "math_private.h"
+static const volatile double vone = 1, vzero = 0;
+
static const double
invsqrtpi= 5.64189583547756279280e-01, /* 0x3FE20DD7, 0x50429B6D */
two = 2.00000000000000000000e+00, /* 0x40000000, 0x00000000 */
@@ -220,10 +223,12 @@
EXTRACT_WORDS(hx,lx,x);
ix = 0x7fffffff&hx;
- /* if Y(n,NaN) is NaN */
+ /* yn(n,NaN) = NaN */
if((ix|((u_int32_t)(lx|-lx))>>31)>0x7ff00000) return x+x;
- if((ix|lx)==0) return -one/zero;
- if(hx<0) return zero/zero;
+ /* yn(n,+-0) = -inf and raise divide-by-zero exception. */
+ if((ix|lx)==0) return -one/vzero;
+ /* yn(n,x<0) = NaN and raise invalid exception. */
+ if(hx<0) return vzero/vzero;
sign = 1;
if(n<0){
n = -n;
Modified: trunk/lib/msun/src/e_jnf.c
===================================================================
--- trunk/lib/msun/src/e_jnf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_jnf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* e_jnf.c -- float version of e_jn.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,11 +15,17 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_jnf.c 284810 2015-06-25 13:01:10Z tijl $");
+/*
+ * See e_jn.c for complete comments.
+ */
+
#include "math.h"
#include "math_private.h"
+static const volatile float vone = 1, vzero = 0;
+
static const float
two = 2.0000000000e+00, /* 0x40000000 */
one = 1.0000000000e+00; /* 0x3F800000 */
@@ -172,10 +179,9 @@
GET_FLOAT_WORD(hx,x);
ix = 0x7fffffff&hx;
- /* if Y(n,NaN) is NaN */
if(ix>0x7f800000) return x+x;
- if(ix==0) return -one/zero;
- if(hx<0) return zero/zero;
+ if(ix==0) return -one/vzero;
+ if(hx<0) return vzero/vzero;
sign = 1;
if(n<0){
n = -n;
Modified: trunk/lib/msun/src/e_lgamma.c
===================================================================
--- trunk/lib/msun/src/e_lgamma.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_lgamma.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_lgamma.c 1.3 95/01/18 */
/*
@@ -13,7 +14,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_lgamma.c 284810 2015-06-25 13:01:10Z tijl $");
/* __ieee754_lgamma(x)
* Return the logarithm of the Gamma function of x.
@@ -21,6 +22,8 @@
* Method: call __ieee754_lgamma_r
*/
+#include <float.h>
+
#include "math.h"
#include "math_private.h"
@@ -31,3 +34,7 @@
{
return __ieee754_lgamma_r(x,&signgam);
}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(lgamma, lgammal);
+#endif
Modified: trunk/lib/msun/src/e_lgamma_r.c
===================================================================
--- trunk/lib/msun/src/e_lgamma_r.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_lgamma_r.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,4 +1,4 @@
-
+/* $MidnightBSD$ */
/* @(#)e_lgamma_r.c 1.3 95/01/18 */
/*
* ====================================================
@@ -6,22 +6,21 @@
*
* Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
- *
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_lgamma_r.c 284810 2015-06-25 13:01:10Z tijl $");
/* __ieee754_lgamma_r(x, signgamp)
- * Reentrant version of the logarithm of the Gamma function
- * with user provide pointer for the sign of Gamma(x).
+ * Reentrant version of the logarithm of the Gamma function
+ * with user provide pointer for the sign of Gamma(x).
*
* Method:
* 1. Argument Reduction for 0 < x <= 8
- * Since gamma(1+s)=s*gamma(s), for x in [0,8], we may
+ * Since gamma(1+s)=s*gamma(s), for x in [0,8], we may
* reduce x to a number in [1.5,2.5] by
* lgamma(1+s) = log(s) + lgamma(s)
* for example,
@@ -59,20 +58,20 @@
* by
* 3 5 11
* w = w0 + w1*z + w2*z + w3*z + ... + w6*z
- * where
+ * where
* |w - f(z)| < 2**-58.74
- *
+ *
* 4. For negative x, since (G is gamma function)
* -x*G(-x)*G(x) = pi/sin(pi*x),
* we have
* G(x) = pi/(sin(pi*x)*(-x)*G(-x))
* since G(-x) is positive, sign(G(x)) = sign(sin(pi*x)) for x<0
- * Hence, for x<0, signgam = sign(sin(pi*x)) and
+ * Hence, for x<0, signgam = sign(sin(pi*x)) and
* lgamma(x) = log(|Gamma(x)|)
* = log(pi/(|x*sin(pi*x)|)) - lgamma(-x);
- * Note: one should avoid compute pi*(-x) directly in the
+ * Note: one should avoid compute pi*(-x) directly in the
* computation of sin(pi*(-x)).
- *
+ *
* 5. Special Cases
* lgamma(2+s) ~ s*(1-Euler) for tiny s
* lgamma(1) = lgamma(2) = 0
@@ -80,14 +79,17 @@
* lgamma(0) = lgamma(neg.integer) = inf and raise divide-by-zero
* lgamma(inf) = inf
* lgamma(-inf) = inf (bug for bug compatible with C99!?)
- *
*/
+#include <float.h>
+
#include "math.h"
#include "math_private.h"
+static const volatile double vzero = 0;
+
static const double
-two52= 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */
+zero= 0.00000000000000000000e+00,
half= 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */
one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
pi = 3.14159265358979311600e+00, /* 0x400921FB, 0x54442D18 */
@@ -154,44 +156,40 @@
w5 = 8.36339918996282139126e-04, /* 0x3F4B67BA, 0x4CDAD5D1 */
w6 = -1.63092934096575273989e-03; /* 0xBF5AB89D, 0x0B9E43E4 */
-static const double zero= 0.00000000000000000000e+00;
-
- static double sin_pi(double x)
+/*
+ * Compute sin(pi*x) without actually doing the pi*x multiplication.
+ * sin_pi(x) is only called for x < 0 and |x| < 2**(p-1) where p is
+ * the precision of x.
+ */
+static double
+sin_pi(double x)
{
+ volatile double vz;
double y,z;
- int n,ix;
+ int n;
- GET_HIGH_WORD(ix,x);
- ix &= 0x7fffffff;
+ y = -x;
- if(ix<0x3fd00000) return __kernel_sin(pi*x,zero,0);
- y = -x; /* x is assume negative */
+ vz = y+0x1p52; /* depend on 0 <= y < 0x1p52 */
+ z = vz-0x1p52; /* rint(y) for the above range */
+ if (z == y)
+ return zero;
- /*
- * argument reduction, make sure inexact flag not raised if input
- * is an integer
- */
- z = floor(y);
- if(z!=y) { /* inexact anyway */
- y *= 0.5;
- y = 2.0*(y - floor(y)); /* y = |x| mod 2.0 */
- n = (int) (y*4.0);
- } else {
- if(ix>=0x43400000) {
- y = zero; n = 0; /* y must be even */
- } else {
- if(ix<0x43300000) z = y+two52; /* exact */
- GET_LOW_WORD(n,z);
- n &= 1;
- y = n;
- n<<= 2;
- }
- }
+ vz = y+0x1p50;
+ GET_LOW_WORD(n,vz); /* bits for rounded y (units 0.25) */
+ z = vz-0x1p50; /* y rounded to a multiple of 0.25 */
+ if (z > y) {
+ z -= 0.25; /* adjust to round down */
+ n--;
+ }
+ n &= 7; /* octant of y mod 2 */
+ y = y - z + n * 0.25; /* y mod 2 */
+
switch (n) {
case 0: y = __kernel_sin(pi*y,zero,0); break;
- case 1:
+ case 1:
case 2: y = __kernel_cos(pi*(0.5-y),zero); break;
- case 3:
+ case 3:
case 4: y = __kernel_sin(pi*(one-y),zero,0); break;
case 5:
case 6: y = -__kernel_cos(pi*(y-1.5),zero); break;
@@ -204,34 +202,38 @@
double
__ieee754_lgamma_r(double x, int *signgamp)
{
- double t,y,z,nadj,p,p1,p2,p3,q,r,w;
+ double nadj,p,p1,p2,p3,q,r,t,w,y,z;
int32_t hx;
- int i,lx,ix;
+ int i,ix,lx;
EXTRACT_WORDS(hx,lx,x);
- /* purge off +-inf, NaN, +-0, tiny and negative arguments */
+ /* purge +-Inf and NaNs */
*signgamp = 1;
ix = hx&0x7fffffff;
if(ix>=0x7ff00000) return x*x;
- if((ix|lx)==0) return one/zero;
- if(ix<0x3b900000) { /* |x|<2**-70, return -log(|x|) */
- if(hx<0) {
- *signgamp = -1;
- return -__ieee754_log(-x);
- } else return -__ieee754_log(x);
+
+ /* purge +-0 and tiny arguments */
+ *signgamp = 1-2*((uint32_t)hx>>31);
+ if(ix<0x3c700000) { /* |x|<2**-56, return -log(|x|) */
+ if((ix|lx)==0)
+ return one/vzero;
+ return -__ieee754_log(fabs(x));
}
+
+ /* purge negative integers and start evaluation for other x < 0 */
if(hx<0) {
+ *signgamp = 1;
if(ix>=0x43300000) /* |x|>=2**52, must be -integer */
- return one/zero;
+ return one/vzero;
t = sin_pi(x);
- if(t==zero) return one/zero; /* -integer */
+ if(t==zero) return one/vzero; /* -integer */
nadj = __ieee754_log(pi/fabs(t*x));
if(t<zero) *signgamp = -1;
x = -x;
}
- /* purge off 1 and 2 */
+ /* purge 1 and 2 */
if((((ix-0x3ff00000)|lx)==0)||(((ix-0x40000000)|lx)==0)) r = 0;
/* for x < 2.0 */
else if(ix<0x40000000) {
@@ -252,7 +254,7 @@
p1 = a0+z*(a2+z*(a4+z*(a6+z*(a8+z*a10))));
p2 = z*(a1+z*(a3+z*(a5+z*(a7+z*(a9+z*a11)))));
p = y*p1+p2;
- r += (p-0.5*y); break;
+ r += p-y/2; break;
case 1:
z = y*y;
w = z*y;
@@ -260,39 +262,43 @@
p2 = t1+w*(t4+w*(t7+w*(t10+w*t13)));
p3 = t2+w*(t5+w*(t8+w*(t11+w*t14)));
p = z*p1-(tt-w*(p2+y*p3));
- r += (tf + p); break;
- case 2:
+ r += tf + p; break;
+ case 2:
p1 = y*(u0+y*(u1+y*(u2+y*(u3+y*(u4+y*u5)))));
p2 = one+y*(v1+y*(v2+y*(v3+y*(v4+y*v5))));
- r += (-0.5*y + p1/p2);
+ r += p1/p2-y/2;
}
}
- else if(ix<0x40200000) { /* x < 8.0 */
- i = (int)x;
- t = zero;
- y = x-(double)i;
+ /* x < 8.0 */
+ else if(ix<0x40200000) {
+ i = x;
+ y = x-i;
p = y*(s0+y*(s1+y*(s2+y*(s3+y*(s4+y*(s5+y*s6))))));
q = one+y*(r1+y*(r2+y*(r3+y*(r4+y*(r5+y*r6)))));
- r = half*y+p/q;
+ r = y/2+p/q;
z = one; /* lgamma(1+s) = log(s) + lgamma(s) */
switch(i) {
- case 7: z *= (y+6.0); /* FALLTHRU */
- case 6: z *= (y+5.0); /* FALLTHRU */
- case 5: z *= (y+4.0); /* FALLTHRU */
- case 4: z *= (y+3.0); /* FALLTHRU */
- case 3: z *= (y+2.0); /* FALLTHRU */
+ case 7: z *= (y+6); /* FALLTHRU */
+ case 6: z *= (y+5); /* FALLTHRU */
+ case 5: z *= (y+4); /* FALLTHRU */
+ case 4: z *= (y+3); /* FALLTHRU */
+ case 3: z *= (y+2); /* FALLTHRU */
r += __ieee754_log(z); break;
}
- /* 8.0 <= x < 2**58 */
- } else if (ix < 0x43900000) {
+ /* 8.0 <= x < 2**56 */
+ } else if (ix < 0x43700000) {
t = __ieee754_log(x);
z = one/x;
y = z*z;
w = w0+z*(w1+y*(w2+y*(w3+y*(w4+y*(w5+y*w6)))));
r = (x-half)*(t-one)+w;
- } else
- /* 2**58 <= x <= inf */
+ } else
+ /* 2**56 <= x <= inf */
r = x*(__ieee754_log(x)-one);
if(hx<0) r = nadj - r;
return r;
}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(lgamma_r, lgammal_r);
+#endif
Modified: trunk/lib/msun/src/e_lgammaf.c
===================================================================
--- trunk/lib/msun/src/e_lgammaf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_lgammaf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* e_lgammaf.c -- float version of e_lgamma.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_lgammaf.c 176451 2008-02-22 02:30:36Z das $");
/* __ieee754_lgammaf(x)
* Return the logarithm of the Gamma function of x.
Modified: trunk/lib/msun/src/e_lgammaf_r.c
===================================================================
--- trunk/lib/msun/src/e_lgammaf_r.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_lgammaf_r.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,5 +1,7 @@
+/* $MidnightBSD$ */
/* e_lgammaf_r.c -- float version of e_lgamma_r.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
+ * Conversion to float fixed By Steven G. Kargl.
*/
/*
@@ -14,112 +16,96 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_lgammaf_r.c 284810 2015-06-25 13:01:10Z tijl $");
#include "math.h"
#include "math_private.h"
+static const volatile float vzero = 0;
+
static const float
-two23= 8.3886080000e+06, /* 0x4b000000 */
-half= 5.0000000000e-01, /* 0x3f000000 */
-one = 1.0000000000e+00, /* 0x3f800000 */
+zero= 0,
+half= 0.5,
+one = 1,
pi = 3.1415927410e+00, /* 0x40490fdb */
-a0 = 7.7215664089e-02, /* 0x3d9e233f */
-a1 = 3.2246702909e-01, /* 0x3ea51a66 */
-a2 = 6.7352302372e-02, /* 0x3d89f001 */
-a3 = 2.0580807701e-02, /* 0x3ca89915 */
-a4 = 7.3855509982e-03, /* 0x3bf2027e */
-a5 = 2.8905137442e-03, /* 0x3b3d6ec6 */
-a6 = 1.1927076848e-03, /* 0x3a9c54a1 */
-a7 = 5.1006977446e-04, /* 0x3a05b634 */
-a8 = 2.2086278477e-04, /* 0x39679767 */
-a9 = 1.0801156895e-04, /* 0x38e28445 */
-a10 = 2.5214456400e-05, /* 0x37d383a2 */
-a11 = 4.4864096708e-05, /* 0x383c2c75 */
-tc = 1.4616321325e+00, /* 0x3fbb16c3 */
-tf = -1.2148628384e-01, /* 0xbdf8cdcd */
-/* tt = -(tail of tf) */
-tt = 6.6971006518e-09, /* 0x31e61c52 */
-t0 = 4.8383611441e-01, /* 0x3ef7b95e */
-t1 = -1.4758771658e-01, /* 0xbe17213c */
-t2 = 6.4624942839e-02, /* 0x3d845a15 */
-t3 = -3.2788541168e-02, /* 0xbd064d47 */
-t4 = 1.7970675603e-02, /* 0x3c93373d */
-t5 = -1.0314224288e-02, /* 0xbc28fcfe */
-t6 = 6.1005386524e-03, /* 0x3bc7e707 */
-t7 = -3.6845202558e-03, /* 0xbb7177fe */
-t8 = 2.2596477065e-03, /* 0x3b141699 */
-t9 = -1.4034647029e-03, /* 0xbab7f476 */
-t10 = 8.8108185446e-04, /* 0x3a66f867 */
-t11 = -5.3859531181e-04, /* 0xba0d3085 */
-t12 = 3.1563205994e-04, /* 0x39a57b6b */
-t13 = -3.1275415677e-04, /* 0xb9a3f927 */
-t14 = 3.3552918467e-04, /* 0x39afe9f7 */
-u0 = -7.7215664089e-02, /* 0xbd9e233f */
-u1 = 6.3282704353e-01, /* 0x3f2200f4 */
-u2 = 1.4549225569e+00, /* 0x3fba3ae7 */
-u3 = 9.7771751881e-01, /* 0x3f7a4bb2 */
-u4 = 2.2896373272e-01, /* 0x3e6a7578 */
-u5 = 1.3381091878e-02, /* 0x3c5b3c5e */
-v1 = 2.4559779167e+00, /* 0x401d2ebe */
-v2 = 2.1284897327e+00, /* 0x4008392d */
-v3 = 7.6928514242e-01, /* 0x3f44efdf */
-v4 = 1.0422264785e-01, /* 0x3dd572af */
-v5 = 3.2170924824e-03, /* 0x3b52d5db */
-s0 = -7.7215664089e-02, /* 0xbd9e233f */
-s1 = 2.1498242021e-01, /* 0x3e5c245a */
-s2 = 3.2577878237e-01, /* 0x3ea6cc7a */
-s3 = 1.4635047317e-01, /* 0x3e15dce6 */
-s4 = 2.6642270386e-02, /* 0x3cda40e4 */
-s5 = 1.8402845599e-03, /* 0x3af135b4 */
-s6 = 3.1947532989e-05, /* 0x3805ff67 */
-r1 = 1.3920053244e+00, /* 0x3fb22d3b */
-r2 = 7.2193557024e-01, /* 0x3f38d0c5 */
-r3 = 1.7193385959e-01, /* 0x3e300f6e */
-r4 = 1.8645919859e-02, /* 0x3c98bf54 */
-r5 = 7.7794247773e-04, /* 0x3a4beed6 */
-r6 = 7.3266842264e-06, /* 0x36f5d7bd */
-w0 = 4.1893854737e-01, /* 0x3ed67f1d */
-w1 = 8.3333335817e-02, /* 0x3daaaaab */
-w2 = -2.7777778450e-03, /* 0xbb360b61 */
-w3 = 7.9365057172e-04, /* 0x3a500cfd */
-w4 = -5.9518753551e-04, /* 0xba1c065c */
-w5 = 8.3633989561e-04, /* 0x3a5b3dd2 */
-w6 = -1.6309292987e-03; /* 0xbad5c4e8 */
+/*
+ * Domain y in [0x1p-27, 0.27], range ~[-3.4599e-10, 3.4590e-10]:
+ * |(lgamma(2 - y) + 0.5 * y) / y - a(y)| < 2**-31.4
+ */
+a0 = 7.72156641e-02, /* 0x3d9e233f */
+a1 = 3.22467119e-01, /* 0x3ea51a69 */
+a2 = 6.73484802e-02, /* 0x3d89ee00 */
+a3 = 2.06395667e-02, /* 0x3ca9144f */
+a4 = 6.98275631e-03, /* 0x3be4cf9b */
+a5 = 4.11768444e-03, /* 0x3b86eda4 */
+/*
+ * Domain x in [tc-0.24, tc+0.28], range ~[-5.6577e-10, 5.5677e-10]:
+ * |(lgamma(x) - tf) - t(x - tc)| < 2**-30.8.
+ */
+tc = 1.46163213e+00, /* 0x3fbb16c3 */
+tf = -1.21486291e-01, /* 0xbdf8cdce */
+t0 = -2.94064460e-11, /* 0xae0154b7 */
+t1 = -2.35939837e-08, /* 0xb2caabb8 */
+t2 = 4.83836412e-01, /* 0x3ef7b968 */
+t3 = -1.47586212e-01, /* 0xbe1720d7 */
+t4 = 6.46013096e-02, /* 0x3d844db1 */
+t5 = -3.28450352e-02, /* 0xbd068884 */
+t6 = 1.86483748e-02, /* 0x3c98c47a */
+t7 = -9.89206228e-03, /* 0xbc221251 */
+/*
+ * Domain y in [-0.1, 0.232], range ~[-8.4931e-10, 8.7794e-10]:
+ * |(lgamma(1 + y) + 0.5 * y) / y - u(y) / v(y)| < 2**-31.2
+ */
+u0 = -7.72156641e-02, /* 0xbd9e233f */
+u1 = 7.36789703e-01, /* 0x3f3c9e40 */
+u2 = 4.95649040e-01, /* 0x3efdc5b6 */
+v1 = 1.10958421e+00, /* 0x3f8e06db */
+v2 = 2.10598111e-01, /* 0x3e57a708 */
+v3 = -1.02995494e-02, /* 0xbc28bf71 */
+/*
+ * Domain x in (2, 3], range ~[-5.5189e-11, 5.2317e-11]:
+ * |(lgamma(y+2) - 0.5 * y) / y - s(y)/r(y)| < 2**-35.0
+ * with y = x - 2.
+ */
+s0 = -7.72156641e-02, /* 0xbd9e233f */
+s1 = 2.69987404e-01, /* 0x3e8a3bca */
+s2 = 1.42851010e-01, /* 0x3e124789 */
+s3 = 1.19389519e-02, /* 0x3c439b98 */
+r1 = 6.79650068e-01, /* 0x3f2dfd8c */
+r2 = 1.16058730e-01, /* 0x3dedb033 */
+r3 = 3.75673687e-03, /* 0x3b763396 */
+/*
+ * Domain z in [8, 0x1p24], range ~[-1.2640e-09, 1.2640e-09]:
+ * |lgamma(x) - (x - 0.5) * (log(x) - 1) - w(1/x)| < 2**-29.6.
+ */
+w0 = 4.18938547e-01, /* 0x3ed67f1d */
+w1 = 8.33332464e-02, /* 0x3daaaa9f */
+w2 = -2.76129087e-03; /* 0xbb34f6c6 */
-static const float zero= 0.0000000000e+00;
-
- static float sin_pif(float x)
+static float
+sin_pif(float x)
{
+ volatile float vz;
float y,z;
- int n,ix;
+ int n;
- GET_FLOAT_WORD(ix,x);
- ix &= 0x7fffffff;
+ y = -x;
- if(ix<0x3e800000) return __kernel_sindf(pi*x);
- y = -x; /* x is assume negative */
+ vz = y+0x1p23F; /* depend on 0 <= y < 0x1p23 */
+ z = vz-0x1p23F; /* rintf(y) for the above range */
+ if (z == y)
+ return zero;
- /*
- * argument reduction, make sure inexact flag not raised if input
- * is an integer
- */
- z = floorf(y);
- if(z!=y) { /* inexact anyway */
- y *= (float)0.5;
- y = (float)2.0*(y - floorf(y)); /* y = |x| mod 2.0 */
- n = (int) (y*(float)4.0);
- } else {
- if(ix>=0x4b800000) {
- y = zero; n = 0; /* y must be even */
- } else {
- if(ix<0x4b000000) z = y+two23; /* exact */
- GET_FLOAT_WORD(n,z);
- n &= 1;
- y = n;
- n<<= 2;
- }
- }
+ vz = y+0x1p21F;
+ GET_FLOAT_WORD(n,vz); /* bits for rounded y (units 0.25) */
+ z = vz-0x1p21F; /* y rounded to a multiple of 0.25 */
+ if (z > y) {
+ z -= 0.25F; /* adjust to round down */
+ n--;
+ }
+ n &= 7; /* octant of y mod 2 */
+ y = y - z + n * 0.25F; /* y mod 2 */
+
switch (n) {
case 0: y = __kernel_sindf(pi*y); break;
case 1:
@@ -137,34 +123,38 @@
float
__ieee754_lgammaf_r(float x, int *signgamp)
{
- float t,y,z,nadj,p,p1,p2,p3,q,r,w;
+ float nadj,p,p1,p2,p3,q,r,t,w,y,z;
int32_t hx;
int i,ix;
GET_FLOAT_WORD(hx,x);
- /* purge off +-inf, NaN, +-0, tiny and negative arguments */
+ /* purge +-Inf and NaNs */
*signgamp = 1;
ix = hx&0x7fffffff;
if(ix>=0x7f800000) return x*x;
- if(ix==0) return one/zero;
- if(ix<0x35000000) { /* |x|<2**-21, return -log(|x|) */
- if(hx<0) {
- *signgamp = -1;
- return -__ieee754_logf(-x);
- } else return -__ieee754_logf(x);
+
+ /* purge +-0 and tiny arguments */
+ *signgamp = 1-2*((uint32_t)hx>>31);
+ if(ix<0x32000000) { /* |x|<2**-27, return -log(|x|) */
+ if(ix==0)
+ return one/vzero;
+ return -__ieee754_logf(fabsf(x));
}
+
+ /* purge negative integers and start evaluation for other x < 0 */
if(hx<0) {
- if(ix>=0x4b000000) /* |x|>=2**23, must be -integer */
- return one/zero;
+ *signgamp = 1;
+ if(ix>=0x4b000000) /* |x|>=2**23, must be -integer */
+ return one/vzero;
t = sin_pif(x);
- if(t==zero) return one/zero; /* -integer */
+ if(t==zero) return one/vzero; /* -integer */
nadj = __ieee754_logf(pi/fabsf(t*x));
if(t<zero) *signgamp = -1;
x = -x;
}
- /* purge off 1 and 2 */
+ /* purge 1 and 2 */
if (ix==0x3f800000||ix==0x40000000) r = 0;
/* for x < 2.0 */
else if(ix<0x40000000) {
@@ -175,7 +165,7 @@
else {y = x; i=2;}
} else {
r = zero;
- if(ix>=0x3fdda618) {y=(float)2.0-x;i=0;} /* [1.7316,2] */
+ if(ix>=0x3fdda618) {y=2-x;i=0;} /* [1.7316,2] */
else if(ix>=0x3F9da620) {y=x-tc;i=1;} /* [1.23,1.73] */
else {y=x-one;i=2;}
}
@@ -182,49 +172,44 @@
switch(i) {
case 0:
z = y*y;
- p1 = a0+z*(a2+z*(a4+z*(a6+z*(a8+z*a10))));
- p2 = z*(a1+z*(a3+z*(a5+z*(a7+z*(a9+z*a11)))));
+ p1 = a0+z*(a2+z*a4);
+ p2 = z*(a1+z*(a3+z*a5));
p = y*p1+p2;
- r += (p-(float)0.5*y); break;
+ r += p-y/2; break;
case 1:
- z = y*y;
- w = z*y;
- p1 = t0+w*(t3+w*(t6+w*(t9 +w*t12))); /* parallel comp */
- p2 = t1+w*(t4+w*(t7+w*(t10+w*t13)));
- p3 = t2+w*(t5+w*(t8+w*(t11+w*t14)));
- p = z*p1-(tt-w*(p2+y*p3));
- r += (tf + p); break;
+ p = t0+y*t1+y*y*(t2+y*(t3+y*(t4+y*(t5+y*(t6+y*t7)))));
+ r += tf + p; break;
case 2:
- p1 = y*(u0+y*(u1+y*(u2+y*(u3+y*(u4+y*u5)))));
- p2 = one+y*(v1+y*(v2+y*(v3+y*(v4+y*v5))));
- r += (-(float)0.5*y + p1/p2);
+ p1 = y*(u0+y*(u1+y*u2));
+ p2 = one+y*(v1+y*(v2+y*v3));
+ r += p1/p2-y/2;
}
}
- else if(ix<0x41000000) { /* x < 8.0 */
- i = (int)x;
- t = zero;
- y = x-(float)i;
- p = y*(s0+y*(s1+y*(s2+y*(s3+y*(s4+y*(s5+y*s6))))));
- q = one+y*(r1+y*(r2+y*(r3+y*(r4+y*(r5+y*r6)))));
- r = half*y+p/q;
+ /* x < 8.0 */
+ else if(ix<0x41000000) {
+ i = x;
+ y = x-i;
+ p = y*(s0+y*(s1+y*(s2+y*s3)));
+ q = one+y*(r1+y*(r2+y*r3));
+ r = y/2+p/q;
z = one; /* lgamma(1+s) = log(s) + lgamma(s) */
switch(i) {
- case 7: z *= (y+(float)6.0); /* FALLTHRU */
- case 6: z *= (y+(float)5.0); /* FALLTHRU */
- case 5: z *= (y+(float)4.0); /* FALLTHRU */
- case 4: z *= (y+(float)3.0); /* FALLTHRU */
- case 3: z *= (y+(float)2.0); /* FALLTHRU */
+ case 7: z *= (y+6); /* FALLTHRU */
+ case 6: z *= (y+5); /* FALLTHRU */
+ case 5: z *= (y+4); /* FALLTHRU */
+ case 4: z *= (y+3); /* FALLTHRU */
+ case 3: z *= (y+2); /* FALLTHRU */
r += __ieee754_logf(z); break;
}
- /* 8.0 <= x < 2**58 */
- } else if (ix < 0x5c800000) {
+ /* 8.0 <= x < 2**27 */
+ } else if (ix < 0x4d000000) {
t = __ieee754_logf(x);
z = one/x;
y = z*z;
- w = w0+z*(w1+y*(w2+y*(w3+y*(w4+y*(w5+y*w6)))));
+ w = w0+z*(w1+y*w2);
r = (x-half)*(t-one)+w;
} else
- /* 2**58 <= x <= inf */
+ /* 2**27 <= x <= inf */
r = x*(__ieee754_logf(x)-one);
if(hx<0) r = nadj - r;
return r;
Added: trunk/lib/msun/src/e_lgammal.c
===================================================================
--- trunk/lib/msun/src/e_lgammal.c (rev 0)
+++ trunk/lib/msun/src/e_lgammal.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -0,0 +1,26 @@
+/* $MidnightBSD$ */
+/* @(#)e_lgamma.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_lgammal.c 284810 2015-06-25 13:01:10Z tijl $");
+
+#include "math.h"
+#include "math_private.h"
+
+extern int signgam;
+
+long double
+lgammal(long double x)
+{
+ return lgammal_r(x,&signgam);
+}
Property changes on: trunk/lib/msun/src/e_lgammal.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/lib/msun/src/e_log.c
===================================================================
--- trunk/lib/msun/src/e_log.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_log.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_log.c 1.3 95/01/18 */
/*
@@ -12,7 +13,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_log.c 251292 2013-06-03 09:14:31Z das $");
/* __ieee754_log(x)
* Return the logrithm of x
@@ -65,6 +66,8 @@
* to produce the hexadecimal values shown.
*/
+#include <float.h>
+
#include "math.h"
#include "math_private.h"
@@ -81,6 +84,7 @@
Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
static const double zero = 0.0;
+static volatile double vzero = 0.0;
double
__ieee754_log(double x)
@@ -94,7 +98,7 @@
k=0;
if (hx < 0x00100000) { /* x < 2**-1022 */
if (((hx&0x7fffffff)|lx)==0)
- return -two54/zero; /* log(+-0)=-inf */
+ return -two54/vzero; /* log(+-0)=-inf */
if (hx<0) return (x-x)/zero; /* log(-#) = NaN */
k -= 54; x *= two54; /* subnormal number, scale up x */
GET_HIGH_WORD(hx,x);
@@ -138,3 +142,7 @@
return dk*ln2_hi-((s*(f-R)-dk*ln2_lo)-f);
}
}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(log, logl);
+#endif
Modified: trunk/lib/msun/src/e_log10.c
===================================================================
--- trunk/lib/msun/src/e_log10.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_log10.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_log10.c 1.3 95/01/18 */
/*
@@ -12,12 +13,18 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_log10.c 251292 2013-06-03 09:14:31Z das $");
/*
- * Return the base 10 logarithm of x. See k_log.c for details on the algorithm.
+ * Return the base 10 logarithm of x. See e_log.c and k_log.h for most
+ * comments.
+ *
+ * log10(x) = (f - 0.5*f*f + k_log1p(f)) / ln10 + k * log10(2)
+ * in not-quite-routine extra precision.
*/
+#include <float.h>
+
#include "math.h"
#include "math_private.h"
#include "k_log.h"
@@ -30,25 +37,28 @@
log10_2lo = 3.69423907715893078616e-13; /* 0x3D59FEF3, 0x11F12B36 */
static const double zero = 0.0;
+static volatile double vzero = 0.0;
double
__ieee754_log10(double x)
{
- double f,hi,lo,y,z;
+ double f,hfsq,hi,lo,r,val_hi,val_lo,w,y,y2;
int32_t i,k,hx;
u_int32_t lx;
EXTRACT_WORDS(hx,lx,x);
- k=0;
- if (hx < 0x00100000) { /* x < 2**-1022 */
- if (((hx&0x7fffffff)|lx)==0)
- return -two54/zero; /* log(+-0)=-inf */
- if (hx<0) return (x-x)/zero; /* log(-#) = NaN */
- k -= 54; x *= two54; /* subnormal number, scale up x */
+ k=0;
+ if (hx < 0x00100000) { /* x < 2**-1022 */
+ if (((hx&0x7fffffff)|lx)==0)
+ return -two54/vzero; /* log(+-0)=-inf */
+ if (hx<0) return (x-x)/zero; /* log(-#) = NaN */
+ k -= 54; x *= two54; /* subnormal number, scale up x */
GET_HIGH_WORD(hx,x);
- }
+ }
if (hx >= 0x7ff00000) return x+x;
+ if (hx == 0x3ff00000 && lx == 0)
+ return zero; /* log(1) = +0 */
k += (hx>>20)-1023;
hx &= 0x000fffff;
i = (hx+0x95f64)&0x100000;
@@ -55,10 +65,31 @@
SET_HIGH_WORD(x,hx|(i^0x3ff00000)); /* normalize x or x/2 */
k += (i>>20);
y = (double)k;
- f = __kernel_log(x);
- hi = x = x - 1;
+ f = x - 1.0;
+ hfsq = 0.5*f*f;
+ r = k_log1p(f);
+
+ /* See e_log2.c for most details. */
+ hi = f - hfsq;
SET_LOW_WORD(hi,0);
- lo = x - hi;
- z = y*log10_2lo + (x+f)*ivln10lo + (lo+f)*ivln10hi + hi*ivln10hi;
- return z+y*log10_2hi;
+ lo = (f - hi) - hfsq + r;
+ val_hi = hi*ivln10hi;
+ y2 = y*log10_2hi;
+ val_lo = y*log10_2lo + (lo+hi)*ivln10lo + lo*ivln10hi;
+
+ /*
+ * Extra precision in for adding y*log10_2hi is not strictly needed
+ * since there is no very large cancellation near x = sqrt(2) or
+ * x = 1/sqrt(2), but we do it anyway since it costs little on CPUs
+ * with some parallelism and it reduces the error for many args.
+ */
+ w = y2 + val_hi;
+ val_lo += (y2 - w) + val_hi;
+ val_hi = w;
+
+ return val_lo + val_hi;
}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(log10, log10l);
+#endif
Modified: trunk/lib/msun/src/e_log10f.c
===================================================================
--- trunk/lib/msun/src/e_log10f.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_log10f.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +11,10 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_log10f.c 251024 2013-05-27 08:50:10Z das $");
/*
- * Return the base 10 logarithm of x. See k_log.c for details on the algorithm.
+ * Float version of e_log10.c. See the latter for most comments.
*/
#include "math.h"
@@ -28,24 +29,27 @@
log10_2lo = 7.9034151668e-07; /* 0x355427db */
static const float zero = 0.0;
+static volatile float vzero = 0.0;
float
__ieee754_log10f(float x)
{
- float f,hi,lo,y,z;
+ float f,hfsq,hi,lo,r,y;
int32_t i,k,hx;
GET_FLOAT_WORD(hx,x);
- k=0;
- if (hx < 0x00800000) { /* x < 2**-126 */
- if ((hx&0x7fffffff)==0)
- return -two25/zero; /* log(+-0)=-inf */
- if (hx<0) return (x-x)/zero; /* log(-#) = NaN */
- k -= 25; x *= two25; /* subnormal number, scale up x */
+ k=0;
+ if (hx < 0x00800000) { /* x < 2**-126 */
+ if ((hx&0x7fffffff)==0)
+ return -two25/vzero; /* log(+-0)=-inf */
+ if (hx<0) return (x-x)/zero; /* log(-#) = NaN */
+ k -= 25; x *= two25; /* subnormal number, scale up x */
GET_FLOAT_WORD(hx,x);
- }
+ }
if (hx >= 0x7f800000) return x+x;
+ if (hx == 0x3f800000)
+ return zero; /* log(1) = +0 */
k += (hx>>23)-127;
hx &= 0x007fffff;
i = (hx+(0x4afb0d))&0x800000;
@@ -52,11 +56,18 @@
SET_FLOAT_WORD(x,hx|(i^0x3f800000)); /* normalize x or x/2 */
k += (i>>23);
y = (float)k;
- f = __kernel_logf(x);
- x = x - (float)1.0;
- GET_FLOAT_WORD(hx,x);
+ f = x - (float)1.0;
+ hfsq = (float)0.5*f*f;
+ r = k_log1pf(f);
+
+ /* See e_log2f.c and e_log2.c for details. */
+ if (sizeof(float_t) > sizeof(float))
+ return (r - hfsq + f) * ((float_t)ivln10lo + ivln10hi) +
+ y * ((float_t)log10_2lo + log10_2hi);
+ hi = f - hfsq;
+ GET_FLOAT_WORD(hx,hi);
SET_FLOAT_WORD(hi,hx&0xfffff000);
- lo = x - hi;
- z = y*log10_2lo + (x+f)*ivln10lo + (lo+f)*ivln10hi + hi*ivln10hi;
- return z+y*log10_2hi;
+ lo = (f - hi) - hfsq + r;
+ return y*log10_2lo + (lo+hi)*ivln10lo + lo*ivln10hi + hi*ivln10hi +
+ y*log10_2hi;
}
Modified: trunk/lib/msun/src/e_log2.c
===================================================================
--- trunk/lib/msun/src/e_log2.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_log2.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_log10.c 1.3 95/01/18 */
/*
@@ -12,12 +13,20 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_log2.c 251404 2013-06-05 05:33:01Z das $");
/*
- * Return the base 2 logarithm of x. See k_log.c for details on the algorithm.
+ * Return the base 2 logarithm of x. See e_log.c and k_log.h for most
+ * comments.
+ *
+ * This reduces x to {k, 1+f} exactly as in e_log.c, then calls the kernel,
+ * then does the combining and scaling steps
+ * log2(x) = (f - 0.5*f*f + k_log1p(f)) / ln2 + k
+ * in not-quite-routine extra precision.
*/
+#include <float.h>
+
#include "math.h"
#include "math_private.h"
#include "k_log.h"
@@ -28,33 +37,82 @@
ivln2lo = 1.67517131648865118353e-10; /* 0x3de705fc, 0x2eefa200 */
static const double zero = 0.0;
+static volatile double vzero = 0.0;
double
__ieee754_log2(double x)
{
- double f,hi,lo;
+ double f,hfsq,hi,lo,r,val_hi,val_lo,w,y;
int32_t i,k,hx;
u_int32_t lx;
EXTRACT_WORDS(hx,lx,x);
- k=0;
- if (hx < 0x00100000) { /* x < 2**-1022 */
- if (((hx&0x7fffffff)|lx)==0)
- return -two54/zero; /* log(+-0)=-inf */
- if (hx<0) return (x-x)/zero; /* log(-#) = NaN */
- k -= 54; x *= two54; /* subnormal number, scale up x */
+ k=0;
+ if (hx < 0x00100000) { /* x < 2**-1022 */
+ if (((hx&0x7fffffff)|lx)==0)
+ return -two54/vzero; /* log(+-0)=-inf */
+ if (hx<0) return (x-x)/zero; /* log(-#) = NaN */
+ k -= 54; x *= two54; /* subnormal number, scale up x */
GET_HIGH_WORD(hx,x);
- }
+ }
if (hx >= 0x7ff00000) return x+x;
+ if (hx == 0x3ff00000 && lx == 0)
+ return zero; /* log(1) = +0 */
k += (hx>>20)-1023;
hx &= 0x000fffff;
i = (hx+0x95f64)&0x100000;
SET_HIGH_WORD(x,hx|(i^0x3ff00000)); /* normalize x or x/2 */
k += (i>>20);
- f = __kernel_log(x);
- hi = x = x - 1;
+ y = (double)k;
+ f = x - 1.0;
+ hfsq = 0.5*f*f;
+ r = k_log1p(f);
+
+ /*
+ * f-hfsq must (for args near 1) be evaluated in extra precision
+ * to avoid a large cancellation when x is near sqrt(2) or 1/sqrt(2).
+ * This is fairly efficient since f-hfsq only depends on f, so can
+ * be evaluated in parallel with R. Not combining hfsq with R also
+ * keeps R small (though not as small as a true `lo' term would be),
+ * so that extra precision is not needed for terms involving R.
+ *
+ * Compiler bugs involving extra precision used to break Dekker's
+ * theorem for spitting f-hfsq as hi+lo, unless double_t was used
+ * or the multi-precision calculations were avoided when double_t
+ * has extra precision. These problems are now automatically
+ * avoided as a side effect of the optimization of combining the
+ * Dekker splitting step with the clear-low-bits step.
+ *
+ * y must (for args near sqrt(2) and 1/sqrt(2)) be added in extra
+ * precision to avoid a very large cancellation when x is very near
+ * these values. Unlike the above cancellations, this problem is
+ * specific to base 2. It is strange that adding +-1 is so much
+ * harder than adding +-ln2 or +-log10_2.
+ *
+ * This uses Dekker's theorem to normalize y+val_hi, so the
+ * compiler bugs are back in some configurations, sigh. And I
+ * don't want to used double_t to avoid them, since that gives a
+ * pessimization and the support for avoiding the pessimization
+ * is not yet available.
+ *
+ * The multi-precision calculations for the multiplications are
+ * routine.
+ */
+ hi = f - hfsq;
SET_LOW_WORD(hi,0);
- lo = x - hi;
- return (x+f)*ivln2lo + (lo+f)*ivln2hi + hi*ivln2hi + k;
+ lo = (f - hi) - hfsq + r;
+ val_hi = hi*ivln2hi;
+ val_lo = (lo+hi)*ivln2lo + lo*ivln2hi;
+
+ /* spadd(val_hi, val_lo, y), except for not using double_t: */
+ w = y + val_hi;
+ val_lo += (y - w) + val_hi;
+ val_hi = w;
+
+ return val_lo + val_hi;
}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(log2, log2l);
+#endif
Modified: trunk/lib/msun/src/e_log2f.c
===================================================================
--- trunk/lib/msun/src/e_log2f.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_log2f.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +11,10 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_log2f.c 251024 2013-05-27 08:50:10Z das $");
/*
- * Return the base 2 logarithm of x. See k_log.c for details on the algorithm.
+ * Float version of e_log2.c. See the latter for most comments.
*/
#include "math.h"
@@ -26,33 +27,57 @@
ivln2lo = -1.7605285393e-04; /* 0xb9389ad4 */
static const float zero = 0.0;
+static volatile float vzero = 0.0;
float
__ieee754_log2f(float x)
{
- float f,hi,lo;
+ float f,hfsq,hi,lo,r,y;
int32_t i,k,hx;
GET_FLOAT_WORD(hx,x);
- k=0;
- if (hx < 0x00800000) { /* x < 2**-126 */
- if ((hx&0x7fffffff)==0)
- return -two25/zero; /* log(+-0)=-inf */
- if (hx<0) return (x-x)/zero; /* log(-#) = NaN */
- k -= 25; x *= two25; /* subnormal number, scale up x */
+ k=0;
+ if (hx < 0x00800000) { /* x < 2**-126 */
+ if ((hx&0x7fffffff)==0)
+ return -two25/vzero; /* log(+-0)=-inf */
+ if (hx<0) return (x-x)/zero; /* log(-#) = NaN */
+ k -= 25; x *= two25; /* subnormal number, scale up x */
GET_FLOAT_WORD(hx,x);
- }
+ }
if (hx >= 0x7f800000) return x+x;
+ if (hx == 0x3f800000)
+ return zero; /* log(1) = +0 */
k += (hx>>23)-127;
hx &= 0x007fffff;
i = (hx+(0x4afb0d))&0x800000;
SET_FLOAT_WORD(x,hx|(i^0x3f800000)); /* normalize x or x/2 */
k += (i>>23);
- f = __kernel_logf(x);
- x = x - (float)1.0;
- GET_FLOAT_WORD(hx,x);
+ y = (float)k;
+ f = x - (float)1.0;
+ hfsq = (float)0.5*f*f;
+ r = k_log1pf(f);
+
+ /*
+ * We no longer need to avoid falling into the multi-precision
+ * calculations due to compiler bugs breaking Dekker's theorem.
+ * Keep avoiding this as an optimization. See e_log2.c for more
+ * details (some details are here only because the optimization
+ * is not yet available in double precision).
+ *
+ * Another compiler bug turned up. With gcc on i386,
+ * (ivln2lo + ivln2hi) would be evaluated in float precision
+ * despite runtime evaluations using double precision. So we
+ * must cast one of its terms to float_t. This makes the whole
+ * expression have type float_t, so return is forced to waste
+ * time clobbering its extra precision.
+ */
+ if (sizeof(float_t) > sizeof(float))
+ return (r - hfsq + f) * ((float_t)ivln2lo + ivln2hi) + y;
+
+ hi = f - hfsq;
+ GET_FLOAT_WORD(hx,hi);
SET_FLOAT_WORD(hi,hx&0xfffff000);
- lo = x - hi;
- return (x+f)*ivln2lo + (lo+f)*ivln2hi + hi*ivln2hi + k;
+ lo = (f - hi) - hfsq + r;
+ return (lo+hi)*ivln2lo + lo*ivln2hi + hi*ivln2hi + y;
}
Modified: trunk/lib/msun/src/e_logf.c
===================================================================
--- trunk/lib/msun/src/e_logf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_logf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* e_logf.c -- float version of e_log.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_logf.c 251024 2013-05-27 08:50:10Z das $");
#include "math.h"
#include "math_private.h"
@@ -30,6 +31,7 @@
Lg4 = 0xf89e26.0p-26; /* 0.24279078841 */
static const float zero = 0.0;
+static volatile float vzero = 0.0;
float
__ieee754_logf(float x)
@@ -42,7 +44,7 @@
k=0;
if (ix < 0x00800000) { /* x < 2**-126 */
if ((ix&0x7fffffff)==0)
- return -two25/zero; /* log(+-0)=-inf */
+ 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);
Modified: trunk/lib/msun/src/e_pow.c
===================================================================
--- trunk/lib/msun/src/e_pow.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_pow.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_pow.c 1.5 04/04/22 SMI */
/*
* ====================================================
@@ -10,7 +11,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_pow.c 271779 2014-09-18 15:10:22Z tijl $");
/* __ieee754_pow(x,y) return x**y
*
@@ -19,7 +20,7 @@
* 1. Compute and return log2(x) in two pieces:
* log2(x) = w1 + w2,
* where w1 has 53-24 = 29 bit trailing zeros.
- * 2. Perform y*log2(x) = n+y' by simulating muti-precision
+ * 2. Perform y*log2(x) = n+y' by simulating multi-precision
* arithmetic, where |y'|<=0.5.
* 3. Return x**y = 2**n*exp(y'*log2)
*
@@ -26,13 +27,13 @@
* Special cases:
* 1. (anything) ** 0 is 1
* 2. (anything) ** 1 is itself
- * 3. (anything) ** NAN is NAN
+ * 3. (anything) ** NAN is NAN except 1 ** NAN = 1
* 4. NAN ** (anything except 0) is NAN
* 5. +-(|x| > 1) ** +INF is +INF
* 6. +-(|x| > 1) ** -INF is +0
* 7. +-(|x| < 1) ** +INF is +0
* 8. +-(|x| < 1) ** -INF is +INF
- * 9. +-1 ** +-INF is NAN
+ * 9. +-1 ** +-INF is 1
* 10. +0 ** (+anything except 0, NAN) is +0
* 11. -0 ** (+anything except 0, NAN, odd integer) is +0
* 12. +0 ** (-anything except 0, NAN) is +INF
@@ -141,7 +142,7 @@
if(ly==0) {
if (iy==0x7ff00000) { /* y is +-inf */
if(((ix-0x3ff00000)|lx)==0)
- return one; /* (-1)**+-inf is NaN */
+ return one; /* (-1)**+-inf is 1 */
else if (ix >= 0x3ff00000)/* (|x|>1)**+-inf = inf,0 */
return (hy>=0)? y: zero;
else /* (|x|<1)**-,+inf = inf,0 */
Modified: trunk/lib/msun/src/e_powf.c
===================================================================
--- trunk/lib/msun/src/e_powf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_powf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* e_powf.c -- float version of e_pow.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_powf.c 226595 2011-10-21 06:26:07Z das $");
#include "math.h"
#include "math_private.h"
Modified: trunk/lib/msun/src/e_rem_pio2.c
===================================================================
--- trunk/lib/msun/src/e_rem_pio2.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_rem_pio2.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_rem_pio2.c 1.4 95/01/18 */
/*
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_rem_pio2.c 239195 2012-08-11 15:47:22Z dim $");
/* __ieee754_rem_pio2(x,y)
*
Modified: trunk/lib/msun/src/e_rem_pio2f.c
===================================================================
--- trunk/lib/msun/src/e_rem_pio2f.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_rem_pio2f.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* e_rem_pio2f.c -- float version of e_rem_pio2.c
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
* Debugged and optimized by Bruce D. Evans.
@@ -15,7 +16,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_rem_pio2f.c 239195 2012-08-11 15:47:22Z dim $");
/* __ieee754_rem_pio2f(x,y)
*
Modified: trunk/lib/msun/src/e_remainder.c
===================================================================
--- trunk/lib/msun/src/e_remainder.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_remainder.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_remainder.c 1.3 95/01/18 */
/*
@@ -12,7 +13,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_remainder.c 177765 2008-03-30 20:47:42Z das $");
/* __ieee754_remainder(x,p)
* Return :
Modified: trunk/lib/msun/src/e_remainderf.c
===================================================================
--- trunk/lib/msun/src/e_remainderf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_remainderf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* e_remainderf.c -- float version of e_remainder.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_remainderf.c 176207 2008-02-12 17:11:36Z bde $");
#include "math.h"
#include "math_private.h"
Modified: trunk/lib/msun/src/e_remainderl.c
===================================================================
--- trunk/lib/msun/src/e_remainderl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_remainderl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2008 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_remainderl.c 177765 2008-03-30 20:47:42Z das $");
#include <math.h>
Modified: trunk/lib/msun/src/e_scalb.c
===================================================================
--- trunk/lib/msun/src/e_scalb.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_scalb.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_scalb.c 1.3 95/01/18 */
/*
@@ -12,7 +13,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_scalb.c 176451 2008-02-22 02:30:36Z das $");
/*
* __ieee754_scalb(x, fn) is provide for
Modified: trunk/lib/msun/src/e_scalbf.c
===================================================================
--- trunk/lib/msun/src/e_scalbf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_scalbf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* e_scalbf.c -- float version of e_scalb.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_scalbf.c 176451 2008-02-22 02:30:36Z das $");
#include "math.h"
#include "math_private.h"
Modified: trunk/lib/msun/src/e_sinh.c
===================================================================
--- trunk/lib/msun/src/e_sinh.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_sinh.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_sinh.c 1.3 95/01/18 */
/*
@@ -12,7 +13,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_sinh.c 271779 2014-09-18 15:10:22Z tijl $");
/* __ieee754_sinh(x)
* Method :
@@ -32,6 +33,8 @@
* only sinh(0)=0 is exact for finite x.
*/
+#include <float.h>
+
#include "math.h"
#include "math_private.h"
@@ -40,9 +43,8 @@
double
__ieee754_sinh(double x)
{
- double t,w,h;
+ double t,h;
int32_t ix,jx;
- u_int32_t lx;
/* High word of |x|. */
GET_HIGH_WORD(jx,x);
@@ -66,13 +68,13 @@
if (ix < 0x40862E42) return h*__ieee754_exp(fabs(x));
/* |x| in [log(maxdouble), overflowthresold] */
- GET_LOW_WORD(lx,x);
- if (ix<0x408633CE || ((ix==0x408633ce)&&(lx<=(u_int32_t)0x8fb9f87d))) {
- w = __ieee754_exp(0.5*fabs(x));
- t = h*w;
- return t*w;
- }
+ if (ix<=0x408633CE)
+ return h*2.0*__ldexp_exp(fabs(x), -1);
/* |x| > overflowthresold, sinh(x) overflow */
return x*shuge;
}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(sinh, sinhl);
+#endif
Modified: trunk/lib/msun/src/e_sinhf.c
===================================================================
--- trunk/lib/msun/src/e_sinhf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_sinhf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* e_sinhf.c -- float version of e_sinh.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_sinhf.c 226598 2011-10-21 06:28:47Z das $");
#include "math.h"
#include "math_private.h"
@@ -24,7 +25,7 @@
float
__ieee754_sinhf(float x)
{
- float t,w,h;
+ float t,h;
int32_t ix,jx;
GET_FLOAT_WORD(jx,x);
@@ -48,11 +49,8 @@
if (ix < 0x42b17217) return h*__ieee754_expf(fabsf(x));
/* |x| in [logf(maxfloat), overflowthresold] */
- if (ix<=0x42b2d4fc) {
- w = __ieee754_expf((float)0.5*fabsf(x));
- t = h*w;
- return t*w;
- }
+ if (ix<=0x42b2d4fc)
+ return h*2.0F*__ldexp_expf(fabsf(x), -1);
/* |x| > overflowthresold, sinh(x) overflow */
return x*shuge;
Added: trunk/lib/msun/src/e_sinhl.c
===================================================================
--- trunk/lib/msun/src/e_sinhl.c (rev 0)
+++ trunk/lib/msun/src/e_sinhl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -0,0 +1,132 @@
+/* $MidnightBSD$ */
+/* from: FreeBSD: head/lib/msun/src/e_sinhl.c XXX */
+
+/*
+ * ====================================================
+ * 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: stable/10/lib/msun/src/e_sinhl.c 271779 2014-09-18 15:10:22Z tijl $");
+
+/*
+ * See e_sinh.c for complete comments.
+ *
+ * Converted to long double by Bruce D. Evans.
+ */
+
+#include <float.h>
+#ifdef __i386__
+#include <ieeefp.h>
+#endif
+
+#include "fpmath.h"
+#include "math.h"
+#include "math_private.h"
+#include "k_expl.h"
+
+#if LDBL_MAX_EXP != 0x4000
+/* We also require the usual expsign encoding. */
+#error "Unsupported long double format"
+#endif
+
+#define BIAS (LDBL_MAX_EXP - 1)
+
+static const long double shuge = 0x1p16383L;
+#if LDBL_MANT_DIG == 64
+/*
+ * Domain [-1, 1], range ~[-6.6749e-22, 6.6749e-22]:
+ * |sinh(x)/x - s(x)| < 2**-70.3
+ */
+static const union IEEEl2bits
+S3u = LD80C(0xaaaaaaaaaaaaaaaa, -3, 1.66666666666666666658e-1L);
+#define S3 S3u.e
+static const double
+S5 = 8.3333333333333332e-3, /* 0x11111111111111.0p-59 */
+S7 = 1.9841269841270074e-4, /* 0x1a01a01a01a070.0p-65 */
+S9 = 2.7557319223873889e-6, /* 0x171de3a5565fe6.0p-71 */
+S11 = 2.5052108406704084e-8, /* 0x1ae6456857530f.0p-78 */
+S13 = 1.6059042748655297e-10, /* 0x161245fa910697.0p-85 */
+S15 = 7.6470006914396920e-13, /* 0x1ae7ce4eff2792.0p-93 */
+S17 = 2.8346142308424267e-15; /* 0x19882ce789ffc6.0p-101 */
+#elif LDBL_MANT_DIG == 113
+/*
+ * Domain [-1, 1], range ~[-2.9673e-36, 2.9673e-36]:
+ * |sinh(x)/x - s(x)| < 2**-118.0
+ */
+static const long double
+S3 = 1.66666666666666666666666666666666033e-1L, /* 0x1555555555555555555555555553b.0p-115L */
+S5 = 8.33333333333333333333333333337643193e-3L, /* 0x111111111111111111111111180f5.0p-119L */
+S7 = 1.98412698412698412698412697391263199e-4L, /* 0x1a01a01a01a01a01a01a0176aad11.0p-125L */
+S9 = 2.75573192239858906525574406205464218e-6L, /* 0x171de3a556c7338faac243aaa9592.0p-131L */
+S11 = 2.50521083854417187749675637460977997e-8L, /* 0x1ae64567f544e38fe59b3380d7413.0p-138L */
+S13 = 1.60590438368216146368737762431552702e-10L, /* 0x16124613a86d098059c7620850fc2.0p-145L */
+S15 = 7.64716373181980539786802470969096440e-13L, /* 0x1ae7f3e733b814193af09ce723043.0p-153L */
+S17 = 2.81145725434775409870584280722701574e-15L; /* 0x1952c77030c36898c3fd0b6dfc562.0p-161L */
+static const double
+S19= 8.2206352435411005e-18, /* 0x12f49b4662b86d.0p-109 */
+S21= 1.9572943931418891e-20, /* 0x171b8f2fab9628.0p-118 */
+S23 = 3.8679983530666939e-23, /* 0x17617002b73afc.0p-127 */
+S25 = 6.5067867911512749e-26; /* 0x1423352626048a.0p-136 */
+#else
+#error "Unsupported long double format"
+#endif /* LDBL_MANT_DIG == 64 */
+
+/* log(2**16385 - 0.5) rounded up: */
+static const float
+o_threshold = 1.13572168e4; /* 0xb174de.0p-10 */
+
+long double
+sinhl(long double x)
+{
+ long double hi,lo,x2,x4;
+ double dx2,s;
+ int16_t ix,jx;
+
+ GET_LDBL_EXPSIGN(jx,x);
+ ix = jx&0x7fff;
+
+ /* x is INF or NaN */
+ if(ix>=0x7fff) return x+x;
+
+ ENTERI();
+
+ s = 1;
+ if (jx<0) s = -1;
+
+ /* |x| < 64, return x, s(x), or accurate s*(exp(|x|)/2-1/exp(|x|)/2) */
+ if (ix<0x4005) { /* |x|<64 */
+ if (ix<BIAS-(LDBL_MANT_DIG+1)/2) /* |x|<TINY */
+ if(shuge+x>1) RETURNI(x); /* sinh(tiny) = tiny with inexact */
+ if (ix<0x3fff) { /* |x|<1 */
+ x2 = x*x;
+#if LDBL_MANT_DIG == 64
+ x4 = x2*x2;
+ RETURNI(((S17*x2 + S15)*x4 + (S13*x2 + S11))*(x2*x*x4*x4) +
+ ((S9*x2 + S7)*x2 + S5)*(x2*x*x2) + S3*(x2*x) + x);
+#elif LDBL_MANT_DIG == 113
+ dx2 = x2;
+ RETURNI(((((((((((S25*dx2 + S23)*dx2 +
+ S21)*x2 + S19)*x2 +
+ S17)*x2 + S15)*x2 + S13)*x2 + S11)*x2 + S9)*x2 + S7)*x2 +
+ S5)* (x2*x*x2) +
+ S3*(x2*x) + x);
+#endif
+ }
+ k_hexpl(fabsl(x), &hi, &lo);
+ RETURNI(s*(lo - 0.25/(hi + lo) + hi));
+ }
+
+ /* |x| in [64, o_threshold], return correctly-overflowing s*exp(|x|)/2 */
+ if (fabsl(x) <= o_threshold)
+ RETURNI(s*hexpl(fabsl(x)));
+
+ /* |x| > o_threshold, sinh(x) overflow */
+ return x*shuge;
+}
Property changes on: trunk/lib/msun/src/e_sinhl.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/lib/msun/src/e_sqrt.c
===================================================================
--- trunk/lib/msun/src/e_sqrt.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_sqrt.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_sqrt.c 1.3 95/01/18 */
/*
@@ -12,7 +13,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_sqrt.c 176720 2008-03-02 01:47:58Z das $");
/* __ieee754_sqrt(x)
* Return correctly rounded sqrt.
Modified: trunk/lib/msun/src/e_sqrtf.c
===================================================================
--- trunk/lib/msun/src/e_sqrtf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_sqrtf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* e_sqrtf.c -- float version of e_sqrt.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#ifndef lint
-static char rcsid[] = "$MidnightBSD$";
+static char rcsid[] = "$FreeBSD: stable/10/lib/msun/src/e_sqrtf.c 97413 2002-05-28 18:15:04Z alfred $";
#endif
#include "math.h"
Modified: trunk/lib/msun/src/e_sqrtl.c
===================================================================
--- trunk/lib/msun/src/e_sqrtl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/e_sqrtl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2007 Steven G. Kargl
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_sqrtl.c 176720 2008-03-02 01:47:58Z das $");
#include <fenv.h>
#include <float.h>
Added: trunk/lib/msun/src/fenv-softfloat.h
===================================================================
--- trunk/lib/msun/src/fenv-softfloat.h (rev 0)
+++ trunk/lib/msun/src/fenv-softfloat.h 2018-06-09 15:08:31 UTC (rev 10591)
@@ -0,0 +1,185 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2004-2011 David Schultz <das at 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.
+ *
+ * $FreeBSD: stable/10/lib/msun/src/fenv-softfloat.h 266133 2014-05-15 15:02:48Z ian $
+ */
+
+#ifndef _FENV_H_
+#error "This file is meant to be included only by <fenv.h>."
+#endif
+
+/*
+ * This file implements the functionality of <fenv.h> on platforms that
+ * lack an FPU and use softfloat in libc for floating point. To use it,
+ * you must write an <fenv.h> that provides the following:
+ *
+ * - a typedef for fenv_t, which may be an integer or struct type
+ * - a typedef for fexcept_t (XXX This file assumes fexcept_t is a
+ * simple integer type containing the exception mask.)
+ * - definitions of FE_* constants for the five exceptions and four
+ * rounding modes in IEEE 754, as described in fenv(3)
+ * - a definition, and the corresponding external symbol, for FE_DFL_ENV
+ * - a macro __set_env(env, flags, mask, rnd), which sets the given fenv_t
+ * from the exception flags, mask, and rounding mode
+ * - macros __env_flags(env), __env_mask(env), and __env_round(env), which
+ * extract fields from an fenv_t
+ * - a definition of __fenv_static
+ *
+ * If the architecture supports an optional FPU, it's recommended that you
+ * define fenv_t and fexcept_t to match the hardware ABI. Otherwise, it
+ * doesn't matter how you define them.
+ */
+
+extern int __softfloat_float_exception_flags;
+extern int __softfloat_float_exception_mask;
+extern int __softfloat_float_rounding_mode;
+void __softfloat_float_raise(int);
+
+__fenv_static inline int
+feclearexcept(int __excepts)
+{
+
+ __softfloat_float_exception_flags &= ~__excepts;
+ return (0);
+}
+
+__fenv_static inline int
+fegetexceptflag(fexcept_t *__flagp, int __excepts)
+{
+
+ *__flagp = __softfloat_float_exception_flags & __excepts;
+ return (0);
+}
+
+__fenv_static inline int
+fesetexceptflag(const fexcept_t *__flagp, int __excepts)
+{
+
+ __softfloat_float_exception_flags &= ~__excepts;
+ __softfloat_float_exception_flags |= *__flagp & __excepts;
+ return (0);
+}
+
+__fenv_static inline int
+feraiseexcept(int __excepts)
+{
+
+ __softfloat_float_raise(__excepts);
+ return (0);
+}
+
+__fenv_static inline int
+fetestexcept(int __excepts)
+{
+
+ return (__softfloat_float_exception_flags & __excepts);
+}
+
+__fenv_static inline int
+fegetround(void)
+{
+
+ return (__softfloat_float_rounding_mode);
+}
+
+__fenv_static inline int
+fesetround(int __round)
+{
+
+ __softfloat_float_rounding_mode = __round;
+ return (0);
+}
+
+__fenv_static inline int
+fegetenv(fenv_t *__envp)
+{
+
+ __set_env(*__envp, __softfloat_float_exception_flags,
+ __softfloat_float_exception_mask, __softfloat_float_rounding_mode);
+ return (0);
+}
+
+__fenv_static inline int
+feholdexcept(fenv_t *__envp)
+{
+ fenv_t __env;
+
+ fegetenv(__envp);
+ __softfloat_float_exception_flags = 0;
+ __softfloat_float_exception_mask = 0;
+ return (0);
+}
+
+__fenv_static inline int
+fesetenv(const fenv_t *__envp)
+{
+
+ __softfloat_float_exception_flags = __env_flags(*__envp);
+ __softfloat_float_exception_mask = __env_mask(*__envp);
+ __softfloat_float_rounding_mode = __env_round(*__envp);
+ return (0);
+}
+
+__fenv_static inline int
+feupdateenv(const fenv_t *__envp)
+{
+ int __oflags = __softfloat_float_exception_flags;
+
+ fesetenv(__envp);
+ feraiseexcept(__oflags);
+ return (0);
+}
+
+#if __BSD_VISIBLE
+
+/* We currently provide no external definitions of the functions below. */
+
+__fenv_static inline int
+feenableexcept(int __mask)
+{
+ int __omask = __softfloat_float_exception_mask;
+
+ __softfloat_float_exception_mask |= __mask;
+ return (__omask);
+}
+
+__fenv_static inline int
+fedisableexcept(int __mask)
+{
+ int __omask = __softfloat_float_exception_mask;
+
+ __softfloat_float_exception_mask &= ~__mask;
+ return (__omask);
+}
+
+__fenv_static inline int
+fegetexcept(void)
+{
+
+ return (__softfloat_float_exception_mask);
+}
+
+#endif /* __BSD_VISIBLE */
Property changes on: trunk/lib/msun/src/fenv-softfloat.h
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/lib/msun/src/imprecise.c
===================================================================
--- trunk/lib/msun/src/imprecise.c (rev 0)
+++ trunk/lib/msun/src/imprecise.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -0,0 +1,64 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2013 David Chisnall
+ * 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.
+ *
+ * $FreeBSD: stable/10/lib/msun/src/imprecise.c 284810 2015-06-25 13:01:10Z tijl $
+ */
+
+#include <float.h>
+#include <math.h>
+
+/*
+ * If long double is not the same size as double, then these will lose
+ * precision and we should emit a warning whenever something links against
+ * them.
+ */
+#if (LDBL_MANT_DIG > 53)
+#define WARN_IMPRECISE(x) \
+ __warn_references(x, # x " has lower than advertised precision");
+#else
+#define WARN_IMPRECISE(x)
+#endif
+/*
+ * Declare the functions as weak variants so that other libraries providing
+ * real versions can override them.
+ */
+#define DECLARE_WEAK(x)\
+ __weak_reference(imprecise_## x, x);\
+ WARN_IMPRECISE(x)
+
+long double
+imprecise_powl(long double x, long double y)
+{
+
+ return pow(x, y);
+}
+DECLARE_WEAK(powl);
+
+#define DECLARE_IMPRECISE(f) \
+ long double imprecise_ ## f ## l(long double v) { return f(v); }\
+ DECLARE_WEAK(f ## l)
+
+DECLARE_IMPRECISE(tgamma);
Property changes on: trunk/lib/msun/src/imprecise.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/lib/msun/src/k_cos.c
===================================================================
--- trunk/lib/msun/src/k_cos.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/k_cos.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)k_cos.c 1.3 95/01/18 */
/*
@@ -12,7 +13,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/k_cos.c 176408 2008-02-19 12:54:14Z bde $");
/*
* __kernel_cos( x, y )
Modified: trunk/lib/msun/src/k_cosf.c
===================================================================
--- trunk/lib/msun/src/k_cosf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/k_cosf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* k_cosf.c -- float version of k_cos.c
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
* Debugged and optimized by Bruce D. Evans.
@@ -16,7 +17,7 @@
#ifndef INLINE_KERNEL_COSDF
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/k_cosf.c 239192 2012-08-11 11:13:48Z dim $");
#endif
#include "math.h"
Added: trunk/lib/msun/src/k_exp.c
===================================================================
--- trunk/lib/msun/src/k_exp.c (rev 0)
+++ trunk/lib/msun/src/k_exp.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -0,0 +1,109 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2011 David Schultz <das at 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: stable/10/lib/msun/src/k_exp.c 284810 2015-06-25 13:01:10Z tijl $");
+
+#include <complex.h>
+
+#include "math.h"
+#include "math_private.h"
+
+static const uint32_t k = 1799; /* constant for reduction */
+static const double kln2 = 1246.97177782734161156; /* k * ln2 */
+
+/*
+ * Compute exp(x), scaled to avoid spurious overflow. An exponent is
+ * returned separately in 'expt'.
+ *
+ * Input: ln(DBL_MAX) <= x < ln(2 * DBL_MAX / DBL_MIN_DENORM) ~= 1454.91
+ * Output: 2**1023 <= y < 2**1024
+ */
+static double
+__frexp_exp(double x, int *expt)
+{
+ double exp_x;
+ uint32_t hx;
+
+ /*
+ * We use exp(x) = exp(x - kln2) * 2**k, carefully chosen to
+ * minimize |exp(kln2) - 2**k|. We also scale the exponent of
+ * exp_x to MAX_EXP so that the result can be multiplied by
+ * a tiny number without losing accuracy due to denormalization.
+ */
+ exp_x = exp(x - kln2);
+ GET_HIGH_WORD(hx, exp_x);
+ *expt = (hx >> 20) - (0x3ff + 1023) + k;
+ SET_HIGH_WORD(exp_x, (hx & 0xfffff) | ((0x3ff + 1023) << 20));
+ return (exp_x);
+}
+
+/*
+ * __ldexp_exp(x, expt) and __ldexp_cexp(x, expt) compute exp(x) * 2**expt.
+ * They are intended for large arguments (real part >= ln(DBL_MAX))
+ * where care is needed to avoid overflow.
+ *
+ * The present implementation is narrowly tailored for our hyperbolic and
+ * exponential functions. We assume expt is small (0 or -1), and the caller
+ * has filtered out very large x, for which overflow would be inevitable.
+ */
+
+double
+__ldexp_exp(double x, int expt)
+{
+ double exp_x, scale;
+ int ex_expt;
+
+ exp_x = __frexp_exp(x, &ex_expt);
+ expt += ex_expt;
+ INSERT_WORDS(scale, (0x3ff + expt) << 20, 0);
+ return (exp_x * scale);
+}
+
+double complex
+__ldexp_cexp(double complex z, int expt)
+{
+ double x, y, exp_x, scale1, scale2;
+ int ex_expt, half_expt;
+
+ x = creal(z);
+ y = cimag(z);
+ exp_x = __frexp_exp(x, &ex_expt);
+ expt += ex_expt;
+
+ /*
+ * Arrange so that scale1 * scale2 == 2**expt. We use this to
+ * compensate for scalbn being horrendously slow.
+ */
+ half_expt = expt / 2;
+ INSERT_WORDS(scale1, (0x3ff + half_expt) << 20, 0);
+ half_expt = expt - half_expt;
+ INSERT_WORDS(scale2, (0x3ff + half_expt) << 20, 0);
+
+ return (CMPLX(cos(y) * exp_x * scale1 * scale2,
+ sin(y) * exp_x * scale1 * scale2));
+}
Property changes on: trunk/lib/msun/src/k_exp.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/lib/msun/src/k_expf.c
===================================================================
--- trunk/lib/msun/src/k_expf.c (rev 0)
+++ trunk/lib/msun/src/k_expf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -0,0 +1,88 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2011 David Schultz <das at 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: stable/10/lib/msun/src/k_expf.c 284810 2015-06-25 13:01:10Z tijl $");
+
+#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.
+ *
+ * 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);
+}
+
+float complex
+__ldexp_cexpf(float complex z, int expt)
+{
+ float x, y, exp_x, scale1, scale2;
+ 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);
+
+ return (CMPLXF(cosf(y) * exp_x * scale1 * scale2,
+ sinf(y) * exp_x * scale1 * scale2));
+}
Property changes on: trunk/lib/msun/src/k_expf.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/lib/msun/src/k_log.h
===================================================================
--- trunk/lib/msun/src/k_log.h 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/k_log.h 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_log.c 1.3 95/01/18 */
/*
@@ -12,10 +13,11 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/k_log.h 226376 2011-10-15 05:23:28Z das $");
-/* __kernel_log(x)
- * Return log(x) - (x-1) for x in ~[sqrt(2)/2, sqrt(2)].
+/*
+ * k_log1p(f):
+ * Return log(1+f) - f for 1+f in ~[sqrt(2)/2, sqrt(2)].
*
* The following describes the overall strategy for computing
* logarithms in base e. The argument reduction and adding the final
@@ -80,37 +82,20 @@
Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
/*
- * We always inline __kernel_log(), since doing so produces a
+ * We always inline k_log1p(), since doing so produces a
* substantial performance improvement (~40% on amd64).
*/
static inline double
-__kernel_log(double x)
+k_log1p(double f)
{
- double hfsq,f,s,z,R,w,t1,t2;
- int32_t hx,i,j;
- u_int32_t lx;
+ double hfsq,s,z,R,w,t1,t2;
- EXTRACT_WORDS(hx,lx,x);
-
- f = x-1.0;
- if((0x000fffff&(2+hx))<3) { /* -2**-20 <= f < 2**-20 */
- if(f==0.0) return 0.0;
- return f*f*(0.33333333333333333*f-0.5);
- }
- s = f/(2.0+f);
+ s = f/(2.0+f);
z = s*s;
- hx &= 0x000fffff;
- i = hx-0x6147a;
w = z*z;
- j = 0x6b851-hx;
- t1= w*(Lg2+w*(Lg4+w*Lg6));
- t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7)));
- i |= j;
+ t1= w*(Lg2+w*(Lg4+w*Lg6));
+ t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7)));
R = t2+t1;
- if (i>0) {
- hfsq=0.5*f*f;
- return s*(hfsq+R) - hfsq;
- } else {
- return s*(R-f);
- }
+ hfsq=0.5*f*f;
+ return s*(hfsq+R);
}
Modified: trunk/lib/msun/src/k_logf.h
===================================================================
--- trunk/lib/msun/src/k_logf.h 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/k_logf.h 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +11,10 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/k_logf.h 226376 2011-10-15 05:23:28Z das $");
/*
- * float version of __kernel_log(x). See k_log.c for details.
+ * Float version of k_log.h. See the latter for most comments.
*/
static const float
@@ -24,32 +25,16 @@
Lg4 = 0xf89e26.0p-26; /* 0.24279078841 */
static inline float
-__kernel_logf(float x)
+k_log1pf(float f)
{
- float hfsq,f,s,z,R,w,t1,t2;
- int32_t ix,i,j;
+ float hfsq,s,z,R,w,t1,t2;
- GET_FLOAT_WORD(ix,x);
-
- f = x-(float)1.0;
- if((0x007fffff&(0x8000+ix))<0xc000) { /* -2**-9 <= f < 2**-9 */
- if(f==0.0f) return 0.0f;
- return f*f*((float)0.33333333333333333*f-(float)0.5);
- }
s = f/((float)2.0+f);
z = s*s;
- ix &= 0x007fffff;
- 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;
- return s*(hfsq+R) - hfsq;
- } else {
- return s*(R-f);
- }
+ hfsq=(float)0.5*f*f;
+ return s*(hfsq+R);
}
Modified: trunk/lib/msun/src/k_rem_pio2.c
===================================================================
--- trunk/lib/msun/src/k_rem_pio2.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/k_rem_pio2.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)k_rem_pio2.c 1.3 95/01/18 */
/*
@@ -12,7 +13,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/k_rem_pio2.c 242692 2012-11-07 07:00:59Z kevlo $");
/*
* __kernel_rem_pio2(x,y,e0,nx,prec)
@@ -45,7 +46,7 @@
* z = (z-x[i])*2**24
*
*
- * y[] ouput result in an array of double precision numbers.
+ * y[] output result in an array of double precision numbers.
* The dimension of y[] is:
* 24-bit precision 1
* 53-bit precision 2
Modified: trunk/lib/msun/src/k_rem_pio2f.c
===================================================================
--- trunk/lib/msun/src/k_rem_pio2f.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/k_rem_pio2f.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* k_rem_pio2f.c -- float version of k_rem_pio2.c
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
Modified: trunk/lib/msun/src/k_sin.c
===================================================================
--- trunk/lib/msun/src/k_sin.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/k_sin.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)k_sin.c 1.3 95/01/18 */
/*
@@ -12,7 +13,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/k_sin.c 176408 2008-02-19 12:54:14Z bde $");
/* __kernel_sin( x, y, iy)
* kernel sin function on ~[-pi/4, pi/4] (except on -0), pi/4 ~ 0.7854
Modified: trunk/lib/msun/src/k_sinf.c
===================================================================
--- trunk/lib/msun/src/k_sinf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/k_sinf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* k_sinf.c -- float version of k_sin.c
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
* Optimized by Bruce D. Evans.
@@ -16,7 +17,7 @@
#ifndef INLINE_KERNEL_SINDF
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/k_sinf.c 239192 2012-08-11 11:13:48Z dim $");
#endif
#include "math.h"
Modified: trunk/lib/msun/src/k_tan.c
===================================================================
--- trunk/lib/msun/src/k_tan.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/k_tan.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)k_tan.c 1.5 04/04/22 SMI */
/*
@@ -12,7 +13,7 @@
/* INDENT OFF */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/k_tan.c 176451 2008-02-22 02:30:36Z das $");
/* __kernel_tan( x, y, k )
* kernel tan function on ~[-pi/4, pi/4] (except on -0), pi/4 ~ 0.7854
Modified: trunk/lib/msun/src/k_tanf.c
===================================================================
--- trunk/lib/msun/src/k_tanf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/k_tanf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* k_tanf.c -- float version of k_tan.c
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
* Optimized by Bruce D. Evans.
@@ -15,7 +16,7 @@
#ifndef INLINE_KERNEL_TANDF
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/k_tanf.c 239192 2012-08-11 11:13:48Z dim $");
#endif
#include "math.h"
Modified: trunk/lib/msun/src/math.h
===================================================================
--- trunk/lib/msun/src/math.h 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/math.h 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,7 +12,7 @@
/*
* from: @(#)fdlibm.h 5.1 93/09/24
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/msun/src/math.h 309510 2016-12-03 20:01:12Z trasz $
*/
#ifndef _MATH_H_
@@ -68,14 +69,11 @@
#define MATH_ERREXCEPT 2
#define math_errhandling MATH_ERREXCEPT
-/* XXX We need a <machine/math.h>. */
-#if defined(__ia64__) || defined(__sparc64__)
+#define FP_FAST_FMAF 1
+#ifdef __ia64__
#define FP_FAST_FMA 1
-#endif
-#ifdef __ia64__
#define FP_FAST_FMAL 1
#endif
-#define FP_FAST_FMAF 1
/* Symbolic constants to classify floating point numbers. */
#define FP_INFINITE 0x01
@@ -83,28 +81,44 @@
#define FP_NORMAL 0x04
#define FP_SUBNORMAL 0x08
#define FP_ZERO 0x10
+
+#if (__STDC_VERSION__ >= 201112L && defined(__clang__)) || \
+ __has_extension(c_generic_selections)
+#define __fp_type_select(x, f, d, ld) _Generic((x), \
+ float: f(x), \
+ double: d(x), \
+ long double: ld(x), \
+ volatile float: f(x), \
+ volatile double: d(x), \
+ volatile long double: ld(x), \
+ volatile const float: f(x), \
+ volatile const double: d(x), \
+ volatile const long double: ld(x), \
+ const float: f(x), \
+ const double: d(x), \
+ const long double: ld(x))
+#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus)
+#define __fp_type_select(x, f, d, ld) __builtin_choose_expr( \
+ __builtin_types_compatible_p(__typeof(x), long double), ld(x), \
+ __builtin_choose_expr( \
+ __builtin_types_compatible_p(__typeof(x), double), d(x), \
+ __builtin_choose_expr( \
+ __builtin_types_compatible_p(__typeof(x), float), f(x), (void)0)))
+#else
+#define __fp_type_select(x, f, d, ld) \
+ ((sizeof(x) == sizeof(float)) ? f(x) \
+ : (sizeof(x) == sizeof(double)) ? d(x) \
+ : ld(x))
+#endif
+
#define fpclassify(x) \
- ((sizeof (x) == sizeof (float)) ? __fpclassifyf(x) \
- : (sizeof (x) == sizeof (double)) ? __fpclassifyd(x) \
- : __fpclassifyl(x))
+ __fp_type_select(x, __fpclassifyf, __fpclassifyd, __fpclassifyl)
+#define isfinite(x) __fp_type_select(x, __isfinitef, __isfinite, __isfinitel)
+#define isinf(x) __fp_type_select(x, __isinff, __isinf, __isinfl)
+#define isnan(x) \
+ __fp_type_select(x, __inline_isnanf, __inline_isnan, __inline_isnanl)
+#define isnormal(x) __fp_type_select(x, __isnormalf, __isnormal, __isnormall)
-#define isfinite(x) \
- ((sizeof (x) == sizeof (float)) ? __isfinitef(x) \
- : (sizeof (x) == sizeof (double)) ? __isfinite(x) \
- : __isfinitel(x))
-#define isinf(x) \
- ((sizeof (x) == sizeof (float)) ? __isinff(x) \
- : (sizeof (x) == sizeof (double)) ? isinf(x) \
- : __isinfl(x))
-#define isnan(x) \
- ((sizeof (x) == sizeof (float)) ? __isnanf(x) \
- : (sizeof (x) == sizeof (double)) ? isnan(x) \
- : __isnanl(x))
-#define isnormal(x) \
- ((sizeof (x) == sizeof (float)) ? __isnormalf(x) \
- : (sizeof (x) == sizeof (double)) ? __isnormal(x) \
- : __isnormall(x))
-
#ifdef __MATH_BUILTIN_RELOPS
#define isgreater(x, y) __builtin_isgreater((x), (y))
#define isgreaterequal(x, y) __builtin_isgreaterequal((x), (y))
@@ -122,10 +136,7 @@
#define isunordered(x, y) (isnan(x) || isnan(y))
#endif /* __MATH_BUILTIN_RELOPS */
-#define signbit(x) \
- ((sizeof (x) == sizeof (float)) ? __signbitf(x) \
- : (sizeof (x) == sizeof (double)) ? __signbit(x) \
- : __signbitl(x))
+#define signbit(x) __fp_type_select(x, __signbitf, __signbit, __signbitl)
typedef __double_t double_t;
typedef __float_t float_t;
@@ -178,9 +189,8 @@
int __isfinite(double) __pure2;
int __isfinitel(long double) __pure2;
int __isinff(float) __pure2;
+int __isinf(double) __pure2;
int __isinfl(long double) __pure2;
-int __isnanf(float) __pure2;
-int __isnanl(long double) __pure2;
int __isnormalf(float) __pure2;
int __isnormal(double) __pure2;
int __isnormall(long double) __pure2;
@@ -188,6 +198,42 @@
int __signbitf(float) __pure2;
int __signbitl(long double) __pure2;
+static __inline int
+__inline_isnan(__const double __x)
+{
+
+ return (__x != __x);
+}
+
+static __inline int
+__inline_isnanf(__const float __x)
+{
+
+ return (__x != __x);
+}
+
+static __inline int
+__inline_isnanl(__const long double __x)
+{
+
+ return (__x != __x);
+}
+
+/*
+ * Version 2 of the Single UNIX Specification (UNIX98) defined isnan() and
+ * isinf() as functions taking double. C99, and the subsequent POSIX revisions
+ * (SUSv3, POSIX.1-2001, define it as a macro that accepts any real floating
+ * point type. If we are targeting SUSv2 and C99 or C11 (or C++11) then we
+ * expose the newer definition, assuming that the language spec takes
+ * precedence over the operating system interface spec.
+ */
+#if __XSI_VISIBLE > 0 && __XSI_VISIBLE < 600 && __ISO_C_VISIBLE < 1999
+#undef isinf
+#undef isnan
+int isinf(double);
+int isnan(double);
+#endif
+
double acos(double);
double asin(double);
double atan(double);
@@ -230,8 +276,6 @@
double fma(double, double, double);
double hypot(double, double);
int ilogb(double) __pure2;
-int (isinf)(double) __pure2;
-int (isnan)(double) __pure2;
double lgamma(double);
long long llrint(double);
long long llround(double);
@@ -398,15 +442,23 @@
* long double versions of ISO/POSIX math functions
*/
#if __ISO_C_VISIBLE >= 1999
+long double acoshl(long double);
long double acosl(long double);
+long double asinhl(long double);
long double asinl(long double);
long double atan2l(long double, long double);
+long double atanhl(long double);
long double atanl(long double);
long double cbrtl(long double);
long double ceill(long double);
long double copysignl(long double, long double) __pure2;
+long double coshl(long double);
long double cosl(long double);
+long double erfcl(long double);
+long double erfl(long double);
long double exp2l(long double);
+long double expl(long double);
+long double expm1l(long double);
long double fabsl(long double) __pure2;
long double fdiml(long double, long double);
long double floorl(long double);
@@ -414,13 +466,18 @@
long double fmaxl(long double, long double) __pure2;
long double fminl(long double, long double) __pure2;
long double fmodl(long double, long double);
-long double frexpl(long double value, int *); /* fundamentally !__pure2 */
+long double frexpl(long double, int *); /* fundamentally !__pure2 */
long double hypotl(long double, long double);
int ilogbl(long double) __pure2;
long double ldexpl(long double, int);
+long double lgammal(long double);
long long llrintl(long double);
long long llroundl(long double);
+long double log10l(long double);
+long double log1pl(long double);
+long double log2l(long double);
long double logbl(long double);
+long double logl(long double);
long lrintl(long double);
long lroundl(long double);
long double modfl(long double, long double *); /* fundamentally !__pure2 */
@@ -430,6 +487,7 @@
double nexttoward(double, long double);
float nexttowardf(float, long double);
long double nexttowardl(long double, long double);
+long double powl(long double, long double);
long double remainderl(long double, long double);
long double remquol(long double, long double, int *);
long double rintl(long double);
@@ -436,48 +494,19 @@
long double roundl(long double);
long double scalblnl(long double, long);
long double scalbnl(long double, int);
+long double sinhl(long double);
long double sinl(long double);
long double sqrtl(long double);
+long double tanhl(long double);
long double tanl(long double);
+long double tgammal(long double);
long double truncl(long double);
-
#endif /* __ISO_C_VISIBLE >= 1999 */
-__END_DECLS
-#endif /* !_MATH_H_ */
+#if __BSD_VISIBLE
+long double lgammal_r(long double, int *);
+#endif
-/* separate header for cmath */
-#ifndef _MATH_EXTRA_H_
-#if __ISO_C_VISIBLE >= 1999
-#if _DECLARE_C99_LDBL_MATH
-
-#define _MATH_EXTRA_H_
-
-/*
- * extra long double versions of math functions for C99 and cmath
- */
-__BEGIN_DECLS
-
-long double acoshl(long double);
-long double asinhl(long double);
-long double atanhl(long double);
-long double coshl(long double);
-long double erfcl(long double);
-long double erfl(long double);
-long double expl(long double);
-long double expm1l(long double);
-long double lgammal(long double);
-long double log10l(long double);
-long double log1pl(long double);
-long double log2l(long double);
-long double logl(long double);
-long double powl(long double, long double);
-long double sinhl(long double);
-long double tanhl(long double);
-long double tgammal(long double);
-
__END_DECLS
-#endif /* !_DECLARE_C99_LDBL_MATH */
-#endif /* __ISO_C_VISIBLE >= 1999 */
-#endif /* !_MATH_EXTRA_H_ */
+#endif /* !_MATH_H_ */
Modified: trunk/lib/msun/src/math_private.h
===================================================================
--- trunk/lib/msun/src/math_private.h 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/math_private.h 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,7 +12,7 @@
/*
* from: @(#)fdlibm.h 5.1 93/09/24
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/msun/src/math_private.h 284810 2015-06-25 13:01:10Z tijl $
*/
#ifndef _MATH_PRIVATE_H_
@@ -39,7 +40,7 @@
*/
#ifdef __arm__
-#if defined(__VFP_FP__)
+#if defined(__VFP_FP__) || defined(__ARM_EABI__)
#define IEEE_WORD_ORDER BYTE_ORDER
#else
#define IEEE_WORD_ORDER BIG_ENDIAN
@@ -188,6 +189,90 @@
(d) = sf_u.value; \
} while (0)
+/*
+ * Get expsign and mantissa as 16 bit and 64 bit ints from an 80 bit long
+ * double.
+ */
+
+#define EXTRACT_LDBL80_WORDS(ix0,ix1,d) \
+do { \
+ union IEEEl2bits ew_u; \
+ ew_u.e = (d); \
+ (ix0) = ew_u.xbits.expsign; \
+ (ix1) = ew_u.xbits.man; \
+} while (0)
+
+/*
+ * Get expsign and mantissa as one 16 bit and two 64 bit ints from a 128 bit
+ * long double.
+ */
+
+#define EXTRACT_LDBL128_WORDS(ix0,ix1,ix2,d) \
+do { \
+ union IEEEl2bits ew_u; \
+ ew_u.e = (d); \
+ (ix0) = ew_u.xbits.expsign; \
+ (ix1) = ew_u.xbits.manh; \
+ (ix2) = ew_u.xbits.manl; \
+} while (0)
+
+/* Get expsign as a 16 bit int from a long double. */
+
+#define GET_LDBL_EXPSIGN(i,d) \
+do { \
+ union IEEEl2bits ge_u; \
+ ge_u.e = (d); \
+ (i) = ge_u.xbits.expsign; \
+} while (0)
+
+/*
+ * Set an 80 bit long double from a 16 bit int expsign and a 64 bit int
+ * mantissa.
+ */
+
+#define INSERT_LDBL80_WORDS(d,ix0,ix1) \
+do { \
+ union IEEEl2bits iw_u; \
+ iw_u.xbits.expsign = (ix0); \
+ iw_u.xbits.man = (ix1); \
+ (d) = iw_u.e; \
+} while (0)
+
+/*
+ * Set a 128 bit long double from a 16 bit int expsign and two 64 bit ints
+ * comprising the mantissa.
+ */
+
+#define INSERT_LDBL128_WORDS(d,ix0,ix1,ix2) \
+do { \
+ union IEEEl2bits iw_u; \
+ iw_u.xbits.expsign = (ix0); \
+ iw_u.xbits.manh = (ix1); \
+ iw_u.xbits.manl = (ix2); \
+ (d) = iw_u.e; \
+} while (0)
+
+/* Set expsign of a long double from a 16 bit int. */
+
+#define SET_LDBL_EXPSIGN(d,v) \
+do { \
+ union IEEEl2bits se_u; \
+ se_u.e = (d); \
+ se_u.xbits.expsign = (v); \
+ (d) = se_u.e; \
+} while (0)
+
+#ifdef __i386__
+/* Long double constants are broken on i386. */
+#define LD80C(m, ex, v) { \
+ .xbits.man = __CONCAT(m, ULL), \
+ .xbits.expsign = (0x3fff + (ex)) | ((v) < 0 ? 0x8000 : 0), \
+}
+#else
+/* The above works on non-i386 too, but we use this to check v. */
+#define LD80C(m, ex, v) { .e = (v), }
+#endif
+
#ifdef FLT_EVAL_METHOD
/*
* Attempt to get strict C99 semantics for assignment with non-C99 compilers.
@@ -198,7 +283,7 @@
#define STRICT_ASSIGN(type, lval, rval) do { \
volatile type __lval; \
\
- if (sizeof(type) >= sizeof(double)) \
+ if (sizeof(type) >= sizeof(long double)) \
(lval) = (rval); \
else { \
__lval = (rval); \
@@ -206,9 +291,135 @@
} \
} while (0)
#endif
+#endif /* FLT_EVAL_METHOD */
+
+/* Support switching the mode to FP_PE if necessary. */
+#if defined(__i386__) && !defined(NO_FPSETPREC)
+#define ENTERI() \
+ long double __retval; \
+ fp_prec_t __oprec; \
+ \
+ if ((__oprec = fpgetprec()) != FP_PE) \
+ fpsetprec(FP_PE)
+#define RETURNI(x) do { \
+ __retval = (x); \
+ if (__oprec != FP_PE) \
+ fpsetprec(__oprec); \
+ RETURNF(__retval); \
+} while (0)
+#else
+#define ENTERI(x)
+#define RETURNI(x) RETURNF(x)
#endif
+/* Default return statement if hack*_t() is not used. */
+#define RETURNF(v) return (v)
+
/*
+ * 2sum gives the same result as 2sumF without requiring |a| >= |b| or
+ * a == 0, but is slower.
+ */
+#define _2sum(a, b) do { \
+ __typeof(a) __s, __w; \
+ \
+ __w = (a) + (b); \
+ __s = __w - (a); \
+ (b) = ((a) - (__w - __s)) + ((b) - __s); \
+ (a) = __w; \
+} while (0)
+
+/*
+ * 2sumF algorithm.
+ *
+ * "Normalize" the terms in the infinite-precision expression a + b for
+ * the sum of 2 floating point values so that b is as small as possible
+ * relative to 'a'. (The resulting 'a' is the value of the expression in
+ * the same precision as 'a' and the resulting b is the rounding error.)
+ * |a| must be >= |b| or 0, b's type must be no larger than 'a's type, and
+ * exponent overflow or underflow must not occur. This uses a Theorem of
+ * Dekker (1971). See Knuth (1981) 4.2.2 Theorem C. The name "TwoSum"
+ * is apparently due to Skewchuk (1997).
+ *
+ * For this to always work, assignment of a + b to 'a' must not retain any
+ * extra precision in a + b. This is required by C standards but broken
+ * in many compilers. The brokenness cannot be worked around using
+ * STRICT_ASSIGN() like we do elsewhere, since the efficiency of this
+ * algorithm would be destroyed by non-null strict assignments. (The
+ * compilers are correct to be broken -- the efficiency of all floating
+ * point code calculations would be destroyed similarly if they forced the
+ * conversions.)
+ *
+ * Fortunately, a case that works well can usually be arranged by building
+ * any extra precision into the type of 'a' -- 'a' should have type float_t,
+ * double_t or long double. b's type should be no larger than 'a's type.
+ * Callers should use these types with scopes as large as possible, to
+ * reduce their own extra-precision and efficiciency problems. In
+ * particular, they shouldn't convert back and forth just to call here.
+ */
+#ifdef DEBUG
+#define _2sumF(a, b) do { \
+ __typeof(a) __w; \
+ volatile __typeof(a) __ia, __ib, __r, __vw; \
+ \
+ __ia = (a); \
+ __ib = (b); \
+ assert(__ia == 0 || fabsl(__ia) >= fabsl(__ib)); \
+ \
+ __w = (a) + (b); \
+ (b) = ((a) - __w) + (b); \
+ (a) = __w; \
+ \
+ /* The next 2 assertions are weak if (a) is already long double. */ \
+ assert((long double)__ia + __ib == (long double)(a) + (b)); \
+ __vw = __ia + __ib; \
+ __r = __ia - __vw; \
+ __r += __ib; \
+ assert(__vw == (a) && __r == (b)); \
+} while (0)
+#else /* !DEBUG */
+#define _2sumF(a, b) do { \
+ __typeof(a) __w; \
+ \
+ __w = (a) + (b); \
+ (b) = ((a) - __w) + (b); \
+ (a) = __w; \
+} while (0)
+#endif /* DEBUG */
+
+/*
+ * Set x += c, where x is represented in extra precision as a + b.
+ * x must be sufficiently normalized and sufficiently larger than c,
+ * and the result is then sufficiently normalized.
+ *
+ * The details of ordering are that |a| must be >= |c| (so that (a, c)
+ * can be normalized without extra work to swap 'a' with c). The details of
+ * the normalization are that b must be small relative to the normalized 'a'.
+ * Normalization of (a, c) makes the normalized c tiny relative to the
+ * normalized a, so b remains small relative to 'a' in the result. However,
+ * b need not ever be tiny relative to 'a'. For example, b might be about
+ * 2**20 times smaller than 'a' to give about 20 extra bits of precision.
+ * That is usually enough, and adding c (which by normalization is about
+ * 2**53 times smaller than a) cannot change b significantly. However,
+ * cancellation of 'a' with c in normalization of (a, c) may reduce 'a'
+ * significantly relative to b. The caller must ensure that significant
+ * cancellation doesn't occur, either by having c of the same sign as 'a',
+ * or by having |c| a few percent smaller than |a|. Pre-normalization of
+ * (a, b) may help.
+ *
+ * This is is a variant of an algorithm of Kahan (see Knuth (1981) 4.2.2
+ * exercise 19). We gain considerable efficiency by requiring the terms to
+ * be sufficiently normalized and sufficiently increasing.
+ */
+#define _3sumF(a, b, c) do { \
+ __typeof(a) __tmp; \
+ \
+ __tmp = (c); \
+ _2sumF(__tmp, (a)); \
+ (b) += (a); \
+ (a) = __tmp; \
+} while (0)
+
+/*
* Common routine to process the arguments to nan(), nanf(), and nanl().
*/
void _scan_nan(uint32_t *__words, int __num_words, const char *__s);
@@ -244,9 +455,15 @@
* (0.0+I)*(y+0.0*I) and laboriously computing the full complex product.
* In particular, I*Inf is corrupted to NaN+I*Inf, and I*-0 is corrupted
* to -0.0+I*0.0.
+ *
+ * The C11 standard introduced the macros CMPLX(), CMPLXF() and CMPLXL()
+ * to construct complex values. Compilers that conform to the C99
+ * standard require the following functions to avoid the above issues.
*/
+
+#ifndef CMPLXF
static __inline float complex
-cpackf(float x, float y)
+CMPLXF(float x, float y)
{
float_complex z;
@@ -254,9 +471,11 @@
IMAGPART(z) = y;
return (z.f);
}
+#endif
+#ifndef CMPLX
static __inline double complex
-cpack(double x, double y)
+CMPLX(double x, double y)
{
double_complex z;
@@ -264,9 +483,11 @@
IMAGPART(z) = y;
return (z.f);
}
+#endif
+#ifndef CMPLXL
static __inline long double complex
-cpackl(long double x, long double y)
+CMPLXL(long double x, long double y)
{
long_double_complex z;
@@ -274,6 +495,8 @@
IMAGPART(z) = y;
return (z.f);
}
+#endif
+
#endif /* _COMPLEX_H */
#ifdef __GNUCLIKE_ASM
@@ -304,8 +527,154 @@
#define HAVE_EFFICIENT_IRINT
#endif
+#if defined(__amd64__) || defined(__i386__)
+static __inline int
+irintl(long double x)
+{
+ int n;
+
+ asm("fistl %0" : "=m" (n) : "t" (x));
+ return (n);
+}
+#define HAVE_EFFICIENT_IRINTL
+#endif
+
#endif /* __GNUCLIKE_ASM */
+#ifdef DEBUG
+#if defined(__amd64__) || defined(__i386__)
+#define breakpoint() asm("int $3")
+#else
+#include <signal.h>
+
+#define breakpoint() raise(SIGTRAP)
+#endif
+#endif
+
+/* Write a pari script to test things externally. */
+#ifdef DOPRINT
+#include <stdio.h>
+
+#ifndef DOPRINT_SWIZZLE
+#define DOPRINT_SWIZZLE 0
+#endif
+
+#ifdef DOPRINT_LD80
+
+#define DOPRINT_START(xp) do { \
+ uint64_t __lx; \
+ uint16_t __hx; \
+ \
+ /* Hack to give more-problematic args. */ \
+ EXTRACT_LDBL80_WORDS(__hx, __lx, *xp); \
+ __lx ^= DOPRINT_SWIZZLE; \
+ INSERT_LDBL80_WORDS(*xp, __hx, __lx); \
+ printf("x = %.21Lg; ", (long double)*xp); \
+} while (0)
+#define DOPRINT_END1(v) \
+ printf("y = %.21Lg; z = 0; show(x, y, z);\n", (long double)(v))
+#define DOPRINT_END2(hi, lo) \
+ printf("y = %.21Lg; z = %.21Lg; show(x, y, z);\n", \
+ (long double)(hi), (long double)(lo))
+
+#elif defined(DOPRINT_D64)
+
+#define DOPRINT_START(xp) do { \
+ uint32_t __hx, __lx; \
+ \
+ EXTRACT_WORDS(__hx, __lx, *xp); \
+ __lx ^= DOPRINT_SWIZZLE; \
+ INSERT_WORDS(*xp, __hx, __lx); \
+ printf("x = %.21Lg; ", (long double)*xp); \
+} while (0)
+#define DOPRINT_END1(v) \
+ printf("y = %.21Lg; z = 0; show(x, y, z);\n", (long double)(v))
+#define DOPRINT_END2(hi, lo) \
+ printf("y = %.21Lg; z = %.21Lg; show(x, y, z);\n", \
+ (long double)(hi), (long double)(lo))
+
+#elif defined(DOPRINT_F32)
+
+#define DOPRINT_START(xp) do { \
+ uint32_t __hx; \
+ \
+ GET_FLOAT_WORD(__hx, *xp); \
+ __hx ^= DOPRINT_SWIZZLE; \
+ SET_FLOAT_WORD(*xp, __hx); \
+ printf("x = %.21Lg; ", (long double)*xp); \
+} while (0)
+#define DOPRINT_END1(v) \
+ printf("y = %.21Lg; z = 0; show(x, y, z);\n", (long double)(v))
+#define DOPRINT_END2(hi, lo) \
+ printf("y = %.21Lg; z = %.21Lg; show(x, y, z);\n", \
+ (long double)(hi), (long double)(lo))
+
+#else /* !DOPRINT_LD80 && !DOPRINT_D64 (LD128 only) */
+
+#ifndef DOPRINT_SWIZZLE_HIGH
+#define DOPRINT_SWIZZLE_HIGH 0
+#endif
+
+#define DOPRINT_START(xp) do { \
+ uint64_t __lx, __llx; \
+ uint16_t __hx; \
+ \
+ EXTRACT_LDBL128_WORDS(__hx, __lx, __llx, *xp); \
+ __llx ^= DOPRINT_SWIZZLE; \
+ __lx ^= DOPRINT_SWIZZLE_HIGH; \
+ INSERT_LDBL128_WORDS(*xp, __hx, __lx, __llx); \
+ printf("x = %.36Lg; ", (long double)*xp); \
+} while (0)
+#define DOPRINT_END1(v) \
+ printf("y = %.36Lg; z = 0; show(x, y, z);\n", (long double)(v))
+#define DOPRINT_END2(hi, lo) \
+ printf("y = %.36Lg; z = %.36Lg; show(x, y, z);\n", \
+ (long double)(hi), (long double)(lo))
+
+#endif /* DOPRINT_LD80 */
+
+#else /* !DOPRINT */
+#define DOPRINT_START(xp)
+#define DOPRINT_END1(v)
+#define DOPRINT_END2(hi, lo)
+#endif /* DOPRINT */
+
+#define RETURNP(x) do { \
+ DOPRINT_END1(x); \
+ RETURNF(x); \
+} while (0)
+#define RETURNPI(x) do { \
+ DOPRINT_END1(x); \
+ RETURNI(x); \
+} while (0)
+#define RETURN2P(x, y) do { \
+ DOPRINT_END2((x), (y)); \
+ RETURNF((x) + (y)); \
+} while (0)
+#define RETURN2PI(x, y) do { \
+ DOPRINT_END2((x), (y)); \
+ RETURNI((x) + (y)); \
+} while (0)
+#ifdef STRUCT_RETURN
+#define RETURNSP(rp) do { \
+ if (!(rp)->lo_set) \
+ RETURNP((rp)->hi); \
+ RETURN2P((rp)->hi, (rp)->lo); \
+} while (0)
+#define RETURNSPI(rp) do { \
+ if (!(rp)->lo_set) \
+ RETURNPI((rp)->hi); \
+ RETURN2PI((rp)->hi, (rp)->lo); \
+} while (0)
+#endif
+#define SUM2P(x, y) ({ \
+ const __typeof (x) __x = (x); \
+ const __typeof (y) __y = (y); \
+ \
+ DOPRINT_END2(__x, __y); \
+ __x + __y; \
+})
+
/*
* ieee style elementary functions
*
@@ -377,6 +746,10 @@
double __kernel_sin(double,double,int);
double __kernel_cos(double,double);
double __kernel_tan(double,double,int);
+double __ldexp_exp(double,int);
+#ifdef _COMPLEX_H
+double complex __ldexp_cexp(double complex,int);
+#endif
/* float precision kernel functions */
#ifndef INLINE_REM_PIO2F
@@ -391,6 +764,10 @@
#ifndef INLINE_KERNEL_TANDF
float __kernel_tandf(double,int);
#endif
+float __ldexp_expf(float,int);
+#ifdef _COMPLEX_H
+float complex __ldexp_cexpf(float complex,int);
+#endif
/* long double precision kernel functions */
long double __kernel_sinl(long double, long double, int);
Modified: trunk/lib/msun/src/s_asinh.c
===================================================================
--- trunk/lib/msun/src/s_asinh.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_asinh.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)s_asinh.c 5.1 93/09/24 */
/*
* ====================================================
@@ -11,7 +12,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_asinh.c 251599 2013-06-10 06:04:58Z das $");
/* asinh(x)
* Method :
@@ -24,6 +25,8 @@
* := sign(x)*log1p(|x| + x^2/(1 + sqrt(1+x^2)))
*/
+#include <float.h>
+
#include "math.h"
#include "math_private.h"
@@ -54,3 +57,7 @@
}
if(hx>0) return w; else return -w;
}
+
+#if LDBL_MANT_DIG == 53
+__weak_reference(asinh, asinhl);
+#endif
Modified: trunk/lib/msun/src/s_asinhf.c
===================================================================
--- trunk/lib/msun/src/s_asinhf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_asinhf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* s_asinhf.c -- float version of s_asinh.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_asinhf.c 176451 2008-02-22 02:30:36Z das $");
#include "math.h"
#include "math_private.h"
Added: trunk/lib/msun/src/s_asinhl.c
===================================================================
--- trunk/lib/msun/src/s_asinhl.c (rev 0)
+++ trunk/lib/msun/src/s_asinhl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -0,0 +1,92 @@
+/* $MidnightBSD$ */
+/* from: FreeBSD: head/lib/msun/src/e_acosh.c 176451 2008-02-22 02:30:36Z das */
+
+/* @(#)s_asinh.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * 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: stable/10/lib/msun/src/s_asinhl.c 251599 2013-06-10 06:04:58Z das $");
+
+/*
+ * See s_asinh.c for complete comments.
+ *
+ * Converted to long double by David Schultz <das at FreeBSD.ORG> and
+ * Bruce D. Evans.
+ */
+
+#include <float.h>
+#ifdef __i386__
+#include <ieeefp.h>
+#endif
+
+#include "fpmath.h"
+#include "math.h"
+#include "math_private.h"
+
+/* EXP_LARGE is the threshold above which we use asinh(x) ~= log(2x). */
+/* EXP_TINY is the threshold below which we use asinh(x) ~= x. */
+#if LDBL_MANT_DIG == 64
+#define EXP_LARGE 34
+#define EXP_TINY -34
+#elif LDBL_MANT_DIG == 113
+#define EXP_LARGE 58
+#define EXP_TINY -58
+#else
+#error "Unsupported long double format"
+#endif
+
+#if LDBL_MAX_EXP != 0x4000
+/* We also require the usual expsign encoding. */
+#error "Unsupported long double format"
+#endif
+
+#define BIAS (LDBL_MAX_EXP - 1)
+
+static const double
+one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
+huge= 1.00000000000000000000e+300;
+
+#if LDBL_MANT_DIG == 64
+static const union IEEEl2bits
+u_ln2 = LD80C(0xb17217f7d1cf79ac, -1, 6.93147180559945309417e-1L);
+#define ln2 u_ln2.e
+#elif LDBL_MANT_DIG == 113
+static const long double
+ln2 = 6.93147180559945309417232121458176568e-1L; /* 0x162e42fefa39ef35793c7673007e6.0p-113 */
+#else
+#error "Unsupported long double format"
+#endif
+
+long double
+asinhl(long double x)
+{
+ long double t, w;
+ uint16_t hx, ix;
+
+ ENTERI();
+ GET_LDBL_EXPSIGN(hx, x);
+ ix = hx & 0x7fff;
+ if (ix >= 0x7fff) RETURNI(x+x); /* x is inf, NaN or misnormal */
+ if (ix < BIAS + EXP_TINY) { /* |x| < TINY, or misnormal */
+ if (huge + x > one) RETURNI(x); /* return x inexact except 0 */
+ }
+ if (ix >= BIAS + EXP_LARGE) { /* |x| >= LARGE, or misnormal */
+ w = logl(fabsl(x))+ln2;
+ } else if (ix >= 0x4000) { /* LARGE > |x| >= 2.0, or misnormal */
+ t = fabsl(x);
+ w = logl(2.0*t+one/(sqrtl(x*x+one)+t));
+ } else { /* 2.0 > |x| >= TINY, or misnormal */
+ t = x*x;
+ w =log1pl(fabsl(x)+t/(one+sqrtl(one+t)));
+ }
+ RETURNI((hx & 0x8000) == 0 ? w : -w);
+}
Property changes on: trunk/lib/msun/src/s_asinhl.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/lib/msun/src/s_atan.c
===================================================================
--- trunk/lib/msun/src/s_atan.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_atan.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)s_atan.c 5.1 93/09/24 */
/*
* ====================================================
@@ -11,7 +12,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_atan.c 218509 2011-02-10 07:37:50Z das $");
/* atan(x)
* Method
Modified: trunk/lib/msun/src/s_atanf.c
===================================================================
--- trunk/lib/msun/src/s_atanf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_atanf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* s_atanf.c -- float version of s_atan.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_atanf.c 181100 2008-08-01 01:24:25Z das $");
#include "math.h"
#include "math_private.h"
Modified: trunk/lib/msun/src/s_atanl.c
===================================================================
--- trunk/lib/msun/src/s_atanl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_atanl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)s_atan.c 5.1 93/09/24 */
/* FreeBSD: head/lib/msun/src/s_atan.c 176451 2008-02-22 02:30:36Z das */
/*
@@ -12,7 +13,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_atanl.c 181074 2008-07-31 22:41:26Z das $");
/*
* See comments in s_atan.c.
Modified: trunk/lib/msun/src/s_carg.c
===================================================================
--- trunk/lib/msun/src/s_carg.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_carg.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2005 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_carg.c 174561 2007-12-12 23:43:51Z das $");
#include <complex.h>
#include <math.h>
Modified: trunk/lib/msun/src/s_cargf.c
===================================================================
--- trunk/lib/msun/src/s_cargf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_cargf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2005 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_cargf.c 174561 2007-12-12 23:43:51Z das $");
#include <complex.h>
#include <math.h>
Modified: trunk/lib/msun/src/s_cargl.c
===================================================================
--- trunk/lib/msun/src/s_cargl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_cargl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2005-2008 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_cargl.c 183714 2008-10-09 02:25:18Z peter $");
#include <complex.h>
#include <math.h>
Modified: trunk/lib/msun/src/s_cbrt.c
===================================================================
--- trunk/lib/msun/src/s_cbrt.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_cbrt.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)s_cbrt.c 5.1 93/09/24 */
/*
* ====================================================
@@ -13,7 +14,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_cbrt.c 219571 2011-03-12 16:50:39Z kargl $");
#include "math.h"
#include "math_private.h"
Modified: trunk/lib/msun/src/s_cbrtf.c
===================================================================
--- trunk/lib/msun/src/s_cbrtf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_cbrtf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* s_cbrtf.c -- float version of s_cbrt.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
* Debugged and optimized by Bruce D. Evans.
@@ -15,7 +16,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_cbrtf.c 176451 2008-02-22 02:30:36Z das $");
#include "math.h"
#include "math_private.h"
Modified: trunk/lib/msun/src/s_cbrtl.c
===================================================================
--- trunk/lib/msun/src/s_cbrtl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_cbrtl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -15,10 +16,12 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_cbrtl.c 238924 2012-07-30 21:58:28Z kargl $");
#include <float.h>
+#ifdef __i386__
#include <ieeefp.h>
+#endif
#include "fpmath.h"
#include "math.h"
@@ -51,23 +54,11 @@
if (k == BIAS + LDBL_MAX_EXP)
return (x + x);
-#ifdef __i386__
- fp_prec_t oprec;
-
- oprec = fpgetprec();
- if (oprec != FP_PE)
- fpsetprec(FP_PE);
-#endif
-
+ ENTERI();
if (k == 0) {
/* If x = +-0, then cbrt(x) = +-0. */
- if ((u.bits.manh | u.bits.manl) == 0) {
-#ifdef __i386__
- if (oprec != FP_PE)
- fpsetprec(oprec);
-#endif
- return (x);
- }
+ if ((u.bits.manh | u.bits.manl) == 0)
+ RETURNI(x);
/* Adjust subnormal numbers. */
u.e *= 0x1.0p514;
k = u.bits.exp;
@@ -149,9 +140,5 @@
t=t+t*r; /* error <= 0.5 + 0.5/3 + epsilon */
t *= v.e;
-#ifdef __i386__
- if (oprec != FP_PE)
- fpsetprec(oprec);
-#endif
- return (t);
+ RETURNI(t);
}
Added: trunk/lib/msun/src/s_ccosh.c
===================================================================
--- trunk/lib/msun/src/s_ccosh.c (rev 0)
+++ trunk/lib/msun/src/s_ccosh.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -0,0 +1,157 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl
+ * 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 unmodified, 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 ``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 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.
+ */
+
+/*
+ * Hyperbolic cosine of a complex argument z = x + i y.
+ *
+ * cosh(z) = cosh(x+iy)
+ * = cosh(x) cos(y) + i sinh(x) sin(y).
+ *
+ * Exceptional values are noted in the comments within the source code.
+ * These values and the return value were taken from n1124.pdf.
+ * The sign of the result for some exceptional values is unspecified but
+ * must satisfy both cosh(conj(z)) == conj(cosh(z)) and cosh(-z) == cosh(z).
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_ccosh.c 284810 2015-06-25 13:01:10Z tijl $");
+
+#include <complex.h>
+#include <math.h>
+
+#include "math_private.h"
+
+static const double huge = 0x1p1023;
+
+double complex
+ccosh(double complex z)
+{
+ double x, y, h;
+ int32_t hx, hy, ix, iy, lx, ly;
+
+ x = creal(z);
+ y = cimag(z);
+
+ EXTRACT_WORDS(hx, lx, x);
+ EXTRACT_WORDS(hy, ly, y);
+
+ ix = 0x7fffffff & hx;
+ iy = 0x7fffffff & hy;
+
+ /* Handle the nearly-non-exceptional cases where x and y are finite. */
+ if (ix < 0x7ff00000 && iy < 0x7ff00000) {
+ if ((iy | ly) == 0)
+ return (CMPLX(cosh(x), x * y));
+ if (ix < 0x40360000) /* |x| < 22: normal case */
+ return (CMPLX(cosh(x) * cos(y), sinh(x) * sin(y)));
+
+ /* |x| >= 22, so cosh(x) ~= exp(|x|) */
+ if (ix < 0x40862e42) {
+ /* x < 710: exp(|x|) won't overflow */
+ h = exp(fabs(x)) * 0.5;
+ return (CMPLX(h * cos(y), copysign(h, x) * sin(y)));
+ } else if (ix < 0x4096bbaa) {
+ /* x < 1455: scale to avoid overflow */
+ z = __ldexp_cexp(CMPLX(fabs(x), y), -1);
+ return (CMPLX(creal(z), cimag(z) * copysign(1, x)));
+ } else {
+ /* x >= 1455: the result always overflows */
+ h = huge * x;
+ return (CMPLX(h * h * cos(y), h * sin(y)));
+ }
+ }
+
+ /*
+ * cosh(+-0 +- I Inf) = dNaN + I (+-)(+-)0.
+ * The sign of 0 in the result is unspecified. Choice = product
+ * of the signs of the argument. Raise the invalid floating-point
+ * exception.
+ *
+ * cosh(+-0 +- I NaN) = d(NaN) + I (+-)(+-)0.
+ * The sign of 0 in the result is unspecified. Choice = product
+ * of the signs of the argument.
+ */
+ if ((ix | lx) == 0) /* && iy >= 0x7ff00000 */
+ return (CMPLX(y - y, x * copysign(0, y)));
+
+ /*
+ * cosh(+-Inf +- I 0) = +Inf + I (+-)(+-)0.
+ *
+ * cosh(NaN +- I 0) = d(NaN) + I (+-)(+-)0.
+ * The sign of 0 in the result is unspecified. Choice = product
+ * of the signs of the argument.
+ */
+ if ((iy | ly) == 0) /* && ix >= 0x7ff00000 */
+ return (CMPLX(x * x, copysign(0, x) * y));
+
+ /*
+ * cosh(x +- I Inf) = dNaN + I dNaN.
+ * Raise the invalid floating-point exception for finite nonzero x.
+ *
+ * cosh(x + I NaN) = d(NaN) + I d(NaN).
+ * Optionally raises the invalid floating-point exception for finite
+ * nonzero x. Choice = don't raise (except for signaling NaNs).
+ */
+ if (ix < 0x7ff00000) /* && iy >= 0x7ff00000 */
+ return (CMPLX(y - y, x * (y - y)));
+
+ /*
+ * cosh(+-Inf + I NaN) = +Inf + I d(NaN).
+ *
+ * cosh(+-Inf +- I Inf) = +Inf + I dNaN.
+ * The sign of Inf in the result is unspecified. Choice = always +.
+ * Raise the invalid floating-point exception.
+ *
+ * cosh(+-Inf + I y) = +Inf cos(y) +- I Inf sin(y)
+ */
+ if (ix == 0x7ff00000 && lx == 0) {
+ if (iy >= 0x7ff00000)
+ return (CMPLX(INFINITY, x * (y - y)));
+ return (CMPLX(INFINITY * cos(y), x * sin(y)));
+ }
+
+ /*
+ * cosh(NaN + I NaN) = d(NaN) + I d(NaN).
+ *
+ * cosh(NaN +- I Inf) = d(NaN) + I d(NaN).
+ * Optionally raises the invalid floating-point exception.
+ * Choice = raise.
+ *
+ * cosh(NaN + I y) = d(NaN) + I d(NaN).
+ * Optionally raises the invalid floating-point exception for finite
+ * nonzero y. Choice = don't raise (except for signaling NaNs).
+ */
+ return (CMPLX((x * x) * (y - y), (x + x) * (y - y)));
+}
+
+double complex
+ccos(double complex z)
+{
+
+ /* ccos(z) = ccosh(I * z) */
+ return (ccosh(CMPLX(-cimag(z), creal(z))));
+}
Property changes on: trunk/lib/msun/src/s_ccosh.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/lib/msun/src/s_ccoshf.c
===================================================================
--- trunk/lib/msun/src/s_ccoshf.c (rev 0)
+++ trunk/lib/msun/src/s_ccoshf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -0,0 +1,102 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl
+ * 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 unmodified, 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 ``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 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.
+ */
+
+/*
+ * Float version of ccosh(). See s_ccosh.c for details.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_ccoshf.c 284810 2015-06-25 13:01:10Z tijl $");
+
+#include <complex.h>
+#include <math.h>
+
+#include "math_private.h"
+
+static const float huge = 0x1p127;
+
+float complex
+ccoshf(float complex z)
+{
+ float x, y, h;
+ int32_t hx, hy, ix, iy;
+
+ x = crealf(z);
+ y = cimagf(z);
+
+ GET_FLOAT_WORD(hx, x);
+ GET_FLOAT_WORD(hy, y);
+
+ ix = 0x7fffffff & hx;
+ iy = 0x7fffffff & hy;
+
+ if (ix < 0x7f800000 && iy < 0x7f800000) {
+ if (iy == 0)
+ return (CMPLXF(coshf(x), x * y));
+ if (ix < 0x41100000) /* |x| < 9: normal case */
+ return (CMPLXF(coshf(x) * cosf(y), sinhf(x) * sinf(y)));
+
+ /* |x| >= 9, so cosh(x) ~= exp(|x|) */
+ if (ix < 0x42b17218) {
+ /* x < 88.7: expf(|x|) won't overflow */
+ h = expf(fabsf(x)) * 0.5F;
+ return (CMPLXF(h * cosf(y), copysignf(h, x) * sinf(y)));
+ } else if (ix < 0x4340b1e7) {
+ /* x < 192.7: scale to avoid overflow */
+ z = __ldexp_cexpf(CMPLXF(fabsf(x), y), -1);
+ return (CMPLXF(crealf(z), cimagf(z) * copysignf(1, x)));
+ } else {
+ /* x >= 192.7: the result always overflows */
+ h = huge * x;
+ return (CMPLXF(h * h * cosf(y), h * sinf(y)));
+ }
+ }
+
+ if (ix == 0) /* && iy >= 0x7f800000 */
+ return (CMPLXF(y - y, x * copysignf(0, y)));
+
+ if (iy == 0) /* && ix >= 0x7f800000 */
+ return (CMPLXF(x * x, copysignf(0, x) * y));
+
+ if (ix < 0x7f800000) /* && iy >= 0x7f800000 */
+ return (CMPLXF(y - y, x * (y - y)));
+
+ if (ix == 0x7f800000) {
+ if (iy >= 0x7f800000)
+ return (CMPLXF(INFINITY, x * (y - y)));
+ return (CMPLXF(INFINITY * cosf(y), x * sinf(y)));
+ }
+
+ return (CMPLXF((x * x) * (y - y), (x + x) * (y - y)));
+}
+
+float complex
+ccosf(float complex z)
+{
+
+ return (ccoshf(CMPLXF(-cimagf(z), crealf(z))));
+}
Property changes on: trunk/lib/msun/src/s_ccoshf.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/lib/msun/src/s_ceil.c
===================================================================
--- trunk/lib/msun/src/s_ceil.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_ceil.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)s_ceil.c 5.1 93/09/24 */
/*
* ====================================================
@@ -11,7 +12,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_ceil.c 176305 2008-02-15 07:01:40Z bde $");
/*
* ceil(x)
Modified: trunk/lib/msun/src/s_ceilf.c
===================================================================
--- trunk/lib/msun/src/s_ceilf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_ceilf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* s_ceilf.c -- float version of s_ceil.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_ceilf.c 176451 2008-02-22 02:30:36Z das $");
#include "math.h"
#include "math_private.h"
Modified: trunk/lib/msun/src/s_ceill.c
===================================================================
--- trunk/lib/msun/src/s_ceill.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_ceill.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -12,7 +13,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_ceill.c 176280 2008-02-14 15:10:34Z bde $");
/*
* ceill(x)
Modified: trunk/lib/msun/src/s_cexp.c
===================================================================
--- trunk/lib/msun/src/s_cexp.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_cexp.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2011 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_cexp.c 284810 2015-06-25 13:01:10Z tijl $");
#include <complex.h>
#include <math.h>
@@ -34,18 +35,13 @@
static const uint32_t
exp_ovfl = 0x40862e42, /* high bits of MAX_EXP * ln2 ~= 710 */
-cexp_ovfl = 0x4096b8e4, /* (MAX_EXP - MIN_DENORM_EXP) * ln2 */
-k = 1799; /* constant for reduction */
+cexp_ovfl = 0x4096b8e4; /* (MAX_EXP - MIN_DENORM_EXP) * ln2 */
-static const double
-kln2 = 1246.97177782734161156; /* k * ln2 */
-
double complex
cexp(double complex z)
{
double x, y, exp_x;
uint32_t hx, hy, lx, ly;
- int scale;
x = creal(z);
y = cimag(z);
@@ -55,36 +51,31 @@
/* cexp(x + I 0) = exp(x) + I 0 */
if ((hy | ly) == 0)
- return (cpack(exp(x), y));
+ return (CMPLX(exp(x), y));
+ EXTRACT_WORDS(hx, lx, x);
+ /* cexp(0 + I y) = cos(y) + I sin(y) */
+ if (((hx & 0x7fffffff) | lx) == 0)
+ return (CMPLX(cos(y), sin(y)));
+
if (hy >= 0x7ff00000) {
- EXTRACT_WORDS(hx, lx, x);
if (lx != 0 || (hx & 0x7fffffff) != 0x7ff00000) {
/* cexp(finite|NaN +- I Inf|NaN) = NaN + I NaN */
- return (cpack(y - y, y - y));
+ return (CMPLX(y - y, y - y));
} else if (hx & 0x80000000) {
/* cexp(-Inf +- I Inf|NaN) = 0 + I 0 */
- return (cpack(0.0, 0.0));
+ return (CMPLX(0.0, 0.0));
} else {
/* cexp(+Inf +- I Inf|NaN) = Inf + I NaN */
- return (cpack(x, y - y));
+ return (CMPLX(x, y - y));
}
}
- GET_HIGH_WORD(hx, x);
if (hx >= exp_ovfl && hx <= cexp_ovfl) {
/*
* x is between 709.7 and 1454.3, so we must scale to avoid
- * overflow in exp(x). We use exp(x) = exp(x - kln2) * 2**k,
- * carefully chosen to minimize |exp(kln2) - 2**k|. We also
- * scale the exponent of exp(x) to MANT_DIG to avoid loss of
- * accuracy due to underflow if sin(y) is tiny.
+ * overflow in exp(x).
*/
- exp_x = exp(x - kln2);
- GET_HIGH_WORD(hx, exp_x);
- SET_HIGH_WORD(exp_x, (hx & 0xfffff) | ((0x3ff + 52) << 20));
- scale = (hx >> 20) - (0x3ff + 52) + k;
- return (cpack(scalbn(cos(y) * exp_x, scale),
- scalbn(sin(y) * exp_x, scale)));
+ return (__ldexp_cexp(z, 0));
} else {
/*
* Cases covered here:
@@ -94,6 +85,6 @@
* - x = NaN (spurious inexact exception from y)
*/
exp_x = exp(x);
- return (cpack(exp_x * cos(y), exp_x * sin(y)));
+ return (CMPLX(exp_x * cos(y), exp_x * sin(y)));
}
}
Modified: trunk/lib/msun/src/s_cexpf.c
===================================================================
--- trunk/lib/msun/src/s_cexpf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_cexpf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2011 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_cexpf.c 284810 2015-06-25 13:01:10Z tijl $");
#include <complex.h>
#include <math.h>
@@ -34,18 +35,13 @@
static const uint32_t
exp_ovfl = 0x42b17218, /* MAX_EXP * ln2 ~= 88.722839355 */
-cexp_ovfl = 0x43400074, /* (MAX_EXP - MIN_DENORM_EXP) * ln2 */
-k = 235; /* constant for reduction */
+cexp_ovfl = 0x43400074; /* (MAX_EXP - MIN_DENORM_EXP) * ln2 */
-static const float
-kln2 = 162.88958740f; /* k * ln2 */
-
float complex
cexpf(float complex z)
{
float x, y, exp_x;
uint32_t hx, hy;
- int scale;
x = crealf(z);
y = cimagf(z);
@@ -55,18 +51,22 @@
/* cexp(x + I 0) = exp(x) + I 0 */
if (hy == 0)
- return (cpackf(expf(x), y));
+ return (CMPLXF(expf(x), y));
GET_FLOAT_WORD(hx, x);
+ /* cexp(0 + I y) = cos(y) + I sin(y) */
+ if ((hx & 0x7fffffff) == 0)
+ return (CMPLXF(cosf(y), sinf(y)));
+
if (hy >= 0x7f800000) {
if ((hx & 0x7fffffff) != 0x7f800000) {
/* cexp(finite|NaN +- I Inf|NaN) = NaN + I NaN */
- return (cpackf(y - y, y - y));
+ return (CMPLXF(y - y, y - y));
} else if (hx & 0x80000000) {
/* cexp(-Inf +- I Inf|NaN) = 0 + I 0 */
- return (cpackf(0.0, 0.0));
+ return (CMPLXF(0.0, 0.0));
} else {
/* cexp(+Inf +- I Inf|NaN) = Inf + I NaN */
- return (cpackf(x, y - y));
+ return (CMPLXF(x, y - y));
}
}
@@ -73,17 +73,9 @@
if (hx >= exp_ovfl && hx <= cexp_ovfl) {
/*
* x is between 88.7 and 192, so we must scale to avoid
- * overflow in expf(x). We use exp(x) = exp(x - kln2) * 2**k,
- * carefully chosen to minimize |exp(kln2) - 2**k|. We also
- * scale the exponent of exp(x) to MANT_DIG to avoid loss of
- * accuracy due to underflow if sin(y) is tiny.
+ * overflow in expf(x).
*/
- exp_x = expf(x - kln2);
- GET_FLOAT_WORD(hx, exp_x);
- SET_FLOAT_WORD(exp_x, (hx & 0x7fffff) | ((0x7f + 23) << 23));
- scale = (hx >> 23) - (0x7f + 23) + k;
- return (cpackf(scalbnf(cosf(y) * exp_x, scale),
- scalbnf(sinf(y) * exp_x, scale)));
+ return (__ldexp_cexpf(z, 0));
} else {
/*
* Cases covered here:
@@ -93,6 +85,6 @@
* - x = NaN (spurious inexact exception from y)
*/
exp_x = expf(x);
- return (cpackf(exp_x * cosf(y), exp_x * sinf(y)));
+ return (CMPLXF(exp_x * cosf(y), exp_x * sinf(y)));
}
}
Modified: trunk/lib/msun/src/s_cimag.c
===================================================================
--- trunk/lib/msun/src/s_cimag.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_cimag.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004 Stefan Farfeleder
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/msun/src/s_cimag.c 189803 2009-03-14 18:24:15Z das $
*/
#include <complex.h>
Modified: trunk/lib/msun/src/s_cimagf.c
===================================================================
--- trunk/lib/msun/src/s_cimagf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_cimagf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004 Stefan Farfeleder
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/msun/src/s_cimagf.c 189803 2009-03-14 18:24:15Z das $
*/
#include <complex.h>
Modified: trunk/lib/msun/src/s_cimagl.c
===================================================================
--- trunk/lib/msun/src/s_cimagl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_cimagl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004 Stefan Farfeleder
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/msun/src/s_cimagl.c 189803 2009-03-14 18:24:15Z das $
*/
#include <complex.h>
Modified: trunk/lib/msun/src/s_conj.c
===================================================================
--- trunk/lib/msun/src/s_conj.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_conj.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004 Stefan Farfeleder
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/msun/src/s_conj.c 284810 2015-06-25 13:01:10Z tijl $
*/
#include <complex.h>
@@ -34,5 +35,5 @@
conj(double complex z)
{
- return (cpack(creal(z), -cimag(z)));
+ return (CMPLX(creal(z), -cimag(z)));
}
Modified: trunk/lib/msun/src/s_conjf.c
===================================================================
--- trunk/lib/msun/src/s_conjf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_conjf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004 Stefan Farfeleder
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/msun/src/s_conjf.c 284810 2015-06-25 13:01:10Z tijl $
*/
#include <complex.h>
@@ -34,5 +35,5 @@
conjf(float complex z)
{
- return (cpackf(crealf(z), -cimagf(z)));
+ return (CMPLXF(crealf(z), -cimagf(z)));
}
Modified: trunk/lib/msun/src/s_conjl.c
===================================================================
--- trunk/lib/msun/src/s_conjl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_conjl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004 Stefan Farfeleder
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/msun/src/s_conjl.c 284810 2015-06-25 13:01:10Z tijl $
*/
#include <complex.h>
@@ -34,5 +35,5 @@
conjl(long double complex z)
{
- return (cpackl(creall(z), -cimagl(z)));
+ return (CMPLXL(creall(z), -cimagl(z)));
}
Modified: trunk/lib/msun/src/s_copysign.c
===================================================================
--- trunk/lib/msun/src/s_copysign.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_copysign.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)s_copysign.c 5.1 93/09/24 */
/*
* ====================================================
@@ -11,7 +12,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_copysign.c 176451 2008-02-22 02:30:36Z das $");
/*
* copysign(double x, double y)
Modified: trunk/lib/msun/src/s_copysignf.c
===================================================================
--- trunk/lib/msun/src/s_copysignf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_copysignf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* s_copysignf.c -- float version of s_copysign.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_copysignf.c 176451 2008-02-22 02:30:36Z das $");
/*
* copysignf(float x, float y)
Modified: trunk/lib/msun/src/s_copysignl.c
===================================================================
--- trunk/lib/msun/src/s_copysignl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_copysignl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004 Stefan Farfeleder
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/msun/src/s_copysignl.c 165855 2007-01-07 07:54:21Z das $
*/
#include <math.h>
Modified: trunk/lib/msun/src/s_cos.c
===================================================================
--- trunk/lib/msun/src/s_cos.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_cos.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)s_cos.c 5.1 93/09/24 */
/*
* ====================================================
@@ -11,7 +12,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_cos.c 218509 2011-02-10 07:37:50Z das $");
/* cos(x)
* Return cosine function of x.
Modified: trunk/lib/msun/src/s_cosf.c
===================================================================
--- trunk/lib/msun/src/s_cosf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_cosf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* s_cosf.c -- float version of s_cos.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
* Optimized by Bruce D. Evans.
@@ -15,7 +16,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_cosf.c 176569 2008-02-25 22:19:17Z bde $");
#include <float.h>
Modified: trunk/lib/msun/src/s_cosl.c
===================================================================
--- trunk/lib/msun/src/s_cosl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_cosl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2007 Steven G. Kargl
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_cosl.c 240828 2012-09-22 15:38:29Z kargl $");
/*
* Limited testing on pseudorandom numbers drawn within [-2e8:4e8] shows
@@ -33,6 +34,9 @@
*/
#include <float.h>
+#ifdef __i386__
+#include <ieeefp.h>
+#endif
#include "math.h"
#include "math_private.h"
@@ -63,9 +67,11 @@
if (z.bits.exp == 32767)
return ((x - x) / (x - x));
+ ENTERI();
+
/* Optimize the case where x is already within range. */
if (z.e < M_PI_4)
- return (__kernel_cosl(z.e, 0));
+ RETURNI(__kernel_cosl(z.e, 0));
e0 = __ieee754_rem_pio2l(x, y);
hi = y[0];
@@ -86,5 +92,5 @@
break;
}
- return (hi);
+ RETURNI(hi);
}
Modified: trunk/lib/msun/src/s_cproj.c
===================================================================
--- trunk/lib/msun/src/s_cproj.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_cproj.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2008 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_cproj.c 284810 2015-06-25 13:01:10Z tijl $");
#include <complex.h>
#include <math.h>
@@ -39,7 +40,7 @@
if (!isinf(creal(z)) && !isinf(cimag(z)))
return (z);
else
- return (cpack(INFINITY, copysign(0.0, cimag(z))));
+ return (CMPLX(INFINITY, copysign(0.0, cimag(z))));
}
#if LDBL_MANT_DIG == 53
Modified: trunk/lib/msun/src/s_cprojf.c
===================================================================
--- trunk/lib/msun/src/s_cprojf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_cprojf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2008 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_cprojf.c 284810 2015-06-25 13:01:10Z tijl $");
#include <complex.h>
#include <math.h>
@@ -39,5 +40,5 @@
if (!isinf(crealf(z)) && !isinf(cimagf(z)))
return (z);
else
- return (cpackf(INFINITY, copysignf(0.0, cimagf(z))));
+ return (CMPLXF(INFINITY, copysignf(0.0, cimagf(z))));
}
Modified: trunk/lib/msun/src/s_cprojl.c
===================================================================
--- trunk/lib/msun/src/s_cprojl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_cprojl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2008 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_cprojl.c 284810 2015-06-25 13:01:10Z tijl $");
#include <complex.h>
#include <math.h>
@@ -39,5 +40,5 @@
if (!isinf(creall(z)) && !isinf(cimagl(z)))
return (z);
else
- return (cpackl(INFINITY, copysignl(0.0, cimagl(z))));
+ return (CMPLXL(INFINITY, copysignl(0.0, cimagl(z))));
}
Modified: trunk/lib/msun/src/s_creal.c
===================================================================
--- trunk/lib/msun/src/s_creal.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_creal.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004 Stefan Farfeleder
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/msun/src/s_creal.c 129864 2004-05-30 09:21:56Z stefanf $
*/
#include <complex.h>
Modified: trunk/lib/msun/src/s_crealf.c
===================================================================
--- trunk/lib/msun/src/s_crealf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_crealf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004 Stefan Farfeleder
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/msun/src/s_crealf.c 129864 2004-05-30 09:21:56Z stefanf $
*/
#include <complex.h>
Modified: trunk/lib/msun/src/s_creall.c
===================================================================
--- trunk/lib/msun/src/s_creall.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_creall.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004 Stefan Farfeleder
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/msun/src/s_creall.c 129864 2004-05-30 09:21:56Z stefanf $
*/
#include <complex.h>
Added: trunk/lib/msun/src/s_csinh.c
===================================================================
--- trunk/lib/msun/src/s_csinh.c (rev 0)
+++ trunk/lib/msun/src/s_csinh.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -0,0 +1,157 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl
+ * 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 unmodified, 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 ``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 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.
+ */
+
+/*
+ * Hyperbolic sine of a complex argument z = x + i y.
+ *
+ * sinh(z) = sinh(x+iy)
+ * = sinh(x) cos(y) + i cosh(x) sin(y).
+ *
+ * Exceptional values are noted in the comments within the source code.
+ * These values and the return value were taken from n1124.pdf.
+ * The sign of the result for some exceptional values is unspecified but
+ * must satisfy both sinh(conj(z)) == conj(sinh(z)) and sinh(-z) == -sinh(z).
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_csinh.c 284810 2015-06-25 13:01:10Z tijl $");
+
+#include <complex.h>
+#include <math.h>
+
+#include "math_private.h"
+
+static const double huge = 0x1p1023;
+
+double complex
+csinh(double complex z)
+{
+ double x, y, h;
+ int32_t hx, hy, ix, iy, lx, ly;
+
+ x = creal(z);
+ y = cimag(z);
+
+ EXTRACT_WORDS(hx, lx, x);
+ EXTRACT_WORDS(hy, ly, y);
+
+ ix = 0x7fffffff & hx;
+ iy = 0x7fffffff & hy;
+
+ /* Handle the nearly-non-exceptional cases where x and y are finite. */
+ if (ix < 0x7ff00000 && iy < 0x7ff00000) {
+ if ((iy | ly) == 0)
+ return (CMPLX(sinh(x), y));
+ if (ix < 0x40360000) /* |x| < 22: normal case */
+ return (CMPLX(sinh(x) * cos(y), cosh(x) * sin(y)));
+
+ /* |x| >= 22, so cosh(x) ~= exp(|x|) */
+ if (ix < 0x40862e42) {
+ /* x < 710: exp(|x|) won't overflow */
+ h = exp(fabs(x)) * 0.5;
+ return (CMPLX(copysign(h, x) * cos(y), h * sin(y)));
+ } else if (ix < 0x4096bbaa) {
+ /* x < 1455: scale to avoid overflow */
+ z = __ldexp_cexp(CMPLX(fabs(x), y), -1);
+ return (CMPLX(creal(z) * copysign(1, x), cimag(z)));
+ } else {
+ /* x >= 1455: the result always overflows */
+ h = huge * x;
+ return (CMPLX(h * cos(y), h * h * sin(y)));
+ }
+ }
+
+ /*
+ * sinh(+-0 +- I Inf) = +-0 + I dNaN.
+ * The sign of 0 in the result is unspecified. Choice = same sign
+ * as the argument. Raise the invalid floating-point exception.
+ *
+ * sinh(+-0 +- I NaN) = +-0 + I d(NaN).
+ * The sign of 0 in the result is unspecified. Choice = same sign
+ * as the argument.
+ */
+ if ((ix | lx) == 0) /* && iy >= 0x7ff00000 */
+ return (CMPLX(x, y - y));
+
+ /*
+ * sinh(+-Inf +- I 0) = +-Inf + I +-0.
+ *
+ * sinh(NaN +- I 0) = d(NaN) + I +-0.
+ */
+ if ((iy | ly) == 0) /* && ix >= 0x7ff00000 */
+ return (CMPLX(x + x, y));
+
+ /*
+ * sinh(x +- I Inf) = dNaN + I dNaN.
+ * Raise the invalid floating-point exception for finite nonzero x.
+ *
+ * sinh(x + I NaN) = d(NaN) + I d(NaN).
+ * Optionally raises the invalid floating-point exception for finite
+ * nonzero x. Choice = don't raise (except for signaling NaNs).
+ */
+ if (ix < 0x7ff00000) /* && iy >= 0x7ff00000 */
+ return (CMPLX(y - y, y - y));
+
+ /*
+ * sinh(+-Inf + I NaN) = +-Inf + I d(NaN).
+ * The sign of Inf in the result is unspecified. Choice = same sign
+ * as the argument.
+ *
+ * sinh(+-Inf +- I Inf) = +-Inf + I dNaN.
+ * The sign of Inf in the result is unspecified. Choice = same sign
+ * as the argument. Raise the invalid floating-point exception.
+ *
+ * sinh(+-Inf + I y) = +-Inf cos(y) + I Inf sin(y)
+ */
+ if (ix == 0x7ff00000 && lx == 0) {
+ if (iy >= 0x7ff00000)
+ return (CMPLX(x, y - y));
+ return (CMPLX(x * cos(y), INFINITY * sin(y)));
+ }
+
+ /*
+ * sinh(NaN1 + I NaN2) = d(NaN1, NaN2) + I d(NaN1, NaN2).
+ *
+ * sinh(NaN +- I Inf) = d(NaN, dNaN) + I d(NaN, dNaN).
+ * Optionally raises the invalid floating-point exception.
+ * Choice = raise.
+ *
+ * sinh(NaN + I y) = d(NaN) + I d(NaN).
+ * Optionally raises the invalid floating-point exception for finite
+ * nonzero y. Choice = don't raise (except for signaling NaNs).
+ */
+ return (CMPLX((x + x) * (y - y), (x * x) * (y - y)));
+}
+
+double complex
+csin(double complex z)
+{
+
+ /* csin(z) = -I * csinh(I * z) = I * conj(csinh(I * conj(z))). */
+ z = csinh(CMPLX(cimag(z), creal(z)));
+ return (CMPLX(cimag(z), creal(z)));
+}
Property changes on: trunk/lib/msun/src/s_csinh.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/lib/msun/src/s_csinhf.c
===================================================================
--- trunk/lib/msun/src/s_csinhf.c (rev 0)
+++ trunk/lib/msun/src/s_csinhf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -0,0 +1,103 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl
+ * 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 unmodified, 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 ``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 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.
+ */
+
+/*
+ * Float version of csinh(). See s_csinh.c for details.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_csinhf.c 284810 2015-06-25 13:01:10Z tijl $");
+
+#include <complex.h>
+#include <math.h>
+
+#include "math_private.h"
+
+static const float huge = 0x1p127;
+
+float complex
+csinhf(float complex z)
+{
+ float x, y, h;
+ int32_t hx, hy, ix, iy;
+
+ x = crealf(z);
+ y = cimagf(z);
+
+ GET_FLOAT_WORD(hx, x);
+ GET_FLOAT_WORD(hy, y);
+
+ ix = 0x7fffffff & hx;
+ iy = 0x7fffffff & hy;
+
+ if (ix < 0x7f800000 && iy < 0x7f800000) {
+ if (iy == 0)
+ return (CMPLXF(sinhf(x), y));
+ if (ix < 0x41100000) /* |x| < 9: normal case */
+ return (CMPLXF(sinhf(x) * cosf(y), coshf(x) * sinf(y)));
+
+ /* |x| >= 9, so cosh(x) ~= exp(|x|) */
+ if (ix < 0x42b17218) {
+ /* x < 88.7: expf(|x|) won't overflow */
+ h = expf(fabsf(x)) * 0.5F;
+ return (CMPLXF(copysignf(h, x) * cosf(y), h * sinf(y)));
+ } else if (ix < 0x4340b1e7) {
+ /* x < 192.7: scale to avoid overflow */
+ z = __ldexp_cexpf(CMPLXF(fabsf(x), y), -1);
+ return (CMPLXF(crealf(z) * copysignf(1, x), cimagf(z)));
+ } else {
+ /* x >= 192.7: the result always overflows */
+ h = huge * x;
+ return (CMPLXF(h * cosf(y), h * h * sinf(y)));
+ }
+ }
+
+ if (ix == 0) /* && iy >= 0x7f800000 */
+ return (CMPLXF(x, y - y));
+
+ if (iy == 0) /* && ix >= 0x7f800000 */
+ return (CMPLXF(x + x, y));
+
+ if (ix < 0x7f800000) /* && iy >= 0x7f800000 */
+ return (CMPLXF(y - y, y - y));
+
+ if (ix == 0x7f800000) {
+ if (iy >= 0x7f800000)
+ return (CMPLXF(x, y - y));
+ return (CMPLXF(x * cosf(y), INFINITY * sinf(y)));
+ }
+
+ return (CMPLXF((x + x) * (y - y), (x * x) * (y - y)));
+}
+
+float complex
+csinf(float complex z)
+{
+
+ z = csinhf(CMPLXF(cimagf(z), crealf(z)));
+ return (CMPLXF(cimagf(z), crealf(z)));
+}
Property changes on: trunk/lib/msun/src/s_csinhf.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/lib/msun/src/s_csqrt.c
===================================================================
--- trunk/lib/msun/src/s_csqrt.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_csqrt.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2007 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_csqrt.c 284810 2015-06-25 13:01:10Z tijl $");
#include <complex.h>
#include <float.h>
@@ -58,12 +59,12 @@
/* Handle special cases. */
if (z == 0)
- return (cpack(0, b));
+ return (CMPLX(0, b));
if (isinf(b))
- return (cpack(INFINITY, b));
+ return (CMPLX(INFINITY, b));
if (isnan(a)) {
t = (b - b) / (b - b); /* raise invalid if b is not a NaN */
- return (cpack(a, t)); /* return NaN + NaN i */
+ return (CMPLX(a, t)); /* return NaN + NaN i */
}
if (isinf(a)) {
/*
@@ -73,9 +74,9 @@
* csqrt(-inf + y i) = 0 + inf i
*/
if (signbit(a))
- return (cpack(fabs(b - b), copysign(a, b)));
+ return (CMPLX(fabs(b - b), copysign(a, b)));
else
- return (cpack(a, copysign(b - b, b)));
+ return (CMPLX(a, copysign(b - b, b)));
}
/*
* The remaining special case (b is NaN) is handled just fine by
@@ -94,10 +95,10 @@
/* Algorithm 312, CACM vol 10, Oct 1967. */
if (a >= 0) {
t = sqrt((a + hypot(a, b)) * 0.5);
- result = cpack(t, b / (2 * t));
+ result = CMPLX(t, b / (2 * t));
} else {
t = sqrt((-a + hypot(a, b)) * 0.5);
- result = cpack(fabs(b) / (2 * t), copysign(t, b));
+ result = CMPLX(fabs(b) / (2 * t), copysign(t, b));
}
/* Rescale. */
Modified: trunk/lib/msun/src/s_csqrtf.c
===================================================================
--- trunk/lib/msun/src/s_csqrtf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_csqrtf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2007 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_csqrtf.c 284810 2015-06-25 13:01:10Z tijl $");
#include <complex.h>
#include <math.h>
@@ -49,12 +50,12 @@
/* Handle special cases. */
if (z == 0)
- return (cpackf(0, b));
+ return (CMPLXF(0, b));
if (isinf(b))
- return (cpackf(INFINITY, b));
+ return (CMPLXF(INFINITY, b));
if (isnan(a)) {
t = (b - b) / (b - b); /* raise invalid if b is not a NaN */
- return (cpackf(a, t)); /* return NaN + NaN i */
+ return (CMPLXF(a, t)); /* return NaN + NaN i */
}
if (isinf(a)) {
/*
@@ -64,9 +65,9 @@
* csqrtf(-inf + y i) = 0 + inf i
*/
if (signbit(a))
- return (cpackf(fabsf(b - b), copysignf(a, b)));
+ return (CMPLXF(fabsf(b - b), copysignf(a, b)));
else
- return (cpackf(a, copysignf(b - b, b)));
+ return (CMPLXF(a, copysignf(b - b, b)));
}
/*
* The remaining special case (b is NaN) is handled just fine by
@@ -80,9 +81,9 @@
*/
if (a >= 0) {
t = sqrt((a + hypot(a, b)) * 0.5);
- return (cpackf(t, b / (2.0 * t)));
+ return (CMPLXF(t, b / (2.0 * t)));
} else {
t = sqrt((-a + hypot(a, b)) * 0.5);
- return (cpackf(fabsf(b) / (2.0 * t), copysignf(t, b)));
+ return (CMPLXF(fabsf(b) / (2.0 * t), copysignf(t, b)));
}
}
Modified: trunk/lib/msun/src/s_csqrtl.c
===================================================================
--- trunk/lib/msun/src/s_csqrtl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_csqrtl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2007-2008 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_csqrtl.c 284810 2015-06-25 13:01:10Z tijl $");
#include <complex.h>
#include <float.h>
@@ -58,12 +59,12 @@
/* Handle special cases. */
if (z == 0)
- return (cpackl(0, b));
+ return (CMPLXL(0, b));
if (isinf(b))
- return (cpackl(INFINITY, b));
+ return (CMPLXL(INFINITY, b));
if (isnan(a)) {
t = (b - b) / (b - b); /* raise invalid if b is not a NaN */
- return (cpackl(a, t)); /* return NaN + NaN i */
+ return (CMPLXL(a, t)); /* return NaN + NaN i */
}
if (isinf(a)) {
/*
@@ -73,9 +74,9 @@
* csqrt(-inf + y i) = 0 + inf i
*/
if (signbit(a))
- return (cpackl(fabsl(b - b), copysignl(a, b)));
+ return (CMPLXL(fabsl(b - b), copysignl(a, b)));
else
- return (cpackl(a, copysignl(b - b, b)));
+ return (CMPLXL(a, copysignl(b - b, b)));
}
/*
* The remaining special case (b is NaN) is handled just fine by
@@ -94,10 +95,10 @@
/* Algorithm 312, CACM vol 10, Oct 1967. */
if (a >= 0) {
t = sqrtl((a + hypotl(a, b)) * 0.5);
- result = cpackl(t, b / (2 * t));
+ result = CMPLXL(t, b / (2 * t));
} else {
t = sqrtl((-a + hypotl(a, b)) * 0.5);
- result = cpackl(fabsl(b) / (2 * t), copysignl(t, b));
+ result = CMPLXL(fabsl(b) / (2 * t), copysignl(t, b));
}
/* Rescale. */
Added: trunk/lib/msun/src/s_ctanh.c
===================================================================
--- trunk/lib/msun/src/s_ctanh.c (rev 0)
+++ trunk/lib/msun/src/s_ctanh.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -0,0 +1,146 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2011 David Schultz
+ * 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 unmodified, 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 ``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 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.
+ */
+
+/*
+ * Hyperbolic tangent of a complex argument z = x + I y.
+ *
+ * The algorithm is from:
+ *
+ * W. Kahan. Branch Cuts for Complex Elementary Functions or Much
+ * Ado About Nothing's Sign Bit. In The State of the Art in
+ * Numerical Analysis, pp. 165 ff. Iserles and Powell, eds., 1987.
+ *
+ * Method:
+ *
+ * Let t = tan(x)
+ * beta = 1/cos^2(y)
+ * s = sinh(x)
+ * rho = cosh(x)
+ *
+ * We have:
+ *
+ * tanh(z) = sinh(z) / cosh(z)
+ *
+ * sinh(x) cos(y) + I cosh(x) sin(y)
+ * = ---------------------------------
+ * cosh(x) cos(y) + I sinh(x) sin(y)
+ *
+ * cosh(x) sinh(x) / cos^2(y) + I tan(y)
+ * = -------------------------------------
+ * 1 + sinh^2(x) / cos^2(y)
+ *
+ * beta rho s + I t
+ * = ----------------
+ * 1 + beta s^2
+ *
+ * Modifications:
+ *
+ * I omitted the original algorithm's handling of overflow in tan(x) after
+ * verifying with nearpi.c that this can't happen in IEEE single or double
+ * precision. I also handle large x differently.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_ctanh.c 284810 2015-06-25 13:01:10Z tijl $");
+
+#include <complex.h>
+#include <math.h>
+
+#include "math_private.h"
+
+double complex
+ctanh(double complex z)
+{
+ double x, y;
+ double t, beta, s, rho, denom;
+ uint32_t hx, ix, lx;
+
+ x = creal(z);
+ y = cimag(z);
+
+ EXTRACT_WORDS(hx, lx, x);
+ ix = hx & 0x7fffffff;
+
+ /*
+ * ctanh(NaN +- I 0) = d(NaN) +- I 0
+ *
+ * ctanh(NaN + I y) = d(NaN,y) + I d(NaN,y) for y != 0
+ *
+ * The imaginary part has the sign of x*sin(2*y), but there's no
+ * special effort to get this right.
+ *
+ * ctanh(+-Inf +- I Inf) = +-1 +- I 0
+ *
+ * ctanh(+-Inf + I y) = +-1 + I 0 sin(2y) for y finite
+ *
+ * The imaginary part of the sign is unspecified. This special
+ * case is only needed to avoid a spurious invalid exception when
+ * y is infinite.
+ */
+ if (ix >= 0x7ff00000) {
+ if ((ix & 0xfffff) | lx) /* x is NaN */
+ return (CMPLX((x + 0) * (y + 0),
+ y == 0 ? y : (x + 0) * (y + 0)));
+ SET_HIGH_WORD(x, hx - 0x40000000); /* x = copysign(1, x) */
+ return (CMPLX(x, copysign(0, isinf(y) ? y : sin(y) * cos(y))));
+ }
+
+ /*
+ * ctanh(x + I NaN) = d(NaN) + I d(NaN)
+ * ctanh(x +- I Inf) = dNaN + I dNaN
+ */
+ if (!isfinite(y))
+ return (CMPLX(y - y, y - y));
+
+ /*
+ * ctanh(+-huge +- I y) ~= +-1 +- I 2sin(2y)/exp(2x), using the
+ * approximation sinh^2(huge) ~= exp(2*huge) / 4.
+ * We use a modified formula to avoid spurious overflow.
+ */
+ if (ix >= 0x40360000) { /* |x| >= 22 */
+ double exp_mx = exp(-fabs(x));
+ return (CMPLX(copysign(1, x),
+ 4 * sin(y) * cos(y) * exp_mx * exp_mx));
+ }
+
+ /* Kahan's algorithm */
+ t = tan(y);
+ beta = 1.0 + t * t; /* = 1 / cos^2(y) */
+ s = sinh(x);
+ rho = sqrt(1 + s * s); /* = cosh(x) */
+ denom = 1 + beta * s * s;
+ return (CMPLX((beta * rho * s) / denom, t / denom));
+}
+
+double complex
+ctan(double complex z)
+{
+
+ /* ctan(z) = -I * ctanh(I * z) = I * conj(ctanh(I * conj(z))) */
+ z = ctanh(CMPLX(cimag(z), creal(z)));
+ return (CMPLX(cimag(z), creal(z)));
+}
Property changes on: trunk/lib/msun/src/s_ctanh.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/lib/msun/src/s_ctanhf.c
===================================================================
--- trunk/lib/msun/src/s_ctanhf.c (rev 0)
+++ trunk/lib/msun/src/s_ctanhf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -0,0 +1,86 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2011 David Schultz
+ * 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 unmodified, 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 ``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 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.
+ */
+
+/*
+ * Hyperbolic tangent of a complex argument z. See s_ctanh.c for details.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_ctanhf.c 284810 2015-06-25 13:01:10Z tijl $");
+
+#include <complex.h>
+#include <math.h>
+
+#include "math_private.h"
+
+float complex
+ctanhf(float complex z)
+{
+ float x, y;
+ float t, beta, s, rho, denom;
+ uint32_t hx, ix;
+
+ x = crealf(z);
+ y = cimagf(z);
+
+ GET_FLOAT_WORD(hx, x);
+ ix = hx & 0x7fffffff;
+
+ if (ix >= 0x7f800000) {
+ if (ix & 0x7fffff)
+ return (CMPLXF((x + 0) * (y + 0),
+ y == 0 ? y : (x + 0) * (y + 0)));
+ SET_FLOAT_WORD(x, hx - 0x40000000);
+ return (CMPLXF(x,
+ copysignf(0, isinf(y) ? y : sinf(y) * cosf(y))));
+ }
+
+ if (!isfinite(y))
+ return (CMPLXF(y - y, y - y));
+
+ if (ix >= 0x41300000) { /* |x| >= 11 */
+ float exp_mx = expf(-fabsf(x));
+ return (CMPLXF(copysignf(1, x),
+ 4 * sinf(y) * cosf(y) * exp_mx * exp_mx));
+ }
+
+ t = tanf(y);
+ beta = 1.0 + t * t;
+ s = sinhf(x);
+ rho = sqrtf(1 + s * s);
+ denom = 1 + beta * s * s;
+ return (CMPLXF((beta * rho * s) / denom, t / denom));
+}
+
+float complex
+ctanf(float complex z)
+{
+
+ z = ctanhf(CMPLXF(cimagf(z), crealf(z)));
+ return (CMPLXF(cimagf(z), crealf(z)));
+}
+
Property changes on: trunk/lib/msun/src/s_ctanhf.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/lib/msun/src/s_erf.c
===================================================================
--- trunk/lib/msun/src/s_erf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_erf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)s_erf.c 5.1 93/09/24 */
/*
* ====================================================
@@ -11,7 +12,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_erf.c 271779 2014-09-18 15:10:22Z tijl $");
/* double erf(double x)
* double erfc(double x)
@@ -111,18 +112,25 @@
#include "math.h"
#include "math_private.h"
+/* XXX Prevent compilers from erroneously constant folding: */
+static const volatile double tiny= 1e-300;
+
static const double
-tiny = 1e-300,
-half= 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */
-one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
-two = 2.00000000000000000000e+00, /* 0x40000000, 0x00000000 */
- /* c = (float)0.84506291151 */
+half= 0.5,
+one = 1,
+two = 2,
+/* c = (float)0.84506291151 */
erx = 8.45062911510467529297e-01, /* 0x3FEB0AC1, 0x60000000 */
/*
- * Coefficients for approximation to erf on [0,0.84375]
+ * In the domain [0, 2**-28], only the first term in the power series
+ * expansion of erf(x) is used. The magnitude of the first neglected
+ * terms is less than 2**-84.
*/
efx = 1.28379167095512586316e-01, /* 0x3FC06EBA, 0x8214DB69 */
efx8= 1.02703333676410069053e+00, /* 0x3FF06EBA, 0x8214DB69 */
+/*
+ * Coefficients for approximation to erf on [0,0.84375]
+ */
pp0 = 1.28379167095512558561e-01, /* 0x3FC06EBA, 0x8214DB68 */
pp1 = -3.25042107247001499370e-01, /* 0xBFD4CD7D, 0x691CB913 */
pp2 = -2.84817495755985104766e-02, /* 0xBF9D2A51, 0xDBD7194F */
@@ -134,7 +142,7 @@
qq4 = 1.32494738004321644526e-04, /* 0x3F215DC9, 0x221C1A10 */
qq5 = -3.96022827877536812320e-06, /* 0xBED09C43, 0x42A26120 */
/*
- * Coefficients for approximation to erf in [0.84375,1.25]
+ * Coefficients for approximation to erf in [0.84375,1.25]
*/
pa0 = -2.36211856075265944077e-03, /* 0xBF6359B8, 0xBEF77538 */
pa1 = 4.14856118683748331666e-01, /* 0x3FDA8D00, 0xAD92B34D */
@@ -150,7 +158,7 @@
qa5 = 1.36370839120290507362e-02, /* 0x3F8BEDC2, 0x6B51DD1C */
qa6 = 1.19844998467991074170e-02, /* 0x3F888B54, 0x5735151D */
/*
- * Coefficients for approximation to erfc in [1.25,1/0.35]
+ * Coefficients for approximation to erfc in [1.25,1/0.35]
*/
ra0 = -9.86494403484714822705e-03, /* 0xBF843412, 0x600D6435 */
ra1 = -6.93858572707181764372e-01, /* 0xBFE63416, 0xE4BA7360 */
@@ -169,7 +177,7 @@
sa7 = 6.57024977031928170135e+00, /* 0x401A47EF, 0x8E484A93 */
sa8 = -6.04244152148580987438e-02, /* 0xBFAEEFF2, 0xEE749A62 */
/*
- * Coefficients for approximation to erfc in [1/.35,28]
+ * Coefficients for approximation to erfc in [1/.35,28]
*/
rb0 = -9.86494292470009928597e-03, /* 0xBF843412, 0x39E86F4A */
rb1 = -7.99283237680523006574e-01, /* 0xBFE993BA, 0x70C285DE */
@@ -201,7 +209,7 @@
if(ix < 0x3feb0000) { /* |x|<0.84375 */
if(ix < 0x3e300000) { /* |x|<2**-28 */
if (ix < 0x00800000)
- return 0.125*(8.0*x+efx8*x); /*avoid underflow */
+ return (8*x+efx8*x)/8; /* avoid spurious underflow */
return x + efx*x;
}
z = x*x;
@@ -222,15 +230,12 @@
x = fabs(x);
s = one/(x*x);
if(ix< 0x4006DB6E) { /* |x| < 1/0.35 */
- R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(
- ra5+s*(ra6+s*ra7))))));
- S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(
- sa5+s*(sa6+s*(sa7+s*sa8)))))));
+ R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(ra5+s*(ra6+s*ra7))))));
+ S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(sa5+s*(sa6+s*(sa7+
+ s*sa8)))))));
} else { /* |x| >= 1/0.35 */
- R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(
- rb5+s*rb6)))));
- S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
- sb5+s*(sb6+s*sb7))))));
+ R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(rb5+s*rb6)))));
+ S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(sb5+s*(sb6+s*sb7))))));
}
z = x;
SET_LOW_WORD(z,0);
@@ -238,6 +243,10 @@
if(hx>=0) return one-r/x; else return r/x-one;
}
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(erf, erfl);
+#endif
+
double
erfc(double x)
{
@@ -279,23 +288,23 @@
x = fabs(x);
s = one/(x*x);
if(ix< 0x4006DB6D) { /* |x| < 1/.35 ~ 2.857143*/
- R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(
- ra5+s*(ra6+s*ra7))))));
- S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(
- sa5+s*(sa6+s*(sa7+s*sa8)))))));
+ R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(ra5+s*(ra6+s*ra7))))));
+ S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(sa5+s*(sa6+s*(sa7+
+ s*sa8)))))));
} else { /* |x| >= 1/.35 ~ 2.857143 */
if(hx<0&&ix>=0x40180000) return two-tiny;/* x < -6 */
- R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(
- rb5+s*rb6)))));
- S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
- sb5+s*(sb6+s*sb7))))));
+ R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(rb5+s*rb6)))));
+ S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(sb5+s*(sb6+s*sb7))))));
}
z = x;
SET_LOW_WORD(z,0);
- r = __ieee754_exp(-z*z-0.5625)*
- __ieee754_exp((z-x)*(z+x)+R/S);
+ r = __ieee754_exp(-z*z-0.5625)*__ieee754_exp((z-x)*(z+x)+R/S);
if(hx>0) return r/x; else return two-r/x;
} else {
if(hx>0) return tiny*tiny; else return two-tiny;
}
}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(erfc, erfcl);
+#endif
Modified: trunk/lib/msun/src/s_erff.c
===================================================================
--- trunk/lib/msun/src/s_erff.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_erff.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* s_erff.c -- float version of s_erf.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,85 +15,68 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_erff.c 271779 2014-09-18 15:10:22Z tijl $");
#include "math.h"
#include "math_private.h"
+/* XXX Prevent compilers from erroneously constant folding: */
+static const volatile float tiny = 1e-30;
+
static const float
-tiny = 1e-30,
-half= 5.0000000000e-01, /* 0x3F000000 */
-one = 1.0000000000e+00, /* 0x3F800000 */
-two = 2.0000000000e+00, /* 0x40000000 */
- /* c = (subfloat)0.84506291151 */
-erx = 8.4506291151e-01, /* 0x3f58560b */
+half= 0.5,
+one = 1,
+two = 2,
+erx = 8.42697144e-01, /* 0x3f57bb00 */
/*
- * Coefficients for approximation to erf on [0,0.84375]
+ * In the domain [0, 2**-14], only the first term in the power series
+ * expansion of erf(x) is used. The magnitude of the first neglected
+ * terms is less than 2**-42.
*/
-efx = 1.2837916613e-01, /* 0x3e0375d4 */
-efx8= 1.0270333290e+00, /* 0x3f8375d4 */
-pp0 = 1.2837916613e-01, /* 0x3e0375d4 */
-pp1 = -3.2504209876e-01, /* 0xbea66beb */
-pp2 = -2.8481749818e-02, /* 0xbce9528f */
-pp3 = -5.7702702470e-03, /* 0xbbbd1489 */
-pp4 = -2.3763017452e-05, /* 0xb7c756b1 */
-qq1 = 3.9791721106e-01, /* 0x3ecbbbce */
-qq2 = 6.5022252500e-02, /* 0x3d852a63 */
-qq3 = 5.0813062117e-03, /* 0x3ba68116 */
-qq4 = 1.3249473704e-04, /* 0x390aee49 */
-qq5 = -3.9602282413e-06, /* 0xb684e21a */
+efx = 1.28379166e-01, /* 0x3e0375d4 */
+efx8= 1.02703333e+00, /* 0x3f8375d4 */
/*
- * Coefficients for approximation to erf in [0.84375,1.25]
+ * Domain [0, 0.84375], range ~[-5.4419e-10, 5.5179e-10]:
+ * |(erf(x) - x)/x - pp(x)/qq(x)| < 2**-31
*/
-pa0 = -2.3621185683e-03, /* 0xbb1acdc6 */
-pa1 = 4.1485610604e-01, /* 0x3ed46805 */
-pa2 = -3.7220788002e-01, /* 0xbebe9208 */
-pa3 = 3.1834661961e-01, /* 0x3ea2fe54 */
-pa4 = -1.1089469492e-01, /* 0xbde31cc2 */
-pa5 = 3.5478305072e-02, /* 0x3d1151b3 */
-pa6 = -2.1663755178e-03, /* 0xbb0df9c0 */
-qa1 = 1.0642088205e-01, /* 0x3dd9f331 */
-qa2 = 5.4039794207e-01, /* 0x3f0a5785 */
-qa3 = 7.1828655899e-02, /* 0x3d931ae7 */
-qa4 = 1.2617121637e-01, /* 0x3e013307 */
-qa5 = 1.3637083583e-02, /* 0x3c5f6e13 */
-qa6 = 1.1984500103e-02, /* 0x3c445aa3 */
+pp0 = 1.28379166e-01, /* 0x3e0375d4 */
+pp1 = -3.36030394e-01, /* 0xbeac0c2d */
+pp2 = -1.86261395e-03, /* 0xbaf422f4 */
+qq1 = 3.12324315e-01, /* 0x3e9fe8f9 */
+qq2 = 2.16070414e-02, /* 0x3cb10140 */
+qq3 = -1.98859372e-03, /* 0xbb025311 */
/*
- * Coefficients for approximation to erfc in [1.25,1/0.35]
+ * Domain [0.84375, 1.25], range ~[-1.023e-9, 1.023e-9]:
+ * |(erf(x) - erx) - pa(x)/qa(x)| < 2**-31
*/
-ra0 = -9.8649440333e-03, /* 0xbc21a093 */
-ra1 = -6.9385856390e-01, /* 0xbf31a0b7 */
-ra2 = -1.0558626175e+01, /* 0xc128f022 */
-ra3 = -6.2375331879e+01, /* 0xc2798057 */
-ra4 = -1.6239666748e+02, /* 0xc322658c */
-ra5 = -1.8460508728e+02, /* 0xc3389ae7 */
-ra6 = -8.1287437439e+01, /* 0xc2a2932b */
-ra7 = -9.8143291473e+00, /* 0xc11d077e */
-sa1 = 1.9651271820e+01, /* 0x419d35ce */
-sa2 = 1.3765776062e+02, /* 0x4309a863 */
-sa3 = 4.3456588745e+02, /* 0x43d9486f */
-sa4 = 6.4538726807e+02, /* 0x442158c9 */
-sa5 = 4.2900814819e+02, /* 0x43d6810b */
-sa6 = 1.0863500214e+02, /* 0x42d9451f */
-sa7 = 6.5702495575e+00, /* 0x40d23f7c */
-sa8 = -6.0424413532e-02, /* 0xbd777f97 */
+pa0 = 3.65041046e-06, /* 0x3674f993 */
+pa1 = 4.15109307e-01, /* 0x3ed48935 */
+pa2 = -2.09395722e-01, /* 0xbe566bd5 */
+pa3 = 8.67677554e-02, /* 0x3db1b34b */
+qa1 = 4.95560974e-01, /* 0x3efdba2b */
+qa2 = 3.71248513e-01, /* 0x3ebe1449 */
+qa3 = 3.92478965e-02, /* 0x3d20c267 */
/*
- * Coefficients for approximation to erfc in [1/.35,28]
+ * Domain [1.25,1/0.35], range ~[-4.821e-9, 4.927e-9]:
+ * |log(x*erfc(x)) + x**2 + 0.5625 - ra(x)/sa(x)| < 2**-28
*/
-rb0 = -9.8649431020e-03, /* 0xbc21a092 */
-rb1 = -7.9928326607e-01, /* 0xbf4c9dd4 */
-rb2 = -1.7757955551e+01, /* 0xc18e104b */
-rb3 = -1.6063638306e+02, /* 0xc320a2ea */
-rb4 = -6.3756646729e+02, /* 0xc41f6441 */
-rb5 = -1.0250950928e+03, /* 0xc480230b */
-rb6 = -4.8351919556e+02, /* 0xc3f1c275 */
-sb1 = 3.0338060379e+01, /* 0x41f2b459 */
-sb2 = 3.2579251099e+02, /* 0x43a2e571 */
-sb3 = 1.5367296143e+03, /* 0x44c01759 */
-sb4 = 3.1998581543e+03, /* 0x4547fdbb */
-sb5 = 2.5530502930e+03, /* 0x451f90ce */
-sb6 = 4.7452853394e+02, /* 0x43ed43a7 */
-sb7 = -2.2440952301e+01; /* 0xc1b38712 */
+ra0 = -9.88156721e-03, /* 0xbc21e64c */
+ra1 = -5.43658376e-01, /* 0xbf0b2d32 */
+ra2 = -1.66828310e+00, /* 0xbfd58a4d */
+ra3 = -6.91554189e-01, /* 0xbf3109b2 */
+sa1 = 4.48581553e+00, /* 0x408f8bcd */
+sa2 = 4.10799170e+00, /* 0x408374ab */
+sa3 = 5.53855181e-01, /* 0x3f0dc974 */
+/*
+ * Domain [2.85715, 11], range ~[-1.484e-9, 1.505e-9]:
+ * |log(x*erfc(x)) + x**2 + 0.5625 - rb(x)/sb(x)| < 2**-30
+ */
+rb0 = -9.86496918e-03, /* 0xbc21a0ae */
+rb1 = -5.48049808e-01, /* 0xbf0c4cfe */
+rb2 = -1.84115684e+00, /* 0xbfebab07 */
+sb1 = 4.87132740e+00, /* 0x409be1ea */
+sb2 = 3.04982710e+00, /* 0x4043305e */
+sb3 = -7.61900663e-01; /* 0xbf430bec */
float
erff(float x)
@@ -101,49 +85,43 @@
float R,S,P,Q,s,y,z,r;
GET_FLOAT_WORD(hx,x);
ix = hx&0x7fffffff;
- if(ix>=0x7f800000) { /* erf(nan)=nan */
+ if(ix>=0x7f800000) { /* erff(nan)=nan */
i = ((u_int32_t)hx>>31)<<1;
- return (float)(1-i)+one/x; /* erf(+-inf)=+-1 */
+ return (float)(1-i)+one/x; /* erff(+-inf)=+-1 */
}
if(ix < 0x3f580000) { /* |x|<0.84375 */
- if(ix < 0x31800000) { /* |x|<2**-28 */
- if (ix < 0x04000000)
- /*avoid underflow */
- return (float)0.125*((float)8.0*x+efx8*x);
+ if(ix < 0x38800000) { /* |x|<2**-14 */
+ if (ix < 0x04000000) /* |x|<0x1p-119 */
+ return (8*x+efx8*x)/8; /* avoid spurious underflow */
return x + efx*x;
}
z = x*x;
- r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4)));
- s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5))));
+ r = pp0+z*(pp1+z*pp2);
+ s = one+z*(qq1+z*(qq2+z*qq3));
y = r/s;
return x + x*y;
}
if(ix < 0x3fa00000) { /* 0.84375 <= |x| < 1.25 */
s = fabsf(x)-one;
- P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
- Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
+ P = pa0+s*(pa1+s*(pa2+s*pa3));
+ Q = one+s*(qa1+s*(qa2+s*qa3));
if(hx>=0) return erx + P/Q; else return -erx - P/Q;
}
- if (ix >= 0x40c00000) { /* inf>|x|>=6 */
+ if (ix >= 0x40800000) { /* inf>|x|>=4 */
if(hx>=0) return one-tiny; else return tiny-one;
}
x = fabsf(x);
s = one/(x*x);
- if(ix< 0x4036DB6E) { /* |x| < 1/0.35 */
- R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(
- ra5+s*(ra6+s*ra7))))));
- S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(
- sa5+s*(sa6+s*(sa7+s*sa8)))))));
- } else { /* |x| >= 1/0.35 */
- R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(
- rb5+s*rb6)))));
- S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
- sb5+s*(sb6+s*sb7))))));
+ if(ix< 0x4036db8c) { /* |x| < 2.85715 ~ 1/0.35 */
+ R=ra0+s*(ra1+s*(ra2+s*ra3));
+ S=one+s*(sa1+s*(sa2+s*sa3));
+ } else { /* |x| >= 2.85715 ~ 1/0.35 */
+ R=rb0+s*(rb1+s*rb2);
+ S=one+s*(sb1+s*(sb2+s*sb3));
}
- GET_FLOAT_WORD(ix,x);
- SET_FLOAT_WORD(z,ix&0xfffff000);
- r = __ieee754_expf(-z*z-(float)0.5625)*__ieee754_expf((z-x)*(z+x)+R/S);
+ SET_FLOAT_WORD(z,hx&0xffffe000);
+ r = expf(-z*z-0.5625F)*expf((z-x)*(z+x)+R/S);
if(hx>=0) return one-r/x; else return r/x-one;
}
@@ -154,17 +132,17 @@
float R,S,P,Q,s,y,z,r;
GET_FLOAT_WORD(hx,x);
ix = hx&0x7fffffff;
- if(ix>=0x7f800000) { /* erfc(nan)=nan */
- /* erfc(+-inf)=0,2 */
+ if(ix>=0x7f800000) { /* erfcf(nan)=nan */
+ /* erfcf(+-inf)=0,2 */
return (float)(((u_int32_t)hx>>31)<<1)+one/x;
}
if(ix < 0x3f580000) { /* |x|<0.84375 */
- if(ix < 0x23800000) /* |x|<2**-56 */
+ if(ix < 0x33800000) /* |x|<2**-24 */
return one-x;
z = x*x;
- r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4)));
- s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5))));
+ r = pp0+z*(pp1+z*pp2);
+ s = one+z*(qq1+z*(qq2+z*qq3));
y = r/s;
if(hx < 0x3e800000) { /* x<1/4 */
return one-(x+x*y);
@@ -176,8 +154,8 @@
}
if(ix < 0x3fa00000) { /* 0.84375 <= |x| < 1.25 */
s = fabsf(x)-one;
- P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
- Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
+ P = pa0+s*(pa1+s*(pa2+s*pa3));
+ Q = one+s*(qa1+s*(qa2+s*qa3));
if(hx>=0) {
z = one-erx; return z - P/Q;
} else {
@@ -184,25 +162,19 @@
z = erx+P/Q; return one+z;
}
}
- if (ix < 0x41e00000) { /* |x|<28 */
+ if (ix < 0x41300000) { /* |x|<11 */
x = fabsf(x);
s = one/(x*x);
- if(ix< 0x4036DB6D) { /* |x| < 1/.35 ~ 2.857143*/
- R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(
- ra5+s*(ra6+s*ra7))))));
- S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(
- sa5+s*(sa6+s*(sa7+s*sa8)))))));
- } else { /* |x| >= 1/.35 ~ 2.857143 */
- if(hx<0&&ix>=0x40c00000) return two-tiny;/* x < -6 */
- R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(
- rb5+s*rb6)))));
- S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
- sb5+s*(sb6+s*sb7))))));
+ if(ix< 0x4036db8c) { /* |x| < 2.85715 ~ 1/.35 */
+ R=ra0+s*(ra1+s*(ra2+s*ra3));
+ S=one+s*(sa1+s*(sa2+s*sa3));
+ } else { /* |x| >= 2.85715 ~ 1/.35 */
+ if(hx<0&&ix>=0x40a00000) return two-tiny;/* x < -5 */
+ R=rb0+s*(rb1+s*rb2);
+ S=one+s*(sb1+s*(sb2+s*sb3));
}
- GET_FLOAT_WORD(ix,x);
- SET_FLOAT_WORD(z,ix&0xfffff000);
- r = __ieee754_expf(-z*z-(float)0.5625)*
- __ieee754_expf((z-x)*(z+x)+R/S);
+ SET_FLOAT_WORD(z,hx&0xffffe000);
+ r = expf(-z*z-0.5625F)*expf((z-x)*(z+x)+R/S);
if(hx>0) return r/x; else return two-r/x;
} else {
if(hx>0) return tiny*tiny; else return two-tiny;
Modified: trunk/lib/msun/src/s_exp2.c
===================================================================
--- trunk/lib/msun/src/s_exp2.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_exp2.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2005 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_exp2.c 286688 2015-08-12 19:06:35Z dim $");
#include <float.h>
@@ -36,7 +37,6 @@
#define TBLSIZE (1 << TBLBITS)
static const double
- huge = 0x1p1000,
redux = 0x1.8p52 / TBLSIZE,
P1 = 0x1.62e42fefa39efp-1,
P2 = 0x1.ebfbdff82c575p-3,
@@ -44,7 +44,9 @@
P4 = 0x1.3b2ab88f70400p-7,
P5 = 0x1.5d88003875c74p-10;
-static volatile double twom1000 = 0x1p-1000;
+static volatile double
+ huge = 0x1p1000,
+ twom1000 = 0x1p-1000;
static const double tbl[TBLSIZE * 2] = {
/* exp2(z + eps) eps */
@@ -375,7 +377,7 @@
/* 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)
+ if (k >= -(1021 << 20))
INSERT_WORDS(twopk, 0x3ff00000 + k, 0);
else
INSERT_WORDS(twopkp1000, 0x3ff00000 + k + (1000 << 20), 0);
@@ -382,7 +384,7 @@
r = t + t * z * (P1 + z * (P2 + z * (P3 + z * (P4 + z * P5))));
/* Scale by 2**(k>>20). */
- if(k >= -1021 << 20) {
+ if(k >= -(1021 << 20)) {
if (k == 1024 << 20)
return (r * 2.0 * 0x1p1023);
return (r * twopk);
Modified: trunk/lib/msun/src/s_exp2f.c
===================================================================
--- trunk/lib/msun/src/s_exp2f.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_exp2f.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2005 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_exp2f.c 251024 2013-05-27 08:50:10Z das $");
#include <float.h>
@@ -36,7 +37,6 @@
#define TBLSIZE (1 << TBLBITS)
static const float
- huge = 0x1p100f,
redux = 0x1.8p23f / TBLSIZE,
P1 = 0x1.62e430p-1f,
P2 = 0x1.ebfbe0p-3f,
@@ -43,7 +43,9 @@
P3 = 0x1.c6b348p-5f,
P4 = 0x1.3b2c9cp-7f;
-static volatile float twom100 = 0x1p-100f;
+static volatile float
+ huge = 0x1p100f,
+ twom100 = 0x1p-100f;
static const double exp2ft[TBLSIZE] = {
0x1.6a09e667f3bcdp-1,
Modified: trunk/lib/msun/src/s_expm1.c
===================================================================
--- trunk/lib/msun/src/s_expm1.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_expm1.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)s_expm1.c 5.1 93/09/24 */
/*
* ====================================================
@@ -11,7 +12,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_expm1.c 251343 2013-06-03 19:51:32Z kargl $");
/* expm1(x)
* Returns exp(x)-1, the exponential of x minus 1.
@@ -108,12 +109,13 @@
* to produce the hexadecimal values shown.
*/
+#include <float.h>
+
#include "math.h"
#include "math_private.h"
static const double
one = 1.0,
-huge = 1.0e+300,
tiny = 1.0e-300,
o_threshold = 7.09782712893383973096e+02,/* 0x40862E42, 0xFEFA39EF */
ln2_hi = 6.93147180369123816490e-01,/* 0x3fe62e42, 0xfee00000 */
@@ -126,6 +128,8 @@
Q4 = 4.00821782732936239552e-06, /* 3ED0CFCA 86E65239 */
Q5 = -2.01099218183624371326e-07; /* BE8AFDB7 6E09C32D */
+static volatile double huge = 1.0e+300;
+
double
expm1(double x)
{
@@ -135,7 +139,6 @@
GET_HIGH_WORD(hx,x);
xsb = hx&0x80000000; /* sign bit of x */
- if(xsb==0) y=x; else y= -x; /* y = |x| */
hx &= 0x7fffffff; /* high word of |x| */
/* filter out huge and non-finite argument */
@@ -169,7 +172,7 @@
hi = x - t*ln2_hi; /* t*ln2_hi is exact here */
lo = t*ln2_lo;
}
- x = hi - lo;
+ STRICT_ASSIGN(double, x, hi - lo);
c = (hi-x)-lo;
}
else if(hx < 0x3c900000) { /* when |x|<2**-54, return x */
@@ -214,3 +217,7 @@
}
return y;
}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(expm1, expm1l);
+#endif
Modified: trunk/lib/msun/src/s_expm1f.c
===================================================================
--- trunk/lib/msun/src/s_expm1f.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_expm1f.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* s_expm1f.c -- float version of s_expm1.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,14 +15,15 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_expm1f.c 251024 2013-05-27 08:50:10Z das $");
+#include <float.h>
+
#include "math.h"
#include "math_private.h"
static const float
one = 1.0,
-huge = 1.0e+30,
tiny = 1.0e-30,
o_threshold = 8.8721679688e+01,/* 0x42b17180 */
ln2_hi = 6.9313812256e-01,/* 0x3f317180 */
@@ -35,6 +37,8 @@
Q1 = -3.3333212137e-2, /* -0x888868.0p-28 */
Q2 = 1.5807170421e-3; /* 0xcf3010.0p-33 */
+static volatile float huge = 1.0e+30;
+
float
expm1f(float x)
{
@@ -44,7 +48,6 @@
GET_FLOAT_WORD(hx,x);
xsb = hx&0x80000000; /* sign bit of x */
- if(xsb==0) y=x; else y= -x; /* y = |x| */
hx &= 0x7fffffff; /* high word of |x| */
/* filter out huge and non-finite argument */
@@ -75,7 +78,7 @@
hi = x - t*ln2_hi; /* t*ln2_hi is exact here */
lo = t*ln2_lo;
}
- x = hi - lo;
+ STRICT_ASSIGN(float, x, hi - lo);
c = (hi-x)-lo;
}
else if(hx < 0x33000000) { /* when |x|<2**-25, return x */
Modified: trunk/lib/msun/src/s_fabs.c
===================================================================
--- trunk/lib/msun/src/s_fabs.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_fabs.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)s_fabs.c 5.1 93/09/24 */
/*
* ====================================================
@@ -11,7 +12,7 @@
*/
#ifndef lint
-static char rcsid[] = "$MidnightBSD$";
+static char rcsid[] = "$FreeBSD: stable/10/lib/msun/src/s_fabs.c 97413 2002-05-28 18:15:04Z alfred $";
#endif
/*
Modified: trunk/lib/msun/src/s_fabsf.c
===================================================================
--- trunk/lib/msun/src/s_fabsf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_fabsf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* s_fabsf.c -- float version of s_fabs.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_fabsf.c 176451 2008-02-22 02:30:36Z das $");
/*
* fabsf(x) returns the absolute value of x.
Modified: trunk/lib/msun/src/s_fabsl.c
===================================================================
--- trunk/lib/msun/src/s_fabsl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_fabsl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2003 Dag-Erling Smørgrav
* All rights reserved.
@@ -25,7 +26,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/msun/src/s_fabsl.c 234685 2012-04-25 18:07:35Z des $
*/
#include <math.h>
Modified: trunk/lib/msun/src/s_fdim.c
===================================================================
--- trunk/lib/msun/src/s_fdim.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_fdim.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_fdim.c 131320 2004-06-30 07:04:01Z das $");
#include <math.h>
Modified: trunk/lib/msun/src/s_finite.c
===================================================================
--- trunk/lib/msun/src/s_finite.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_finite.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)s_finite.c 5.1 93/09/24 */
/*
* ====================================================
@@ -11,7 +12,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_finite.c 176451 2008-02-22 02:30:36Z das $");
/*
* finite(x) returns 1 is x is finite, else 0;
Modified: trunk/lib/msun/src/s_finitef.c
===================================================================
--- trunk/lib/msun/src/s_finitef.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_finitef.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* s_finitef.c -- float version of s_finite.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_finitef.c 176451 2008-02-22 02:30:36Z das $");
/*
* finitef(x) returns 1 is x is finite, else 0;
Modified: trunk/lib/msun/src/s_floor.c
===================================================================
--- trunk/lib/msun/src/s_floor.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_floor.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)s_floor.c 5.1 93/09/24 */
/*
* ====================================================
@@ -11,7 +12,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_floor.c 176305 2008-02-15 07:01:40Z bde $");
/*
* floor(x)
Modified: trunk/lib/msun/src/s_floorf.c
===================================================================
--- trunk/lib/msun/src/s_floorf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_floorf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* s_floorf.c -- float version of s_floor.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_floorf.c 176451 2008-02-22 02:30:36Z das $");
/*
* floorf(x)
Modified: trunk/lib/msun/src/s_floorl.c
===================================================================
--- trunk/lib/msun/src/s_floorl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_floorl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -12,7 +13,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_floorl.c 176280 2008-02-14 15:10:34Z bde $");
/*
* floorl(x)
Modified: trunk/lib/msun/src/s_fma.c
===================================================================
--- trunk/lib/msun/src/s_fma.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_fma.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2005-2011 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_fma.c 252170 2013-06-24 19:12:17Z eadler $");
#include <fenv.h>
#include <float.h>
@@ -117,7 +118,7 @@
if (sum.lo != 0) {
EXTRACT_WORD64(hibits, sum.hi);
bits_lost = -((int)(hibits >> 52) & 0x7ff) - scale + 1;
- if (bits_lost != 1 ^ (int)(hibits & 1)) {
+ if ((bits_lost != 1) ^ (int)(hibits & 1)) {
/* hibits += (int)copysign(1.0, sum.hi * sum.lo) */
EXTRACT_WORD64(lobits, sum.lo);
hibits += 1 - (((hibits ^ lobits) >> 62) & 2);
@@ -238,6 +239,8 @@
zs = copysign(DBL_MIN, zs);
fesetround(FE_TONEAREST);
+ /* work around clang bug 8100 */
+ volatile double vxs = xs;
/*
* Basic approach for round-to-nearest:
@@ -247,7 +250,7 @@
* adj = xy.lo + r.lo (inexact; low bit is sticky)
* result = r.hi + adj (correctly rounded)
*/
- xy = dd_mul(xs, ys);
+ xy = dd_mul(vxs, ys);
r = dd_add(xy.hi, zs);
spread = ex + ey;
@@ -268,7 +271,9 @@
* rounding modes.
*/
fesetround(oround);
- adj = r.lo + xy.lo;
+ /* work around clang bug 8100 */
+ volatile double vrlo = r.lo;
+ adj = vrlo + xy.lo;
return (ldexp(r.hi + adj, spread));
}
Modified: trunk/lib/msun/src/s_fmaf.c
===================================================================
--- trunk/lib/msun/src/s_fmaf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_fmaf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2005-2011 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_fmaf.c 226371 2011-10-15 04:16:58Z das $");
#include <fenv.h>
Modified: trunk/lib/msun/src/s_fmal.c
===================================================================
--- trunk/lib/msun/src/s_fmal.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_fmal.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2005-2011 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_fmal.c 252170 2013-06-24 19:12:17Z eadler $");
#include <fenv.h>
#include <float.h>
@@ -113,7 +114,7 @@
if (sum.lo != 0) {
u.e = sum.hi;
bits_lost = -u.bits.exp - scale + 1;
- if (bits_lost != 1 ^ (int)(u.bits.manl & 1))
+ if ((bits_lost != 1) ^ (int)(u.bits.manl & 1))
sum.hi = nextafterl(sum.hi, INFINITY * sum.lo);
}
return (ldexp(sum.hi, scale));
@@ -226,6 +227,8 @@
zs = copysignl(LDBL_MIN, zs);
fesetround(FE_TONEAREST);
+ /* work around clang bug 8100 */
+ volatile long double vxs = xs;
/*
* Basic approach for round-to-nearest:
@@ -235,7 +238,7 @@
* adj = xy.lo + r.lo (inexact; low bit is sticky)
* result = r.hi + adj (correctly rounded)
*/
- xy = dd_mul(xs, ys);
+ xy = dd_mul(vxs, ys);
r = dd_add(xy.hi, zs);
spread = ex + ey;
@@ -256,7 +259,9 @@
* rounding modes.
*/
fesetround(oround);
- adj = r.lo + xy.lo;
+ /* work around clang bug 8100 */
+ volatile long double vrlo = r.lo;
+ adj = vrlo + xy.lo;
return (ldexpl(r.hi + adj, spread));
}
Modified: trunk/lib/msun/src/s_fmax.c
===================================================================
--- trunk/lib/msun/src/s_fmax.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_fmax.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_fmax.c 131320 2004-06-30 07:04:01Z das $");
#include <math.h>
Modified: trunk/lib/msun/src/s_fmaxf.c
===================================================================
--- trunk/lib/msun/src/s_fmaxf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_fmaxf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_fmaxf.c 131320 2004-06-30 07:04:01Z das $");
#include <math.h>
Modified: trunk/lib/msun/src/s_fmaxl.c
===================================================================
--- trunk/lib/msun/src/s_fmaxl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_fmaxl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_fmaxl.c 131320 2004-06-30 07:04:01Z das $");
#include <math.h>
Modified: trunk/lib/msun/src/s_fmin.c
===================================================================
--- trunk/lib/msun/src/s_fmin.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_fmin.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_fmin.c 131320 2004-06-30 07:04:01Z das $");
#include <math.h>
Modified: trunk/lib/msun/src/s_fminf.c
===================================================================
--- trunk/lib/msun/src/s_fminf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_fminf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_fminf.c 131320 2004-06-30 07:04:01Z das $");
#include <math.h>
Modified: trunk/lib/msun/src/s_fminl.c
===================================================================
--- trunk/lib/msun/src/s_fminl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_fminl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_fminl.c 131320 2004-06-30 07:04:01Z das $");
#include <math.h>
Modified: trunk/lib/msun/src/s_frexp.c
===================================================================
--- trunk/lib/msun/src/s_frexp.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_frexp.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)s_frexp.c 5.1 93/09/24 */
/*
* ====================================================
@@ -11,7 +12,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_frexp.c 176451 2008-02-22 02:30:36Z das $");
/*
* for non-zero x
Modified: trunk/lib/msun/src/s_frexpf.c
===================================================================
--- trunk/lib/msun/src/s_frexpf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_frexpf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* s_frexpf.c -- float version of s_frexp.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_frexpf.c 176451 2008-02-22 02:30:36Z das $");
#include "math.h"
#include "math_private.h"
Modified: trunk/lib/msun/src/s_frexpl.c
===================================================================
--- trunk/lib/msun/src/s_frexpl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_frexpl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004-2005 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/msun/src/s_frexpl.c 143213 2005-03-07 04:54:51Z das $
*/
#include <float.h>
Modified: trunk/lib/msun/src/s_ilogb.c
===================================================================
--- trunk/lib/msun/src/s_ilogb.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_ilogb.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)s_ilogb.c 5.1 93/09/24 */
/*
* ====================================================
@@ -11,7 +12,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_ilogb.c 176451 2008-02-22 02:30:36Z das $");
/* ilogb(double x)
* return the binary exponent of non-zero x
Modified: trunk/lib/msun/src/s_ilogbf.c
===================================================================
--- trunk/lib/msun/src/s_ilogbf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_ilogbf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* s_ilogbf.c -- float version of s_ilogb.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_ilogbf.c 176451 2008-02-22 02:30:36Z das $");
#include <limits.h>
Modified: trunk/lib/msun/src/s_ilogbl.c
===================================================================
--- trunk/lib/msun/src/s_ilogbl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_ilogbl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* From: @(#)s_ilogb.c 5.1 93/09/24
* ====================================================
@@ -11,7 +12,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_ilogbl.c 176451 2008-02-22 02:30:36Z das $");
#include <float.h>
#include <limits.h>
Modified: trunk/lib/msun/src/s_isfinite.c
===================================================================
--- trunk/lib/msun/src/s_isfinite.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_isfinite.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/msun/src/s_isfinite.c 131852 2004-07-09 03:32:40Z das $
*/
#include <math.h>
Modified: trunk/lib/msun/src/s_isnan.c
===================================================================
--- trunk/lib/msun/src/s_isnan.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_isnan.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/msun/src/s_isnan.c 242879 2012-11-10 21:22:10Z dim $
*/
#include <math.h>
Modified: trunk/lib/msun/src/s_isnormal.c
===================================================================
--- trunk/lib/msun/src/s_isnormal.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_isnormal.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/msun/src/s_isnormal.c 131852 2004-07-09 03:32:40Z das $
*/
#include <math.h>
Modified: trunk/lib/msun/src/s_llrint.c
===================================================================
--- trunk/lib/msun/src/s_llrint.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_llrint.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,5 +1,6 @@
+/* $MidnightBSD$ */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_llrint.c 140088 2005-01-11 23:12:55Z das $");
#define type double
#define roundit rint
Modified: trunk/lib/msun/src/s_llrintf.c
===================================================================
--- trunk/lib/msun/src/s_llrintf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_llrintf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,5 +1,6 @@
+/* $MidnightBSD$ */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_llrintf.c 140088 2005-01-11 23:12:55Z das $");
#define type float
#define roundit rintf
Modified: trunk/lib/msun/src/s_llrintl.c
===================================================================
--- trunk/lib/msun/src/s_llrintl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_llrintl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,5 +1,6 @@
+/* $MidnightBSD$ */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_llrintl.c 175309 2008-01-14 02:12:07Z das $");
#define type long double
#define roundit rintl
Modified: trunk/lib/msun/src/s_llround.c
===================================================================
--- trunk/lib/msun/src/s_llround.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_llround.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,5 +1,6 @@
+/* $MidnightBSD$ */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_llround.c 144771 2005-04-08 00:52:27Z das $");
#define type double
#define roundit round
Modified: trunk/lib/msun/src/s_llroundf.c
===================================================================
--- trunk/lib/msun/src/s_llroundf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_llroundf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,5 +1,6 @@
+/* $MidnightBSD$ */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_llroundf.c 144771 2005-04-08 00:52:27Z das $");
#define type float
#define roundit roundf
Modified: trunk/lib/msun/src/s_llroundl.c
===================================================================
--- trunk/lib/msun/src/s_llroundl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_llroundl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,5 +1,6 @@
+/* $MidnightBSD$ */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_llroundl.c 144772 2005-04-08 01:24:08Z das $");
#define type long double
#define roundit roundl
Modified: trunk/lib/msun/src/s_log1p.c
===================================================================
--- trunk/lib/msun/src/s_log1p.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_log1p.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)s_log1p.c 5.1 93/09/24 */
/*
* ====================================================
@@ -11,7 +12,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_log1p.c 251292 2013-06-03 09:14:31Z das $");
/* double log1p(double x)
*
@@ -96,6 +97,7 @@
Lp7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
static const double zero = 0.0;
+static volatile double vzero = 0.0;
double
log1p(double x)
@@ -109,7 +111,7 @@
k = 1;
if (hx < 0x3FDA827A) { /* 1+x < sqrt(2)+ */
if(ax>=0x3ff00000) { /* x <= -1.0 */
- if(x==-1.0) return -two54/zero; /* log1p(-1)=+inf */
+ if(x==-1.0) return -two54/vzero; /* log1p(-1)=+inf */
else return (x-x)/(x-x); /* log1p(x<-1)=NaN */
}
if(ax<0x3e200000) { /* |x| < 2**-29 */
@@ -173,3 +175,7 @@
if(k==0) return f-(hfsq-s*(hfsq+R)); else
return k*ln2_hi-((hfsq-(s*(hfsq+R)+(k*ln2_lo+c)))-f);
}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(log1p, log1pl);
+#endif
Modified: trunk/lib/msun/src/s_log1pf.c
===================================================================
--- trunk/lib/msun/src/s_log1pf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_log1pf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* s_log1pf.c -- float version of s_log1p.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_log1pf.c 251024 2013-05-27 08:50:10Z das $");
#include <float.h>
@@ -34,6 +35,7 @@
Lp7 = 1.4798198640e-01; /* 3E178897 */
static const float zero = 0.0;
+static volatile float vzero = 0.0;
float
log1pf(float x)
@@ -47,7 +49,7 @@
k = 1;
if (hx < 0x3ed413d0) { /* 1+x < sqrt(2)+ */
if(ax>=0x3f800000) { /* x <= -1.0 */
- if(x==(float)-1.0) return -two25/zero; /* log1p(-1)=+inf */
+ if(x==(float)-1.0) return -two25/vzero; /* log1p(-1)=+inf */
else return (x-x)/(x-x); /* log1p(x<-1)=NaN */
}
if(ax<0x38000000) { /* |x| < 2**-15 */
Modified: trunk/lib/msun/src/s_logb.c
===================================================================
--- trunk/lib/msun/src/s_logb.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_logb.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)s_logb.c 5.1 93/09/24 */
/*
* ====================================================
@@ -11,7 +12,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_logb.c 176101 2008-02-08 01:22:13Z bde $");
/*
* double logb(x)
Modified: trunk/lib/msun/src/s_logbf.c
===================================================================
--- trunk/lib/msun/src/s_logbf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_logbf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* s_logbf.c -- float version of s_logb.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_logbf.c 176451 2008-02-22 02:30:36Z das $");
#include "math.h"
#include "math_private.h"
Modified: trunk/lib/msun/src/s_logbl.c
===================================================================
--- trunk/lib/msun/src/s_logbl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_logbl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* From: @(#)s_ilogb.c 5.1 93/09/24
* ====================================================
@@ -11,7 +12,7 @@
*/
#ifndef lint
-static char rcsid[] = "$MidnightBSD$";
+static char rcsid[] = "$FreeBSD: stable/10/lib/msun/src/s_logbl.c 174698 2007-12-17 03:53:38Z das $";
#endif
#include <float.h>
Modified: trunk/lib/msun/src/s_lrint.c
===================================================================
--- trunk/lib/msun/src/s_lrint.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_lrint.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2005 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -29,7 +30,7 @@
#include <math.h>
#ifndef type
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_lrint.c 140088 2005-01-11 23:12:55Z das $");
#define type double
#define roundit rint
#define dtype long
Modified: trunk/lib/msun/src/s_lrintf.c
===================================================================
--- trunk/lib/msun/src/s_lrintf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_lrintf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,5 +1,6 @@
+/* $MidnightBSD$ */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_lrintf.c 140088 2005-01-11 23:12:55Z das $");
#define type float
#define roundit rintf
Modified: trunk/lib/msun/src/s_lrintl.c
===================================================================
--- trunk/lib/msun/src/s_lrintl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_lrintl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,5 +1,6 @@
+/* $MidnightBSD$ */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_lrintl.c 175309 2008-01-14 02:12:07Z das $");
#define type long double
#define roundit rintl
Modified: trunk/lib/msun/src/s_lround.c
===================================================================
--- trunk/lib/msun/src/s_lround.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_lround.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2005 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -30,7 +31,7 @@
#include <math.h>
#ifndef type
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_lround.c 144770 2005-04-08 00:52:16Z das $");
#define type double
#define roundit round
#define dtype long
Modified: trunk/lib/msun/src/s_lroundf.c
===================================================================
--- trunk/lib/msun/src/s_lroundf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_lroundf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,5 +1,6 @@
+/* $MidnightBSD$ */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_lroundf.c 144771 2005-04-08 00:52:27Z das $");
#define type float
#define roundit roundf
Modified: trunk/lib/msun/src/s_lroundl.c
===================================================================
--- trunk/lib/msun/src/s_lroundl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_lroundl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,5 +1,6 @@
+/* $MidnightBSD$ */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_lroundl.c 144772 2005-04-08 01:24:08Z das $");
#define type long double
#define roundit roundl
Modified: trunk/lib/msun/src/s_modf.c
===================================================================
--- trunk/lib/msun/src/s_modf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_modf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)s_modf.c 5.1 93/09/24 */
/*
* ====================================================
@@ -11,7 +12,7 @@
*/
#ifndef lint
-static char rcsid[] = "$MidnightBSD$";
+static char rcsid[] = "$FreeBSD: stable/10/lib/msun/src/s_modf.c 165838 2007-01-06 21:22:38Z das $";
#endif
/*
Modified: trunk/lib/msun/src/s_modff.c
===================================================================
--- trunk/lib/msun/src/s_modff.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_modff.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* s_modff.c -- float version of s_modf.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_modff.c 176451 2008-02-22 02:30:36Z das $");
#include "math.h"
#include "math_private.h"
Modified: trunk/lib/msun/src/s_modfl.c
===================================================================
--- trunk/lib/msun/src/s_modfl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_modfl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2007 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -33,7 +34,7 @@
* is preserved.
* ====================================================
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/msun/src/s_modfl.c 165855 2007-01-07 07:54:21Z das $
*/
#include <float.h>
Modified: trunk/lib/msun/src/s_nan.c
===================================================================
--- trunk/lib/msun/src/s_nan.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_nan.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2007 David Schultz
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/msun/src/s_nan.c 174759 2007-12-18 23:46:32Z das $
*/
#include <sys/endian.h>
Modified: trunk/lib/msun/src/s_nearbyint.c
===================================================================
--- trunk/lib/msun/src/s_nearbyint.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_nearbyint.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_nearbyint.c 251024 2013-05-27 08:50:10Z das $");
#include <fenv.h>
#include <math.h>
@@ -36,12 +37,16 @@
* instead of feclearexcept()/feupdateenv() to restore the environment
* because the only exception defined for rint() is overflow, and
* rounding can't overflow as long as emax >= p.
+ *
+ * The volatile keyword is needed below because clang incorrectly assumes
+ * that rint won't raise any floating-point exceptions. Declaring ret volatile
+ * is sufficient to trick the compiler into doing the right thing.
*/
#define DECL(type, fn, rint) \
type \
fn(type x) \
{ \
- type ret; \
+ volatile type ret; \
fenv_t env; \
\
fegetenv(&env); \
Modified: trunk/lib/msun/src/s_nextafter.c
===================================================================
--- trunk/lib/msun/src/s_nextafter.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_nextafter.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)s_nextafter.c 5.1 93/09/24 */
/*
* ====================================================
@@ -11,7 +12,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_nextafter.c 176451 2008-02-22 02:30:36Z das $");
/* IEEE functions
* nextafter(x,y)
Modified: trunk/lib/msun/src/s_nextafterf.c
===================================================================
--- trunk/lib/msun/src/s_nextafterf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_nextafterf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* s_nextafterf.c -- float version of s_nextafter.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_nextafterf.c 176451 2008-02-22 02:30:36Z das $");
#include "math.h"
#include "math_private.h"
Modified: trunk/lib/msun/src/s_nextafterl.c
===================================================================
--- trunk/lib/msun/src/s_nextafterl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_nextafterl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)s_nextafter.c 5.1 93/09/24 */
/*
* ====================================================
@@ -11,7 +12,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_nextafterl.c 176451 2008-02-22 02:30:36Z das $");
/* IEEE functions
* nextafter(x,y)
Modified: trunk/lib/msun/src/s_nexttoward.c
===================================================================
--- trunk/lib/msun/src/s_nexttoward.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_nexttoward.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)s_nextafter.c 5.1 93/09/24 */
/*
* ====================================================
@@ -11,7 +12,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_nexttoward.c 218510 2011-02-10 07:38:13Z das $");
/*
* We assume that a long double has a 15-bit exponent. On systems
Modified: trunk/lib/msun/src/s_nexttowardf.c
===================================================================
--- trunk/lib/msun/src/s_nexttowardf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_nexttowardf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +11,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_nexttowardf.c 218511 2011-02-10 07:38:38Z das $");
#include <float.h>
Modified: trunk/lib/msun/src/s_remquo.c
===================================================================
--- trunk/lib/msun/src/s_remquo.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_remquo.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_fmod.c 1.3 95/01/18 */
/*-
* ====================================================
@@ -11,7 +12,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_remquo.c 233973 2012-04-07 03:59:12Z das $");
#include <float.h>
Modified: trunk/lib/msun/src/s_remquof.c
===================================================================
--- trunk/lib/msun/src/s_remquof.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_remquof.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_fmod.c 1.3 95/01/18 */
/*-
* ====================================================
@@ -11,7 +12,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_remquof.c 233973 2012-04-07 03:59:12Z das $");
#include "math.h"
#include "math_private.h"
Modified: trunk/lib/msun/src/s_remquol.c
===================================================================
--- trunk/lib/msun/src/s_remquol.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_remquol.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)e_fmod.c 1.3 95/01/18 */
/*-
* ====================================================
@@ -11,7 +12,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_remquol.c 233973 2012-04-07 03:59:12Z das $");
#include <float.h>
#include <stdint.h>
Modified: trunk/lib/msun/src/s_rint.c
===================================================================
--- trunk/lib/msun/src/s_rint.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_rint.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)s_rint.c 5.1 93/09/24 */
/*
* ====================================================
@@ -11,7 +12,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_rint.c 176451 2008-02-22 02:30:36Z das $");
/*
* rint(x)
Modified: trunk/lib/msun/src/s_rintf.c
===================================================================
--- trunk/lib/msun/src/s_rintf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_rintf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* s_rintf.c -- float version of s_rint.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_rintf.c 176451 2008-02-22 02:30:36Z das $");
#include <float.h>
#include <stdint.h>
Modified: trunk/lib/msun/src/s_rintl.c
===================================================================
--- trunk/lib/msun/src/s_rintl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_rintl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2008 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_rintl.c 176461 2008-02-22 11:59:05Z bde $");
#include <float.h>
#include <math.h>
Modified: trunk/lib/msun/src/s_round.c
===================================================================
--- trunk/lib/msun/src/s_round.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_round.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2003, Steven G. Kargl
* All rights reserved.
@@ -25,27 +26,36 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_round.c 271779 2014-09-18 15:10:22Z tijl $");
-#include <math.h>
+#include <float.h>
+#include "math.h"
+#include "math_private.h"
+
double
round(double x)
{
double t;
+ uint32_t hx;
- if (!isfinite(x))
- return (x);
+ GET_HIGH_WORD(hx, x);
+ if ((hx & 0x7fffffff) == 0x7ff00000)
+ return (x + x);
- if (x >= 0.0) {
+ if (!(hx & 0x80000000)) {
t = floor(x);
if (t - x <= -0.5)
- t += 1.0;
+ t += 1;
return (t);
} else {
t = floor(-x);
if (t + x <= -0.5)
- t += 1.0;
+ t += 1;
return (-t);
}
}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(round, roundl);
+#endif
Modified: trunk/lib/msun/src/s_roundf.c
===================================================================
--- trunk/lib/msun/src/s_roundf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_roundf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2003, Steven G. Kargl
* All rights reserved.
@@ -25,27 +26,30 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_roundf.c 271779 2014-09-18 15:10:22Z tijl $");
-#include <math.h>
+#include "math.h"
+#include "math_private.h"
float
roundf(float x)
{
float t;
+ uint32_t hx;
- if (!isfinite(x))
- return (x);
+ GET_FLOAT_WORD(hx, x);
+ if ((hx & 0x7fffffff) == 0x7f800000)
+ return (x + x);
- if (x >= 0.0) {
+ if (!(hx & 0x80000000)) {
t = floorf(x);
- if (t - x <= -0.5)
- t += 1.0;
+ if (t - x <= -0.5F)
+ t += 1;
return (t);
} else {
t = floorf(-x);
- if (t + x <= -0.5)
- t += 1.0;
+ if (t + x <= -0.5F)
+ t += 1;
return (-t);
}
}
Modified: trunk/lib/msun/src/s_roundl.c
===================================================================
--- trunk/lib/msun/src/s_roundl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_roundl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2003, Steven G. Kargl
* All rights reserved.
@@ -25,27 +26,38 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_roundl.c 271779 2014-09-18 15:10:22Z tijl $");
-#include <math.h>
+#include <float.h>
+#ifdef __i386__
+#include <ieeefp.h>
+#endif
+#include "fpmath.h"
+#include "math.h"
+#include "math_private.h"
+
long double
roundl(long double x)
{
long double t;
+ uint16_t hx;
- if (!isfinite(x))
- return (x);
+ GET_LDBL_EXPSIGN(hx, x);
+ if ((hx & 0x7fff) == 0x7fff)
+ return (x + x);
- if (x >= 0.0) {
+ ENTERI();
+
+ if (!(hx & 0x8000)) {
t = floorl(x);
- if (t - x <= -0.5)
- t += 1.0;
- return (t);
+ if (t - x <= -0.5L)
+ t += 1;
+ RETURNI(t);
} else {
t = floorl(-x);
- if (t + x <= -0.5)
- t += 1.0;
- return (-t);
+ if (t + x <= -0.5L)
+ t += 1;
+ RETURNI(-t);
}
}
Modified: trunk/lib/msun/src/s_scalbln.c
===================================================================
--- trunk/lib/msun/src/s_scalbln.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_scalbln.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -25,52 +26,30 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_scalbln.c 284810 2015-06-25 13:01:10Z tijl $");
-#include <limits.h>
#include <math.h>
+#define NMAX 65536
+#define NMIN -65536
+
double
-scalbln (double x, long n)
+scalbln(double x, long n)
{
- int in;
- in = (int)n;
- if (in != n) {
- if (n > 0)
- in = INT_MAX;
- else
- in = INT_MIN;
- }
- return (scalbn(x, in));
+ return (scalbn(x, (n > NMAX) ? NMAX : (n < NMIN) ? NMIN : (int)n));
}
float
-scalblnf (float x, long n)
+scalblnf(float x, long n)
{
- int in;
- in = (int)n;
- if (in != n) {
- if (n > 0)
- in = INT_MAX;
- else
- in = INT_MIN;
- }
- return (scalbnf(x, in));
+ return (scalbnf(x, (n > NMAX) ? NMAX : (n < NMIN) ? NMIN : (int)n));
}
long double
-scalblnl (long double x, long n)
+scalblnl(long double x, long n)
{
- int in;
- in = (int)n;
- if (in != n) {
- if (n > 0)
- in = INT_MAX;
- else
- in = INT_MIN;
- }
- return (scalbnl(x, (int)n));
+ return (scalbnl(x, (n > NMAX) ? NMAX : (n < NMIN) ? NMIN : (int)n));
}
Modified: trunk/lib/msun/src/s_scalbn.c
===================================================================
--- trunk/lib/msun/src/s_scalbn.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_scalbn.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)s_scalbn.c 5.1 93/09/24 */
/*
* ====================================================
@@ -11,7 +12,7 @@
*/
#ifndef lint
-static char rcsid[] = "$MidnightBSD$";
+static char rcsid[] = "$FreeBSD: stable/10/lib/msun/src/s_scalbn.c 143264 2005-03-07 21:27:37Z das $";
#endif
/*
Modified: trunk/lib/msun/src/s_scalbnf.c
===================================================================
--- trunk/lib/msun/src/s_scalbnf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_scalbnf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* s_scalbnf.c -- float version of s_scalbn.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#ifndef lint
-static char rcsid[] = "$MidnightBSD$";
+static char rcsid[] = "$FreeBSD: stable/10/lib/msun/src/s_scalbnf.c 143205 2005-03-07 04:52:43Z das $";
#endif
#include <sys/cdefs.h>
Modified: trunk/lib/msun/src/s_scalbnl.c
===================================================================
--- trunk/lib/msun/src/s_scalbnl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_scalbnl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)s_scalbn.c 5.1 93/09/24 */
/*
* ====================================================
@@ -11,7 +12,7 @@
*/
#ifndef lint
-static char rcsid[] = "$MidnightBSD$";
+static char rcsid[] = "$FreeBSD: stable/10/lib/msun/src/s_scalbnl.c 143206 2005-03-07 04:52:58Z das $";
#endif
/*
Modified: trunk/lib/msun/src/s_signbit.c
===================================================================
--- trunk/lib/msun/src/s_signbit.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_signbit.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2003 Mike Barcroft <mike at FreeBSD.org>
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/msun/src/s_signbit.c 132382 2004-07-19 08:16:10Z das $
*/
#include <math.h>
Modified: trunk/lib/msun/src/s_signgam.c
===================================================================
--- trunk/lib/msun/src/s_signgam.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_signgam.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
#include "math.h"
#include "math_private.h"
int signgam = 0;
Modified: trunk/lib/msun/src/s_significand.c
===================================================================
--- trunk/lib/msun/src/s_significand.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_significand.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)s_signif.c 5.1 93/09/24 */
/*
* ====================================================
@@ -11,7 +12,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_significand.c 176451 2008-02-22 02:30:36Z das $");
/*
* significand(x) computes just
Modified: trunk/lib/msun/src/s_significandf.c
===================================================================
--- trunk/lib/msun/src/s_significandf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_significandf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* s_significandf.c -- float version of s_significand.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_significandf.c 176451 2008-02-22 02:30:36Z das $");
#include "math.h"
#include "math_private.h"
Modified: trunk/lib/msun/src/s_sin.c
===================================================================
--- trunk/lib/msun/src/s_sin.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_sin.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)s_sin.c 5.1 93/09/24 */
/*
* ====================================================
@@ -11,7 +12,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_sin.c 218509 2011-02-10 07:37:50Z das $");
/* sin(x)
* Return sine function of x.
Modified: trunk/lib/msun/src/s_sinf.c
===================================================================
--- trunk/lib/msun/src/s_sinf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_sinf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* s_sinf.c -- float version of s_sin.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
* Optimized by Bruce D. Evans.
@@ -15,7 +16,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_sinf.c 176569 2008-02-25 22:19:17Z bde $");
#include <float.h>
Modified: trunk/lib/msun/src/s_sinl.c
===================================================================
--- trunk/lib/msun/src/s_sinl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_sinl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2007 Steven G. Kargl
* All rights reserved.
@@ -25,9 +26,12 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_sinl.c 240828 2012-09-22 15:38:29Z kargl $");
#include <float.h>
+#ifdef __i386__
+#include <ieeefp.h>
+#endif
#include "math.h"
#include "math_private.h"
@@ -59,10 +63,12 @@
if (z.bits.exp == 32767)
return ((x - x) / (x - x));
+ ENTERI();
+
/* Optimize the case where x is already within range. */
if (z.e < M_PI_4) {
hi = __kernel_sinl(z.e, 0, 0);
- return (s ? -hi : hi);
+ RETURNI(s ? -hi : hi);
}
e0 = __ieee754_rem_pio2l(x, y);
@@ -84,5 +90,5 @@
break;
}
- return (hi);
+ RETURNI(hi);
}
Modified: trunk/lib/msun/src/s_tan.c
===================================================================
--- trunk/lib/msun/src/s_tan.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_tan.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)s_tan.c 5.1 93/09/24 */
/*
* ====================================================
@@ -11,7 +12,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_tan.c 218509 2011-02-10 07:37:50Z das $");
/* tan(x)
* Return tangent function of x.
Modified: trunk/lib/msun/src/s_tanf.c
===================================================================
--- trunk/lib/msun/src/s_tanf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_tanf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* s_tanf.c -- float version of s_tan.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
* Optimized by Bruce D. Evans.
@@ -15,7 +16,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_tanf.c 176569 2008-02-25 22:19:17Z bde $");
#include <float.h>
Modified: trunk/lib/msun/src/s_tanh.c
===================================================================
--- trunk/lib/msun/src/s_tanh.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_tanh.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)s_tanh.c 5.1 93/09/24 */
/*
* ====================================================
@@ -11,7 +12,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_tanh.c 271779 2014-09-18 15:10:22Z tijl $");
/* Tanh(x)
* Return the Hyperbolic Tangent of x
@@ -37,10 +38,13 @@
* only tanh(0)=0 is exact for finite argument.
*/
+#include <float.h>
+
#include "math.h"
#include "math_private.h"
-static const double one = 1.0, two = 2.0, tiny = 1.0e-300, huge = 1.0e300;
+static const volatile double tiny = 1.0e-300;
+static const double one = 1.0, two = 2.0, huge = 1.0e300;
double
tanh(double x)
@@ -75,3 +79,7 @@
}
return (jx>=0)? z: -z;
}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(tanh, tanhl);
+#endif
Modified: trunk/lib/msun/src/s_tanhf.c
===================================================================
--- trunk/lib/msun/src/s_tanhf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_tanhf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* s_tanhf.c -- float version of s_tanh.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian at cygnus.com.
*/
@@ -14,12 +15,14 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_tanhf.c 271779 2014-09-18 15:10:22Z tijl $");
#include "math.h"
#include "math_private.h"
-static const float one=1.0, two=2.0, tiny = 1.0e-30, huge = 1.0e30;
+static const volatile float tiny = 1.0e-30;
+static const float one=1.0, two=2.0, huge = 1.0e30;
+
float
tanhf(float x)
{
Added: trunk/lib/msun/src/s_tanhl.c
===================================================================
--- trunk/lib/msun/src/s_tanhl.c (rev 0)
+++ trunk/lib/msun/src/s_tanhl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -0,0 +1,173 @@
+/* $MidnightBSD$ */
+/* from: FreeBSD: head/lib/msun/src/s_tanhl.c XXX */
+
+/* @(#)s_tanh.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * 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: stable/10/lib/msun/src/s_tanhl.c 271779 2014-09-18 15:10:22Z tijl $");
+
+/*
+ * See s_tanh.c for complete comments.
+ *
+ * Converted to long double by Bruce D. Evans.
+ */
+
+#include <float.h>
+#ifdef __i386__
+#include <ieeefp.h>
+#endif
+
+#include "math.h"
+#include "math_private.h"
+#include "fpmath.h"
+#include "k_expl.h"
+
+#if LDBL_MAX_EXP != 0x4000
+/* We also require the usual expsign encoding. */
+#error "Unsupported long double format"
+#endif
+
+#define BIAS (LDBL_MAX_EXP - 1)
+
+static const volatile double tiny = 1.0e-300;
+static const double one = 1.0;
+#if LDBL_MANT_DIG == 64
+/*
+ * Domain [-0.25, 0.25], range ~[-1.6304e-22, 1.6304e-22]:
+ * |tanh(x)/x - t(x)| < 2**-72.3
+ */
+static const union IEEEl2bits
+T3u = LD80C(0xaaaaaaaaaaaaaa9f, -2, -3.33333333333333333017e-1L);
+#define T3 T3u.e
+static const double
+T5 = 1.3333333333333314e-1, /* 0x1111111111110a.0p-55 */
+T7 = -5.3968253968210485e-2, /* -0x1ba1ba1ba1a1a1.0p-57 */
+T9 = 2.1869488531393817e-2, /* 0x1664f488172022.0p-58 */
+T11 = -8.8632352345964591e-3, /* -0x1226e34bc138d5.0p-59 */
+T13 = 3.5921169709993771e-3, /* 0x1d6d371d3e400f.0p-61 */
+T15 = -1.4555786415756001e-3, /* -0x17d923aa63814d.0p-62 */
+T17 = 5.8645267876296793e-4, /* 0x13378589b85aa7.0p-63 */
+T19 = -2.1121033571392224e-4; /* -0x1baf0af80c4090.0p-65 */
+#elif LDBL_MANT_DIG == 113
+/*
+ * Domain [-0.25, 0.25], range ~[-2.4211e-37, 2.4211e-37]:
+ * |tanh(x)/x - t(x)| < 2**121.6
+ */
+static const long double
+T3 = -3.33333333333333333333333333333332980e-1L, /* -0x1555555555555555555555555554e.0p-114L */
+T5 = 1.33333333333333333333333333332707260e-1L, /* 0x1111111111111111111111110ab7b.0p-115L */
+T7 = -5.39682539682539682539682535723482314e-2L, /* -0x1ba1ba1ba1ba1ba1ba1ba17b5fc98.0p-117L */
+T9 = 2.18694885361552028218693591149061717e-2L, /* 0x1664f4882c10f9f32d6b1a12a25e5.0p-118L */
+T11 = -8.86323552990219656883762347736381851e-3L, /* -0x1226e355e6c23c8f5a5a0f386cb4d.0p-119L */
+T13 = 3.59212803657248101358314398220822722e-3L, /* 0x1d6d3d0e157ddfb403ad3637442c6.0p-121L */
+T15 = -1.45583438705131796512568010348874662e-3L; /* -0x17da36452b75e150c44cc34253b34.0p-122L */
+static const double
+T17 = 5.9002744094556621e-4, /* 0x1355824803668e.0p-63 */
+T19 = -2.3912911424260516e-4, /* -0x1f57d7734c8dde.0p-65 */
+T21 = 9.6915379535512898e-5, /* 0x1967e18ad6a6ca.0p-66 */
+T23 = -3.9278322983156353e-5, /* -0x1497d8e6b75729.0p-67 */
+T25 = 1.5918887220143869e-5, /* 0x10b1319998cafa.0p-68 */
+T27 = -6.4514295231630956e-6, /* -0x1b0f2b71b218eb.0p-70 */
+T29 = 2.6120754043964365e-6, /* 0x15e963a3cf3a39.0p-71 */
+T31 = -1.0407567231003314e-6, /* -0x1176041e656869.0p-72 */
+T33 = 3.4744117554063574e-7; /* 0x1750fe732cab9c.0p-74 */
+#endif /* LDBL_MANT_DIG == 64 */
+
+static inline long double
+divl(long double a, long double b, long double c, long double d,
+ long double e, long double f)
+{
+ long double inv, r;
+ float fr, fw;
+
+ _2sumF(a, c);
+ b = b + c;
+ _2sumF(d, f);
+ e = e + f;
+
+ inv = 1 / (d + e);
+
+ r = (a + b) * inv;
+ fr = r;
+ r = fr;
+
+ fw = d + e;
+ e = d - fw + e;
+ d = fw;
+
+ r = r + (a - d * r + b - e * r) * inv;
+
+ return r;
+}
+
+long double
+tanhl(long double x)
+{
+ long double hi,lo,s,x2,x4,z;
+ double dx2;
+ int16_t jx,ix;
+
+ GET_LDBL_EXPSIGN(jx,x);
+ ix = jx&0x7fff;
+
+ /* x is INF or NaN */
+ if(ix>=0x7fff) {
+ if (jx>=0) return one/x+one; /* tanh(+-inf)=+-1 */
+ else return one/x-one; /* tanh(NaN) = NaN */
+ }
+
+ ENTERI();
+
+ /* |x| < 40 */
+ if (ix < 0x4004 || fabsl(x) < 40) { /* |x|<40 */
+ if (__predict_false(ix<BIAS-(LDBL_MANT_DIG+1)/2)) { /* |x|<TINY */
+ /* tanh(+-0) = +0; tanh(tiny) = tiny(-+) with inexact: */
+ return (x == 0 ? x : (0x1p200 * x - x) * 0x1p-200);
+ }
+ if (ix<0x3ffd) { /* |x|<0.25 */
+ x2 = x*x;
+#if LDBL_MANT_DIG == 64
+ x4 = x2*x2;
+ RETURNI(((T19*x2 + T17)*x4 + (T15*x2 + T13))*(x2*x*x2*x4*x4) +
+ ((T11*x2 + T9)*x4 + (T7*x2 + T5))*(x2*x*x2) +
+ T3*(x2*x) + x);
+#elif LDBL_MANT_DIG == 113
+ dx2 = x2;
+#if 0
+ RETURNI(((((((((((((((T33*dx2 + T31)*dx2 + T29)*dx2 + T27)*dx2 +
+ T25)*x2 + T23)*x2 + T21)*x2 + T19)*x2 + T17)*x2 +
+ T15)*x2 + T13)*x2 + T11)*x2 + T9)*x2 + T7)*x2 + T5)*
+ (x2*x*x2) +
+ T3*(x2*x) + x);
+#else
+ long double q = ((((((((((((((T33*dx2 + T31)*dx2 + T29)*dx2 + T27)*dx2 +
+ T25)*x2 + T23)*x2 + T21)*x2 + T19)*x2 + T17)*x2 +
+ T15)*x2 + T13)*x2 + T11)*x2 + T9)*x2 + T7)*x2 + T5)*
+ (x2*x*x2);
+ RETURNI(q + T3*(x2*x) + x);
+#endif
+#endif
+ }
+ k_hexpl(2*fabsl(x), &hi, &lo);
+ if (ix<0x4001 && fabsl(x) < 1.5) /* |x|<1.5 */
+ z = divl(hi, lo, -0.5, hi, lo, 0.5);
+ else
+ z = one - one/(lo+0.5+hi);
+ /* |x| >= 40, return +-1 */
+ } else {
+ z = one - tiny; /* raise inexact flag */
+ }
+ s = 1;
+ if (jx<0) s = -1;
+ RETURNI(s*z);
+}
Property changes on: trunk/lib/msun/src/s_tanhl.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/lib/msun/src/s_tanl.c
===================================================================
--- trunk/lib/msun/src/s_tanl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_tanl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2007 Steven G. Kargl
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_tanl.c 240828 2012-09-22 15:38:29Z kargl $");
/*
* Limited testing on pseudorandom numbers drawn within [0:4e8] shows
@@ -34,6 +35,9 @@
*/
#include <float.h>
+#ifdef __i386__
+#include <ieeefp.h>
+#endif
#include "math.h"
#include "math_private.h"
@@ -65,10 +69,12 @@
if (z.bits.exp == 32767)
return ((x - x) / (x - x));
+ ENTERI();
+
/* Optimize the case where x is already within range. */
if (z.e < M_PI_4) {
hi = __kernel_tanl(z.e, 0, 0);
- return (s ? -hi : hi);
+ RETURNI(s ? -hi : hi);
}
e0 = __ieee754_rem_pio2l(x, y);
@@ -86,5 +92,5 @@
break;
}
- return (hi);
+ RETURNI(hi);
}
Modified: trunk/lib/msun/src/s_tgammaf.c
===================================================================
--- trunk/lib/msun/src/s_tgammaf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_tgammaf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2008 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_tgammaf.c 176388 2008-02-18 17:27:11Z das $");
#include <math.h>
Modified: trunk/lib/msun/src/s_trunc.c
===================================================================
--- trunk/lib/msun/src/s_trunc.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_trunc.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)s_floor.c 5.1 93/09/24 */
/*
* ====================================================
@@ -11,7 +12,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_trunc.c 176450 2008-02-22 02:27:34Z das $");
/*
* trunc(x)
Modified: trunk/lib/msun/src/s_truncf.c
===================================================================
--- trunk/lib/msun/src/s_truncf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_truncf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)s_floor.c 5.1 93/09/24 */
/*
* ====================================================
@@ -11,7 +12,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_truncf.c 130767 2004-06-20 09:25:43Z das $");
/*
* truncf(x)
Modified: trunk/lib/msun/src/s_truncl.c
===================================================================
--- trunk/lib/msun/src/s_truncl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/s_truncl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -12,7 +13,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_truncl.c 176280 2008-02-14 15:10:34Z bde $");
/*
* truncl(x)
Modified: trunk/lib/msun/src/w_cabs.c
===================================================================
--- trunk/lib/msun/src/w_cabs.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/w_cabs.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* cabs() wrapper for hypot().
*
@@ -6,7 +7,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/w_cabs.c 177758 2008-03-30 20:03:06Z das $");
#include <complex.h>
#include <float.h>
Modified: trunk/lib/msun/src/w_cabsf.c
===================================================================
--- trunk/lib/msun/src/w_cabsf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/w_cabsf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* cabsf() wrapper for hypotf().
*
@@ -7,7 +8,7 @@
#ifndef lint
static const char rcsid[] =
- "$MidnightBSD$";
+ "$FreeBSD: stable/10/lib/msun/src/w_cabsf.c 78172 2001-06-13 15:16:30Z ru $";
#endif /* not lint */
#include <complex.h>
Modified: trunk/lib/msun/src/w_cabsl.c
===================================================================
--- trunk/lib/msun/src/w_cabsl.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/w_cabsl.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* cabs() wrapper for hypot().
*
@@ -8,7 +9,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/msun/src/w_cabsl.c 177757 2008-03-30 20:02:03Z das $");
#include <complex.h>
#include <math.h>
Modified: trunk/lib/msun/src/w_drem.c
===================================================================
--- trunk/lib/msun/src/w_drem.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/w_drem.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* drem() wrapper for remainder().
*
Modified: trunk/lib/msun/src/w_dremf.c
===================================================================
--- trunk/lib/msun/src/w_dremf.c 2018-06-09 15:08:08 UTC (rev 10590)
+++ trunk/lib/msun/src/w_dremf.c 2018-06-09 15:08:31 UTC (rev 10591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* dremf() wrapper for remainderf().
*
@@ -4,7 +5,7 @@
* Written by J.T. Conklin, <jtc at wimsey.com>
* Placed into the Public Domain, 1994.
*/
-/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/msun/src/w_dremf.c 132760 2004-07-28 05:53:18Z kan $ */
#include "math.h"
#include "math_private.h"
More information about the Midnightbsd-cvs
mailing list