Index: stable/11/lib/msun/Makefile =================================================================== --- stable/11/lib/msun/Makefile (revision 324005) +++ stable/11/lib/msun/Makefile (revision 324006) @@ -1,231 +1,235 @@ # @(#)Makefile 5.1beta 93/09/24 # $FreeBSD$ # # ==================================================== # 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. # ==================================================== # # PACKAGE= clibs -.if ${MACHINE_CPUARCH} == "i386" -ARCH_SUBDIR= i387 -.else -ARCH_SUBDIR= ${MACHINE_CPUARCH} -.endif +ARCH_SUBDIR= ${MACHINE_CPUARCH:S/i386/i387/} .include "${ARCH_SUBDIR}/Makefile.inc" .PATH: ${.CURDIR}/${ARCH_SUBDIR} .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" .PATH: ${.CURDIR}/x86 CFLAGS+= -I${.CURDIR}/x86 .endif # long double format .if ${LDBL_PREC} == 64 .PATH: ${.CURDIR}/ld80 CFLAGS+= -I${.CURDIR}/ld80 .elif ${LDBL_PREC} == 113 .PATH: ${.CURDIR}/ld128 CFLAGS+= -I${.CURDIR}/ld128 .endif CFLAGS+= -I${.CURDIR}/${ARCH_SUBDIR} .PATH: ${.CURDIR}/bsdsrc .PATH: ${.CURDIR}/src .PATH: ${.CURDIR}/man LIB= m SHLIBDIR?= /lib SHLIB_MAJOR= 5 WARNS?= 1 IGNORE_PRAGMA= COMMON_SRCS= b_exp.c b_log.c b_tgamma.c \ e_acos.c e_acosf.c e_acosh.c e_acoshf.c e_asin.c e_asinf.c \ e_atan2.c e_atan2f.c e_atanh.c e_atanhf.c e_cosh.c e_coshf.c e_exp.c \ e_expf.c e_fmod.c e_fmodf.c e_gamma.c e_gamma_r.c e_gammaf.c \ e_gammaf_r.c e_hypot.c e_hypotf.c e_j0.c e_j0f.c e_j1.c e_j1f.c \ e_jn.c e_jnf.c e_lgamma.c e_lgamma_r.c e_lgammaf.c e_lgammaf_r.c \ e_log.c e_log10.c e_log10f.c e_log2.c e_log2f.c e_logf.c \ e_pow.c e_powf.c e_rem_pio2.c \ e_rem_pio2f.c e_remainder.c e_remainderf.c e_scalb.c e_scalbf.c \ e_sinh.c e_sinhf.c e_sqrt.c e_sqrtf.c fenv.c \ imprecise.c \ k_cos.c k_cosf.c k_exp.c k_expf.c k_rem_pio2.c k_sin.c k_sinf.c \ k_tan.c k_tanf.c \ s_asinh.c s_asinhf.c s_atan.c s_atanf.c s_carg.c s_cargf.c s_cargl.c \ s_cbrt.c s_cbrtf.c s_ceil.c s_ceilf.c \ s_copysign.c s_copysignf.c s_cos.c s_cosf.c \ s_csqrt.c s_csqrtf.c s_erf.c s_erff.c \ s_exp2.c s_exp2f.c s_expm1.c s_expm1f.c s_fabsf.c s_fdim.c \ s_finite.c s_finitef.c \ s_floor.c s_floorf.c s_fma.c s_fmaf.c \ - s_fmax.c s_fmaxf.c s_fmaxl.c s_fmin.c \ - s_fminf.c s_fminl.c s_frexp.c s_frexpf.c s_ilogb.c s_ilogbf.c \ + s_fmax.c s_fmaxf.c s_fmin.c \ + s_fminf.c s_frexp.c s_frexpf.c s_ilogb.c s_ilogbf.c \ s_ilogbl.c s_isfinite.c s_isnan.c s_isnormal.c \ s_llrint.c s_llrintf.c s_llround.c s_llroundf.c s_llroundl.c \ s_log1p.c s_log1pf.c s_logb.c s_logbf.c s_lrint.c s_lrintf.c \ s_lround.c s_lroundf.c s_lroundl.c s_modff.c \ s_nan.c s_nearbyint.c s_nextafter.c s_nextafterf.c \ s_nexttowardf.c s_remquo.c s_remquof.c \ s_rint.c s_rintf.c s_round.c s_roundf.c \ s_scalbln.c s_scalbn.c s_scalbnf.c s_signbit.c \ - s_signgam.c s_significand.c s_significandf.c s_sin.c s_sinf.c \ + s_signgam.c s_significand.c s_significandf.c s_sin.c \ + s_sincos.c s_sincosf.c s_sinf.c \ s_tan.c s_tanf.c s_tanh.c s_tanhf.c s_tgammaf.c s_trunc.c s_truncf.c \ w_cabs.c w_cabsf.c w_drem.c w_dremf.c # Location of fpmath.h and _fpmath.h .if exists(${LIBCSRCDIR}/${MACHINE_ARCH}) LIBC_ARCH=${MACHINE_ARCH} .else LIBC_ARCH=${MACHINE_CPUARCH} .endif CFLAGS+= -I${.CURDIR}/src -I${LIBCSRCDIR}/include \ -I${LIBCSRCDIR}/${LIBC_ARCH} SYM_MAPS+= ${.CURDIR}/Symbol.map VERSION_DEF= ${LIBCSRCDIR}/Versions.def SYMBOL_MAPS= ${SYM_MAPS} # C99 long double functions COMMON_SRCS+= s_copysignl.c s_fabsl.c s_llrintl.c s_lrintl.c s_modfl.c .if ${LDBL_PREC} != 53 # If long double != double use these; otherwise, we alias the double versions. -COMMON_SRCS+= e_acoshl.c e_acosl.c e_asinl.c e_atan2l.c e_atanhl.c \ +COMMON_SRCS+= catrigl.c \ + e_acoshl.c e_acosl.c e_asinl.c e_atan2l.c e_atanhl.c \ e_coshl.c e_fmodl.c e_hypotl.c \ e_lgammal.c e_lgammal_r.c \ e_remainderl.c e_sinhl.c e_sqrtl.c \ invtrig.c k_cosl.c k_sinl.c k_tanl.c \ s_asinhl.c s_atanl.c s_cbrtl.c s_ceill.c s_cosl.c s_cprojl.c \ s_csqrtl.c s_erfl.c s_exp2l.c s_expl.c s_floorl.c s_fmal.c \ - s_frexpl.c s_logbl.c s_logl.c s_nanl.c s_nextafterl.c \ - s_nexttoward.c s_remquol.c s_rintl.c s_roundl.c s_scalbnl.c \ - s_sinl.c s_tanhl.c s_tanl.c s_truncl.c w_cabsl.c + s_fmaxl.c s_fminl.c s_frexpl.c s_logbl.c s_logl.c s_nanl.c \ + s_nextafterl.c s_nexttoward.c s_remquol.c s_rintl.c s_roundl.c \ + s_scalbnl.c s_sinl.c s_sincosl.c \ + s_tanhl.c s_tanl.c s_truncl.c w_cabsl.c .endif # C99 complex functions COMMON_SRCS+= catrig.c catrigf.c \ s_ccosh.c s_ccoshf.c s_cexp.c s_cexpf.c \ s_cimag.c s_cimagf.c s_cimagl.c \ s_conj.c s_conjf.c s_conjl.c \ s_cproj.c s_cprojf.c s_creal.c s_crealf.c s_creall.c \ s_csinh.c s_csinhf.c s_ctanh.c s_ctanhf.c # FreeBSD's C library supplies these functions: #COMMON_SRCS+= s_fabs.c s_frexp.c s_isnan.c s_ldexp.c s_modf.c # Exclude the generic versions of what we provide in the MD area. .if defined(ARCH_SRCS) .for i in ${ARCH_SRCS} COMMON_SRCS:= ${COMMON_SRCS:N${i:R}.c} .endfor .endif SRCS= ${COMMON_SRCS} ${ARCH_SRCS} INCS+= fenv.h math.h MAN= acos.3 acosh.3 asin.3 asinh.3 atan.3 atan2.3 atanh.3 \ ceil.3 cacos.3 ccos.3 ccosh.3 cexp.3 \ cimag.3 copysign.3 cos.3 cosh.3 csqrt.3 erf.3 exp.3 fabs.3 fdim.3 \ feclearexcept.3 feenableexcept.3 fegetenv.3 \ fegetround.3 fenv.3 floor.3 \ fma.3 fmax.3 fmod.3 hypot.3 ieee.3 ieee_test.3 ilogb.3 j0.3 \ lgamma.3 log.3 lrint.3 lround.3 math.3 nan.3 \ nextafter.3 remainder.3 rint.3 \ - round.3 scalbn.3 signbit.3 sin.3 sinh.3 sqrt.3 tan.3 tanh.3 trunc.3 \ + round.3 scalbn.3 signbit.3 sin.3 sincos.3 \ + sinh.3 sqrt.3 tan.3 tanh.3 trunc.3 \ complex.3 MLINKS+=acos.3 acosf.3 acos.3 acosl.3 MLINKS+=acosh.3 acoshf.3 acosh.3 acoshl.3 MLINKS+=asin.3 asinf.3 asin.3 asinl.3 MLINKS+=asinh.3 asinhf.3 asinh.3 asinhl.3 MLINKS+=atan.3 atanf.3 atan.3 atanl.3 MLINKS+=atanh.3 atanhf.3 atanh.3 atanhl.3 MLINKS+=atan2.3 atan2f.3 atan2.3 atan2l.3 \ atan2.3 carg.3 atan2.3 cargf.3 atan2.3 cargl.3 -MLINKS+=cacos.3 cacosf.3 cacos.3 cacosh.3 cacos.3 cacoshf.3 \ - cacos.3 casin.3 cacos.3 casinf.3 cacos.3 casinh.3 cacos.3 casinhf.3 \ - cacos.3 catan.3 cacos.3 catanf.3 cacos.3 catanh.3 cacos.3 catanhf.3 +MLINKS+=cacos.3 cacosf.3 cacos.3 cacosl.3 \ + cacos.3 cacosh.3 cacos.3 cacoshf.3 cacos.3 cacoshl.3 \ + cacos.3 casin.3 cacos.3 casinf.3 cacos.3 casinl.3 \ + cacos.3 casinh.3 cacos.3 casinhf.3 cacos.3 casinhl.3 \ + cacos.3 catan.3 cacos.3 catanf.3 cacos.3 catanl.3 \ + cacos.3 catanh.3 cacos.3 catanhf.3 cacos.3 catanhl.3 MLINKS+=ccos.3 ccosf.3 ccos.3 csin.3 ccos.3 csinf.3 ccos.3 ctan.3 ccos.3 ctanf.3 MLINKS+=ccosh.3 ccoshf.3 ccosh.3 csinh.3 ccosh.3 csinhf.3 \ ccosh.3 ctanh.3 ccosh.3 ctanhf.3 MLINKS+=ceil.3 ceilf.3 ceil.3 ceill.3 MLINKS+=cexp.3 cexpf.3 MLINKS+=cimag.3 cimagf.3 cimag.3 cimagl.3 \ cimag.3 conj.3 cimag.3 conjf.3 cimag.3 conjl.3 \ cimag.3 cproj.3 cimag.3 cprojf.3 cimag.3 cprojl.3 \ cimag.3 creal.3 cimag.3 crealf.3 cimag.3 creall.3 MLINKS+=copysign.3 copysignf.3 copysign.3 copysignl.3 MLINKS+=cos.3 cosf.3 cos.3 cosl.3 MLINKS+=cosh.3 coshf.3 cosh.3 coshl.3 MLINKS+=csqrt.3 csqrtf.3 csqrt.3 csqrtl.3 MLINKS+=erf.3 erfc.3 erf.3 erff.3 erf.3 erfcf.3 erf.3 erfl.3 erf.3 erfcl.3 MLINKS+=exp.3 expm1.3 exp.3 expm1f.3 exp.3 expm1l.3 exp.3 pow.3 exp.3 powf.3 \ exp.3 powl.3 exp.3 exp2.3 exp.3 exp2f.3 exp.3 exp2l.3 exp.3 expf.3 \ exp.3 expl.3 MLINKS+=fabs.3 fabsf.3 fabs.3 fabsl.3 MLINKS+=fdim.3 fdimf.3 fdim.3 fdiml.3 MLINKS+=feclearexcept.3 fegetexceptflag.3 feclearexcept.3 feraiseexcept.3 \ feclearexcept.3 fesetexceptflag.3 feclearexcept.3 fetestexcept.3 MLINKS+=feenableexcept.3 fedisableexcept.3 feenableexcept.3 fegetexcept.3 MLINKS+=fegetenv.3 feholdexcept.3 fegetenv.3 fesetenv.3 \ fegetenv.3 feupdateenv.3 MLINKS+=fegetround.3 fesetround.3 MLINKS+=floor.3 floorf.3 floor.3 floorl.3 MLINKS+=fma.3 fmaf.3 fma.3 fmal.3 MLINKS+=fmax.3 fmaxf.3 fmax.3 fmaxl.3 \ fmax.3 fmin.3 fmax.3 fminf.3 fmax.3 fminl.3 MLINKS+=fmod.3 fmodf.3 fmod.3 fmodl.3 MLINKS+=hypot.3 cabs.3 hypot.3 cabsf.3 hypot.3 cabsl.3 \ hypot.3 hypotf.3 hypot.3 hypotl.3 MLINKS+=ieee_test.3 scalb.3 ieee_test.3 scalbf.3 MLINKS+=ieee_test.3 significand.3 ieee_test.3 significandf.3 MLINKS+=ilogb.3 ilogbf.3 ilogb.3 ilogbl.3 \ ilogb.3 logb.3 ilogb.3 logbf.3 ilogb.3 logbl.3 MLINKS+=j0.3 j1.3 j0.3 jn.3 j0.3 y0.3 j0.3 y1.3 j0.3 y1f.3 j0.3 yn.3 MLINKS+=j0.3 j0f.3 j0.3 j1f.3 j0.3 jnf.3 j0.3 y0f.3 j0.3 ynf.3 MLINKS+=lgamma.3 gamma.3 lgamma.3 gammaf.3 \ lgamma.3 lgammaf.3 lgamma.3 lgammal.3 \ lgamma.3 tgamma.3 lgamma.3 tgammaf.3 MLINKS+=log.3 log10.3 log.3 log10f.3 log.3 log10l.3 \ log.3 log1p.3 log.3 log1pf.3 log.3 log1pl.3 \ log.3 logf.3 log.3 logl.3 \ log.3 log2.3 log.3 log2f.3 log.3 log2l.3 MLINKS+=lrint.3 llrint.3 lrint.3 llrintf.3 lrint.3 llrintl.3 \ lrint.3 lrintf.3 lrint.3 lrintl.3 MLINKS+=lround.3 llround.3 lround.3 llroundf.3 lround.3 llroundl.3 \ lround.3 lroundf.3 lround.3 lroundl.3 MLINKS+=nan.3 nanf.3 nan.3 nanl.3 MLINKS+=nextafter.3 nextafterf.3 nextafter.3 nextafterl.3 MLINKS+=nextafter.3 nexttoward.3 nextafter.3 nexttowardf.3 MLINKS+=nextafter.3 nexttowardl.3 MLINKS+=remainder.3 remainderf.3 remainder.3 remainderl.3 \ remainder.3 remquo.3 remainder.3 remquof.3 remainder.3 remquol.3 MLINKS+=rint.3 rintf.3 rint.3 rintl.3 \ rint.3 nearbyint.3 rint.3 nearbyintf.3 rint.3 nearbyintl.3 MLINKS+=round.3 roundf.3 round.3 roundl.3 MLINKS+=scalbn.3 scalbln.3 scalbn.3 scalblnf.3 scalbn.3 scalblnl.3 MLINKS+=scalbn.3 scalbnf.3 scalbn.3 scalbnl.3 MLINKS+=sin.3 sinf.3 sin.3 sinl.3 +MLINKS+=sincos.3 sincosf.3 sin.3 sincosl.3 MLINKS+=sinh.3 sinhf.3 sinh.3 sinhl.3 MLINKS+=sqrt.3 cbrt.3 sqrt.3 cbrtf.3 sqrt.3 cbrtl.3 sqrt.3 sqrtf.3 \ sqrt.3 sqrtl.3 MLINKS+=tan.3 tanf.3 tan.3 tanl.3 MLINKS+=tanh.3 tanhf.3 tanh.3 tanhl.3 MLINKS+=trunc.3 truncf.3 trunc.3 truncl.3 .include .if ${MK_TESTS} != "no" SUBDIR+= tests .endif .include Index: stable/11/lib/msun/Symbol.map =================================================================== --- stable/11/lib/msun/Symbol.map (revision 324005) +++ stable/11/lib/msun/Symbol.map (revision 324006) @@ -1,287 +1,300 @@ /* * $FreeBSD$ */ /* 7.0-CURRENT */ FBSD_1.0 { __fe_dfl_env; tgamma; acos; acosf; acosh; acoshf; asin; asinf; atan2; atan2f; atanh; atanhf; cosh; coshf; exp; expf; fmod; fmodf; gamma; gamma_r; gammaf; gammaf_r; hypot; hypotf; j0; y0; j0f; y0f; j1; y1; j1f; y1f; jn; yn; jnf; ynf; lgamma; lgamma_r; lgammaf; lgammaf_r; log; log10; log10f; logf; pow; powf; remainder; remainderf; scalb; scalbf; sinh; sinhf; sqrt; sqrtf; asinh; asinhf; atan; atanf; cbrt; cbrtf; ceil; ceilf; ceill; cimag; cimagf; cimagl; conj; conjf; conjl; copysign; copysignf; copysignl; cos; cosf; creal; crealf; creall; erf; erfc; erff; erfcf; exp2; exp2f; expm1; expm1f; fabs; fabsf; fabsl; fdim; fdimf; fdiml; finite; finitef; floor; floorf; floorl; fma; fmaf; fmal; fmax; fmaxf; fmaxl; fmin; fminf; fminl; frexp; frexpf; frexpl; ilogb; ilogbf; ilogbl; __isfinite; __isfinitef; __isfinitel; isnanf; __isnanl; __isnormal; __isnormalf; __isnormall; llrint; llrintf; llround; llroundf; llroundl; log1p; log1pf; logb; logbf; lrint; lrintf; lround; lroundf; lroundl; modff; modfl; nearbyint; nearbyintf; nextafter; nexttoward; nexttowardl; nextafterl; nextafterf; nexttowardf; remquo; remquof; rint; rintf; round; roundf; roundl; scalbln; scalblnf; scalblnl; scalbn; scalbnl; scalbnf; ldexpf; ldexpl; __signbit; __signbitf; __signbitl; signgam; significand; significandf; sin; sinf; tan; tanf; tanh; tanhf; trunc; truncf; truncl; cabs; cabsf; drem; dremf; }; /* First added in 8.0-CURRENT */ FBSD_1.1 { carg; cargf; csqrt; csqrtf; logbl; nan; nanf; nanl; llrintl; lrintl; nearbyintl; rintl; exp2l; sinl; cosl; tanl; tgammaf; sqrtl; hypotl; cabsl; csqrtl; remquol; remainderl; fmodl; acosl; asinl; atan2l; atanl; cargl; cproj; cprojf; cprojl; }; /* First added in 9.0-CURRENT */ FBSD_1.2 { __isnanf; cbrtl; cexp; cexpf; log2; log2f; }; /* First added in 10.0-CURRENT */ FBSD_1.3 { feclearexcept; fegetexceptflag; fetestexcept; fegetround; fesetround; fesetenv; acoshl; asinhl; atanhl; cacos; cacosf; cacosh; cacoshf; casin; casinf; casinh; casinhf; catan; catanf; catanh; catanhf; csin; csinf; csinh; csinhf; ccos; ccosf; ccosh; ccoshf; coshl; ctan; ctanf; ctanh; ctanhf; erfcl; erfl; expl; expm1l; lgammal; log10l; log1pl; log2l; logl; sinhl; tanhl; /* Implemented as weak aliases for imprecise versions */ powl; tgammal; }; /* First added in 11.0-CURRENT */ FBSD_1.4 { lgammal_r; }; + +/* First added in 12.0-CURRENT */ +FBSD_1.5 { + cacoshl; + cacosl; + casinhl; + casinl; + catanl; + catanhl; + sincos; + sincosf; + sincosl; +}; Index: stable/11/lib/msun/amd64/Makefile.inc =================================================================== --- stable/11/lib/msun/amd64/Makefile.inc (revision 324005) +++ stable/11/lib/msun/amd64/Makefile.inc (revision 324006) @@ -1,10 +1,11 @@ # $FreeBSD$ -ARCH_SRCS = e_remainder.S e_remainderf.S e_remainderl.S \ +ARCH_SRCS = e_fmod.S e_fmodf.S e_fmodl.S \ + e_remainder.S e_remainderf.S e_remainderl.S \ e_sqrt.S e_sqrtf.S e_sqrtl.S \ s_llrint.S s_llrintf.S s_llrintl.S \ s_logbl.S s_lrint.S s_lrintf.S s_lrintl.S \ s_remquo.S s_remquof.S s_remquol.S \ s_rintl.S s_scalbn.S s_scalbnf.S s_scalbnl.S LDBL_PREC = 64 SYM_MAPS += ${.CURDIR}/amd64/Symbol.map Index: stable/11/lib/msun/amd64/e_fmod.S =================================================================== --- stable/11/lib/msun/amd64/e_fmod.S (nonexistent) +++ stable/11/lib/msun/amd64/e_fmod.S (revision 324006) @@ -0,0 +1,54 @@ +/* + * Copyright (c) 1993,94 Winning Strategies, Inc. + * 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. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Winning Strategies, Inc. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * 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. + */ + +/* + * Based on the i387 version written by: + * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. + */ + +#include +__FBSDID("$FreeBSD$") + +ENTRY(fmod) + movsd %xmm0,-8(%rsp) + movsd %xmm1,-16(%rsp) + fldl -16(%rsp) + fldl -8(%rsp) +1: fprem + fstsw %ax + testw $0x400,%ax + jne 1b + fstpl -8(%rsp) + movsd -8(%rsp),%xmm0 + fstp %st + ret +END(fmod) + + .section .note.GNU-stack,"",%progbits Property changes on: stable/11/lib/msun/amd64/e_fmod.S ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/lib/msun/amd64/e_fmodf.S =================================================================== --- stable/11/lib/msun/amd64/e_fmodf.S (nonexistent) +++ stable/11/lib/msun/amd64/e_fmodf.S (revision 324006) @@ -0,0 +1,24 @@ +/* + * Based on the i387 version written by J.T. Conklin . + * Public domain. + */ + +#include +__FBSDID("$FreeBSD$") + +ENTRY(fmodf) + movss %xmm0,-4(%rsp) + movss %xmm1,-8(%rsp) + flds -8(%rsp) + flds -4(%rsp) +1: fprem + fstsw %ax + testw $0x400,%ax + jne 1b + fstps -4(%rsp) + movss -4(%rsp),%xmm0 + fstp %st + ret +END(fmodf) + + .section .note.GNU-stack,"",%progbits Property changes on: stable/11/lib/msun/amd64/e_fmodf.S ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/lib/msun/amd64/e_fmodl.S =================================================================== --- stable/11/lib/msun/amd64/e_fmodl.S (nonexistent) +++ stable/11/lib/msun/amd64/e_fmodl.S (revision 324006) @@ -0,0 +1,50 @@ +/* + * Copyright (c) 1993,94 Winning Strategies, Inc. + * 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. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Winning Strategies, Inc. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * 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. + */ + +/* + * Based on the i387 version written by: + * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. + */ + +#include +__FBSDID("$FreeBSD$") + +ENTRY(fmodl) + fldt 24(%rsp) + fldt 8(%rsp) +1: fprem + fstsw %ax + testw $0x400,%ax + jne 1b + fstp %st(1) + ret +END(fmodl) + + .section .note.GNU-stack,"",%progbits Property changes on: stable/11/lib/msun/amd64/e_fmodl.S ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/lib/msun/i387/Makefile.inc =================================================================== --- stable/11/lib/msun/i387/Makefile.inc (revision 324005) +++ stable/11/lib/msun/i387/Makefile.inc (revision 324006) @@ -1,21 +1,22 @@ # $FreeBSD$ ARCH_SRCS = e_exp.S e_fmod.S e_log.S e_log10.S \ e_remainder.S e_sqrt.S s_ceil.S s_copysign.S \ - s_cos.S s_finite.S s_floor.S s_llrint.S s_logb.S s_lrint.S \ - s_remquo.S s_rint.S s_scalbn.S s_significand.S s_sin.S s_tan.S \ + s_finite.S s_floor.S s_llrint.S s_logb.S s_lrint.S \ + s_remquo.S s_rint.S s_scalbn.S s_significand.S \ s_trunc.S # float counterparts -ARCH_SRCS+= e_log10f.S e_logf.S e_remainderf.S \ +ARCH_SRCS+= e_fmodf.S e_log10f.S e_logf.S e_remainderf.S \ e_sqrtf.S s_ceilf.S s_copysignf.S s_floorf.S \ s_llrintf.S s_logbf.S s_lrintf.S \ s_remquof.S s_rintf.S s_scalbnf.S s_significandf.S s_truncf.S # long double counterparts -ARCH_SRCS+= e_remainderl.S e_sqrtl.S s_ceill.S s_copysignl.S \ +ARCH_SRCS+= e_fmodl.S \ + e_remainderl.S e_sqrtl.S s_ceill.S s_copysignl.S \ s_floorl.S s_llrintl.S \ s_logbl.S s_lrintl.S s_remquol.S s_rintl.S s_scalbnl.S s_truncl.S LDBL_PREC = 64 # XXX 64-bit format, but truncated to 53 bits SYM_MAPS += ${.CURDIR}/i387/Symbol.map Index: stable/11/lib/msun/i387/e_fmodf.S =================================================================== --- stable/11/lib/msun/i387/e_fmodf.S (nonexistent) +++ stable/11/lib/msun/i387/e_fmodf.S (revision 324006) @@ -0,0 +1,20 @@ +/* + * Written by J.T. Conklin . + * Public domain. + */ + +#include +__FBSDID("$FreeBSD$") + +ENTRY(fmodf) + flds 8(%esp) + flds 4(%esp) +1: fprem + fstsw %ax + sahf + jp 1b + fstp %st(1) + ret +END(fmodf) + + .section .note.GNU-stack,"",%progbits Property changes on: stable/11/lib/msun/i387/e_fmodf.S ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/lib/msun/i387/e_fmodl.S =================================================================== --- stable/11/lib/msun/i387/e_fmodl.S (nonexistent) +++ stable/11/lib/msun/i387/e_fmodl.S (revision 324006) @@ -0,0 +1,50 @@ +/* + * Copyright (c) 1993,94 Winning Strategies, Inc. + * 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. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Winning Strategies, Inc. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * 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. + */ + +/* + * Written by: + * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. + */ + +#include +__FBSDID("$FreeBSD$") + +ENTRY(fmodl) + fldt 16(%esp) + fldt 4(%esp) +1: fprem + fstsw %ax + sahf + jp 1b + fstp %st(1) + ret +END(fmodl) + + .section .note.GNU-stack,"",%progbits Property changes on: stable/11/lib/msun/i387/e_fmodl.S ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/lib/msun/ld80/e_lgammal_r.c =================================================================== --- stable/11/lib/msun/ld80/e_lgammal_r.c (revision 324005) +++ stable/11/lib/msun/ld80/e_lgammal_r.c (revision 324006) @@ -1,358 +1,358 @@ /* @(#)e_lgamma_r.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 __FBSDID("$FreeBSD$"); /* * See e_lgamma_r.c for complete comments. * * Converted to long double by Steven G. Kargl. */ #ifdef __i386__ #include #endif #include "fpmath.h" #include "math.h" #include "math_private.h" static const volatile double vzero = 0; static const double zero= 0, half= 0.5, one = 1; static const union IEEEl2bits piu = LD80C(0xc90fdaa22168c235, 1, 3.14159265358979323851e+00L); #define pi (piu.e) /* * Domain y in [0x1p-70, 0.27], range ~[-4.5264e-22, 4.5264e-22]: * |(lgamma(2 - y) + y / 2) / y - a(y)| < 2**-70.9 */ static const union IEEEl2bits a0u = LD80C(0x9e233f1bed863d26, -4, 7.72156649015328606028e-02L), a1u = LD80C(0xa51a6625307d3249, -2, 3.22467033424113218889e-01L), a2u = LD80C(0x89f000d2abafda8c, -4, 6.73523010531979398946e-02L), a3u = LD80C(0xa8991563eca75f26, -6, 2.05808084277991211934e-02L), a4u = LD80C(0xf2027e10634ce6b6, -8, 7.38555102796070454026e-03L), a5u = LD80C(0xbd6eb76dd22187f4, -9, 2.89051035162703932972e-03L), a6u = LD80C(0x9c562ab05e0458ed, -10, 1.19275351624639999297e-03L), a7u = LD80C(0x859baed93ee48e46, -11, 5.09674593842117925320e-04L), a8u = LD80C(0xe9f28a4432949af2, -13, 2.23109648015769155122e-04L), a9u = LD80C(0xd12ad0d9b93c6bb0, -14, 9.97387167479808509830e-05L), a10u= LD80C(0xb7522643c78a219b, -15, 4.37071076331030136818e-05L), a11u= LD80C(0xca024dcdece2cb79, -16, 2.40813493372040143061e-05L), a12u= LD80C(0xbb90fb6968ebdbf9, -19, 2.79495621083634031729e-06L), a13u= LD80C(0xba1c9ffeeae07b37, -17, 1.10931287015513924136e-05L); #define a0 (a0u.e) #define a1 (a1u.e) #define a2 (a2u.e) #define a3 (a3u.e) #define a4 (a4u.e) #define a5 (a5u.e) #define a6 (a6u.e) #define a7 (a7u.e) #define a8 (a8u.e) #define a9 (a9u.e) #define a10 (a10u.e) #define a11 (a11u.e) #define a12 (a12u.e) #define a13 (a13u.e) /* * Domain x in [tc-0.24, tc+0.28], range ~[-6.1205e-22, 6.1205e-22]: * |(lgamma(x) - tf) - t(x - tc)| < 2**-70.5 */ static const union IEEEl2bits tcu = LD80C(0xbb16c31ab5f1fb71, 0, 1.46163214496836234128e+00L), tfu = LD80C(0xf8cdcde61c520e0f, -4, -1.21486290535849608093e-01L), ttu = LD80C(0xd46ee54b27d4de99, -69, -2.81152980996018785880e-21L), t0u = LD80C(0x80b9406556a62a6b, -68, 3.40728634996055147231e-21L), t1u = LD80C(0xc7e9c6f6df3f8c39, -67, -1.05833162742737073665e-20L), t2u = LD80C(0xf7b95e4771c55d51, -2, 4.83836122723810583532e-01L), t3u = LD80C(0x97213c6e35e119ff, -3, -1.47587722994530691476e-01L), t4u = LD80C(0x845a14a6a81dc94b, -4, 6.46249402389135358063e-02L), t5u = LD80C(0x864d46fa89997796, -5, -3.27885410884846056084e-02L), t6u = LD80C(0x93373cbd00297438, -6, 1.79706751150707171293e-02L), t7u = LD80C(0xa8fcfca7eddc8d1d, -7, -1.03142230361450732547e-02L), t8u = LD80C(0xc7e7015ff4bc45af, -8, 6.10053603296546099193e-03L), t9u = LD80C(0xf178d2247adc5093, -9, -3.68456964904901200152e-03L), t10u = LD80C(0x94188d58f12e5e9f, -9, 2.25976420273774583089e-03L), t11u = LD80C(0xb7cbaef14e1406f1, -10, -1.40224943666225639823e-03L), t12u = LD80C(0xe63a671e6704ea4d, -11, 8.78250640744776944887e-04L), t13u = LD80C(0x914b6c9cae61783e, -11, -5.54255012657716808811e-04L), t14u = LD80C(0xb858f5bdb79276fe, -12, 3.51614951536825927370e-04L), t15u = LD80C(0xea73e744c34b9591, -13, -2.23591563824520112236e-04L), t16u = LD80C(0x99aeabb0d67ba835, -13, 1.46562869351659194136e-04L), t17u = LD80C(0xd7c6938325db2024, -14, -1.02889866046435680588e-04L), t18u = LD80C(0xe24cb1e3b0474775, -15, 5.39540265505221957652e-05L); #define tc (tcu.e) #define tf (tfu.e) #define tt (ttu.e) #define t0 (t0u.e) #define t1 (t1u.e) #define t2 (t2u.e) #define t3 (t3u.e) #define t4 (t4u.e) #define t5 (t5u.e) #define t6 (t6u.e) #define t7 (t7u.e) #define t8 (t8u.e) #define t9 (t9u.e) #define t10 (t10u.e) #define t11 (t11u.e) #define t12 (t12u.e) #define t13 (t13u.e) #define t14 (t14u.e) #define t15 (t15u.e) #define t16 (t16u.e) #define t17 (t17u.e) #define t18 (t18u.e) /* * Domain y in [-0.1, 0.232], range ~[-8.1938e-22, 8.3815e-22]: * |(lgamma(1 + y) + 0.5 * y) / y - u(y) / v(y)| < 2**-71.2 */ static const union IEEEl2bits u0u = LD80C(0x9e233f1bed863d27, -4, -7.72156649015328606095e-02L), u1u = LD80C(0x98280ee45e4ddd3d, -1, 5.94361239198682739769e-01L), u2u = LD80C(0xe330c8ead4130733, 0, 1.77492629495841234275e+00L), u3u = LD80C(0xd4a213f1a002ec52, 0, 1.66119622514818078064e+00L), u4u = LD80C(0xa5a9ca6f5bc62163, -1, 6.47122051417476492989e-01L), u5u = LD80C(0xc980e49cd5b019e6, -4, 9.83903751718671509455e-02L), u6u = LD80C(0xff636a8bdce7025b, -9, 3.89691687802305743450e-03L), v1u = LD80C(0xbd109c533a19fbf5, 1, 2.95413883330948556544e+00L), v2u = LD80C(0xd295cbf96f31f099, 1, 3.29039286955665403176e+00L), v3u = LD80C(0xdab8bcfee40496cb, 0, 1.70876276441416471410e+00L), v4u = LD80C(0xd2f2dc3638567e9f, -2, 4.12009126299534668571e-01L), v5u = LD80C(0xa07d9b0851070f41, -5, 3.91822868305682491442e-02L), v6u = LD80C(0xe3cd8318f7adb2c4, -11, 8.68998648222144351114e-04L); #define u0 (u0u.e) #define u1 (u1u.e) #define u2 (u2u.e) #define u3 (u3u.e) #define u4 (u4u.e) #define u5 (u5u.e) #define u6 (u6u.e) #define v1 (v1u.e) #define v2 (v2u.e) #define v3 (v3u.e) #define v4 (v4u.e) #define v5 (v5u.e) #define v6 (v6u.e) /* * Domain x in (2, 3], range ~[-3.3648e-22, 3.4416e-22]: * |(lgamma(y+2) - 0.5 * y) / y - s(y)/r(y)| < 2**-72.3 * with y = x - 2. */ static const union IEEEl2bits s0u = LD80C(0x9e233f1bed863d27, -4, -7.72156649015328606095e-02L), s1u = LD80C(0xd3ff0dcc7fa91f94, -3, 2.07027640921219389860e-01L), s2u = LD80C(0xb2bb62782478ef31, -2, 3.49085881391362090549e-01L), s3u = LD80C(0xb49f7438c4611a74, -3, 1.76389518704213357954e-01L), s4u = LD80C(0x9a957008fa27ecf9, -5, 3.77401710862930008071e-02L), s5u = LD80C(0xda9b389a6ca7a7ac, -9, 3.33566791452943399399e-03L), s6u = LD80C(0xbc7a2263faf59c14, -14, 8.98728786745638844395e-05L), r1u = LD80C(0xbf5cff5b11477d4d, 0, 1.49502555796294337722e+00L), r2u = LD80C(0xd9aec89de08e3da6, -1, 8.50323236984473285866e-01L), r3u = LD80C(0xeab7ae5057c443f9, -3, 2.29216312078225806131e-01L), r4u = LD80C(0xf29707d9bd2b1e37, -6, 2.96130326586640089145e-02L), r5u = LD80C(0xd376c2f09736c5a3, -10, 1.61334161411590662495e-03L), r6u = LD80C(0xc985983d0cd34e3d, -16, 2.40232770710953450636e-05L), r7u = LD80C(0xe5c7a4f7fc2ef13d, -25, -5.34997929289167573510e-08L); #define s0 (s0u.e) #define s1 (s1u.e) #define s2 (s2u.e) #define s3 (s3u.e) #define s4 (s4u.e) #define s5 (s5u.e) #define s6 (s6u.e) #define r1 (r1u.e) #define r2 (r2u.e) #define r3 (r3u.e) #define r4 (r4u.e) #define r5 (r5u.e) #define r6 (r6u.e) #define r7 (r7u.e) /* * Domain z in [8, 0x1p70], range ~[-3.0235e-22, 3.0563e-22]: * |lgamma(x) - (x - 0.5) * (log(x) - 1) - w(1/x)| < 2**-71.7 */ static const union IEEEl2bits w0u = LD80C(0xd67f1c864beb4a69, -2, 4.18938533204672741776e-01L), w1u = LD80C(0xaaaaaaaaaaaaaaa1, -4, 8.33333333333333332678e-02L), w2u = LD80C(0xb60b60b60b5491c9, -9, -2.77777777777760927870e-03L), w3u = LD80C(0xd00d00cf58aede4c, -11, 7.93650793490637233668e-04L), w4u = LD80C(0x9c09bf626783d4a5, -11, -5.95238023926039051268e-04L), w5u = LD80C(0xdca7cadc5baa517b, -11, 8.41733700408000822962e-04L), w6u = LD80C(0xfb060e361e1ffd07, -10, -1.91515849570245136604e-03L), w7u = LD80C(0xcbd5101bb58d1f2b, -8, 6.22046743903262649294e-03L), w8u = LD80C(0xad27a668d32c821b, -6, -2.11370706734662081843e-02L); #define w0 (w0u.e) #define w1 (w1u.e) #define w2 (w2u.e) #define w3 (w3u.e) #define w4 (w4u.e) #define w5 (w5u.e) #define w6 (w6u.e) #define w7 (w7u.e) #define w8 (w8u.e) static long double sin_pil(long double x) { volatile long double vz; long double y,z; uint64_t n; uint16_t hx; y = -x; vz = y+0x1p63; z = vz-0x1p63; if (z == y) return zero; vz = y+0x1p61; EXTRACT_LDBL80_WORDS(hx,n,vz); z = vz-0x1p61; 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_sinl(pi*y,zero,0); break; case 1: case 2: y = __kernel_cosl(pi*(0.5-y),zero); break; case 3: case 4: y = __kernel_sinl(pi*(one-y),zero,0); break; case 5: case 6: y = -__kernel_cosl(pi*(y-1.5),zero); break; default: y = __kernel_sinl(pi*(y-2.0),zero,0); break; } return -y; } long double lgammal_r(long double x, int *signgamp) { - long double nadj,p,p1,p2,p3,q,r,t,w,y,z; + long double nadj,p,p1,p2,q,r,t,w,y,z; uint64_t lx; int i; uint16_t hx,ix; EXTRACT_LDBL80_WORDS(hx,lx,x); /* purge +-Inf and NaNs */ *signgamp = 1; ix = hx&0x7fff; if(ix==0x7fff) return x*x; ENTERI(); /* purge +-0 and tiny arguments */ *signgamp = 1-2*(hx>>15); if(ix<0x3fff-67) { /* |x|<2**-(p+3), return -log(|x|) */ if((ix|lx)==0) RETURNI(one/vzero); RETURNI(-logl(fabsl(x))); } /* purge negative integers and start evaluation for other x < 0 */ if(hx&0x8000) { *signgamp = 1; if(ix>=0x3fff+63) /* |x|>=2**(p-1), must be -integer */ RETURNI(one/vzero); t = sin_pil(x); if(t==zero) RETURNI(one/vzero); /* -integer */ nadj = logl(pi/fabsl(t*x)); if(t=7.3159980773925781e-01) {y = 1-x; i= 0;} else if(x>=2.3163998126983643e-01) {y= x-(tc-1); i=1;} else {y = x; i=2;} } else { r = 0; if(x>=1.7316312789916992e+00) {y=2-x;i=0;} else if(x>=1.2316322326660156e+00) {y=x-tc;i=1;} else {y=x-1;i=2;} } switch(i) { case 0: z = y*y; p1 = a0+z*(a2+z*(a4+z*(a6+z*(a8+z*(a10+z*a12))))); p2 = z*(a1+z*(a3+z*(a5+z*(a7+z*(a9+z*(a11+z*a13)))))); p = y*p1+p2; r += p-y/2; break; case 1: p = t0+y*t1+tt+y*y*(t2+y*(t3+y*(t4+y*(t5+y*(t6+y*(t7+y*(t8+ y*(t9+y*(t10+y*(t11+y*(t12+y*(t13+y*(t14+y*(t15+y*(t16+ y*(t17+y*t18)))))))))))))))); r += tf + p; break; case 2: p1 = y*(u0+y*(u1+y*(u2+y*(u3+y*(u4+y*(u5+y*u6)))))); p2 = 1+y*(v1+y*(v2+y*(v3+y*(v4+y*(v5+y*v6))))); r += p1/p2-y/2; } } /* x < 8.0 */ else if(ix<0x4002) { i = x; y = x-i; p = y*(s0+y*(s1+y*(s2+y*(s3+y*(s4+y*(s5+y*s6)))))); q = 1+y*(r1+y*(r2+y*(r3+y*(r4+y*(r5+y*(r6+y*r7)))))); r = y/2+p/q; z = 1; /* lgamma(1+s) = log(s) + lgamma(s) */ switch(i) { 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 += logl(z); break; } /* 8.0 <= x < 2**(p+3) */ } else if (ix<0x3fff+67) { t = logl(x); z = one/x; y = z*z; w = w0+z*(w1+y*(w2+y*(w3+y*(w4+y*(w5+y*(w6+y*(w7+y*w8))))))); r = (x-half)*(t-one)+w; /* 2**(p+3) <= x <= inf */ } else r = x*(logl(x)-1); if(hx&0x8000) r = nadj - r; RETURNI(r); } Index: stable/11/lib/msun/ld80/k_expl.h =================================================================== --- stable/11/lib/msun/ld80/k_expl.h (revision 324005) +++ stable/11/lib/msun/ld80/k_expl.h (revision 324006) @@ -1,305 +1,305 @@ /* from: FreeBSD: head/lib/msun/ld80/s_expl.c 251343 2013-06-03 19:51:32Z kargl */ /*- * Copyright (c) 2009-2013 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. * * Optimized by Bruce D. Evans. */ #include __FBSDID("$FreeBSD$"); /* * See s_expl.c for more comments about __k_expl(). * * See ../src/e_exp.c and ../src/k_exp.h for precision-independent comments * about the secondary kernels. */ #define INTERVALS 128 #define LOG2_INTERVALS 7 #define BIAS (LDBL_MAX_EXP - 1) static const double /* * ln2/INTERVALS = L1+L2 (hi+lo decomposition for multiplication). L1 must * have at least 22 (= log2(|LDBL_MIN_EXP-extras|) + log2(INTERVALS)) lowest * bits zero so that multiplication of it by n is exact. */ INV_L = 1.8466496523378731e+2, /* 0x171547652b82fe.0p-45 */ L1 = 5.4152123484527692e-3, /* 0x162e42ff000000.0p-60 */ L2 = -3.2819649005320973e-13, /* -0x1718432a1b0e26.0p-94 */ /* * Domain [-0.002708, 0.002708], range ~[-5.7136e-24, 5.7110e-24]: * |exp(x) - p(x)| < 2**-77.2 * (0.002708 is ln2/(2*INTERVALS) rounded up a little). */ A2 = 0.5, A3 = 1.6666666666666119e-1, /* 0x15555555555490.0p-55 */ A4 = 4.1666666666665887e-2, /* 0x155555555554e5.0p-57 */ A5 = 8.3333354987869413e-3, /* 0x1111115b789919.0p-59 */ A6 = 1.3888891738560272e-3; /* 0x16c16c651633ae.0p-62 */ /* * 2^(i/INTERVALS) for i in [0,INTERVALS] is represented by two values where * the first 53 bits of the significand are stored in hi and the next 53 * bits are in lo. Tang's paper states that the trailing 6 bits of hi must * be zero for his algorithm in both single and double precision, because * the table is re-used in the implementation of expm1() where a floating * point addition involving hi must be exact. Here hi is double, so * converting it to long double gives 11 trailing zero bits. */ static const struct { double hi; double lo; } tbl[INTERVALS] = { - 0x1p+0, 0x0p+0, + { 0x1p+0, 0x0p+0 }, /* * XXX hi is rounded down, and the formatting is not quite normal. * But I rather like both. The 0x1.*p format is good for 4N+1 * mantissa bits. Rounding down makes the lo terms positive, * so that the columnar formatting can be simpler. */ - 0x1.0163da9fb3335p+0, 0x1.b61299ab8cdb7p-54, - 0x1.02c9a3e778060p+0, 0x1.dcdef95949ef4p-53, - 0x1.04315e86e7f84p+0, 0x1.7ae71f3441b49p-53, - 0x1.059b0d3158574p+0, 0x1.d73e2a475b465p-55, - 0x1.0706b29ddf6ddp+0, 0x1.8db880753b0f6p-53, - 0x1.0874518759bc8p+0, 0x1.186be4bb284ffp-57, - 0x1.09e3ecac6f383p+0, 0x1.1487818316136p-54, - 0x1.0b5586cf9890fp+0, 0x1.8a62e4adc610bp-54, - 0x1.0cc922b7247f7p+0, 0x1.01edc16e24f71p-54, - 0x1.0e3ec32d3d1a2p+0, 0x1.03a1727c57b53p-59, - 0x1.0fb66affed31ap+0, 0x1.e464123bb1428p-53, - 0x1.11301d0125b50p+0, 0x1.49d77e35db263p-53, - 0x1.12abdc06c31cbp+0, 0x1.f72575a649ad2p-53, - 0x1.1429aaea92ddfp+0, 0x1.66820328764b1p-53, - 0x1.15a98c8a58e51p+0, 0x1.2406ab9eeab0ap-55, - 0x1.172b83c7d517ap+0, 0x1.b9bef918a1d63p-53, - 0x1.18af9388c8de9p+0, 0x1.777ee1734784ap-53, - 0x1.1a35beb6fcb75p+0, 0x1.e5b4c7b4968e4p-55, - 0x1.1bbe084045cd3p+0, 0x1.3563ce56884fcp-53, - 0x1.1d4873168b9aap+0, 0x1.e016e00a2643cp-54, - 0x1.1ed5022fcd91cp+0, 0x1.71033fec2243ap-53, - 0x1.2063b88628cd6p+0, 0x1.dc775814a8495p-55, - 0x1.21f49917ddc96p+0, 0x1.2a97e9494a5eep-55, - 0x1.2387a6e756238p+0, 0x1.9b07eb6c70573p-54, - 0x1.251ce4fb2a63fp+0, 0x1.ac155bef4f4a4p-55, - 0x1.26b4565e27cddp+0, 0x1.2bd339940e9d9p-55, - 0x1.284dfe1f56380p+0, 0x1.2d9e2b9e07941p-53, - 0x1.29e9df51fdee1p+0, 0x1.612e8afad1255p-55, - 0x1.2b87fd0dad98fp+0, 0x1.fbbd48ca71f95p-53, - 0x1.2d285a6e4030bp+0, 0x1.0024754db41d5p-54, - 0x1.2ecafa93e2f56p+0, 0x1.1ca0f45d52383p-56, - 0x1.306fe0a31b715p+0, 0x1.6f46ad23182e4p-55, - 0x1.32170fc4cd831p+0, 0x1.a9ce78e18047cp-55, - 0x1.33c08b26416ffp+0, 0x1.32721843659a6p-54, - 0x1.356c55f929ff0p+0, 0x1.928c468ec6e76p-53, - 0x1.371a7373aa9cap+0, 0x1.4e28aa05e8a8fp-53, - 0x1.38cae6d05d865p+0, 0x1.0b53961b37da2p-53, - 0x1.3a7db34e59ff6p+0, 0x1.d43792533c144p-53, - 0x1.3c32dc313a8e4p+0, 0x1.08003e4516b1ep-53, - 0x1.3dea64c123422p+0, 0x1.ada0911f09ebcp-55, - 0x1.3fa4504ac801bp+0, 0x1.417ee03548306p-53, - 0x1.4160a21f72e29p+0, 0x1.f0864b71e7b6cp-53, - 0x1.431f5d950a896p+0, 0x1.b8e088728219ap-53, - 0x1.44e086061892dp+0, 0x1.89b7a04ef80d0p-59, - 0x1.46a41ed1d0057p+0, 0x1.c944bd1648a76p-54, - 0x1.486a2b5c13cd0p+0, 0x1.3c1a3b69062f0p-56, - 0x1.4a32af0d7d3dep+0, 0x1.9cb62f3d1be56p-54, - 0x1.4bfdad5362a27p+0, 0x1.d4397afec42e2p-56, - 0x1.4dcb299fddd0dp+0, 0x1.8ecdbbc6a7833p-54, - 0x1.4f9b2769d2ca6p+0, 0x1.5a67b16d3540ep-53, - 0x1.516daa2cf6641p+0, 0x1.8225ea5909b04p-53, - 0x1.5342b569d4f81p+0, 0x1.be1507893b0d5p-53, - 0x1.551a4ca5d920ep+0, 0x1.8a5d8c4048699p-53, - 0x1.56f4736b527dap+0, 0x1.9bb2c011d93adp-54, - 0x1.58d12d497c7fdp+0, 0x1.295e15b9a1de8p-55, - 0x1.5ab07dd485429p+0, 0x1.6324c054647adp-54, - 0x1.5c9268a5946b7p+0, 0x1.c4b1b816986a2p-60, - 0x1.5e76f15ad2148p+0, 0x1.ba6f93080e65ep-54, - 0x1.605e1b976dc08p+0, 0x1.60edeb25490dcp-53, - 0x1.6247eb03a5584p+0, 0x1.63e1f40dfa5b5p-53, - 0x1.6434634ccc31fp+0, 0x1.8edf0e2989db3p-53, - 0x1.6623882552224p+0, 0x1.224fb3c5371e6p-53, - 0x1.68155d44ca973p+0, 0x1.038ae44f73e65p-57, - 0x1.6a09e667f3bccp+0, 0x1.21165f626cdd5p-53, - 0x1.6c012750bdabep+0, 0x1.daed533001e9ep-53, - 0x1.6dfb23c651a2ep+0, 0x1.e441c597c3775p-53, - 0x1.6ff7df9519483p+0, 0x1.9f0fc369e7c42p-53, - 0x1.71f75e8ec5f73p+0, 0x1.ba46e1e5de15ap-53, - 0x1.73f9a48a58173p+0, 0x1.7ab9349cd1562p-53, - 0x1.75feb564267c8p+0, 0x1.7edd354674916p-53, - 0x1.780694fde5d3fp+0, 0x1.866b80a02162dp-54, - 0x1.7a11473eb0186p+0, 0x1.afaa2047ed9b4p-53, - 0x1.7c1ed0130c132p+0, 0x1.f124cd1164dd6p-54, - 0x1.7e2f336cf4e62p+0, 0x1.05d02ba15797ep-56, - 0x1.80427543e1a11p+0, 0x1.6c1bccec9346bp-53, - 0x1.82589994cce12p+0, 0x1.159f115f56694p-53, - 0x1.8471a4623c7acp+0, 0x1.9ca5ed72f8c81p-53, - 0x1.868d99b4492ecp+0, 0x1.01c83b21584a3p-53, - 0x1.88ac7d98a6699p+0, 0x1.994c2f37cb53ap-54, - 0x1.8ace5422aa0dbp+0, 0x1.6e9f156864b27p-54, - 0x1.8cf3216b5448bp+0, 0x1.de55439a2c38bp-53, - 0x1.8f1ae99157736p+0, 0x1.5cc13a2e3976cp-55, - 0x1.9145b0b91ffc5p+0, 0x1.114c368d3ed6ep-53, - 0x1.93737b0cdc5e4p+0, 0x1.e8a0387e4a814p-53, - 0x1.95a44cbc8520ep+0, 0x1.d36906d2b41f9p-53, - 0x1.97d829fde4e4fp+0, 0x1.173d241f23d18p-53, - 0x1.9a0f170ca07b9p+0, 0x1.7462137188ce7p-53, - 0x1.9c49182a3f090p+0, 0x1.c7c46b071f2bep-56, - 0x1.9e86319e32323p+0, 0x1.824ca78e64c6ep-56, - 0x1.a0c667b5de564p+0, 0x1.6535b51719567p-53, - 0x1.a309bec4a2d33p+0, 0x1.6305c7ddc36abp-54, - 0x1.a5503b23e255cp+0, 0x1.1684892395f0fp-53, - 0x1.a799e1330b358p+0, 0x1.bcb7ecac563c7p-54, - 0x1.a9e6b5579fdbfp+0, 0x1.0fac90ef7fd31p-54, - 0x1.ac36bbfd3f379p+0, 0x1.81b72cd4624ccp-53, - 0x1.ae89f995ad3adp+0, 0x1.7a1cd345dcc81p-54, - 0x1.b0e07298db665p+0, 0x1.2108559bf8deep-53, - 0x1.b33a2b84f15fap+0, 0x1.ed7fa1cf7b290p-53, - 0x1.b59728de55939p+0, 0x1.1c7102222c90ep-53, - 0x1.b7f76f2fb5e46p+0, 0x1.d54f610356a79p-53, - 0x1.ba5b030a10649p+0, 0x1.0819678d5eb69p-53, - 0x1.bcc1e904bc1d2p+0, 0x1.23dd07a2d9e84p-55, - 0x1.bf2c25bd71e08p+0, 0x1.0811ae04a31c7p-53, - 0x1.c199bdd85529cp+0, 0x1.11065895048ddp-55, - 0x1.c40ab5fffd07ap+0, 0x1.b4537e083c60ap-54, - 0x1.c67f12e57d14bp+0, 0x1.2884dff483cadp-54, - 0x1.c8f6d9406e7b5p+0, 0x1.1acbc48805c44p-56, - 0x1.cb720dcef9069p+0, 0x1.503cbd1e949dbp-56, - 0x1.cdf0b555dc3f9p+0, 0x1.889f12b1f58a3p-53, - 0x1.d072d4a07897bp+0, 0x1.1a1e45e4342b2p-53, - 0x1.d2f87080d89f1p+0, 0x1.15bc247313d44p-53, - 0x1.d5818dcfba487p+0, 0x1.2ed02d75b3707p-55, - 0x1.d80e316c98397p+0, 0x1.7709f3a09100cp-53, - 0x1.da9e603db3285p+0, 0x1.c2300696db532p-54, - 0x1.dd321f301b460p+0, 0x1.2da5778f018c3p-54, - 0x1.dfc97337b9b5ep+0, 0x1.72d195873da52p-53, - 0x1.e264614f5a128p+0, 0x1.424ec3f42f5b5p-53, - 0x1.e502ee78b3ff6p+0, 0x1.39e8980a9cc8fp-55, - 0x1.e7a51fbc74c83p+0, 0x1.2d522ca0c8de2p-54, - 0x1.ea4afa2a490d9p+0, 0x1.0b1ee7431ebb6p-53, - 0x1.ecf482d8e67f0p+0, 0x1.1b60625f7293ap-53, - 0x1.efa1bee615a27p+0, 0x1.dc7f486a4b6b0p-54, - 0x1.f252b376bba97p+0, 0x1.3a1a5bf0d8e43p-54, - 0x1.f50765b6e4540p+0, 0x1.9d3e12dd8a18bp-54, - 0x1.f7bfdad9cbe13p+0, 0x1.1227697fce57bp-53, - 0x1.fa7c1819e90d8p+0, 0x1.74853f3a5931ep-55, - 0x1.fd3c22b8f71f1p+0, 0x1.2eb74966579e7p-57 + { 0x1.0163da9fb3335p+0, 0x1.b61299ab8cdb7p-54 }, + { 0x1.02c9a3e778060p+0, 0x1.dcdef95949ef4p-53 }, + { 0x1.04315e86e7f84p+0, 0x1.7ae71f3441b49p-53 }, + { 0x1.059b0d3158574p+0, 0x1.d73e2a475b465p-55 }, + { 0x1.0706b29ddf6ddp+0, 0x1.8db880753b0f6p-53 }, + { 0x1.0874518759bc8p+0, 0x1.186be4bb284ffp-57 }, + { 0x1.09e3ecac6f383p+0, 0x1.1487818316136p-54 }, + { 0x1.0b5586cf9890fp+0, 0x1.8a62e4adc610bp-54 }, + { 0x1.0cc922b7247f7p+0, 0x1.01edc16e24f71p-54 }, + { 0x1.0e3ec32d3d1a2p+0, 0x1.03a1727c57b53p-59 }, + { 0x1.0fb66affed31ap+0, 0x1.e464123bb1428p-53 }, + { 0x1.11301d0125b50p+0, 0x1.49d77e35db263p-53 }, + { 0x1.12abdc06c31cbp+0, 0x1.f72575a649ad2p-53 }, + { 0x1.1429aaea92ddfp+0, 0x1.66820328764b1p-53 }, + { 0x1.15a98c8a58e51p+0, 0x1.2406ab9eeab0ap-55 }, + { 0x1.172b83c7d517ap+0, 0x1.b9bef918a1d63p-53 }, + { 0x1.18af9388c8de9p+0, 0x1.777ee1734784ap-53 }, + { 0x1.1a35beb6fcb75p+0, 0x1.e5b4c7b4968e4p-55 }, + { 0x1.1bbe084045cd3p+0, 0x1.3563ce56884fcp-53 }, + { 0x1.1d4873168b9aap+0, 0x1.e016e00a2643cp-54 }, + { 0x1.1ed5022fcd91cp+0, 0x1.71033fec2243ap-53 }, + { 0x1.2063b88628cd6p+0, 0x1.dc775814a8495p-55 }, + { 0x1.21f49917ddc96p+0, 0x1.2a97e9494a5eep-55 }, + { 0x1.2387a6e756238p+0, 0x1.9b07eb6c70573p-54 }, + { 0x1.251ce4fb2a63fp+0, 0x1.ac155bef4f4a4p-55 }, + { 0x1.26b4565e27cddp+0, 0x1.2bd339940e9d9p-55 }, + { 0x1.284dfe1f56380p+0, 0x1.2d9e2b9e07941p-53 }, + { 0x1.29e9df51fdee1p+0, 0x1.612e8afad1255p-55 }, + { 0x1.2b87fd0dad98fp+0, 0x1.fbbd48ca71f95p-53 }, + { 0x1.2d285a6e4030bp+0, 0x1.0024754db41d5p-54 }, + { 0x1.2ecafa93e2f56p+0, 0x1.1ca0f45d52383p-56 }, + { 0x1.306fe0a31b715p+0, 0x1.6f46ad23182e4p-55 }, + { 0x1.32170fc4cd831p+0, 0x1.a9ce78e18047cp-55 }, + { 0x1.33c08b26416ffp+0, 0x1.32721843659a6p-54 }, + { 0x1.356c55f929ff0p+0, 0x1.928c468ec6e76p-53 }, + { 0x1.371a7373aa9cap+0, 0x1.4e28aa05e8a8fp-53 }, + { 0x1.38cae6d05d865p+0, 0x1.0b53961b37da2p-53 }, + { 0x1.3a7db34e59ff6p+0, 0x1.d43792533c144p-53 }, + { 0x1.3c32dc313a8e4p+0, 0x1.08003e4516b1ep-53 }, + { 0x1.3dea64c123422p+0, 0x1.ada0911f09ebcp-55 }, + { 0x1.3fa4504ac801bp+0, 0x1.417ee03548306p-53 }, + { 0x1.4160a21f72e29p+0, 0x1.f0864b71e7b6cp-53 }, + { 0x1.431f5d950a896p+0, 0x1.b8e088728219ap-53 }, + { 0x1.44e086061892dp+0, 0x1.89b7a04ef80d0p-59 }, + { 0x1.46a41ed1d0057p+0, 0x1.c944bd1648a76p-54 }, + { 0x1.486a2b5c13cd0p+0, 0x1.3c1a3b69062f0p-56 }, + { 0x1.4a32af0d7d3dep+0, 0x1.9cb62f3d1be56p-54 }, + { 0x1.4bfdad5362a27p+0, 0x1.d4397afec42e2p-56 }, + { 0x1.4dcb299fddd0dp+0, 0x1.8ecdbbc6a7833p-54 }, + { 0x1.4f9b2769d2ca6p+0, 0x1.5a67b16d3540ep-53 }, + { 0x1.516daa2cf6641p+0, 0x1.8225ea5909b04p-53 }, + { 0x1.5342b569d4f81p+0, 0x1.be1507893b0d5p-53 }, + { 0x1.551a4ca5d920ep+0, 0x1.8a5d8c4048699p-53 }, + { 0x1.56f4736b527dap+0, 0x1.9bb2c011d93adp-54 }, + { 0x1.58d12d497c7fdp+0, 0x1.295e15b9a1de8p-55 }, + { 0x1.5ab07dd485429p+0, 0x1.6324c054647adp-54 }, + { 0x1.5c9268a5946b7p+0, 0x1.c4b1b816986a2p-60 }, + { 0x1.5e76f15ad2148p+0, 0x1.ba6f93080e65ep-54 }, + { 0x1.605e1b976dc08p+0, 0x1.60edeb25490dcp-53 }, + { 0x1.6247eb03a5584p+0, 0x1.63e1f40dfa5b5p-53 }, + { 0x1.6434634ccc31fp+0, 0x1.8edf0e2989db3p-53 }, + { 0x1.6623882552224p+0, 0x1.224fb3c5371e6p-53 }, + { 0x1.68155d44ca973p+0, 0x1.038ae44f73e65p-57 }, + { 0x1.6a09e667f3bccp+0, 0x1.21165f626cdd5p-53 }, + { 0x1.6c012750bdabep+0, 0x1.daed533001e9ep-53 }, + { 0x1.6dfb23c651a2ep+0, 0x1.e441c597c3775p-53 }, + { 0x1.6ff7df9519483p+0, 0x1.9f0fc369e7c42p-53 }, + { 0x1.71f75e8ec5f73p+0, 0x1.ba46e1e5de15ap-53 }, + { 0x1.73f9a48a58173p+0, 0x1.7ab9349cd1562p-53 }, + { 0x1.75feb564267c8p+0, 0x1.7edd354674916p-53 }, + { 0x1.780694fde5d3fp+0, 0x1.866b80a02162dp-54 }, + { 0x1.7a11473eb0186p+0, 0x1.afaa2047ed9b4p-53 }, + { 0x1.7c1ed0130c132p+0, 0x1.f124cd1164dd6p-54 }, + { 0x1.7e2f336cf4e62p+0, 0x1.05d02ba15797ep-56 }, + { 0x1.80427543e1a11p+0, 0x1.6c1bccec9346bp-53 }, + { 0x1.82589994cce12p+0, 0x1.159f115f56694p-53 }, + { 0x1.8471a4623c7acp+0, 0x1.9ca5ed72f8c81p-53 }, + { 0x1.868d99b4492ecp+0, 0x1.01c83b21584a3p-53 }, + { 0x1.88ac7d98a6699p+0, 0x1.994c2f37cb53ap-54 }, + { 0x1.8ace5422aa0dbp+0, 0x1.6e9f156864b27p-54 }, + { 0x1.8cf3216b5448bp+0, 0x1.de55439a2c38bp-53 }, + { 0x1.8f1ae99157736p+0, 0x1.5cc13a2e3976cp-55 }, + { 0x1.9145b0b91ffc5p+0, 0x1.114c368d3ed6ep-53 }, + { 0x1.93737b0cdc5e4p+0, 0x1.e8a0387e4a814p-53 }, + { 0x1.95a44cbc8520ep+0, 0x1.d36906d2b41f9p-53 }, + { 0x1.97d829fde4e4fp+0, 0x1.173d241f23d18p-53 }, + { 0x1.9a0f170ca07b9p+0, 0x1.7462137188ce7p-53 }, + { 0x1.9c49182a3f090p+0, 0x1.c7c46b071f2bep-56 }, + { 0x1.9e86319e32323p+0, 0x1.824ca78e64c6ep-56 }, + { 0x1.a0c667b5de564p+0, 0x1.6535b51719567p-53 }, + { 0x1.a309bec4a2d33p+0, 0x1.6305c7ddc36abp-54 }, + { 0x1.a5503b23e255cp+0, 0x1.1684892395f0fp-53 }, + { 0x1.a799e1330b358p+0, 0x1.bcb7ecac563c7p-54 }, + { 0x1.a9e6b5579fdbfp+0, 0x1.0fac90ef7fd31p-54 }, + { 0x1.ac36bbfd3f379p+0, 0x1.81b72cd4624ccp-53 }, + { 0x1.ae89f995ad3adp+0, 0x1.7a1cd345dcc81p-54 }, + { 0x1.b0e07298db665p+0, 0x1.2108559bf8deep-53 }, + { 0x1.b33a2b84f15fap+0, 0x1.ed7fa1cf7b290p-53 }, + { 0x1.b59728de55939p+0, 0x1.1c7102222c90ep-53 }, + { 0x1.b7f76f2fb5e46p+0, 0x1.d54f610356a79p-53 }, + { 0x1.ba5b030a10649p+0, 0x1.0819678d5eb69p-53 }, + { 0x1.bcc1e904bc1d2p+0, 0x1.23dd07a2d9e84p-55 }, + { 0x1.bf2c25bd71e08p+0, 0x1.0811ae04a31c7p-53 }, + { 0x1.c199bdd85529cp+0, 0x1.11065895048ddp-55 }, + { 0x1.c40ab5fffd07ap+0, 0x1.b4537e083c60ap-54 }, + { 0x1.c67f12e57d14bp+0, 0x1.2884dff483cadp-54 }, + { 0x1.c8f6d9406e7b5p+0, 0x1.1acbc48805c44p-56 }, + { 0x1.cb720dcef9069p+0, 0x1.503cbd1e949dbp-56 }, + { 0x1.cdf0b555dc3f9p+0, 0x1.889f12b1f58a3p-53 }, + { 0x1.d072d4a07897bp+0, 0x1.1a1e45e4342b2p-53 }, + { 0x1.d2f87080d89f1p+0, 0x1.15bc247313d44p-53 }, + { 0x1.d5818dcfba487p+0, 0x1.2ed02d75b3707p-55 }, + { 0x1.d80e316c98397p+0, 0x1.7709f3a09100cp-53 }, + { 0x1.da9e603db3285p+0, 0x1.c2300696db532p-54 }, + { 0x1.dd321f301b460p+0, 0x1.2da5778f018c3p-54 }, + { 0x1.dfc97337b9b5ep+0, 0x1.72d195873da52p-53 }, + { 0x1.e264614f5a128p+0, 0x1.424ec3f42f5b5p-53 }, + { 0x1.e502ee78b3ff6p+0, 0x1.39e8980a9cc8fp-55 }, + { 0x1.e7a51fbc74c83p+0, 0x1.2d522ca0c8de2p-54 }, + { 0x1.ea4afa2a490d9p+0, 0x1.0b1ee7431ebb6p-53 }, + { 0x1.ecf482d8e67f0p+0, 0x1.1b60625f7293ap-53 }, + { 0x1.efa1bee615a27p+0, 0x1.dc7f486a4b6b0p-54 }, + { 0x1.f252b376bba97p+0, 0x1.3a1a5bf0d8e43p-54 }, + { 0x1.f50765b6e4540p+0, 0x1.9d3e12dd8a18bp-54 }, + { 0x1.f7bfdad9cbe13p+0, 0x1.1227697fce57bp-53 }, + { 0x1.fa7c1819e90d8p+0, 0x1.74853f3a5931ep-55 }, + { 0x1.fd3c22b8f71f1p+0, 0x1.2eb74966579e7p-57 } }; /* * Kernel for expl(x). x must be finite and not tiny or huge. * "tiny" is anything that would make us underflow (|A6*x^6| < ~LDBL_MIN). * "huge" is anything that would make fn*L1 inexact (|x| > ~2**17*ln2). */ static inline void __k_expl(long double x, long double *hip, long double *lop, int *kp) { long double fn, q, r, r1, r2, t, z; int n, n2; /* Reduce x to (k*ln2 + endpoint[n2] + r1 + r2). */ /* Use a specialized rint() to get fn. Assume round-to-nearest. */ fn = x * INV_L + 0x1.8p63 - 0x1.8p63; r = x - fn * L1 - fn * L2; /* r = r1 + r2 done independently. */ #if defined(HAVE_EFFICIENT_IRINTL) n = irintl(fn); #elif defined(HAVE_EFFICIENT_IRINT) n = irint(fn); #else n = (int)fn; #endif n2 = (unsigned)n % INTERVALS; /* Depend on the sign bit being propagated: */ *kp = n >> LOG2_INTERVALS; r1 = x - fn * L1; r2 = fn * -L2; /* Evaluate expl(endpoint[n2] + r1 + r2) = tbl[n2] * expl(r1 + r2). */ z = r * r; #if 0 q = r2 + z * (A2 + r * A3) + z * z * (A4 + r * A5) + z * z * z * A6; #else q = r2 + z * A2 + z * r * (A3 + r * A4 + z * (A5 + r * A6)); #endif t = (long double)tbl[n2].lo + tbl[n2].hi; *hip = tbl[n2].hi; *lop = tbl[n2].lo + t * (q + r1); } static inline void k_hexpl(long double x, long double *hip, long double *lop) { float twopkm1; int k; __k_expl(x, hip, lop, &k); SET_FLOAT_WORD(twopkm1, 0x3f800000 + ((k - 1) << 23)); *hip *= twopkm1; *lop *= twopkm1; } static inline long double hexpl(long double x) { long double hi, lo, twopkm2; int k; twopkm2 = 1; __k_expl(x, &hi, &lo, &k); SET_LDBL_EXPSIGN(twopkm2, BIAS + k - 2); return (lo + hi) * 2 * twopkm2; } #ifdef _COMPLEX_H /* * See ../src/k_exp.c for details. */ static inline long double complex __ldexp_cexpl(long double complex z, int expt) { long double exp_x, hi, lo; long double x, y, scale1, scale2; int half_expt, k; x = creall(z); y = cimagl(z); __k_expl(x, &hi, &lo, &k); exp_x = (lo + hi) * 0x1p16382; expt += k - 16382; scale1 = 1; half_expt = expt / 2; SET_LDBL_EXPSIGN(scale1, BIAS + half_expt); scale2 = 1; SET_LDBL_EXPSIGN(scale1, BIAS + expt - half_expt); return (CMPLXL(cos(y) * exp_x * scale1 * scale2, sinl(y) * exp_x * scale1 * scale2)); } #endif /* _COMPLEX_H */ Index: stable/11/lib/msun/ld80/s_logl.c =================================================================== --- stable/11/lib/msun/ld80/s_logl.c (revision 324005) +++ stable/11/lib/msun/ld80/s_logl.c (revision 324006) @@ -1,717 +1,717 @@ /*- * Copyright (c) 2007-2013 Bruce D. Evans * 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. */ #include __FBSDID("$FreeBSD$"); /** * Implementation of the natural logarithm of x for Intel 80-bit format. * * First decompose x into its base 2 representation: * * log(x) = log(X * 2**k), where X is in [1, 2) * = log(X) + k * log(2). * * Let X = X_i + e, where X_i is the center of one of the intervals * [-1.0/256, 1.0/256), [1.0/256, 3.0/256), .... [2.0-1.0/256, 2.0+1.0/256) * and X is in this interval. Then * * log(X) = log(X_i + e) * = log(X_i * (1 + e / X_i)) * = log(X_i) + log(1 + e / X_i). * * The values log(X_i) are tabulated below. Let d = e / X_i and use * * log(1 + d) = p(d) * * where p(d) = d - 0.5*d*d + ... is a special minimax polynomial of * suitably high degree. * * To get sufficiently small roundoff errors, k * log(2), log(X_i), and * sometimes (if |k| is not large) the first term in p(d) must be evaluated * and added up in extra precision. Extra precision is not needed for the * rest of p(d). In the worst case when k = 0 and log(X_i) is 0, the final * error is controlled mainly by the error in the second term in p(d). The * error in this term itself is at most 0.5 ulps from the d*d operation in * it. The error in this term relative to the first term is thus at most * 0.5 * |-0.5| * |d| < 1.0/1024 ulps. We aim for an accumulated error of * at most twice this at the point of the final rounding step. Thus the * final error should be at most 0.5 + 1.0/512 = 0.5020 ulps. Exhaustive * testing of a float variant of this function showed a maximum final error * of 0.5008 ulps. Non-exhaustive testing of a double variant of this * function showed a maximum final error of 0.5078 ulps (near 1+1.0/256). * * We made the maximum of |d| (and thus the total relative error and the * degree of p(d)) small by using a large number of intervals. Using * centers of intervals instead of endpoints reduces this maximum by a * factor of 2 for a given number of intervals. p(d) is special only * in beginning with the Taylor coefficients 0 + 1*d, which tends to happen * naturally. The most accurate minimax polynomial of a given degree might * be different, but then we wouldn't want it since we would have to do * extra work to avoid roundoff error (especially for P0*d instead of d). */ #ifdef DEBUG #include #include #endif #ifdef __i386__ #include #endif #include "fpmath.h" #include "math.h" #define i386_SSE_GOOD #ifndef NO_STRUCT_RETURN #define STRUCT_RETURN #endif #include "math_private.h" #if !defined(NO_UTAB) && !defined(NO_UTABL) #define USE_UTAB #endif /* * Domain [-0.005280, 0.004838], range ~[-5.1736e-22, 5.1738e-22]: * |log(1 + d)/d - p(d)| < 2**-70.7 */ static const double P2 = -0.5, P3 = 3.3333333333333359e-1, /* 0x1555555555555a.0p-54 */ P4 = -2.5000000000004424e-1, /* -0x1000000000031d.0p-54 */ P5 = 1.9999999992970016e-1, /* 0x1999999972f3c7.0p-55 */ P6 = -1.6666666072191585e-1, /* -0x15555548912c09.0p-55 */ P7 = 1.4286227413310518e-1, /* 0x12494f9d9def91.0p-55 */ P8 = -1.2518388626763144e-1; /* -0x1006068cc0b97c.0p-55 */ static volatile const double zero = 0; #define INTERVALS 128 #define LOG2_INTERVALS 7 #define TSIZE (INTERVALS + 1) #define G(i) (T[(i)].G) #define F_hi(i) (T[(i)].F_hi) #define F_lo(i) (T[(i)].F_lo) #define ln2_hi F_hi(TSIZE - 1) #define ln2_lo F_lo(TSIZE - 1) #define E(i) (U[(i)].E) #define H(i) (U[(i)].H) static const struct { float G; /* 1/(1 + i/128) rounded to 8/9 bits */ float F_hi; /* log(1 / G_i) rounded (see below) */ double F_lo; /* next 53 bits for log(1 / G_i) */ } T[TSIZE] = { /* * ln2_hi and each F_hi(i) are rounded to a number of bits that * makes F_hi(i) + dk*ln2_hi exact for all i and all dk. * * The last entry (for X just below 2) is used to define ln2_hi * and ln2_lo, to ensure that F_hi(i) and F_lo(i) cancel exactly * with dk*ln2_hi and dk*ln2_lo, respectively, when dk = -1. * This is needed for accuracy when x is just below 1. (To avoid * special cases, such x are "reduced" strangely to X just below * 2 and dk = -1, and then the exact cancellation is needed * because any the error from any non-exactness would be too * large). * * We want to share this table between double precision and ld80, * so the relevant range of dk is the larger one of ld80 * ([-16445, 16383]) and the relevant exactness requirement is * the stricter one of double precision. The maximum number of * bits in F_hi(i) that works is very dependent on i but has * a minimum of 33. We only need about 12 bits in F_hi(i) for * it to provide enough extra precision in double precision (11 * more than that are required for ld80). * * We round F_hi(i) to 24 bits so that it can have type float, * mainly to minimize the size of the table. Using all 24 bits * in a float for it automatically satisfies the above constraints. */ - 0x800000.0p-23, 0, 0, - 0xfe0000.0p-24, 0x8080ac.0p-30, -0x14ee431dae6675.0p-84, - 0xfc0000.0p-24, 0x8102b3.0p-29, -0x1db29ee2d83718.0p-84, - 0xfa0000.0p-24, 0xc24929.0p-29, 0x1191957d173698.0p-83, - 0xf80000.0p-24, 0x820aec.0p-28, 0x13ce8888e02e79.0p-82, - 0xf60000.0p-24, 0xa33577.0p-28, -0x17a4382ce6eb7c.0p-82, - 0xf48000.0p-24, 0xbc42cb.0p-28, -0x172a21161a1076.0p-83, - 0xf30000.0p-24, 0xd57797.0p-28, -0x1e09de07cb9589.0p-82, - 0xf10000.0p-24, 0xf7518e.0p-28, 0x1ae1eec1b036c5.0p-91, - 0xef0000.0p-24, 0x8cb9df.0p-27, -0x1d7355325d560e.0p-81, - 0xed8000.0p-24, 0x999ec0.0p-27, -0x1f9f02d256d503.0p-82, - 0xec0000.0p-24, 0xa6988b.0p-27, -0x16fc0a9d12c17a.0p-83, - 0xea0000.0p-24, 0xb80698.0p-27, 0x15d581c1e8da9a.0p-81, - 0xe80000.0p-24, 0xc99af3.0p-27, -0x1535b3ba8f150b.0p-83, - 0xe70000.0p-24, 0xd273b2.0p-27, 0x163786f5251af0.0p-85, - 0xe50000.0p-24, 0xe442c0.0p-27, 0x1bc4b2368e32d5.0p-84, - 0xe38000.0p-24, 0xf1b83f.0p-27, 0x1c6090f684e676.0p-81, - 0xe20000.0p-24, 0xff448a.0p-27, -0x1890aa69ac9f42.0p-82, - 0xe08000.0p-24, 0x8673f6.0p-26, 0x1b9985194b6b00.0p-80, - 0xdf0000.0p-24, 0x8d515c.0p-26, -0x1dc08d61c6ef1e.0p-83, - 0xdd8000.0p-24, 0x943a9e.0p-26, -0x1f72a2dac729b4.0p-82, - 0xdc0000.0p-24, 0x9b2fe6.0p-26, -0x1fd4dfd3a0afb9.0p-80, - 0xda8000.0p-24, 0xa2315d.0p-26, -0x11b26121629c47.0p-82, - 0xd90000.0p-24, 0xa93f2f.0p-26, 0x1286d633e8e569.0p-81, - 0xd78000.0p-24, 0xb05988.0p-26, 0x16128eba936770.0p-84, - 0xd60000.0p-24, 0xb78094.0p-26, 0x16ead577390d32.0p-80, - 0xd50000.0p-24, 0xbc4c6c.0p-26, 0x151131ccf7c7b7.0p-81, - 0xd38000.0p-24, 0xc3890a.0p-26, -0x115e2cd714bd06.0p-80, - 0xd20000.0p-24, 0xcad2d7.0p-26, -0x1847f406ebd3b0.0p-82, - 0xd10000.0p-24, 0xcfb620.0p-26, 0x1c2259904d6866.0p-81, - 0xcf8000.0p-24, 0xd71653.0p-26, 0x1ece57a8d5ae55.0p-80, - 0xce0000.0p-24, 0xde843a.0p-26, -0x1f109d4bc45954.0p-81, - 0xcd0000.0p-24, 0xe37fde.0p-26, 0x1bc03dc271a74d.0p-81, - 0xcb8000.0p-24, 0xeb050c.0p-26, -0x1bf2badc0df842.0p-85, - 0xca0000.0p-24, 0xf29878.0p-26, -0x18efededd89fbe.0p-87, - 0xc90000.0p-24, 0xf7ad6f.0p-26, 0x1373ff977baa69.0p-81, - 0xc80000.0p-24, 0xfcc8e3.0p-26, 0x196766f2fb3283.0p-80, - 0xc68000.0p-24, 0x823f30.0p-25, 0x19bd076f7c434e.0p-79, - 0xc58000.0p-24, 0x84d52c.0p-25, -0x1a327257af0f46.0p-79, - 0xc40000.0p-24, 0x88bc74.0p-25, 0x113f23def19c5a.0p-81, - 0xc30000.0p-24, 0x8b5ae6.0p-25, 0x1759f6e6b37de9.0p-79, - 0xc20000.0p-24, 0x8dfccb.0p-25, 0x1ad35ca6ed5148.0p-81, - 0xc10000.0p-24, 0x90a22b.0p-25, 0x1a1d71a87deba4.0p-79, - 0xbf8000.0p-24, 0x94a0d8.0p-25, -0x139e5210c2b731.0p-80, - 0xbe8000.0p-24, 0x974f16.0p-25, -0x18f6ebcff3ed73.0p-81, - 0xbd8000.0p-24, 0x9a00f1.0p-25, -0x1aa268be39aab7.0p-79, - 0xbc8000.0p-24, 0x9cb672.0p-25, -0x14c8815839c566.0p-79, - 0xbb0000.0p-24, 0xa0cda1.0p-25, 0x1eaf46390dbb24.0p-81, - 0xba0000.0p-24, 0xa38c6e.0p-25, 0x138e20d831f698.0p-81, - 0xb90000.0p-24, 0xa64f05.0p-25, -0x1e8d3c41123616.0p-82, - 0xb80000.0p-24, 0xa91570.0p-25, 0x1ce28f5f3840b2.0p-80, - 0xb70000.0p-24, 0xabdfbb.0p-25, -0x186e5c0a424234.0p-79, - 0xb60000.0p-24, 0xaeadef.0p-25, -0x14d41a0b2a08a4.0p-83, - 0xb50000.0p-24, 0xb18018.0p-25, 0x16755892770634.0p-79, - 0xb40000.0p-24, 0xb45642.0p-25, -0x16395ebe59b152.0p-82, - 0xb30000.0p-24, 0xb73077.0p-25, 0x1abc65c8595f09.0p-80, - 0xb20000.0p-24, 0xba0ec4.0p-25, -0x1273089d3dad89.0p-79, - 0xb10000.0p-24, 0xbcf133.0p-25, 0x10f9f67b1f4bbf.0p-79, - 0xb00000.0p-24, 0xbfd7d2.0p-25, -0x109fab90486409.0p-80, - 0xaf0000.0p-24, 0xc2c2ac.0p-25, -0x1124680aa43333.0p-79, - 0xae8000.0p-24, 0xc439b3.0p-25, -0x1f360cc4710fc0.0p-80, - 0xad8000.0p-24, 0xc72afd.0p-25, -0x132d91f21d89c9.0p-80, - 0xac8000.0p-24, 0xca20a2.0p-25, -0x16bf9b4d1f8da8.0p-79, - 0xab8000.0p-24, 0xcd1aae.0p-25, 0x19deb5ce6a6a87.0p-81, - 0xaa8000.0p-24, 0xd0192f.0p-25, 0x1a29fb48f7d3cb.0p-79, - 0xaa0000.0p-24, 0xd19a20.0p-25, 0x1127d3c6457f9d.0p-81, - 0xa90000.0p-24, 0xd49f6a.0p-25, -0x1ba930e486a0ac.0p-81, - 0xa80000.0p-24, 0xd7a94b.0p-25, -0x1b6e645f31549e.0p-79, - 0xa70000.0p-24, 0xdab7d0.0p-25, 0x1118a425494b61.0p-80, - 0xa68000.0p-24, 0xdc40d5.0p-25, 0x1966f24d29d3a3.0p-80, - 0xa58000.0p-24, 0xdf566d.0p-25, -0x1d8e52eb2248f1.0p-82, - 0xa48000.0p-24, 0xe270ce.0p-25, -0x1ee370f96e6b68.0p-80, - 0xa40000.0p-24, 0xe3ffce.0p-25, 0x1d155324911f57.0p-80, - 0xa30000.0p-24, 0xe72179.0p-25, -0x1fe6e2f2f867d9.0p-80, - 0xa20000.0p-24, 0xea4812.0p-25, 0x1b7be9add7f4d4.0p-80, - 0xa18000.0p-24, 0xebdd3d.0p-25, 0x1b3cfb3f7511dd.0p-79, - 0xa08000.0p-24, 0xef0b5b.0p-25, -0x1220de1f730190.0p-79, - 0xa00000.0p-24, 0xf0a451.0p-25, -0x176364c9ac81cd.0p-80, - 0x9f0000.0p-24, 0xf3da16.0p-25, 0x1eed6b9aafac8d.0p-81, - 0x9e8000.0p-24, 0xf576e9.0p-25, 0x1d593218675af2.0p-79, - 0x9d8000.0p-24, 0xf8b47c.0p-25, -0x13e8eb7da053e0.0p-84, - 0x9d0000.0p-24, 0xfa553f.0p-25, 0x1c063259bcade0.0p-79, - 0x9c0000.0p-24, 0xfd9ac5.0p-25, 0x1ef491085fa3c1.0p-79, - 0x9b8000.0p-24, 0xff3f8c.0p-25, 0x1d607a7c2b8c53.0p-79, - 0x9a8000.0p-24, 0x814697.0p-24, -0x12ad3817004f3f.0p-78, - 0x9a0000.0p-24, 0x821b06.0p-24, -0x189fc53117f9e5.0p-81, - 0x990000.0p-24, 0x83c5f8.0p-24, 0x14cf15a048907b.0p-79, - 0x988000.0p-24, 0x849c7d.0p-24, 0x1cbb1d35fb8287.0p-78, - 0x978000.0p-24, 0x864ba6.0p-24, 0x1128639b814f9c.0p-78, - 0x970000.0p-24, 0x87244c.0p-24, 0x184733853300f0.0p-79, - 0x968000.0p-24, 0x87fdaa.0p-24, 0x109d23aef77dd6.0p-80, - 0x958000.0p-24, 0x89b293.0p-24, -0x1a81ef367a59de.0p-78, - 0x950000.0p-24, 0x8a8e20.0p-24, -0x121ad3dbb2f452.0p-78, - 0x948000.0p-24, 0x8b6a6a.0p-24, -0x1cfb981628af72.0p-79, - 0x938000.0p-24, 0x8d253a.0p-24, -0x1d21730ea76cfe.0p-79, - 0x930000.0p-24, 0x8e03c2.0p-24, 0x135cc00e566f77.0p-78, - 0x928000.0p-24, 0x8ee30d.0p-24, -0x10fcb5df257a26.0p-80, - 0x918000.0p-24, 0x90a3ee.0p-24, -0x16e171b15433d7.0p-79, - 0x910000.0p-24, 0x918587.0p-24, -0x1d050da07f3237.0p-79, - 0x908000.0p-24, 0x9267e7.0p-24, 0x1be03669a5268d.0p-79, - 0x8f8000.0p-24, 0x942f04.0p-24, 0x10b28e0e26c337.0p-79, - 0x8f0000.0p-24, 0x9513c3.0p-24, 0x1a1d820da57cf3.0p-78, - 0x8e8000.0p-24, 0x95f950.0p-24, -0x19ef8f13ae3cf1.0p-79, - 0x8e0000.0p-24, 0x96dfab.0p-24, -0x109e417a6e507c.0p-78, - 0x8d0000.0p-24, 0x98aed2.0p-24, 0x10d01a2c5b0e98.0p-79, - 0x8c8000.0p-24, 0x9997a2.0p-24, -0x1d6a50d4b61ea7.0p-78, - 0x8c0000.0p-24, 0x9a8145.0p-24, 0x1b3b190b83f952.0p-78, - 0x8b8000.0p-24, 0x9b6bbf.0p-24, 0x13a69fad7e7abe.0p-78, - 0x8b0000.0p-24, 0x9c5711.0p-24, -0x11cd12316f576b.0p-78, - 0x8a8000.0p-24, 0x9d433b.0p-24, 0x1c95c444b807a2.0p-79, - 0x898000.0p-24, 0x9f1e22.0p-24, -0x1b9c224ea698c3.0p-79, - 0x890000.0p-24, 0xa00ce1.0p-24, 0x125ca93186cf0f.0p-81, - 0x888000.0p-24, 0xa0fc80.0p-24, -0x1ee38a7bc228b3.0p-79, - 0x880000.0p-24, 0xa1ed00.0p-24, -0x1a0db876613d20.0p-78, - 0x878000.0p-24, 0xa2de62.0p-24, 0x193224e8516c01.0p-79, - 0x870000.0p-24, 0xa3d0a9.0p-24, 0x1fa28b4d2541ad.0p-79, - 0x868000.0p-24, 0xa4c3d6.0p-24, 0x1c1b5760fb4572.0p-78, - 0x858000.0p-24, 0xa6acea.0p-24, 0x1fed5d0f65949c.0p-80, - 0x850000.0p-24, 0xa7a2d4.0p-24, 0x1ad270c9d74936.0p-80, - 0x848000.0p-24, 0xa899ab.0p-24, 0x199ff15ce53266.0p-79, - 0x840000.0p-24, 0xa99171.0p-24, 0x1a19e15ccc45d2.0p-79, - 0x838000.0p-24, 0xaa8a28.0p-24, -0x121a14ec532b36.0p-80, - 0x830000.0p-24, 0xab83d1.0p-24, 0x1aee319980bff3.0p-79, - 0x828000.0p-24, 0xac7e6f.0p-24, -0x18ffd9e3900346.0p-80, - 0x820000.0p-24, 0xad7a03.0p-24, -0x1e4db102ce29f8.0p-80, - 0x818000.0p-24, 0xae768f.0p-24, 0x17c35c55a04a83.0p-81, - 0x810000.0p-24, 0xaf7415.0p-24, 0x1448324047019b.0p-78, - 0x808000.0p-24, 0xb07298.0p-24, -0x1750ee3915a198.0p-78, - 0x800000.0p-24, 0xb17218.0p-24, -0x105c610ca86c39.0p-81, + { 0x800000.0p-23, 0, 0 }, + { 0xfe0000.0p-24, 0x8080ac.0p-30, -0x14ee431dae6675.0p-84 }, + { 0xfc0000.0p-24, 0x8102b3.0p-29, -0x1db29ee2d83718.0p-84 }, + { 0xfa0000.0p-24, 0xc24929.0p-29, 0x1191957d173698.0p-83 }, + { 0xf80000.0p-24, 0x820aec.0p-28, 0x13ce8888e02e79.0p-82 }, + { 0xf60000.0p-24, 0xa33577.0p-28, -0x17a4382ce6eb7c.0p-82 }, + { 0xf48000.0p-24, 0xbc42cb.0p-28, -0x172a21161a1076.0p-83 }, + { 0xf30000.0p-24, 0xd57797.0p-28, -0x1e09de07cb9589.0p-82 }, + { 0xf10000.0p-24, 0xf7518e.0p-28, 0x1ae1eec1b036c5.0p-91 }, + { 0xef0000.0p-24, 0x8cb9df.0p-27, -0x1d7355325d560e.0p-81 }, + { 0xed8000.0p-24, 0x999ec0.0p-27, -0x1f9f02d256d503.0p-82 }, + { 0xec0000.0p-24, 0xa6988b.0p-27, -0x16fc0a9d12c17a.0p-83 }, + { 0xea0000.0p-24, 0xb80698.0p-27, 0x15d581c1e8da9a.0p-81 }, + { 0xe80000.0p-24, 0xc99af3.0p-27, -0x1535b3ba8f150b.0p-83 }, + { 0xe70000.0p-24, 0xd273b2.0p-27, 0x163786f5251af0.0p-85 }, + { 0xe50000.0p-24, 0xe442c0.0p-27, 0x1bc4b2368e32d5.0p-84 }, + { 0xe38000.0p-24, 0xf1b83f.0p-27, 0x1c6090f684e676.0p-81 }, + { 0xe20000.0p-24, 0xff448a.0p-27, -0x1890aa69ac9f42.0p-82 }, + { 0xe08000.0p-24, 0x8673f6.0p-26, 0x1b9985194b6b00.0p-80 }, + { 0xdf0000.0p-24, 0x8d515c.0p-26, -0x1dc08d61c6ef1e.0p-83 }, + { 0xdd8000.0p-24, 0x943a9e.0p-26, -0x1f72a2dac729b4.0p-82 }, + { 0xdc0000.0p-24, 0x9b2fe6.0p-26, -0x1fd4dfd3a0afb9.0p-80 }, + { 0xda8000.0p-24, 0xa2315d.0p-26, -0x11b26121629c47.0p-82 }, + { 0xd90000.0p-24, 0xa93f2f.0p-26, 0x1286d633e8e569.0p-81 }, + { 0xd78000.0p-24, 0xb05988.0p-26, 0x16128eba936770.0p-84 }, + { 0xd60000.0p-24, 0xb78094.0p-26, 0x16ead577390d32.0p-80 }, + { 0xd50000.0p-24, 0xbc4c6c.0p-26, 0x151131ccf7c7b7.0p-81 }, + { 0xd38000.0p-24, 0xc3890a.0p-26, -0x115e2cd714bd06.0p-80 }, + { 0xd20000.0p-24, 0xcad2d7.0p-26, -0x1847f406ebd3b0.0p-82 }, + { 0xd10000.0p-24, 0xcfb620.0p-26, 0x1c2259904d6866.0p-81 }, + { 0xcf8000.0p-24, 0xd71653.0p-26, 0x1ece57a8d5ae55.0p-80 }, + { 0xce0000.0p-24, 0xde843a.0p-26, -0x1f109d4bc45954.0p-81 }, + { 0xcd0000.0p-24, 0xe37fde.0p-26, 0x1bc03dc271a74d.0p-81 }, + { 0xcb8000.0p-24, 0xeb050c.0p-26, -0x1bf2badc0df842.0p-85 }, + { 0xca0000.0p-24, 0xf29878.0p-26, -0x18efededd89fbe.0p-87 }, + { 0xc90000.0p-24, 0xf7ad6f.0p-26, 0x1373ff977baa69.0p-81 }, + { 0xc80000.0p-24, 0xfcc8e3.0p-26, 0x196766f2fb3283.0p-80 }, + { 0xc68000.0p-24, 0x823f30.0p-25, 0x19bd076f7c434e.0p-79 }, + { 0xc58000.0p-24, 0x84d52c.0p-25, -0x1a327257af0f46.0p-79 }, + { 0xc40000.0p-24, 0x88bc74.0p-25, 0x113f23def19c5a.0p-81 }, + { 0xc30000.0p-24, 0x8b5ae6.0p-25, 0x1759f6e6b37de9.0p-79 }, + { 0xc20000.0p-24, 0x8dfccb.0p-25, 0x1ad35ca6ed5148.0p-81 }, + { 0xc10000.0p-24, 0x90a22b.0p-25, 0x1a1d71a87deba4.0p-79 }, + { 0xbf8000.0p-24, 0x94a0d8.0p-25, -0x139e5210c2b731.0p-80 }, + { 0xbe8000.0p-24, 0x974f16.0p-25, -0x18f6ebcff3ed73.0p-81 }, + { 0xbd8000.0p-24, 0x9a00f1.0p-25, -0x1aa268be39aab7.0p-79 }, + { 0xbc8000.0p-24, 0x9cb672.0p-25, -0x14c8815839c566.0p-79 }, + { 0xbb0000.0p-24, 0xa0cda1.0p-25, 0x1eaf46390dbb24.0p-81 }, + { 0xba0000.0p-24, 0xa38c6e.0p-25, 0x138e20d831f698.0p-81 }, + { 0xb90000.0p-24, 0xa64f05.0p-25, -0x1e8d3c41123616.0p-82 }, + { 0xb80000.0p-24, 0xa91570.0p-25, 0x1ce28f5f3840b2.0p-80 }, + { 0xb70000.0p-24, 0xabdfbb.0p-25, -0x186e5c0a424234.0p-79 }, + { 0xb60000.0p-24, 0xaeadef.0p-25, -0x14d41a0b2a08a4.0p-83 }, + { 0xb50000.0p-24, 0xb18018.0p-25, 0x16755892770634.0p-79 }, + { 0xb40000.0p-24, 0xb45642.0p-25, -0x16395ebe59b152.0p-82 }, + { 0xb30000.0p-24, 0xb73077.0p-25, 0x1abc65c8595f09.0p-80 }, + { 0xb20000.0p-24, 0xba0ec4.0p-25, -0x1273089d3dad89.0p-79 }, + { 0xb10000.0p-24, 0xbcf133.0p-25, 0x10f9f67b1f4bbf.0p-79 }, + { 0xb00000.0p-24, 0xbfd7d2.0p-25, -0x109fab90486409.0p-80 }, + { 0xaf0000.0p-24, 0xc2c2ac.0p-25, -0x1124680aa43333.0p-79 }, + { 0xae8000.0p-24, 0xc439b3.0p-25, -0x1f360cc4710fc0.0p-80 }, + { 0xad8000.0p-24, 0xc72afd.0p-25, -0x132d91f21d89c9.0p-80 }, + { 0xac8000.0p-24, 0xca20a2.0p-25, -0x16bf9b4d1f8da8.0p-79 }, + { 0xab8000.0p-24, 0xcd1aae.0p-25, 0x19deb5ce6a6a87.0p-81 }, + { 0xaa8000.0p-24, 0xd0192f.0p-25, 0x1a29fb48f7d3cb.0p-79 }, + { 0xaa0000.0p-24, 0xd19a20.0p-25, 0x1127d3c6457f9d.0p-81 }, + { 0xa90000.0p-24, 0xd49f6a.0p-25, -0x1ba930e486a0ac.0p-81 }, + { 0xa80000.0p-24, 0xd7a94b.0p-25, -0x1b6e645f31549e.0p-79 }, + { 0xa70000.0p-24, 0xdab7d0.0p-25, 0x1118a425494b61.0p-80 }, + { 0xa68000.0p-24, 0xdc40d5.0p-25, 0x1966f24d29d3a3.0p-80 }, + { 0xa58000.0p-24, 0xdf566d.0p-25, -0x1d8e52eb2248f1.0p-82 }, + { 0xa48000.0p-24, 0xe270ce.0p-25, -0x1ee370f96e6b68.0p-80 }, + { 0xa40000.0p-24, 0xe3ffce.0p-25, 0x1d155324911f57.0p-80 }, + { 0xa30000.0p-24, 0xe72179.0p-25, -0x1fe6e2f2f867d9.0p-80 }, + { 0xa20000.0p-24, 0xea4812.0p-25, 0x1b7be9add7f4d4.0p-80 }, + { 0xa18000.0p-24, 0xebdd3d.0p-25, 0x1b3cfb3f7511dd.0p-79 }, + { 0xa08000.0p-24, 0xef0b5b.0p-25, -0x1220de1f730190.0p-79 }, + { 0xa00000.0p-24, 0xf0a451.0p-25, -0x176364c9ac81cd.0p-80 }, + { 0x9f0000.0p-24, 0xf3da16.0p-25, 0x1eed6b9aafac8d.0p-81 }, + { 0x9e8000.0p-24, 0xf576e9.0p-25, 0x1d593218675af2.0p-79 }, + { 0x9d8000.0p-24, 0xf8b47c.0p-25, -0x13e8eb7da053e0.0p-84 }, + { 0x9d0000.0p-24, 0xfa553f.0p-25, 0x1c063259bcade0.0p-79 }, + { 0x9c0000.0p-24, 0xfd9ac5.0p-25, 0x1ef491085fa3c1.0p-79 }, + { 0x9b8000.0p-24, 0xff3f8c.0p-25, 0x1d607a7c2b8c53.0p-79 }, + { 0x9a8000.0p-24, 0x814697.0p-24, -0x12ad3817004f3f.0p-78 }, + { 0x9a0000.0p-24, 0x821b06.0p-24, -0x189fc53117f9e5.0p-81 }, + { 0x990000.0p-24, 0x83c5f8.0p-24, 0x14cf15a048907b.0p-79 }, + { 0x988000.0p-24, 0x849c7d.0p-24, 0x1cbb1d35fb8287.0p-78 }, + { 0x978000.0p-24, 0x864ba6.0p-24, 0x1128639b814f9c.0p-78 }, + { 0x970000.0p-24, 0x87244c.0p-24, 0x184733853300f0.0p-79 }, + { 0x968000.0p-24, 0x87fdaa.0p-24, 0x109d23aef77dd6.0p-80 }, + { 0x958000.0p-24, 0x89b293.0p-24, -0x1a81ef367a59de.0p-78 }, + { 0x950000.0p-24, 0x8a8e20.0p-24, -0x121ad3dbb2f452.0p-78 }, + { 0x948000.0p-24, 0x8b6a6a.0p-24, -0x1cfb981628af72.0p-79 }, + { 0x938000.0p-24, 0x8d253a.0p-24, -0x1d21730ea76cfe.0p-79 }, + { 0x930000.0p-24, 0x8e03c2.0p-24, 0x135cc00e566f77.0p-78 }, + { 0x928000.0p-24, 0x8ee30d.0p-24, -0x10fcb5df257a26.0p-80 }, + { 0x918000.0p-24, 0x90a3ee.0p-24, -0x16e171b15433d7.0p-79 }, + { 0x910000.0p-24, 0x918587.0p-24, -0x1d050da07f3237.0p-79 }, + { 0x908000.0p-24, 0x9267e7.0p-24, 0x1be03669a5268d.0p-79 }, + { 0x8f8000.0p-24, 0x942f04.0p-24, 0x10b28e0e26c337.0p-79 }, + { 0x8f0000.0p-24, 0x9513c3.0p-24, 0x1a1d820da57cf3.0p-78 }, + { 0x8e8000.0p-24, 0x95f950.0p-24, -0x19ef8f13ae3cf1.0p-79 }, + { 0x8e0000.0p-24, 0x96dfab.0p-24, -0x109e417a6e507c.0p-78 }, + { 0x8d0000.0p-24, 0x98aed2.0p-24, 0x10d01a2c5b0e98.0p-79 }, + { 0x8c8000.0p-24, 0x9997a2.0p-24, -0x1d6a50d4b61ea7.0p-78 }, + { 0x8c0000.0p-24, 0x9a8145.0p-24, 0x1b3b190b83f952.0p-78 }, + { 0x8b8000.0p-24, 0x9b6bbf.0p-24, 0x13a69fad7e7abe.0p-78 }, + { 0x8b0000.0p-24, 0x9c5711.0p-24, -0x11cd12316f576b.0p-78 }, + { 0x8a8000.0p-24, 0x9d433b.0p-24, 0x1c95c444b807a2.0p-79 }, + { 0x898000.0p-24, 0x9f1e22.0p-24, -0x1b9c224ea698c3.0p-79 }, + { 0x890000.0p-24, 0xa00ce1.0p-24, 0x125ca93186cf0f.0p-81 }, + { 0x888000.0p-24, 0xa0fc80.0p-24, -0x1ee38a7bc228b3.0p-79 }, + { 0x880000.0p-24, 0xa1ed00.0p-24, -0x1a0db876613d20.0p-78 }, + { 0x878000.0p-24, 0xa2de62.0p-24, 0x193224e8516c01.0p-79 }, + { 0x870000.0p-24, 0xa3d0a9.0p-24, 0x1fa28b4d2541ad.0p-79 }, + { 0x868000.0p-24, 0xa4c3d6.0p-24, 0x1c1b5760fb4572.0p-78 }, + { 0x858000.0p-24, 0xa6acea.0p-24, 0x1fed5d0f65949c.0p-80 }, + { 0x850000.0p-24, 0xa7a2d4.0p-24, 0x1ad270c9d74936.0p-80 }, + { 0x848000.0p-24, 0xa899ab.0p-24, 0x199ff15ce53266.0p-79 }, + { 0x840000.0p-24, 0xa99171.0p-24, 0x1a19e15ccc45d2.0p-79 }, + { 0x838000.0p-24, 0xaa8a28.0p-24, -0x121a14ec532b36.0p-80 }, + { 0x830000.0p-24, 0xab83d1.0p-24, 0x1aee319980bff3.0p-79 }, + { 0x828000.0p-24, 0xac7e6f.0p-24, -0x18ffd9e3900346.0p-80 }, + { 0x820000.0p-24, 0xad7a03.0p-24, -0x1e4db102ce29f8.0p-80 }, + { 0x818000.0p-24, 0xae768f.0p-24, 0x17c35c55a04a83.0p-81 }, + { 0x810000.0p-24, 0xaf7415.0p-24, 0x1448324047019b.0p-78 }, + { 0x808000.0p-24, 0xb07298.0p-24, -0x1750ee3915a198.0p-78 }, + { 0x800000.0p-24, 0xb17218.0p-24, -0x105c610ca86c39.0p-81 }, }; #ifdef USE_UTAB static const struct { float H; /* 1 + i/INTERVALS (exact) */ float E; /* H(i) * G(i) - 1 (exact) */ } U[TSIZE] = { - 0x800000.0p-23, 0, - 0x810000.0p-23, -0x800000.0p-37, - 0x820000.0p-23, -0x800000.0p-35, - 0x830000.0p-23, -0x900000.0p-34, - 0x840000.0p-23, -0x800000.0p-33, - 0x850000.0p-23, -0xc80000.0p-33, - 0x860000.0p-23, -0xa00000.0p-36, - 0x870000.0p-23, 0x940000.0p-33, - 0x880000.0p-23, 0x800000.0p-35, - 0x890000.0p-23, -0xc80000.0p-34, - 0x8a0000.0p-23, 0xe00000.0p-36, - 0x8b0000.0p-23, 0x900000.0p-33, - 0x8c0000.0p-23, -0x800000.0p-35, - 0x8d0000.0p-23, -0xe00000.0p-33, - 0x8e0000.0p-23, 0x880000.0p-33, - 0x8f0000.0p-23, -0xa80000.0p-34, - 0x900000.0p-23, -0x800000.0p-35, - 0x910000.0p-23, 0x800000.0p-37, - 0x920000.0p-23, 0x900000.0p-35, - 0x930000.0p-23, 0xd00000.0p-35, - 0x940000.0p-23, 0xe00000.0p-35, - 0x950000.0p-23, 0xc00000.0p-35, - 0x960000.0p-23, 0xe00000.0p-36, - 0x970000.0p-23, -0x800000.0p-38, - 0x980000.0p-23, -0xc00000.0p-35, - 0x990000.0p-23, -0xd00000.0p-34, - 0x9a0000.0p-23, 0x880000.0p-33, - 0x9b0000.0p-23, 0xe80000.0p-35, - 0x9c0000.0p-23, -0x800000.0p-35, - 0x9d0000.0p-23, 0xb40000.0p-33, - 0x9e0000.0p-23, 0x880000.0p-34, - 0x9f0000.0p-23, -0xe00000.0p-35, - 0xa00000.0p-23, 0x800000.0p-33, - 0xa10000.0p-23, -0x900000.0p-36, - 0xa20000.0p-23, -0xb00000.0p-33, - 0xa30000.0p-23, -0xa00000.0p-36, - 0xa40000.0p-23, 0x800000.0p-33, - 0xa50000.0p-23, -0xf80000.0p-35, - 0xa60000.0p-23, 0x880000.0p-34, - 0xa70000.0p-23, -0x900000.0p-33, - 0xa80000.0p-23, -0x800000.0p-35, - 0xa90000.0p-23, 0x900000.0p-34, - 0xaa0000.0p-23, 0xa80000.0p-33, - 0xab0000.0p-23, -0xac0000.0p-34, - 0xac0000.0p-23, -0x800000.0p-37, - 0xad0000.0p-23, 0xf80000.0p-35, - 0xae0000.0p-23, 0xf80000.0p-34, - 0xaf0000.0p-23, -0xac0000.0p-33, - 0xb00000.0p-23, -0x800000.0p-33, - 0xb10000.0p-23, -0xb80000.0p-34, - 0xb20000.0p-23, -0x800000.0p-34, - 0xb30000.0p-23, -0xb00000.0p-35, - 0xb40000.0p-23, -0x800000.0p-35, - 0xb50000.0p-23, -0xe00000.0p-36, - 0xb60000.0p-23, -0x800000.0p-35, - 0xb70000.0p-23, -0xb00000.0p-35, - 0xb80000.0p-23, -0x800000.0p-34, - 0xb90000.0p-23, -0xb80000.0p-34, - 0xba0000.0p-23, -0x800000.0p-33, - 0xbb0000.0p-23, -0xac0000.0p-33, - 0xbc0000.0p-23, 0x980000.0p-33, - 0xbd0000.0p-23, 0xbc0000.0p-34, - 0xbe0000.0p-23, 0xe00000.0p-36, - 0xbf0000.0p-23, -0xb80000.0p-35, - 0xc00000.0p-23, -0x800000.0p-33, - 0xc10000.0p-23, 0xa80000.0p-33, - 0xc20000.0p-23, 0x900000.0p-34, - 0xc30000.0p-23, -0x800000.0p-35, - 0xc40000.0p-23, -0x900000.0p-33, - 0xc50000.0p-23, 0x820000.0p-33, - 0xc60000.0p-23, 0x800000.0p-38, - 0xc70000.0p-23, -0x820000.0p-33, - 0xc80000.0p-23, 0x800000.0p-33, - 0xc90000.0p-23, -0xa00000.0p-36, - 0xca0000.0p-23, -0xb00000.0p-33, - 0xcb0000.0p-23, 0x840000.0p-34, - 0xcc0000.0p-23, -0xd00000.0p-34, - 0xcd0000.0p-23, 0x800000.0p-33, - 0xce0000.0p-23, -0xe00000.0p-35, - 0xcf0000.0p-23, 0xa60000.0p-33, - 0xd00000.0p-23, -0x800000.0p-35, - 0xd10000.0p-23, 0xb40000.0p-33, - 0xd20000.0p-23, -0x800000.0p-35, - 0xd30000.0p-23, 0xaa0000.0p-33, - 0xd40000.0p-23, -0xe00000.0p-35, - 0xd50000.0p-23, 0x880000.0p-33, - 0xd60000.0p-23, -0xd00000.0p-34, - 0xd70000.0p-23, 0x9c0000.0p-34, - 0xd80000.0p-23, -0xb00000.0p-33, - 0xd90000.0p-23, -0x800000.0p-38, - 0xda0000.0p-23, 0xa40000.0p-33, - 0xdb0000.0p-23, -0xdc0000.0p-34, - 0xdc0000.0p-23, 0xc00000.0p-35, - 0xdd0000.0p-23, 0xca0000.0p-33, - 0xde0000.0p-23, -0xb80000.0p-34, - 0xdf0000.0p-23, 0xd00000.0p-35, - 0xe00000.0p-23, 0xc00000.0p-33, - 0xe10000.0p-23, -0xf40000.0p-34, - 0xe20000.0p-23, 0x800000.0p-37, - 0xe30000.0p-23, 0x860000.0p-33, - 0xe40000.0p-23, -0xc80000.0p-33, - 0xe50000.0p-23, -0xa80000.0p-34, - 0xe60000.0p-23, 0xe00000.0p-36, - 0xe70000.0p-23, 0x880000.0p-33, - 0xe80000.0p-23, -0xe00000.0p-33, - 0xe90000.0p-23, -0xfc0000.0p-34, - 0xea0000.0p-23, -0x800000.0p-35, - 0xeb0000.0p-23, 0xe80000.0p-35, - 0xec0000.0p-23, 0x900000.0p-33, - 0xed0000.0p-23, 0xe20000.0p-33, - 0xee0000.0p-23, -0xac0000.0p-33, - 0xef0000.0p-23, -0xc80000.0p-34, - 0xf00000.0p-23, -0x800000.0p-35, - 0xf10000.0p-23, 0x800000.0p-35, - 0xf20000.0p-23, 0xb80000.0p-34, - 0xf30000.0p-23, 0x940000.0p-33, - 0xf40000.0p-23, 0xc80000.0p-33, - 0xf50000.0p-23, -0xf20000.0p-33, - 0xf60000.0p-23, -0xc80000.0p-33, - 0xf70000.0p-23, -0xa20000.0p-33, - 0xf80000.0p-23, -0x800000.0p-33, - 0xf90000.0p-23, -0xc40000.0p-34, - 0xfa0000.0p-23, -0x900000.0p-34, - 0xfb0000.0p-23, -0xc80000.0p-35, - 0xfc0000.0p-23, -0x800000.0p-35, - 0xfd0000.0p-23, -0x900000.0p-36, - 0xfe0000.0p-23, -0x800000.0p-37, - 0xff0000.0p-23, -0x800000.0p-39, - 0x800000.0p-22, 0, + { 0x800000.0p-23, 0 }, + { 0x810000.0p-23, -0x800000.0p-37 }, + { 0x820000.0p-23, -0x800000.0p-35 }, + { 0x830000.0p-23, -0x900000.0p-34 }, + { 0x840000.0p-23, -0x800000.0p-33 }, + { 0x850000.0p-23, -0xc80000.0p-33 }, + { 0x860000.0p-23, -0xa00000.0p-36 }, + { 0x870000.0p-23, 0x940000.0p-33 }, + { 0x880000.0p-23, 0x800000.0p-35 }, + { 0x890000.0p-23, -0xc80000.0p-34 }, + { 0x8a0000.0p-23, 0xe00000.0p-36 }, + { 0x8b0000.0p-23, 0x900000.0p-33 }, + { 0x8c0000.0p-23, -0x800000.0p-35 }, + { 0x8d0000.0p-23, -0xe00000.0p-33 }, + { 0x8e0000.0p-23, 0x880000.0p-33 }, + { 0x8f0000.0p-23, -0xa80000.0p-34 }, + { 0x900000.0p-23, -0x800000.0p-35 }, + { 0x910000.0p-23, 0x800000.0p-37 }, + { 0x920000.0p-23, 0x900000.0p-35 }, + { 0x930000.0p-23, 0xd00000.0p-35 }, + { 0x940000.0p-23, 0xe00000.0p-35 }, + { 0x950000.0p-23, 0xc00000.0p-35 }, + { 0x960000.0p-23, 0xe00000.0p-36 }, + { 0x970000.0p-23, -0x800000.0p-38 }, + { 0x980000.0p-23, -0xc00000.0p-35 }, + { 0x990000.0p-23, -0xd00000.0p-34 }, + { 0x9a0000.0p-23, 0x880000.0p-33 }, + { 0x9b0000.0p-23, 0xe80000.0p-35 }, + { 0x9c0000.0p-23, -0x800000.0p-35 }, + { 0x9d0000.0p-23, 0xb40000.0p-33 }, + { 0x9e0000.0p-23, 0x880000.0p-34 }, + { 0x9f0000.0p-23, -0xe00000.0p-35 }, + { 0xa00000.0p-23, 0x800000.0p-33 }, + { 0xa10000.0p-23, -0x900000.0p-36 }, + { 0xa20000.0p-23, -0xb00000.0p-33 }, + { 0xa30000.0p-23, -0xa00000.0p-36 }, + { 0xa40000.0p-23, 0x800000.0p-33 }, + { 0xa50000.0p-23, -0xf80000.0p-35 }, + { 0xa60000.0p-23, 0x880000.0p-34 }, + { 0xa70000.0p-23, -0x900000.0p-33 }, + { 0xa80000.0p-23, -0x800000.0p-35 }, + { 0xa90000.0p-23, 0x900000.0p-34 }, + { 0xaa0000.0p-23, 0xa80000.0p-33 }, + { 0xab0000.0p-23, -0xac0000.0p-34 }, + { 0xac0000.0p-23, -0x800000.0p-37 }, + { 0xad0000.0p-23, 0xf80000.0p-35 }, + { 0xae0000.0p-23, 0xf80000.0p-34 }, + { 0xaf0000.0p-23, -0xac0000.0p-33 }, + { 0xb00000.0p-23, -0x800000.0p-33 }, + { 0xb10000.0p-23, -0xb80000.0p-34 }, + { 0xb20000.0p-23, -0x800000.0p-34 }, + { 0xb30000.0p-23, -0xb00000.0p-35 }, + { 0xb40000.0p-23, -0x800000.0p-35 }, + { 0xb50000.0p-23, -0xe00000.0p-36 }, + { 0xb60000.0p-23, -0x800000.0p-35 }, + { 0xb70000.0p-23, -0xb00000.0p-35 }, + { 0xb80000.0p-23, -0x800000.0p-34 }, + { 0xb90000.0p-23, -0xb80000.0p-34 }, + { 0xba0000.0p-23, -0x800000.0p-33 }, + { 0xbb0000.0p-23, -0xac0000.0p-33 }, + { 0xbc0000.0p-23, 0x980000.0p-33 }, + { 0xbd0000.0p-23, 0xbc0000.0p-34 }, + { 0xbe0000.0p-23, 0xe00000.0p-36 }, + { 0xbf0000.0p-23, -0xb80000.0p-35 }, + { 0xc00000.0p-23, -0x800000.0p-33 }, + { 0xc10000.0p-23, 0xa80000.0p-33 }, + { 0xc20000.0p-23, 0x900000.0p-34 }, + { 0xc30000.0p-23, -0x800000.0p-35 }, + { 0xc40000.0p-23, -0x900000.0p-33 }, + { 0xc50000.0p-23, 0x820000.0p-33 }, + { 0xc60000.0p-23, 0x800000.0p-38 }, + { 0xc70000.0p-23, -0x820000.0p-33 }, + { 0xc80000.0p-23, 0x800000.0p-33 }, + { 0xc90000.0p-23, -0xa00000.0p-36 }, + { 0xca0000.0p-23, -0xb00000.0p-33 }, + { 0xcb0000.0p-23, 0x840000.0p-34 }, + { 0xcc0000.0p-23, -0xd00000.0p-34 }, + { 0xcd0000.0p-23, 0x800000.0p-33 }, + { 0xce0000.0p-23, -0xe00000.0p-35 }, + { 0xcf0000.0p-23, 0xa60000.0p-33 }, + { 0xd00000.0p-23, -0x800000.0p-35 }, + { 0xd10000.0p-23, 0xb40000.0p-33 }, + { 0xd20000.0p-23, -0x800000.0p-35 }, + { 0xd30000.0p-23, 0xaa0000.0p-33 }, + { 0xd40000.0p-23, -0xe00000.0p-35 }, + { 0xd50000.0p-23, 0x880000.0p-33 }, + { 0xd60000.0p-23, -0xd00000.0p-34 }, + { 0xd70000.0p-23, 0x9c0000.0p-34 }, + { 0xd80000.0p-23, -0xb00000.0p-33 }, + { 0xd90000.0p-23, -0x800000.0p-38 }, + { 0xda0000.0p-23, 0xa40000.0p-33 }, + { 0xdb0000.0p-23, -0xdc0000.0p-34 }, + { 0xdc0000.0p-23, 0xc00000.0p-35 }, + { 0xdd0000.0p-23, 0xca0000.0p-33 }, + { 0xde0000.0p-23, -0xb80000.0p-34 }, + { 0xdf0000.0p-23, 0xd00000.0p-35 }, + { 0xe00000.0p-23, 0xc00000.0p-33 }, + { 0xe10000.0p-23, -0xf40000.0p-34 }, + { 0xe20000.0p-23, 0x800000.0p-37 }, + { 0xe30000.0p-23, 0x860000.0p-33 }, + { 0xe40000.0p-23, -0xc80000.0p-33 }, + { 0xe50000.0p-23, -0xa80000.0p-34 }, + { 0xe60000.0p-23, 0xe00000.0p-36 }, + { 0xe70000.0p-23, 0x880000.0p-33 }, + { 0xe80000.0p-23, -0xe00000.0p-33 }, + { 0xe90000.0p-23, -0xfc0000.0p-34 }, + { 0xea0000.0p-23, -0x800000.0p-35 }, + { 0xeb0000.0p-23, 0xe80000.0p-35 }, + { 0xec0000.0p-23, 0x900000.0p-33 }, + { 0xed0000.0p-23, 0xe20000.0p-33 }, + { 0xee0000.0p-23, -0xac0000.0p-33 }, + { 0xef0000.0p-23, -0xc80000.0p-34 }, + { 0xf00000.0p-23, -0x800000.0p-35 }, + { 0xf10000.0p-23, 0x800000.0p-35 }, + { 0xf20000.0p-23, 0xb80000.0p-34 }, + { 0xf30000.0p-23, 0x940000.0p-33 }, + { 0xf40000.0p-23, 0xc80000.0p-33 }, + { 0xf50000.0p-23, -0xf20000.0p-33 }, + { 0xf60000.0p-23, -0xc80000.0p-33 }, + { 0xf70000.0p-23, -0xa20000.0p-33 }, + { 0xf80000.0p-23, -0x800000.0p-33 }, + { 0xf90000.0p-23, -0xc40000.0p-34 }, + { 0xfa0000.0p-23, -0x900000.0p-34 }, + { 0xfb0000.0p-23, -0xc80000.0p-35 }, + { 0xfc0000.0p-23, -0x800000.0p-35 }, + { 0xfd0000.0p-23, -0x900000.0p-36 }, + { 0xfe0000.0p-23, -0x800000.0p-37 }, + { 0xff0000.0p-23, -0x800000.0p-39 }, + { 0x800000.0p-22, 0 }, }; #endif /* USE_UTAB */ #ifdef STRUCT_RETURN #define RETURN1(rp, v) do { \ (rp)->hi = (v); \ (rp)->lo_set = 0; \ return; \ } while (0) #define RETURN2(rp, h, l) do { \ (rp)->hi = (h); \ (rp)->lo = (l); \ (rp)->lo_set = 1; \ return; \ } while (0) struct ld { long double hi; long double lo; int lo_set; }; #else #define RETURN1(rp, v) RETURNF(v) #define RETURN2(rp, h, l) RETURNI((h) + (l)) #endif #ifdef STRUCT_RETURN static inline __always_inline void k_logl(long double x, struct ld *rp) #else long double logl(long double x) #endif { long double d, dk, val_hi, val_lo, z; uint64_t ix, lx; int i, k; uint16_t hx; EXTRACT_LDBL80_WORDS(hx, lx, x); k = -16383; #if 0 /* Hard to do efficiently. Don't do it until we support all modes. */ if (x == 1) RETURN1(rp, 0); /* log(1) = +0 in all rounding modes */ #endif if (hx == 0 || hx >= 0x8000) { /* zero, negative or subnormal? */ if (((hx & 0x7fff) | lx) == 0) RETURN1(rp, -1 / zero); /* log(+-0) = -Inf */ if (hx != 0) /* log(neg or [pseudo-]NaN) = qNaN: */ RETURN1(rp, (x - x) / zero); x *= 0x1.0p65; /* subnormal; scale up x */ /* including pseudo-subnormals */ EXTRACT_LDBL80_WORDS(hx, lx, x); k = -16383 - 65; } else if (hx >= 0x7fff || (lx & 0x8000000000000000ULL) == 0) RETURN1(rp, x + x); /* log(Inf or NaN) = Inf or qNaN */ /* log(pseudo-Inf) = qNaN */ /* log(pseudo-NaN) = qNaN */ /* log(unnormal) = qNaN */ #ifndef STRUCT_RETURN ENTERI(); #endif k += hx; ix = lx & 0x7fffffffffffffffULL; dk = k; /* Scale x to be in [1, 2). */ SET_LDBL_EXPSIGN(x, 0x3fff); /* 0 <= i <= INTERVALS: */ #define L2I (64 - LOG2_INTERVALS) i = (ix + (1LL << (L2I - 2))) >> (L2I - 1); /* * -0.005280 < d < 0.004838. In particular, the infinite- * precision |d| is <= 2**-7. Rounding of G(i) to 8 bits * ensures that d is representable without extra precision for * this bound on |d| (since when this calculation is expressed * as x*G(i)-1, the multiplication needs as many extra bits as * G(i) has and the subtraction cancels 8 bits). But for * most i (107 cases out of 129), the infinite-precision |d| * is <= 2**-8. G(i) is rounded to 9 bits for such i to give * better accuracy (this works by improving the bound on |d|, * which in turn allows rounding to 9 bits in more cases). * This is only important when the original x is near 1 -- it * lets us avoid using a special method to give the desired * accuracy for such x. */ if (0) d = x * G(i) - 1; else { #ifdef USE_UTAB d = (x - H(i)) * G(i) + E(i); #else long double x_hi, x_lo; float fx_hi; /* * Split x into x_hi + x_lo to calculate x*G(i)-1 exactly. * G(i) has at most 9 bits, so the splitting point is not * critical. */ SET_FLOAT_WORD(fx_hi, (lx >> 40) | 0x3f800000); x_hi = fx_hi; x_lo = x - x_hi; d = x_hi * G(i) - 1 + x_lo * G(i); #endif } /* * Our algorithm depends on exact cancellation of F_lo(i) and * F_hi(i) with dk*ln_2_lo and dk*ln2_hi when k is -1 and i is * at the end of the table. This and other technical complications * make it difficult to avoid the double scaling in (dk*ln2) * * log(base) for base != e without losing more accuracy and/or * efficiency than is gained. */ z = d * d; val_lo = z * d * z * (z * (d * P8 + P7) + (d * P6 + P5)) + (F_lo(i) + dk * ln2_lo + z * d * (d * P4 + P3)) + z * P2; val_hi = d; #ifdef DEBUG if (fetestexcept(FE_UNDERFLOW)) breakpoint(); #endif _3sumF(val_hi, val_lo, F_hi(i) + dk * ln2_hi); RETURN2(rp, val_hi, val_lo); } long double log1pl(long double x) { long double d, d_hi, d_lo, dk, f_lo, val_hi, val_lo, z; long double f_hi, twopminusk; uint64_t ix, lx; int i, k; int16_t ax, hx; DOPRINT_START(&x); EXTRACT_LDBL80_WORDS(hx, lx, x); if (hx < 0x3fff) { /* x < 1, or x neg NaN */ ax = hx & 0x7fff; if (ax >= 0x3fff) { /* x <= -1, or x neg NaN */ if (ax == 0x3fff && lx == 0x8000000000000000ULL) RETURNP(-1 / zero); /* log1p(-1) = -Inf */ /* log1p(x < 1, or x [pseudo-]NaN) = qNaN: */ RETURNP((x - x) / (x - x)); } if (ax <= 0x3fbe) { /* |x| < 2**-64 */ if ((int)x == 0) RETURNP(x); /* x with inexact if x != 0 */ } f_hi = 1; f_lo = x; } else if (hx >= 0x7fff) { /* x +Inf or non-neg NaN */ RETURNP(x + x); /* log1p(Inf or NaN) = Inf or qNaN */ /* log1p(pseudo-Inf) = qNaN */ /* log1p(pseudo-NaN) = qNaN */ /* log1p(unnormal) = qNaN */ } else if (hx < 0x407f) { /* 1 <= x < 2**128 */ f_hi = x; f_lo = 1; } else { /* 2**128 <= x < +Inf */ f_hi = x; f_lo = 0; /* avoid underflow of the P5 term */ } ENTERI(); x = f_hi + f_lo; f_lo = (f_hi - x) + f_lo; EXTRACT_LDBL80_WORDS(hx, lx, x); k = -16383; k += hx; ix = lx & 0x7fffffffffffffffULL; dk = k; SET_LDBL_EXPSIGN(x, 0x3fff); twopminusk = 1; SET_LDBL_EXPSIGN(twopminusk, 0x7ffe - (hx & 0x7fff)); f_lo *= twopminusk; i = (ix + (1LL << (L2I - 2))) >> (L2I - 1); /* * x*G(i)-1 (with a reduced x) can be represented exactly, as * above, but now we need to evaluate the polynomial on d = * (x+f_lo)*G(i)-1 and extra precision is needed for that. * Since x+x_lo is a hi+lo decomposition and subtracting 1 * doesn't lose too many bits, an inexact calculation for * f_lo*G(i) is good enough. */ if (0) d_hi = x * G(i) - 1; else { #ifdef USE_UTAB d_hi = (x - H(i)) * G(i) + E(i); #else long double x_hi, x_lo; float fx_hi; SET_FLOAT_WORD(fx_hi, (lx >> 40) | 0x3f800000); x_hi = fx_hi; x_lo = x - x_hi; d_hi = x_hi * G(i) - 1 + x_lo * G(i); #endif } d_lo = f_lo * G(i); /* * This is _2sumF(d_hi, d_lo) inlined. The condition * (d_hi == 0 || |d_hi| >= |d_lo|) for using _2sumF() is not * always satisifed, so it is not clear that this works, but * it works in practice. It works even if it gives a wrong * normalized d_lo, since |d_lo| > |d_hi| implies that i is * nonzero and d is tiny, so the F(i) term dominates d_lo. * In float precision: * (By exhaustive testing, the worst case is d_hi = 0x1.bp-25. * And if d is only a little tinier than that, we would have * another underflow problem for the P3 term; this is also ruled * out by exhaustive testing.) */ d = d_hi + d_lo; d_lo = d_hi - d + d_lo; d_hi = d; z = d * d; val_lo = z * d * z * (z * (d * P8 + P7) + (d * P6 + P5)) + (F_lo(i) + dk * ln2_lo + d_lo + z * d * (d * P4 + P3)) + z * P2; val_hi = d_hi; #ifdef DEBUG if (fetestexcept(FE_UNDERFLOW)) breakpoint(); #endif _3sumF(val_hi, val_lo, F_hi(i) + dk * ln2_hi); RETURN2PI(val_hi, val_lo); } #ifdef STRUCT_RETURN long double logl(long double x) { struct ld r; ENTERI(); DOPRINT_START(&x); k_logl(x, &r); RETURNSPI(&r); } static const double invln10_hi = 4.3429448190317999e-1, /* 0x1bcb7b1526e000.0p-54 */ invln10_lo = 7.1842412889749798e-14, /* 0x1438ca9aadd558.0p-96 */ invln2_hi = 1.4426950408887933e0, /* 0x171547652b8000.0p-52 */ invln2_lo = 1.7010652264631490e-13; /* 0x17f0bbbe87fed0.0p-95 */ long double log10l(long double x) { struct ld r; long double hi, lo; ENTERI(); DOPRINT_START(&x); k_logl(x, &r); if (!r.lo_set) RETURNPI(r.hi); _2sumF(r.hi, r.lo); hi = (float)r.hi; lo = r.lo + (r.hi - hi); RETURN2PI(invln10_hi * hi, (invln10_lo + invln10_hi) * lo + invln10_lo * hi); } long double log2l(long double x) { struct ld r; long double hi, lo; ENTERI(); DOPRINT_START(&x); k_logl(x, &r); if (!r.lo_set) RETURNPI(r.hi); _2sumF(r.hi, r.lo); hi = (float)r.hi; lo = r.lo + (r.hi - hi); RETURN2PI(invln2_hi * hi, (invln2_lo + invln2_hi) * lo + invln2_lo * hi); } #endif /* STRUCT_RETURN */ Index: stable/11/lib/msun/man/cacos.3 =================================================================== --- stable/11/lib/msun/man/cacos.3 (revision 324005) +++ stable/11/lib/msun/man/cacos.3 (revision 324006) @@ -1,124 +1,154 @@ .\" Copyright (c) 2013 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, 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$ .\" -.Dd Jul 14, 2015 +.Dd February 15, 2017 .Dt CACOS 3 .Os .Sh NAME .Nm cacos , .Nm cacosf , +.Nm cacosl , .Nm cacosh , .Nm cacoshf , +.Nm cacoshl , .Nm casin , -.Nm casinf +.Nm casinf , +.Nm casinl , .Nm casinh , -.Nm casinhf -.Nm catan , -.Nm catanf +.Nm casinhf , +.Nm casinhl , +.Nm catan , +.Nm catanf , +.Nm catanl , .Nm catanh , -.Nm catanhf -.Nd complex arc trigonometric and hyperbolic functions +.Nm catanhf , +.Nm catanhl +.Nd complex inverse trigonometric and hyperbolic functions .Sh LIBRARY .Lb libm .Sh SYNOPSIS .In complex.h .Ft double complex .Fn cacos "double complex z" .Ft float complex .Fn cacosf "float complex z" +.Ft long double complex +.Fn cacosl "long double complex z" .Ft double complex .Fn cacosh "double complex z" .Ft float complex .Fn cacoshf "float complex z" +.Ft long double complex +.Fn cacoshl "long double complex z" .Ft double complex .Fn casin "double complex z" .Ft float complex .Fn casinf "float complex z" +.Ft long double complex +.Fn casinl "long double complex z" .Ft double complex .Fn casinh "double complex z" .Ft float complex .Fn casinhf "float complex z" +.Ft long double complex +.Fn casinhl "long double complex z" .Ft double complex .Fn catan "double complex z" .Ft float complex .Fn catanf "float complex z" +.Ft long double complex +.Fn catanl "long double complex z" .Ft double complex .Fn catanh "double complex z" .Ft float complex .Fn catanhf "float complex z" +.Ft long double complex +.Fn catanhl "long double complex z" .Sh DESCRIPTION The .Fn cacos , .Fn casin , and .Fn catan functions compute the principal value of the inverse cosine, sine, and tangent of the complex number .Fa z , respectively. The .Fn cacosh , .Fn casinh , and .Fn catanh functions compute the principal value of the inverse hyperbolic cosine, sine, and tangent. The .Fn cacosf , .Fn casinf , .Fn catanf .Fn cacoshf , .Fn casinhf , and .Fn catanhf functions perform the same operations in .Fa float precision. +The +.Fn cacosl , +.Fn casinl , +.Fn catanl +.Fn cacoshl , +.Fn casinhl , +and +.Fn catanhl +functions perform the same operations in +.Fa long double +precision. .Pp .ds Un \[cu] There is no universal convention for defining the principal values of -these functions. The following table gives the branch cuts, and the +these functions. +The following table gives the branch cuts, and the corresponding ranges for the return values, adopted by the C language. .Bl -column ".Sy Function" ".Sy (-\*(If*I, -I) \*(Un (I, \*(If*I)" ".Sy [-\*(Pi/2*I, \*(Pi/2*I]" .It Sy Function Ta Sy Branch Cut(s) Ta Sy Range .It cacos Ta (-\*(If, -1) \*(Un (1, \*(If) Ta [0, \*(Pi] .It casin Ta (-\*(If, -1) \*(Un (1, \*(If) Ta [-\*(Pi/2, \*(Pi/2] .It catan Ta (-\*(If*I, -i) \*(Un (I, \*(If*I) Ta [-\*(Pi/2, \*(Pi/2] .It cacosh Ta (-\*(If, 1) Ta [-\*(Pi*I, \*(Pi*I] .It casinh Ta (-\*(If*I, -i) \*(Un (I, \*(If*I) Ta [-\*(Pi/2*I, \*(Pi/2*I] .It catanh Ta (-\*(If, -1) \*(Un (1, \*(If) Ta [-\*(Pi/2*I, \*(Pi/2*I] .El .Sh SEE ALSO .Xr ccos 3 , .Xr ccosh 3 , .Xr complex 3 , .Xr cos 3 , .Xr math 3 , .Xr sin 3 , .Xr tan 3 .Sh STANDARDS These functions conform to .St -isoC-99 . Index: stable/11/lib/msun/man/sincos.3 =================================================================== --- stable/11/lib/msun/man/sincos.3 (nonexistent) +++ stable/11/lib/msun/man/sincos.3 (revision 324006) @@ -0,0 +1,82 @@ +.\" Copyright (c) 2011 Steven G. Kargl. +.\" +.\" 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 REGENTS 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 REGENTS 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$ +.\" +.Dd March 12, 2011 +.Dt SINCOS 3 +.Os +.Sh NAME +.Nm sincos , +.Nm sincosf , +.Nm sincosl +.Nd sine and cosine functions +.Sh LIBRARY +.Lb libm +.Sh SYNOPSIS +.In math.h +.Ft void +.Fn sincos "double x" "double *s" "double *c" +.Ft void +.Fn sincosf "float x" "float *s" "float *c" +.Ft void +.Fn sincosl "long double x" "long double *s" "long double *c" +.Sh DESCRIPTION +The +.Fn sincos , +.Fn sincosf , +and +.Fn sincosl +functions compute the sine and cosine of +.Fa x . +Using these functions allows argument reduction to occur only +once instead of twice with individual invocations of +.Fn sin +and +.Fn cos . +Like +.Fn sin +and +.Fn cos , +a large magnitude argument may yield a result with little +or no significance. +.Sh RETURN VALUES +Upon returning from +.Fn sincos , +.Fn sincosf , +and +.Fn sincosl , +the memory pointed to by +.Ar "*s" +and +.Ar "*c" +are assigned the values of sine and cosine, respectively. +.Sh SEE ALSO +.Xr cos 3 , +.Xr sin 3 , +.Sh HISTORY +These functions were added to +.Fx 9.0 +to aid in writing various complex function contained in +.St -isoC-99 . + Property changes on: stable/11/lib/msun/man/sincos.3 ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/lib/msun/src/catrig.c =================================================================== --- stable/11/lib/msun/src/catrig.c (revision 324005) +++ stable/11/lib/msun/src/catrig.c (revision 324006) @@ -1,644 +1,653 @@ /*- * Copyright (c) 2012 Stephen Montgomery-Smith * 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 __FBSDID("$FreeBSD$"); #include #include #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), since the return value of * hypot cannot overflow if neither argument is greater in magnitude * than 1/sqrt(2) of the maximum value of the return type. Likewise * this determines the necessary threshold for using this method * (however, actually use 1/2 instead as it is simpler). * * 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))); } + +#if LDBL_MANT_DIG == 53 +__weak_reference(cacosh, cacoshl); +__weak_reference(cacos, cacosl); +__weak_reference(casinh, casinhl); +__weak_reference(casin, casinl); +__weak_reference(catanh, catanhl); +__weak_reference(catan, catanl); +#endif Index: stable/11/lib/msun/src/catrigl.c =================================================================== --- stable/11/lib/msun/src/catrigl.c (nonexistent) +++ stable/11/lib/msun/src/catrigl.c (revision 324006) @@ -0,0 +1,417 @@ +/*- + * Copyright (c) 2012 Stephen Montgomery-Smith + * Copyright (c) 2017 Mahdi Mokhtari + * 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 +__FBSDID("$FreeBSD$"); + +#include +#include + +#include "invtrig.h" +#include "math.h" +#include "math_private.h" + +#undef isinf +#define isinf(x) (fabsl(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_signbitl(x)) + +#if LDBL_MAX_EXP != 0x4000 +#error "Unsupported long double format" +#endif + +static const long double +A_crossover = 10, +B_crossover = 0.6417, +FOUR_SQRT_MIN = 0x1p-8189L, +HALF_MAX = 0x1p16383L, +QUARTER_SQRT_MAX = 0x1p8189L, +RECIP_EPSILON = 1 / LDBL_EPSILON, +SQRT_MIN = 0x1p-8191L; + +#if LDBL_MANT_DIG == 64 +static const union IEEEl2bits +um_e = LD80C(0xadf85458a2bb4a9b, 1, 2.71828182845904523536e+0L), +um_ln2 = LD80C(0xb17217f7d1cf79ac, -1, 6.93147180559945309417e-1L); +#define m_e um_e.e +#define m_ln2 um_ln2.e +static const long double +/* The next 2 literals for non-i386. Misrounding them on i386 is harmless. */ +SQRT_3_EPSILON = 5.70316273435758915310e-10, /* 0x9cc470a0490973e8.0p-94 */ +SQRT_6_EPSILON = 8.06549008734932771664e-10; /* 0xddb3d742c265539e.0p-94 */ +#elif LDBL_MANT_DIG == 113 +static const long double +m_e = 2.71828182845904523536028747135266250e0L, /* 0x15bf0a8b1457695355fb8ac404e7a.0p-111 */ +m_ln2 = 6.93147180559945309417232121458176568e-1L, /* 0x162e42fefa39ef35793c7673007e6.0p-113 */ +SQRT_3_EPSILON = 2.40370335797945490975336727199878124e-17, /* 0x1bb67ae8584caa73b25742d7078b8.0p-168 */ +SQRT_6_EPSILON = 3.39934988877629587239082586223300391e-17; /* 0x13988e1409212e7d0321914321a55.0p-167 */ +#else +#error "Unsupported long double format" +#endif + +static const volatile float +tiny = 0x1p-100; + +static long double complex clog_for_large_values(long double complex z); + +static inline long double +f(long double a, long double b, long 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); +} + +static inline void +do_hard_work(long double x, long double y, long double *rx, int *B_is_usable, + long double *B, long double *sqrt_A2my2, long double *new_y) +{ + long double R, S, A; + long double Am1, Amy; + + R = hypotl(x, y + 1); + S = hypotl(x, y - 1); + + A = (R + S) / 2; + if (A < 1) + A = 1; + + if (A < A_crossover) { + if (y == 1 && x < LDBL_EPSILON * LDBL_EPSILON / 128) { + *rx = sqrtl(x); + } else if (x >= LDBL_EPSILON * fabsl(y - 1)) { + Am1 = f(x, 1 + y, R) + f(x, 1 - y, S); + *rx = log1pl(Am1 + sqrtl(Am1 * (A + 1))); + } else if (y < 1) { + *rx = x / sqrtl((1 - y) * (1 + y)); + } else { + *rx = log1pl((y - 1) + sqrtl((y - 1) * (y + 1))); + } + } else { + *rx = logl(A + sqrtl(A * A - 1)); + } + + *new_y = y; + + if (y < FOUR_SQRT_MIN) { + *B_is_usable = 0; + *sqrt_A2my2 = A * (2 / LDBL_EPSILON); + *new_y = y * (2 / LDBL_EPSILON); + return; + } + + *B = y / A; + *B_is_usable = 1; + + if (*B > B_crossover) { + *B_is_usable = 0; + if (y == 1 && x < LDBL_EPSILON / 128) { + *sqrt_A2my2 = sqrtl(x) * sqrtl((A + y) / 2); + } else if (x >= LDBL_EPSILON * fabsl(y - 1)) { + Amy = f(x, y + 1, R) + f(x, y - 1, S); + *sqrt_A2my2 = sqrtl(Amy * (A + y)); + } else if (y > 1) { + *sqrt_A2my2 = x * (4 / LDBL_EPSILON / LDBL_EPSILON) * y / + sqrtl((y + 1) * (y - 1)); + *new_y = y * (4 / LDBL_EPSILON / LDBL_EPSILON); + } else { + *sqrt_A2my2 = sqrtl((1 - y) * (1 + y)); + } + } +} + +long double complex +casinhl(long double complex z) +{ + long double x, y, ax, ay, rx, ry, B, sqrt_A2my2, new_y; + int B_is_usable; + long double complex w; + + x = creall(z); + y = cimagl(z); + ax = fabsl(x); + ay = fabsl(y); + + if (isnan(x) || isnan(y)) { + if (isinf(x)) + return (CMPLXL(x, y + y)); + if (isinf(y)) + return (CMPLXL(y, x + x)); + if (y == 0) + return (CMPLXL(x + x, y)); + return (CMPLXL(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 (CMPLXL(copysignl(creall(w), x), + copysignl(cimagl(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 = asinl(B); + else + ry = atan2l(new_y, sqrt_A2my2); + return (CMPLXL(copysignl(rx, x), copysignl(ry, y))); +} + +long double complex +casinl(long double complex z) +{ + long double complex w; + + w = casinhl(CMPLXL(cimagl(z), creall(z))); + return (CMPLXL(cimagl(w), creall(w))); +} + +long double complex +cacosl(long double complex z) +{ + long double x, y, ax, ay, rx, ry, B, sqrt_A2mx2, new_x; + int sx, sy; + int B_is_usable; + long double complex w; + + x = creall(z); + y = cimagl(z); + sx = signbit(x); + sy = signbit(y); + ax = fabsl(x); + ay = fabsl(y); + + if (isnan(x) || isnan(y)) { + if (isinf(x)) + return (CMPLXL(y + y, -INFINITY)); + if (isinf(y)) + return (CMPLXL(x + x, -y)); + if (x == 0) + return (CMPLXL(pio2_hi + pio2_lo, y + y)); + return (CMPLXL(x + 0.0L + (y + 0), x + 0.0L + (y + 0))); + } + + if (ax > RECIP_EPSILON || ay > RECIP_EPSILON) { + w = clog_for_large_values(z); + rx = fabsl(cimagl(w)); + ry = creall(w) + m_ln2; + if (sy == 0) + ry = -ry; + return (CMPLXL(rx, ry)); + } + + if (x == 1 && y == 0) + return (CMPLXL(0, -y)); + + raise_inexact(); + + if (ax < SQRT_6_EPSILON / 4 && ay < SQRT_6_EPSILON / 4) + return (CMPLXL(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 = acosl(B); + else + rx = acosl(-B); + } else { + if (sx == 0) + rx = atan2l(sqrt_A2mx2, new_x); + else + rx = atan2l(sqrt_A2mx2, -new_x); + } + if (sy == 0) + ry = -ry; + return (CMPLXL(rx, ry)); +} + +long double complex +cacoshl(long double complex z) +{ + long double complex w; + long double rx, ry; + + w = cacosl(z); + rx = creall(w); + ry = cimagl(w); + if (isnan(rx) && isnan(ry)) + return (CMPLXL(ry, rx)); + if (isnan(rx)) + return (CMPLXL(fabsl(ry), rx)); + if (isnan(ry)) + return (CMPLXL(ry, ry)); + return (CMPLXL(fabsl(ry), copysignl(rx, cimagl(z)))); +} + +static long double complex +clog_for_large_values(long double complex z) +{ + long double x, y; + long double ax, ay, t; + + x = creall(z); + y = cimagl(z); + ax = fabsl(x); + ay = fabsl(y); + if (ax < ay) { + t = ax; + ax = ay; + ay = t; + } + + if (ax > HALF_MAX) + return (CMPLXL(logl(hypotl(x / m_e, y / m_e)) + 1, + atan2l(y, x))); + + if (ax > QUARTER_SQRT_MAX || ay < SQRT_MIN) + return (CMPLXL(logl(hypotl(x, y)), atan2l(y, x))); + + return (CMPLXL(logl(ax * ax + ay * ay) / 2, atan2l(y, x))); +} + +static inline long double +sum_squares(long double x, long double y) +{ + + if (y < SQRT_MIN) + return (x * x); + + return (x * x + y * y); +} + +static inline long double +real_part_reciprocal(long double x, long double y) +{ + long double scale; + uint16_t hx, hy; + int16_t ix, iy; + + GET_LDBL_EXPSIGN(hx, x); + ix = hx & 0x7fff; + GET_LDBL_EXPSIGN(hy, y); + iy = hy & 0x7fff; +#define BIAS (LDBL_MAX_EXP - 1) +#define CUTOFF (LDBL_MANT_DIG / 2 + 1) + if (ix - iy >= CUTOFF || isinf(x)) + return (1 / x); + if (iy - ix >= CUTOFF) + return (x / y / y); + if (ix <= BIAS + LDBL_MAX_EXP / 2 - CUTOFF) + return (x / (x * x + y * y)); + scale = 1; + SET_LDBL_EXPSIGN(scale, 0x7fff - ix); + x *= scale; + y *= scale; + return (x / (x * x + y * y) * scale); +} + +long double complex +catanhl(long double complex z) +{ + long double x, y, ax, ay, rx, ry; + + x = creall(z); + y = cimagl(z); + ax = fabsl(x); + ay = fabsl(y); + + if (y == 0 && ax <= 1) + return (CMPLXL(atanhl(x), y)); + + if (x == 0) + return (CMPLXL(x, atanl(y))); + + if (isnan(x) || isnan(y)) { + if (isinf(x)) + return (CMPLXL(copysignl(0, x), y + y)); + if (isinf(y)) + return (CMPLXL(copysignl(0, x), + copysignl(pio2_hi + pio2_lo, y))); + return (CMPLXL(x + 0.0L + (y + 0), x + 0.0L + (y + 0))); + } + + if (ax > RECIP_EPSILON || ay > RECIP_EPSILON) + return (CMPLXL(real_part_reciprocal(x, y), + copysignl(pio2_hi + pio2_lo, y))); + + if (ax < SQRT_3_EPSILON / 2 && ay < SQRT_3_EPSILON / 2) { + raise_inexact(); + return (z); + } + + if (ax == 1 && ay < LDBL_EPSILON) + rx = (m_ln2 - logl(ay)) / 2; + else + rx = log1pl(4 * ax / sum_squares(ax - 1, ay)) / 4; + + if (ax == 1) + ry = atan2l(2, -ay) / 2; + else if (ay < LDBL_EPSILON) + ry = atan2l(2 * ay, (1 - ax) * (1 + ax)) / 2; + else + ry = atan2l(2 * ay, (1 - ax) * (1 + ax) - ay * ay) / 2; + + return (CMPLXL(copysignl(rx, x), copysignl(ry, y))); +} + +long double complex +catanl(long double complex z) +{ + long double complex w; + + w = catanhl(CMPLXL(cimagl(z), creall(z))); + return (CMPLXL(cimagl(w), creall(w))); +} Property changes on: stable/11/lib/msun/src/catrigl.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/lib/msun/src/e_asin.c =================================================================== --- stable/11/lib/msun/src/e_asin.c (revision 324005) +++ stable/11/lib/msun/src/e_asin.c (revision 324006) @@ -1,117 +1,117 @@ /* @(#)e_asin.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 + * software is freely granted, provided that this notice * is preserved. * ==================================================== */ #include __FBSDID("$FreeBSD$"); /* __ieee754_asin(x) * Method : * Since asin(x) = x + x^3/6 + x^5*3/40 + x^7*15/336 + ... * we approximate asin(x) on [0,0.5] by * asin(x) = x + x*x^2*R(x^2) * where * R(x^2) is a rational approximation of (asin(x)-x)/x^3 * and its remez error is bounded by * |(asin(x)-x)/x^3 - R(x^2)| < 2^(-58.75) * * For x in [0.5,1] * asin(x) = pi/2-2*asin(sqrt((1-x)/2)) * Let y = (1-x), z = y/2, s := sqrt(z), and pio2_hi+pio2_lo=pi/2; * then for x>0.98 * asin(x) = pi/2 - 2*(s+s*z*R(z)) * = pio2_hi - (2*(s+s*z*R(z)) - pio2_lo) * For x<=0.98, let pio4_hi = pio2_hi/2, then * f = hi part of s; * c = sqrt(z) - f = (z-f*f)/(s+f) ...f+c=sqrt(z) * and * asin(x) = pi/2 - 2*(s+s*z*R(z)) * = pio4_hi+(pio4-2s)-(2s*z*R(z)-pio2_lo) * = pio4_hi+(pio4-2f)-(2s*z*R(z)-(pio2_lo+2c)) * * Special cases: * if x is NaN, return x itself; * if |x|>1, return NaN with invalid signal. * */ #include #include "math.h" #include "math_private.h" static const double one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ huge = 1.000e+300, pio2_hi = 1.57079632679489655800e+00, /* 0x3FF921FB, 0x54442D18 */ pio2_lo = 6.12323399573676603587e-17, /* 0x3C91A626, 0x33145C07 */ pio4_hi = 7.85398163397448278999e-01, /* 0x3FE921FB, 0x54442D18 */ /* coefficient for R(x^2) */ pS0 = 1.66666666666666657415e-01, /* 0x3FC55555, 0x55555555 */ pS1 = -3.25565818622400915405e-01, /* 0xBFD4D612, 0x03EB6F7D */ pS2 = 2.01212532134862925881e-01, /* 0x3FC9C155, 0x0E884455 */ pS3 = -4.00555345006794114027e-02, /* 0xBFA48228, 0xB5688F3B */ pS4 = 7.91534994289814532176e-04, /* 0x3F49EFE0, 0x7501B288 */ pS5 = 3.47933107596021167570e-05, /* 0x3F023DE1, 0x0DFDF709 */ qS1 = -2.40339491173441421878e+00, /* 0xC0033A27, 0x1C8A2D4B */ qS2 = 2.02094576023350569471e+00, /* 0x40002AE5, 0x9C598AC8 */ qS3 = -6.88283971605453293030e-01, /* 0xBFE6066C, 0x1B8D0159 */ qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */ double __ieee754_asin(double x) { double t=0.0,w,p,q,c,r,s; int32_t hx,ix; GET_HIGH_WORD(hx,x); ix = hx&0x7fffffff; if(ix>= 0x3ff00000) { /* |x|>= 1 */ u_int32_t lx; GET_LOW_WORD(lx,x); if(((ix-0x3ff00000)|lx)==0) /* asin(1)=+-pi/2 with inexact */ return x*pio2_hi+x*pio2_lo; return (x-x)/(x-x); /* asin(|x|>1) is NaN */ } else if (ix<0x3fe00000) { /* |x|<0.5 */ if(ix<0x3e500000) { /* if |x| < 2**-26 */ if(huge+x>one) return x;/* return x with inexact if x!=0*/ } t = x*x; p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5))))); q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4))); w = p/q; return x+x*w; } /* 1> |x|>= 0.5 */ w = one-fabs(x); t = w*0.5; p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5))))); q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4))); s = sqrt(t); if(ix>=0x3FEF3333) { /* if |x| > 0.975 */ w = p/q; t = pio2_hi-(2.0*(s+s*w)-pio2_lo); } else { w = s; SET_LOW_WORD(w,0); c = (t-w*w)/(s+w); r = p/q; p = 2.0*s*r-(pio2_lo-2.0*c); q = pio4_hi-2.0*w; t = pio4_hi-(p-q); } if(hx>0) return t; else return -t; } #if LDBL_MANT_DIG == 53 __weak_reference(asin, asinl); #endif Index: stable/11/lib/msun/src/e_coshl.c =================================================================== --- stable/11/lib/msun/src/e_coshl.c (revision 324005) +++ stable/11/lib/msun/src/e_coshl.c (revision 324006) @@ -1,130 +1,132 @@ /* 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 __FBSDID("$FreeBSD$"); /* * See e_cosh.c for complete comments. * * Converted to long double by Bruce D. Evans. */ #include #ifdef __i386__ #include #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; +#if LDBL_MANT_DIG == 113 double dx2; +#endif 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 o_threshold, cosh(x) overflow */ RETURNI(huge*huge); } Index: stable/11/lib/msun/src/e_lgammaf_r.c =================================================================== --- stable/11/lib/msun/src/e_lgammaf_r.c (revision 324005) +++ stable/11/lib/msun/src/e_lgammaf_r.c (revision 324006) @@ -1,215 +1,215 @@ /* e_lgammaf_r.c -- float version of e_lgamma_r.c. * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. * Conversion to float fixed By Steven G. Kargl. */ /* * ==================================================== * 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 __FBSDID("$FreeBSD$"); #include "math.h" #include "math_private.h" static const volatile float vzero = 0; static const float zero= 0, half= 0.5, one = 1, pi = 3.1415927410e+00, /* 0x40490fdb */ /* * 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 float sin_pif(float x) { volatile float vz; float y,z; int n; y = -x; vz = y+0x1p23F; /* depend on 0 <= y < 0x1p23 */ z = vz-0x1p23F; /* rintf(y) for the above range */ if (z == y) return zero; 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: case 2: y = __kernel_cosdf(pi*((float)0.5-y)); break; case 3: case 4: y = __kernel_sindf(pi*(one-y)); break; case 5: case 6: y = -__kernel_cosdf(pi*(y-(float)1.5)); break; default: y = __kernel_sindf(pi*(y-(float)2.0)); break; } return -y; } float __ieee754_lgammaf_r(float x, int *signgamp) { - float nadj,p,p1,p2,p3,q,r,t,w,y,z; + float nadj,p,p1,p2,q,r,t,w,y,z; int32_t hx; int i,ix; GET_FLOAT_WORD(hx,x); /* purge +-Inf and NaNs */ *signgamp = 1; ix = hx&0x7fffffff; if(ix>=0x7f800000) return x*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) { *signgamp = 1; if(ix>=0x4b000000) /* |x|>=2**23, must be -integer */ return one/vzero; t = sin_pif(x); if(t==zero) return one/vzero; /* -integer */ nadj = __ieee754_logf(pi/fabsf(t*x)); if(t=0x3f3b4a20) {y = one-x; i= 0;} else if(ix>=0x3e6d3308) {y= x-(tc-one); i=1;} else {y = x; i=2;} } else { r = zero; 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;} } switch(i) { case 0: z = y*y; p1 = a0+z*(a2+z*a4); p2 = z*(a1+z*(a3+z*a5)); p = y*p1+p2; r += p-y/2; break; case 1: 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)); p2 = one+y*(v1+y*(v2+y*v3)); r += p1/p2-y/2; } } /* 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+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**27 */ } else if (ix < 0x4d000000) { t = __ieee754_logf(x); z = one/x; y = z*z; w = w0+z*(w1+y*w2); r = (x-half)*(t-one)+w; } else /* 2**27 <= x <= inf */ r = x*(__ieee754_logf(x)-one); if(hx<0) r = nadj - r; return r; } Index: stable/11/lib/msun/src/e_sinhl.c =================================================================== --- stable/11/lib/msun/src/e_sinhl.c (revision 324005) +++ stable/11/lib/msun/src/e_sinhl.c (revision 324006) @@ -1,131 +1,134 @@ /* 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 __FBSDID("$FreeBSD$"); /* * See e_sinh.c for complete comments. * * Converted to long double by Bruce D. Evans. */ #include #ifdef __i386__ #include #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; +#if LDBL_MANT_DIG == 113 + double dx2; +#endif + double 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 (ix1) 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; } Index: stable/11/lib/msun/src/k_sincos.h =================================================================== --- stable/11/lib/msun/src/k_sincos.h (nonexistent) +++ stable/11/lib/msun/src/k_sincos.h (revision 324006) @@ -0,0 +1,52 @@ +/*- + * ==================================================== + * 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. + * ==================================================== + * + * k_sin.c and k_cos.c merged by Steven G. Kargl. + */ + +#include +__FBSDID("$FreeBSD$"); + +static const double +S1 = -1.66666666666666324348e-01, /* 0xBFC55555, 0x55555549 */ +S2 = 8.33333333332248946124e-03, /* 0x3F811111, 0x1110F8A6 */ +S3 = -1.98412698298579493134e-04, /* 0xBF2A01A0, 0x19C161D5 */ +S4 = 2.75573137070700676789e-06, /* 0x3EC71DE3, 0x57B1FE7D */ +S5 = -2.50507602534068634195e-08, /* 0xBE5AE5E6, 0x8A2B9CEB */ +S6 = 1.58969099521155010221e-10; /* 0x3DE5D93A, 0x5ACFD57C */ + +static const double +C1 = 4.16666666666666019037e-02, /* 0x3FA55555, 0x5555554C */ +C2 = -1.38888888888741095749e-03, /* 0xBF56C16C, 0x16C15177 */ +C3 = 2.48015872894767294178e-05, /* 0x3EFA01A0, 0x19CB1590 */ +C4 = -2.75573143513906633035e-07, /* 0xBE927E4F, 0x809C52AD */ +C5 = 2.08757232129817482790e-09, /* 0x3E21EE9E, 0xBDB4B1C4 */ +C6 = -1.13596475577881948265e-11; /* 0xBDA8FAE9, 0xBE8838D4 */ + +static inline void +__kernel_sincos(double x, double y, int iy, double *sn, double *cs) +{ + double hz, r, v, w, z; + + z = x * x; + w = z * z; + r = S2 + z * (S3 + z * S4) + z * w * (S5 + z * S6); + v = z * x; + + if (iy == 0) + *sn = x + v * (S1 + z * r); + else + *sn = x - ((z * (y / 2 - v * r) - y) - v * S1); + + r = z * (C1 + z * (C2 + z * C3)) + w * w * (C4 + z * (C5 + z * C6)); + hz = z / 2; + w = 1 - hz; + *cs = w + (((1 - w) - hz) + (z * r - x * y)); +} Property changes on: stable/11/lib/msun/src/k_sincos.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/lib/msun/src/k_sincosf.h =================================================================== --- stable/11/lib/msun/src/k_sincosf.h (nonexistent) +++ stable/11/lib/msun/src/k_sincosf.h (revision 324006) @@ -0,0 +1,43 @@ +/*- + * ==================================================== + * 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. + * ==================================================== + * + * k_sinf.c and k_cosf.c merged by Steven G. Kargl. + */ + +#include +__FBSDID("$FreeBSD$"); + +/* |sin(x)/x - s(x)| < 2**-37.5 (~[-4.89e-12, 4.824e-12]). */ +static const double +S1 = -0x15555554cbac77.0p-55, /* -0.166666666416265235595 */ +S2 = 0x111110896efbb2.0p-59, /* 0.0083333293858894631756 */ +S3 = -0x1a00f9e2cae774.0p-65, /* -0.000198393348360966317347 */ +S4 = 0x16cd878c3b46a7.0p-71; /* 0.0000027183114939898219064 */ + +/* |cos(x) - c(x)| < 2**-34.1 (~[-5.37e-11, 5.295e-11]). */ +static const double +C0 = -0x1ffffffd0c5e81.0p-54, /* -0.499999997251031003120 */ +C1 = 0x155553e1053a42.0p-57, /* 0.0416666233237390631894 */ +C2 = -0x16c087e80f1e27.0p-62, /* -0.00138867637746099294692 */ +C3 = 0x199342e0ee5069.0p-68; /* 0.0000243904487962774090654 */ + +static inline void +__kernel_sincosdf(double x, float *sn, float *cs) +{ + double r, s, w, z; + + z = x * x; + w = z * z; + r = S3 + z * S4; + s = z * x; + *sn = (x + s * (S1 + z * S2)) + s * w * r; + r = C2 + z * C3; + *cs = ((1 + z * C0) + w * C1) + (w * z) * r; +} Property changes on: stable/11/lib/msun/src/k_sincosf.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/lib/msun/src/k_sincosl.h =================================================================== --- stable/11/lib/msun/src/k_sincosl.h (nonexistent) +++ stable/11/lib/msun/src/k_sincosl.h (revision 324006) @@ -0,0 +1,134 @@ +/*- + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * Copyright (c) 2008 Steven G. Kargl, David Schultz, Bruce D. Evans. + * + * 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. + * ==================================================== + * + * k_sinl.c and k_cosl.c merged by Steven G. Kargl + */ + +#include +__FBSDID("$FreeBSD$"); + +#if LDBL_MANT_DIG == 64 /* ld80 version of k_sincosl.c. */ + +#if defined(__amd64__) || defined(__i386__) +/* Long double constants are slow on these arches, and broken on i386. */ +static const volatile double +C1hi = 0.041666666666666664, /* 0x15555555555555.0p-57 */ +C1lo = 2.2598839032744733e-18, /* 0x14d80000000000.0p-111 */ +S1hi = -0.16666666666666666, /* -0x15555555555555.0p-55 */ +S1lo = -9.2563760475949941e-18; /* -0x15580000000000.0p-109 */ +#define S1 ((long double)S1hi + S1lo) +#define C1 ((long double)C1hi + C1lo) +#else +static const long double +C1 = 0.0416666666666666666136L; /* 0xaaaaaaaaaaaaaa9b.0p-68 */ +S1 = -0.166666666666666666671L, /* -0xaaaaaaaaaaaaaaab.0p-66 */ +#endif + +static const double +C2 = -0.0013888888888888874, /* -0x16c16c16c16c10.0p-62 */ +C3 = 0.000024801587301571716, /* 0x1a01a01a018e22.0p-68 */ +C4 = -0.00000027557319215507120, /* -0x127e4fb7602f22.0p-74 */ +C5 = 0.0000000020876754400407278, /* 0x11eed8caaeccf1.0p-81 */ +C6 = -1.1470297442401303e-11, /* -0x19393412bd1529.0p-89 */ +C7 = 4.7383039476436467e-14, /* 0x1aac9d9af5c43e.0p-97 */ +S2 = 0.0083333333333333332, /* 0x11111111111111.0p-59 */ +S3 = -0.00019841269841269427, /* -0x1a01a01a019f81.0p-65 */ +S4 = 0.0000027557319223597490, /* 0x171de3a55560f7.0p-71 */ +S5 = -0.000000025052108218074604, /* -0x1ae64564f16cad.0p-78 */ +S6 = 1.6059006598854211e-10, /* 0x161242b90243b5.0p-85 */ +S7 = -7.6429779983024564e-13, /* -0x1ae42ebd1b2e00.0p-93 */ +S8 = 2.6174587166648325e-15; /* 0x179372ea0b3f64.0p-101 */ + +static inline void +__kernel_sincosl(long double x, long double y, int iy, long double *sn, + long double *cs) +{ + long double hz, r, v, w, z; + + z = x * x; + v = z * x; + /* + * XXX Replace Horner scheme with an algorithm suitable for CPUs + * with more complex pipelines. + */ + r = S2 + z * (S3 + z * (S4 + z * (S5 + z * (S6 + z * (S7 + z * S8))))); + + if (iy == 0) + *sn = x + v * (S1 + z * r); + else + *sn = x - ((z * (y / 2 - v * r) - y) - v * S1); + + hz = z / 2; + w = 1 - hz; + r = z * (C1 + z * (C2 + z * (C3 + z * (C4 + z * (C5 + z * (C6 + + z * C7)))))); + *cs = w + (((1 - w) - hz) + (z * r - x * y)); +} + +#elif LDBL_MANT_DIG == 113 /* ld128 version of k_sincosl.c. */ + +static const long double +C1 = 0.04166666666666666666666666666666658424671L, +C2 = -0.001388888888888888888888888888863490893732L, +C3 = 0.00002480158730158730158730158600795304914210L, +C4 = -0.2755731922398589065255474947078934284324e-6L, +C5 = 0.2087675698786809897659225313136400793948e-8L, +C6 = -0.1147074559772972315817149986812031204775e-10L, +C7 = 0.4779477332386808976875457937252120293400e-13L, +S1 = -0.16666666666666666666666666666666666606732416116558L, +S2 = 0.0083333333333333333333333333333331135404851288270047L, +S3 = -0.00019841269841269841269841269839935785325638310428717L, +S4 = 0.27557319223985890652557316053039946268333231205686e-5L, +S5 = -0.25052108385441718775048214826384312253862930064745e-7L, +S6 = 0.16059043836821614596571832194524392581082444805729e-9L, +S7 = -0.76471637318198151807063387954939213287488216303768e-12L, +S8 = 0.28114572543451292625024967174638477283187397621303e-14L; + +static const double +C8 = -0.1561920696721507929516718307820958119868e-15, +C9 = 0.4110317413744594971475941557607804508039e-18, +C10 = -0.8896592467191938803288521958313920156409e-21, +C11 = 0.1601061435794535138244346256065192782581e-23, +S9 = -0.82206352458348947812512122163446202498005154296863e-17, +S10 = 0.19572940011906109418080609928334380560135358385256e-19, +S11 = -0.38680813379701966970673724299207480965452616911420e-22, +S12 = 0.64038150078671872796678569586315881020659912139412e-25; + +static inline void +__kernel_sincosl(long double x, long double y, int iy, long double *sn, + long double *cs) +{ + long double hz, r, v, w, z; + + z = x * x; + v = z * x; + /* + * XXX Replace Horner scheme with an algorithm suitable for CPUs + * with more complex pipelines. + */ + r = S2 + z * (S3 + z * (S4 + z * (S5 + z * (S6 + z * (S7 + z * (S8 + + z * (S9 + z * (S10 + z * (S11 + z * S12))))))))); + + if (iy == 0) + *sn = x + v * (S1 + z * r); + else + *cs = x - ((z * (y / 2 - v * r) - y) - v * S1); + + hz = z / 2; + w = 1 - hz; + r = z * (C1 + z * (C2 + z * (C3 + z * (C4 + z * (C5 + z * (C6 + + z * (C7 + z * (C8 + z * (C9 + z * (C10 + z * C11)))))))))); + + *cs = w + (((1 - w) - hz) + (z * r - x * y)); +} +#else +#error "Unsupported long double format" +#endif Property changes on: stable/11/lib/msun/src/k_sincosl.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/lib/msun/src/math.h =================================================================== --- stable/11/lib/msun/src/math.h (revision 324005) +++ stable/11/lib/msun/src/math.h (revision 324006) @@ -1,507 +1,510 @@ /* * ==================================================== * 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. * ==================================================== */ /* * from: @(#)fdlibm.h 5.1 93/09/24 * $FreeBSD$ */ #ifndef _MATH_H_ #define _MATH_H_ #include #include #include /* * ANSI/POSIX */ extern const union __infinity_un { unsigned char __uc[8]; double __ud; } __infinity; extern const union __nan_un { unsigned char __uc[sizeof(float)]; float __uf; } __nan; #if __GNUC_PREREQ__(3, 3) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 800) #define __MATH_BUILTIN_CONSTANTS #endif #if __GNUC_PREREQ__(3, 0) && !defined(__INTEL_COMPILER) #define __MATH_BUILTIN_RELOPS #endif #ifdef __MATH_BUILTIN_CONSTANTS #define HUGE_VAL __builtin_huge_val() #else #define HUGE_VAL (__infinity.__ud) #endif #if __ISO_C_VISIBLE >= 1999 #define FP_ILOGB0 (-__INT_MAX) #define FP_ILOGBNAN __INT_MAX #ifdef __MATH_BUILTIN_CONSTANTS #define HUGE_VALF __builtin_huge_valf() #define HUGE_VALL __builtin_huge_vall() #define INFINITY __builtin_inff() #define NAN __builtin_nanf("") #else #define HUGE_VALF (float)HUGE_VAL #define HUGE_VALL (long double)HUGE_VAL #define INFINITY HUGE_VALF #define NAN (__nan.__uf) #endif /* __MATH_BUILTIN_CONSTANTS */ #define MATH_ERRNO 1 #define MATH_ERREXCEPT 2 #define math_errhandling MATH_ERREXCEPT #define FP_FAST_FMAF 1 /* Symbolic constants to classify floating point numbers. */ #define FP_INFINITE 0x01 #define FP_NAN 0x02 #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) \ __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) #ifdef __MATH_BUILTIN_RELOPS #define isgreater(x, y) __builtin_isgreater((x), (y)) #define isgreaterequal(x, y) __builtin_isgreaterequal((x), (y)) #define isless(x, y) __builtin_isless((x), (y)) #define islessequal(x, y) __builtin_islessequal((x), (y)) #define islessgreater(x, y) __builtin_islessgreater((x), (y)) #define isunordered(x, y) __builtin_isunordered((x), (y)) #else #define isgreater(x, y) (!isunordered((x), (y)) && (x) > (y)) #define isgreaterequal(x, y) (!isunordered((x), (y)) && (x) >= (y)) #define isless(x, y) (!isunordered((x), (y)) && (x) < (y)) #define islessequal(x, y) (!isunordered((x), (y)) && (x) <= (y)) #define islessgreater(x, y) (!isunordered((x), (y)) && \ ((x) > (y) || (y) > (x))) #define isunordered(x, y) (isnan(x) || isnan(y)) #endif /* __MATH_BUILTIN_RELOPS */ #define signbit(x) __fp_type_select(x, __signbitf, __signbit, __signbitl) typedef __double_t double_t; typedef __float_t float_t; #endif /* __ISO_C_VISIBLE >= 1999 */ /* * XOPEN/SVID */ #if __BSD_VISIBLE || __XSI_VISIBLE #define M_E 2.7182818284590452354 /* e */ #define M_LOG2E 1.4426950408889634074 /* log 2e */ #define M_LOG10E 0.43429448190325182765 /* log 10e */ #define M_LN2 0.69314718055994530942 /* log e2 */ #define M_LN10 2.30258509299404568402 /* log e10 */ #define M_PI 3.14159265358979323846 /* pi */ #define M_PI_2 1.57079632679489661923 /* pi/2 */ #define M_PI_4 0.78539816339744830962 /* pi/4 */ #define M_1_PI 0.31830988618379067154 /* 1/pi */ #define M_2_PI 0.63661977236758134308 /* 2/pi */ #define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */ #define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ #define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ #define MAXFLOAT ((float)3.40282346638528860e+38) extern int signgam; #endif /* __BSD_VISIBLE || __XSI_VISIBLE */ #if __BSD_VISIBLE #if 0 /* Old value from 4.4BSD-Lite math.h; this is probably better. */ #define HUGE HUGE_VAL #else #define HUGE MAXFLOAT #endif #endif /* __BSD_VISIBLE */ /* * Most of these functions depend on the rounding mode and have the side * effect of raising floating-point exceptions, so they are not declared * as __pure2. In C99, FENV_ACCESS affects the purity of these functions. */ __BEGIN_DECLS /* * ANSI/POSIX */ int __fpclassifyd(double) __pure2; int __fpclassifyf(float) __pure2; int __fpclassifyl(long double) __pure2; int __isfinitef(float) __pure2; int __isfinite(double) __pure2; int __isfinitel(long double) __pure2; int __isinff(float) __pure2; int __isinf(double) __pure2; int __isinfl(long double) __pure2; int __isnormalf(float) __pure2; int __isnormal(double) __pure2; int __isnormall(long double) __pure2; int __signbit(double) __pure2; 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); double atan2(double, double); double cos(double); double sin(double); double tan(double); double cosh(double); double sinh(double); double tanh(double); double exp(double); double frexp(double, int *); /* fundamentally !__pure2 */ double ldexp(double, int); double log(double); double log10(double); double modf(double, double *); /* fundamentally !__pure2 */ double pow(double, double); double sqrt(double); double ceil(double); double fabs(double) __pure2; double floor(double); double fmod(double, double); /* * These functions are not in C90. */ #if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE double acosh(double); double asinh(double); double atanh(double); double cbrt(double); double erf(double); double erfc(double); double exp2(double); double expm1(double); double fma(double, double, double); double hypot(double, double); int ilogb(double) __pure2; double lgamma(double); long long llrint(double); long long llround(double); double log1p(double); double log2(double); double logb(double); long lrint(double); long lround(double); double nan(const char *) __pure2; double nextafter(double, double); double remainder(double, double); double remquo(double, double, int *); double rint(double); #endif /* __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE */ #if __BSD_VISIBLE || __XSI_VISIBLE double j0(double); double j1(double); double jn(int, double); double y0(double); double y1(double); double yn(int, double); #if __XSI_VISIBLE <= 500 || __BSD_VISIBLE double gamma(double); #endif #if __XSI_VISIBLE <= 600 || __BSD_VISIBLE double scalb(double, double); #endif #endif /* __BSD_VISIBLE || __XSI_VISIBLE */ #if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 double copysign(double, double) __pure2; double fdim(double, double); double fmax(double, double) __pure2; double fmin(double, double) __pure2; double nearbyint(double); double round(double); double scalbln(double, long); double scalbn(double, int); double tgamma(double); double trunc(double); #endif /* * BSD math library entry points */ #if __BSD_VISIBLE double drem(double, double); int finite(double) __pure2; int isnanf(float) __pure2; /* * Reentrant version of gamma & lgamma; passes signgam back by reference * as the second argument; user must allocate space for signgam. */ double gamma_r(double, int *); double lgamma_r(double, int *); /* * IEEE Test Vector */ double significand(double); #endif /* __BSD_VISIBLE */ /* float versions of ANSI/POSIX functions */ #if __ISO_C_VISIBLE >= 1999 float acosf(float); float asinf(float); float atanf(float); float atan2f(float, float); float cosf(float); float sinf(float); float tanf(float); float coshf(float); float sinhf(float); float tanhf(float); float exp2f(float); float expf(float); float expm1f(float); float frexpf(float, int *); /* fundamentally !__pure2 */ int ilogbf(float) __pure2; float ldexpf(float, int); float log10f(float); float log1pf(float); float log2f(float); float logf(float); float modff(float, float *); /* fundamentally !__pure2 */ float powf(float, float); float sqrtf(float); float ceilf(float); float fabsf(float) __pure2; float floorf(float); float fmodf(float, float); float roundf(float); float erff(float); float erfcf(float); float hypotf(float, float); float lgammaf(float); float tgammaf(float); float acoshf(float); float asinhf(float); float atanhf(float); float cbrtf(float); float logbf(float); float copysignf(float, float) __pure2; long long llrintf(float); long long llroundf(float); long lrintf(float); long lroundf(float); float nanf(const char *) __pure2; float nearbyintf(float); float nextafterf(float, float); float remainderf(float, float); float remquof(float, float, int *); float rintf(float); float scalblnf(float, long); float scalbnf(float, int); float truncf(float); float fdimf(float, float); float fmaf(float, float, float); float fmaxf(float, float) __pure2; float fminf(float, float) __pure2; #endif /* * float versions of BSD math library entry points */ #if __BSD_VISIBLE float dremf(float, float); int finitef(float) __pure2; float gammaf(float); float j0f(float); float j1f(float); float jnf(int, float); float scalbf(float, float); float y0f(float); float y1f(float); float ynf(int, float); /* * Float versions of reentrant version of gamma & lgamma; passes * signgam back by reference as the second argument; user must * allocate space for signgam. */ float gammaf_r(float, int *); float lgammaf_r(float, int *); /* * float version of IEEE Test Vector */ float significandf(float); #endif /* __BSD_VISIBLE */ /* * 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); long double fmal(long double, long double, long double); 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, 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 */ long double nanl(const char *) __pure2; long double nearbyintl(long double); long double nextafterl(long double, long double); 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); 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 */ #if __BSD_VISIBLE long double lgammal_r(long double, int *); +void sincos(double, double *, double *); +void sincosf(float, float *, float *); +void sincosl(long double, long double *, long double *); #endif __END_DECLS #endif /* !_MATH_H_ */ Index: stable/11/lib/msun/src/math_private.h =================================================================== --- stable/11/lib/msun/src/math_private.h (revision 324005) +++ stable/11/lib/msun/src/math_private.h (revision 324006) @@ -1,776 +1,788 @@ /* * ==================================================== * 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. * ==================================================== */ /* * from: @(#)fdlibm.h 5.1 93/09/24 * $FreeBSD$ */ #ifndef _MATH_PRIVATE_H_ #define _MATH_PRIVATE_H_ #include #include /* * The original fdlibm code used statements like: * n0 = ((*(int*)&one)>>29)^1; * index of high word * * ix0 = *(n0+(int*)&x); * high word of x * * ix1 = *((1-n0)+(int*)&x); * low word of x * * to dig two 32 bit words out of the 64 bit IEEE floating point * value. That is non-ANSI, and, moreover, the gcc instruction * scheduler gets it wrong. We instead use the following macros. * Unlike the original code, we determine the endianness at compile * time, not at run time; I don't see much benefit to selecting * endianness at run time. */ /* * A union which permits us to convert between a double and two 32 bit * ints. */ #ifdef __arm__ #if defined(__VFP_FP__) || defined(__ARM_EABI__) #define IEEE_WORD_ORDER BYTE_ORDER #else #define IEEE_WORD_ORDER BIG_ENDIAN #endif #else /* __arm__ */ #define IEEE_WORD_ORDER BYTE_ORDER #endif #if IEEE_WORD_ORDER == BIG_ENDIAN typedef union { double value; struct { u_int32_t msw; u_int32_t lsw; } parts; struct { u_int64_t w; } xparts; } ieee_double_shape_type; #endif #if IEEE_WORD_ORDER == LITTLE_ENDIAN typedef union { double value; struct { u_int32_t lsw; u_int32_t msw; } parts; struct { u_int64_t w; } xparts; } ieee_double_shape_type; #endif /* Get two 32 bit ints from a double. */ #define EXTRACT_WORDS(ix0,ix1,d) \ do { \ ieee_double_shape_type ew_u; \ ew_u.value = (d); \ (ix0) = ew_u.parts.msw; \ (ix1) = ew_u.parts.lsw; \ } while (0) /* Get a 64-bit int from a double. */ #define EXTRACT_WORD64(ix,d) \ do { \ ieee_double_shape_type ew_u; \ ew_u.value = (d); \ (ix) = ew_u.xparts.w; \ } while (0) /* Get the more significant 32 bit int from a double. */ #define GET_HIGH_WORD(i,d) \ do { \ ieee_double_shape_type gh_u; \ gh_u.value = (d); \ (i) = gh_u.parts.msw; \ } while (0) /* Get the less significant 32 bit int from a double. */ #define GET_LOW_WORD(i,d) \ do { \ ieee_double_shape_type gl_u; \ gl_u.value = (d); \ (i) = gl_u.parts.lsw; \ } while (0) /* Set a double from two 32 bit ints. */ #define INSERT_WORDS(d,ix0,ix1) \ do { \ ieee_double_shape_type iw_u; \ iw_u.parts.msw = (ix0); \ iw_u.parts.lsw = (ix1); \ (d) = iw_u.value; \ } while (0) /* Set a double from a 64-bit int. */ #define INSERT_WORD64(d,ix) \ do { \ ieee_double_shape_type iw_u; \ iw_u.xparts.w = (ix); \ (d) = iw_u.value; \ } while (0) /* Set the more significant 32 bits of a double from an int. */ #define SET_HIGH_WORD(d,v) \ do { \ ieee_double_shape_type sh_u; \ sh_u.value = (d); \ sh_u.parts.msw = (v); \ (d) = sh_u.value; \ } while (0) /* Set the less significant 32 bits of a double from an int. */ #define SET_LOW_WORD(d,v) \ do { \ ieee_double_shape_type sl_u; \ sl_u.value = (d); \ sl_u.parts.lsw = (v); \ (d) = sl_u.value; \ } while (0) /* * A union which permits us to convert between a float and a 32 bit * int. */ typedef union { float value; /* FIXME: Assumes 32 bit int. */ unsigned int word; } ieee_float_shape_type; /* Get a 32 bit int from a float. */ #define GET_FLOAT_WORD(i,d) \ do { \ ieee_float_shape_type gf_u; \ gf_u.value = (d); \ (i) = gf_u.word; \ } while (0) /* Set a float from a 32 bit int. */ #define SET_FLOAT_WORD(d,i) \ do { \ ieee_float_shape_type sf_u; \ sf_u.word = (i); \ (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. */ #if FLT_EVAL_METHOD == 0 || __GNUC__ == 0 #define STRICT_ASSIGN(type, lval, rval) ((lval) = (rval)) #else #define STRICT_ASSIGN(type, lval, rval) do { \ volatile type __lval; \ \ if (sizeof(type) >= sizeof(long double)) \ (lval) = (rval); \ else { \ __lval = (rval); \ (lval) = __lval; \ } \ } 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) +#define ENTERV() \ + fp_prec_t __oprec; \ + \ + if ((__oprec = fpgetprec()) != FP_PE) \ + fpsetprec(FP_PE) +#define RETURNV() do { \ + if (__oprec != FP_PE) \ + fpsetprec(__oprec); \ + return; \ +} while (0) #else -#define ENTERI(x) +#define ENTERI() #define RETURNI(x) RETURNF(x) +#define ENTERV() +#define RETURNV() return #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); #ifdef _COMPLEX_H /* * C99 specifies that complex numbers have the same representation as * an array of two elements, where the first element is the real part * and the second element is the imaginary part. */ typedef union { float complex f; float a[2]; } float_complex; typedef union { double complex f; double a[2]; } double_complex; typedef union { long double complex f; long double a[2]; } long_double_complex; #define REALPART(z) ((z).a[0]) #define IMAGPART(z) ((z).a[1]) /* * Inline functions that can be used to construct complex values. * * The C99 standard intends x+I*y to be used for this, but x+I*y is * currently unusable in general since gcc introduces many overflow, * underflow, sign and efficiency bugs by rewriting I*y as * (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 CMPLXF(float x, float y) { float_complex z; REALPART(z) = x; IMAGPART(z) = y; return (z.f); } #endif #ifndef CMPLX static __inline double complex CMPLX(double x, double y) { double_complex z; REALPART(z) = x; IMAGPART(z) = y; return (z.f); } #endif #ifndef CMPLXL static __inline long double complex CMPLXL(long double x, long double y) { long_double_complex z; REALPART(z) = x; IMAGPART(z) = y; return (z.f); } #endif #endif /* _COMPLEX_H */ #ifdef __GNUCLIKE_ASM /* Asm versions of some functions. */ #ifdef __amd64__ static __inline int irint(double x) { int n; asm("cvtsd2si %1,%0" : "=r" (n) : "x" (x)); return (n); } #define HAVE_EFFICIENT_IRINT #endif #ifdef __i386__ static __inline int irint(double x) { int n; asm("fistl %0" : "=m" (n) : "t" (x)); return (n); } #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 #define breakpoint() raise(SIGTRAP) #endif #endif /* Write a pari script to test things externally. */ #ifdef DOPRINT #include #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 * * We rename functions here to improve other sources' diffability * against fdlibm. */ #define __ieee754_sqrt sqrt #define __ieee754_acos acos #define __ieee754_acosh acosh #define __ieee754_log log #define __ieee754_log2 log2 #define __ieee754_atanh atanh #define __ieee754_asin asin #define __ieee754_atan2 atan2 #define __ieee754_exp exp #define __ieee754_cosh cosh #define __ieee754_fmod fmod #define __ieee754_pow pow #define __ieee754_lgamma lgamma #define __ieee754_gamma gamma #define __ieee754_lgamma_r lgamma_r #define __ieee754_gamma_r gamma_r #define __ieee754_log10 log10 #define __ieee754_sinh sinh #define __ieee754_hypot hypot #define __ieee754_j0 j0 #define __ieee754_j1 j1 #define __ieee754_y0 y0 #define __ieee754_y1 y1 #define __ieee754_jn jn #define __ieee754_yn yn #define __ieee754_remainder remainder #define __ieee754_scalb scalb #define __ieee754_sqrtf sqrtf #define __ieee754_acosf acosf #define __ieee754_acoshf acoshf #define __ieee754_logf logf #define __ieee754_atanhf atanhf #define __ieee754_asinf asinf #define __ieee754_atan2f atan2f #define __ieee754_expf expf #define __ieee754_coshf coshf #define __ieee754_fmodf fmodf #define __ieee754_powf powf #define __ieee754_lgammaf lgammaf #define __ieee754_gammaf gammaf #define __ieee754_lgammaf_r lgammaf_r #define __ieee754_gammaf_r gammaf_r #define __ieee754_log10f log10f #define __ieee754_log2f log2f #define __ieee754_sinhf sinhf #define __ieee754_hypotf hypotf #define __ieee754_j0f j0f #define __ieee754_j1f j1f #define __ieee754_y0f y0f #define __ieee754_y1f y1f #define __ieee754_jnf jnf #define __ieee754_ynf ynf #define __ieee754_remainderf remainderf #define __ieee754_scalbf scalbf /* fdlibm kernel function */ int __kernel_rem_pio2(double*,double*,int,int,int); /* double precision kernel functions */ #ifndef INLINE_REM_PIO2 int __ieee754_rem_pio2(double,double*); #endif 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 int __ieee754_rem_pio2f(float,double*); #endif #ifndef INLINE_KERNEL_SINDF float __kernel_sindf(double); #endif #ifndef INLINE_KERNEL_COSDF float __kernel_cosdf(double); #endif #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); long double __kernel_cosl(long double, long double); long double __kernel_tanl(long double, long double, int); #endif /* !_MATH_PRIVATE_H_ */ Index: stable/11/lib/msun/src/s_fabs.c =================================================================== --- stable/11/lib/msun/src/s_fabs.c (revision 324005) +++ stable/11/lib/msun/src/s_fabs.c (revision 324006) @@ -1,31 +1,30 @@ /* @(#)s_fabs.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. * ==================================================== */ -#ifndef lint -static char rcsid[] = "$FreeBSD$"; -#endif +#include +__FBSDID("$FreeBSD$"); /* * fabs(x) returns the absolute value of x. */ #include "math.h" #include "math_private.h" double fabs(double x) { u_int32_t high; GET_HIGH_WORD(high,x); SET_HIGH_WORD(x,high&0x7fffffff); return x; } Index: stable/11/lib/msun/src/s_fmax.c =================================================================== --- stable/11/lib/msun/src/s_fmax.c (revision 324005) +++ stable/11/lib/msun/src/s_fmax.c (revision 324006) @@ -1,53 +1,58 @@ /*- * Copyright (c) 2004 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, 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 __FBSDID("$FreeBSD$"); +#include #include #include "fpmath.h" double fmax(double x, double y) { union IEEEd2bits u[2]; u[0].d = x; u[1].d = y; /* Check for NaNs to avoid raising spurious exceptions. */ if (u[0].bits.exp == 2047 && (u[0].bits.manh | u[0].bits.manl) != 0) return (y); if (u[1].bits.exp == 2047 && (u[1].bits.manh | u[1].bits.manl) != 0) return (x); /* Handle comparisons of signed zeroes. */ if (u[0].bits.sign != u[1].bits.sign) return (u[u[0].bits.sign].d); return (x > y ? x : y); } + +#if (LDBL_MANT_DIG == 53) +__weak_reference(fmax, fmaxl); +#endif Index: stable/11/lib/msun/src/s_fmin.c =================================================================== --- stable/11/lib/msun/src/s_fmin.c (revision 324005) +++ stable/11/lib/msun/src/s_fmin.c (revision 324006) @@ -1,53 +1,58 @@ /*- * Copyright (c) 2004 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, 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 __FBSDID("$FreeBSD$"); +#include #include #include "fpmath.h" double fmin(double x, double y) { union IEEEd2bits u[2]; u[0].d = x; u[1].d = y; /* Check for NaNs to avoid raising spurious exceptions. */ if (u[0].bits.exp == 2047 && (u[0].bits.manh | u[0].bits.manl) != 0) return (y); if (u[1].bits.exp == 2047 && (u[1].bits.manh | u[1].bits.manl) != 0) return (x); /* Handle comparisons of signed zeroes. */ if (u[0].bits.sign != u[1].bits.sign) return (u[u[1].bits.sign].d); return (x < y ? x : y); } + +#if (LDBL_MANT_DIG == 53) +__weak_reference(fmin, fminl); +#endif Index: stable/11/lib/msun/src/s_logbl.c =================================================================== --- stable/11/lib/msun/src/s_logbl.c (revision 324005) +++ stable/11/lib/msun/src/s_logbl.c (revision 324006) @@ -1,55 +1,54 @@ /* * From: @(#)s_ilogb.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. * ==================================================== */ -#ifndef lint -static char rcsid[] = "$FreeBSD$"; -#endif +#include +__FBSDID("$FreeBSD$"); #include #include #include #include "fpmath.h" long double logbl(long double x) { union IEEEl2bits u; unsigned long m; int b; u.e = x; if (u.bits.exp == 0) { if ((u.bits.manl | u.bits.manh) == 0) { /* x == 0 */ u.bits.sign = 1; return (1.0L / u.e); } /* denormalized */ if (u.bits.manh == 0) { m = 1lu << (LDBL_MANL_SIZE - 1); for (b = LDBL_MANH_SIZE; !(u.bits.manl & m); m >>= 1) b++; } else { m = 1lu << (LDBL_MANH_SIZE - 1); for (b = 0; !(u.bits.manh & m); m >>= 1) b++; } #ifdef LDBL_IMPLICIT_NBIT b++; #endif return ((long double)(LDBL_MIN_EXP - b - 1)); } if (u.bits.exp < (LDBL_MAX_EXP << 1) - 1) /* normal */ return ((long double)(u.bits.exp - LDBL_MAX_EXP + 1)); else /* +/- inf or nan */ return (x * x); } Index: stable/11/lib/msun/src/s_scalbn.c =================================================================== --- stable/11/lib/msun/src/s_scalbn.c (revision 324005) +++ stable/11/lib/msun/src/s_scalbn.c (revision 324006) @@ -1,66 +1,66 @@ /* @(#)s_scalbn.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. * ==================================================== */ -#ifndef lint -static char rcsid[] = "$FreeBSD$"; -#endif +#include +__FBSDID("$FreeBSD$"); /* * scalbn (double x, int n) * scalbn(x,n) returns x* 2**n computed by exponent * manipulation rather than by actually performing an * exponentiation or a multiplication. */ -#include #include #include "math.h" #include "math_private.h" static const double two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */ twom54 = 5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */ huge = 1.0e+300, tiny = 1.0e-300; double scalbn (double x, int n) { int32_t k,hx,lx; EXTRACT_WORDS(hx,lx,x); k = (hx&0x7ff00000)>>20; /* extract exponent */ if (k==0) { /* 0 or subnormal x */ if ((lx|(hx&0x7fffffff))==0) return x; /* +-0 */ x *= two54; GET_HIGH_WORD(hx,x); k = ((hx&0x7ff00000)>>20) - 54; if (n< -50000) return tiny*x; /*underflow*/ } if (k==0x7ff) return x+x; /* NaN or Inf */ k = k+n; if (k > 0x7fe) return huge*copysign(huge,x); /* overflow */ if (k > 0) /* normal result */ {SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); return x;} - if (k <= -54) + if (k <= -54) { if (n > 50000) /* in case integer overflow in n+k */ return huge*copysign(huge,x); /*overflow*/ - else return tiny*copysign(tiny,x); /*underflow*/ + else + return tiny*copysign(tiny,x); /*underflow*/ + } k += 54; /* subnormal result */ SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); return x*twom54; } #if (LDBL_MANT_DIG == 53) __weak_reference(scalbn, ldexpl); __weak_reference(scalbn, scalbnl); #endif Index: stable/11/lib/msun/src/s_scalbnf.c =================================================================== --- stable/11/lib/msun/src/s_scalbnf.c (revision 324005) +++ stable/11/lib/msun/src/s_scalbnf.c (revision 324006) @@ -1,58 +1,57 @@ /* s_scalbnf.c -- float version of s_scalbn.c. * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. * * Developed at SunPro, a Sun Microsystems, Inc. business. * Permission to use, copy, modify, and distribute this * software is freely granted, provided that this notice * is preserved. * ==================================================== */ -#ifndef lint -static char rcsid[] = "$FreeBSD$"; -#endif - #include +__FBSDID("$FreeBSD$"); #include "math.h" #include "math_private.h" static const float two25 = 3.355443200e+07, /* 0x4c000000 */ twom25 = 2.9802322388e-08, /* 0x33000000 */ huge = 1.0e+30, tiny = 1.0e-30; float scalbnf (float x, int n) { int32_t k,ix; GET_FLOAT_WORD(ix,x); k = (ix&0x7f800000)>>23; /* extract exponent */ if (k==0) { /* 0 or subnormal x */ if ((ix&0x7fffffff)==0) return x; /* +-0 */ x *= two25; GET_FLOAT_WORD(ix,x); k = ((ix&0x7f800000)>>23) - 25; if (n< -50000) return tiny*x; /*underflow*/ } if (k==0xff) return x+x; /* NaN or Inf */ k = k+n; if (k > 0xfe) return huge*copysignf(huge,x); /* overflow */ if (k > 0) /* normal result */ {SET_FLOAT_WORD(x,(ix&0x807fffff)|(k<<23)); return x;} - if (k <= -25) + if (k <= -25) { if (n > 50000) /* in case integer overflow in n+k */ return huge*copysignf(huge,x); /*overflow*/ - else return tiny*copysignf(tiny,x); /*underflow*/ + else + return tiny*copysignf(tiny,x); /*underflow*/ + } k += 25; /* subnormal result */ SET_FLOAT_WORD(x,(ix&0x807fffff)|(k<<23)); return x*twom25; } __strong_reference(scalbnf, ldexpf); Index: stable/11/lib/msun/src/s_scalbnl.c =================================================================== --- stable/11/lib/msun/src/s_scalbnl.c (revision 324005) +++ stable/11/lib/msun/src/s_scalbnl.c (revision 324006) @@ -1,71 +1,71 @@ /* @(#)s_scalbn.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. * ==================================================== */ -#ifndef lint -static char rcsid[] = "$FreeBSD$"; -#endif +#include +__FBSDID("$FreeBSD$"); /* * scalbnl (long double x, int n) * scalbnl(x,n) returns x* 2**n computed by exponent * manipulation rather than by actually performing an * exponentiation or a multiplication. */ /* * We assume that a long double has a 15-bit exponent. On systems * where long double is the same as double, scalbnl() is an alias * for scalbn(), so we don't use this routine. */ -#include #include #include #include "fpmath.h" #if LDBL_MAX_EXP != 0x4000 #error "Unsupported long double format" #endif static const long double huge = 0x1p16000L, tiny = 0x1p-16000L; long double scalbnl (long double x, int n) { union IEEEl2bits u; int k; u.e = x; k = u.bits.exp; /* extract exponent */ if (k==0) { /* 0 or subnormal x */ if ((u.bits.manh|u.bits.manl)==0) return x; /* +-0 */ u.e *= 0x1p+128; k = u.bits.exp - 128; if (n< -50000) return tiny*x; /*underflow*/ } if (k==0x7fff) return x+x; /* NaN or Inf */ k = k+n; if (k >= 0x7fff) return huge*copysignl(huge,x); /* overflow */ if (k > 0) /* normal result */ {u.bits.exp = k; return u.e;} - if (k <= -128) + if (k <= -128) { if (n > 50000) /* in case integer overflow in n+k */ return huge*copysign(huge,x); /*overflow*/ - else return tiny*copysign(tiny,x); /*underflow*/ + else + return tiny*copysign(tiny,x); /*underflow*/ + } k += 128; /* subnormal result */ u.bits.exp = k; return u.e*0x1p-128; } __strong_reference(scalbnl, ldexpl); Index: stable/11/lib/msun/src/s_sincos.c =================================================================== --- stable/11/lib/msun/src/s_sincos.c (nonexistent) +++ stable/11/lib/msun/src/s_sincos.c (revision 324006) @@ -0,0 +1,80 @@ +/*- + * ==================================================== + * 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. + * ==================================================== + * + * s_sin.c and s_cos.c merged by Steven G. Kargl. Descriptions of the + * algorithms are contained in the original files. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include "math.h" +#define INLINE_REM_PIO2 +#include "math_private.h" +#include "e_rem_pio2.c" +#include "k_sincos.h" + +void +sincos(double x, double *sn, double *cs) +{ + double y[2]; + int32_t n, ix; + + /* High word of x. */ + GET_HIGH_WORD(ix, x); + + /* |x| ~< pi/4 */ + ix &= 0x7fffffff; + if (ix <= 0x3fe921fb) { + if (ix < 0x3e400000) { /* |x| < 2**-27 */ + if ((int)x == 0) { /* Generate inexact. */ + *sn = x; + *cs = 1; + return; + } + } + __kernel_sincos(x, 0, 0, sn, cs); + return; + } + + /* If x = Inf or NaN, then sin(x) = NaN and cos(x) = NaN. */ + if (ix >= 0x7ff00000) { + *sn = x - x; + *cs = x - x; + return; + } + + /* Argument reduction. */ + n = __ieee754_rem_pio2(x, y); + + switch(n & 3) { + case 0: + __kernel_sincos(y[0], y[1], 1, sn, cs); + break; + case 1: + __kernel_sincos(y[0], y[1], 1, cs, sn); + *cs = -*cs; + break; + case 2: + __kernel_sincos(y[0], y[1], 1, sn, cs); + *sn = -*sn; + *cs = -*cs; + break; + default: + __kernel_sincos(y[0], y[1], 1, cs, sn); + *sn = -*sn; + } +} + +#if (LDBL_MANT_DIG == 53) +__weak_reference(sincos, sincosl); +#endif Property changes on: stable/11/lib/msun/src/s_sincos.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/lib/msun/src/s_sincosf.c =================================================================== --- stable/11/lib/msun/src/s_sincosf.c (nonexistent) +++ stable/11/lib/msun/src/s_sincosf.c (revision 324006) @@ -0,0 +1,126 @@ +/*- + * ==================================================== + * 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. + * ==================================================== + */ + +/* s_sincosf.c -- float version of s_sincos.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + * Optimized by Bruce D. Evans. + * Merged s_sinf.c and s_cosf.c by Steven G. Kargl. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include "math.h" +#define INLINE_REM_PIO2F +#include "math_private.h" +#include "e_rem_pio2f.c" +#include "k_sincosf.h" + +/* Small multiples of pi/2 rounded to double precision. */ +static const double +p1pio2 = 1*M_PI_2, /* 0x3FF921FB, 0x54442D18 */ +p2pio2 = 2*M_PI_2, /* 0x400921FB, 0x54442D18 */ +p3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */ +p4pio2 = 4*M_PI_2; /* 0x401921FB, 0x54442D18 */ + +void +sincosf(float x, float *sn, float *cs) +{ + float c, s; + double y; + int32_t n, hx, ix; + + GET_FLOAT_WORD(hx, x); + ix = hx & 0x7fffffff; + + if (ix <= 0x3f490fda) { /* |x| ~<= pi/4 */ + if (ix < 0x39800000) { /* |x| < 2**-12 */ + if ((int)x == 0) { + *sn = x; /* x with inexact if x != 0 */ + *cs = 1; + return; + } + } + __kernel_sincosdf(x, sn, cs); + return; + } + + if (ix <= 0x407b53d1) { /* |x| ~<= 5*pi/4 */ + if (ix <= 0x4016cbe3) { /* |x| ~<= 3pi/4 */ + if (hx > 0) { + __kernel_sincosdf(x - p1pio2, cs, sn); + *cs = -*cs; + } else { + __kernel_sincosdf(x + p1pio2, cs, sn); + *sn = -*sn; + } + } else { + if (hx > 0) + __kernel_sincosdf(x - p2pio2, sn, cs); + else + __kernel_sincosdf(x + p2pio2, sn, cs); + *sn = -*sn; + *cs = -*cs; + } + return; + } + + if (ix <= 0x40e231d5) { /* |x| ~<= 9*pi/4 */ + if (ix <= 0x40afeddf) { /* |x| ~<= 7*pi/4 */ + if (hx > 0) { + __kernel_sincosdf(x - p3pio2, cs, sn); + *sn = -*sn; + } else { + __kernel_sincosdf(x + p3pio2, cs, sn); + *cs = -*cs; + } + } else { + if (hx > 0) + __kernel_sincosdf(x - p4pio2, sn, cs); + else + __kernel_sincosdf(x + p4pio2, sn, cs); + } + return; + } + + /* If x = Inf or NaN, then sin(x) = NaN and cos(x) = NaN. */ + if (ix >= 0x7f800000) { + *sn = x - x; + *cs = x - x; + return; + } + + /* Argument reduction. */ + n = __ieee754_rem_pio2f(x, &y); + __kernel_sincosdf(y, &s, &c); + + switch(n & 3) { + case 0: + *sn = s; + *cs = c; + break; + case 1: + *sn = c; + *cs = -s; + break; + case 2: + *sn = -s; + *cs = -c; + break; + default: + *sn = -c; + *cs = s; + } +} + + Property changes on: stable/11/lib/msun/src/s_sincosf.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/lib/msun/src/s_sincosl.c =================================================================== --- stable/11/lib/msun/src/s_sincosl.c (nonexistent) +++ stable/11/lib/msun/src/s_sincosl.c (revision 324006) @@ -0,0 +1,105 @@ +/*- + * Copyright (c) 2007, 2010-2013 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. + * + * s_sinl.c and s_cosl.c merged by Steven G. Kargl. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#ifdef __i386__ +#include +#endif + +#include "math.h" +#include "math_private.h" +#include "k_sincosl.h" + +#if LDBL_MANT_DIG == 64 +#include "../ld80/e_rem_pio2l.h" +#elif LDBL_MANT_DIG == 113 +#include "../ld128/e_rem_pio2l.h" +#else +#error "Unsupported long double format" +#endif + +void +sincosl(long double x, long double *sn, long double *cs) +{ + union IEEEl2bits z; + int e0, sgn; + long double y[2]; + + z.e = x; + sgn = z.bits.sign; + z.bits.sign = 0; + + ENTERV(); + + /* Optimize the case where x is already within range. */ + if (z.e < M_PI_4) { + /* + * If x = +-0 or x is a subnormal number, then sin(x) = x and + * cos(x) = 1. + */ + if (z.bits.exp == 0) { + *sn = x; + *cs = 1; + } else + __kernel_sincosl(x, 0, 0, sn, cs); + RETURNV(); + } + + /* If x = NaN or Inf, then sin(x) and cos(x) are NaN. */ + if (z.bits.exp == 32767) { + *sn = x - x; + *cs = x - x; + RETURNV(); + } + + /* Range reduction. */ + e0 = __ieee754_rem_pio2l(x, y); + + switch (e0 & 3) { + case 0: + __kernel_sincosl(y[0], y[1], 1, sn, cs); + break; + case 1: + __kernel_sincosl(y[0], y[1], 1, cs, sn); + *cs = -*cs; + break; + case 2: + __kernel_sincosl(y[0], y[1], 1, sn, cs); + *sn = -*sn; + *cs = -*cs; + break; + default: + __kernel_sincosl(y[0], y[1], 1, cs, sn); + *sn = -*sn; + } + + RETURNV(); +} Property changes on: stable/11/lib/msun/src/s_sincosl.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/lib/msun/src/s_tanhl.c =================================================================== --- stable/11/lib/msun/src/s_tanhl.c (revision 324005) +++ stable/11/lib/msun/src/s_tanhl.c (revision 324006) @@ -1,172 +1,174 @@ /* 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 __FBSDID("$FreeBSD$"); /* * See s_tanh.c for complete comments. * * Converted to long double by Bruce D. Evans. */ #include #ifdef __i386__ #include #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; +#if LDBL_MANT_DIG == 113 double dx2; +#endif 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= 40, return +-1 */ } else { z = one - tiny; /* raise inexact flag */ } s = 1; if (jx<0) s = -1; RETURNI(s*z); } Index: stable/11/lib/msun/tests/ctrig_test.c =================================================================== --- stable/11/lib/msun/tests/ctrig_test.c (revision 324005) +++ stable/11/lib/msun/tests/ctrig_test.c (revision 324006) @@ -1,498 +1,494 @@ /*- * Copyright (c) 2008-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, 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. */ /* * Tests for csin[h](), ccos[h](), and ctan[h](). */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include #include #include "test-utils.h" #pragma STDC FENV_ACCESS ON #pragma STDC CX_LIMITED_RANGE OFF /* * Test that a function returns the correct value and sets the * exception flags correctly. The exceptmask specifies which * exceptions we should check. We need to be lenient for several * reasons, but mainly because on some architectures it's impossible * to raise FE_OVERFLOW without raising FE_INEXACT. * * These are macros instead of functions so that assert provides more * meaningful error messages. * * XXX The volatile here is to avoid gcc's bogus constant folding and work * around the lack of support for the FENV_ACCESS pragma. */ #define test_p(func, z, result, exceptmask, excepts, checksign) do { \ volatile long double complex _d = z; \ debug(" testing %s(%Lg + %Lg I) == %Lg + %Lg I\n", #func, \ creall(_d), cimagl(_d), creall(result), cimagl(result)); \ ATF_CHECK(feclearexcept(FE_ALL_EXCEPT) == 0); \ ATF_CHECK(cfpequal_cs((func)(_d), (result), (checksign))); \ ATF_CHECK(((void)(func), fetestexcept(exceptmask) == (excepts))); \ } while (0) /* * Test within a given tolerance. The tolerance indicates relative error * in ulps. If result is 0, however, it measures absolute error in units * of _EPSILON. */ #define test_p_tol(func, z, result, tol) do { \ volatile long double complex _d = z; \ debug(" testing %s(%Lg + %Lg I) ~= %Lg + %Lg I\n", #func, \ creall(_d), cimagl(_d), creall(result), cimagl(result)); \ ATF_CHECK(cfpequal_tol((func)(_d), (result), (tol), FPE_ABS_ZERO)); \ } while (0) /* These wrappers apply the identities f(conj(z)) = conj(f(z)). */ #define test(func, z, result, exceptmask, excepts, checksign) do { \ test_p(func, z, result, exceptmask, excepts, checksign); \ test_p(func, conjl(z), conjl(result), exceptmask, excepts, checksign); \ } while (0) #define test_tol(func, z, result, tol) do { \ test_p_tol(func, z, result, tol); \ test_p_tol(func, conjl(z), conjl(result), tol); \ } while (0) #define test_odd_tol(func, z, result, tol) do { \ test_tol(func, z, result, tol); \ test_tol(func, -(z), -(result), tol); \ } while (0) #define test_even_tol(func, z, result, tol) do { \ test_tol(func, z, result, tol); \ test_tol(func, -(z), result, tol); \ } while (0) /* Test the given function in all precisions. */ #define testall(func, x, result, exceptmask, excepts, checksign) do { \ test(func, x, result, exceptmask, excepts, checksign); \ test(func##f, x, result, exceptmask, excepts, checksign); \ } while (0) #define testall_odd(func, x, result, exceptmask, excepts, checksign) do { \ testall(func, x, result, exceptmask, excepts, checksign); \ testall(func, -x, -result, exceptmask, excepts, checksign); \ } while (0) #define testall_even(func, x, result, exceptmask, excepts, checksign) do { \ testall(func, x, result, exceptmask, excepts, checksign); \ testall(func, -x, result, exceptmask, excepts, checksign); \ } while (0) /* * Test the given function in all precisions, within a given tolerance. * The tolerance is specified in ulps. */ #define testall_tol(func, x, result, tol) do { \ test_tol(func, x, result, tol * DBL_ULP()); \ test_tol(func##f, x, result, tol * FLT_ULP()); \ } while (0) #define testall_odd_tol(func, x, result, tol) do { \ test_odd_tol(func, x, result, tol * DBL_ULP()); \ test_odd_tol(func##f, x, result, tol * FLT_ULP()); \ } while (0) #define testall_even_tol(func, x, result, tol) do { \ test_even_tol(func, x, result, tol * DBL_ULP()); \ test_even_tol(func##f, x, result, tol * FLT_ULP()); \ } while (0) ATF_TC(test_zero_input); ATF_TC_HEAD(test_zero_input, tc) { atf_tc_set_md_var(tc, "descr", "test 0 input"); } ATF_TC_BODY(test_zero_input, tc) { long double complex zero = CMPLXL(0.0, 0.0); #if defined(__amd64__) #if defined(__clang__) && \ ((__clang_major__ >= 4)) atf_tc_expect_fail("test fails with clang 4.x+ - bug 217528"); #endif #endif /* csinh(0) = ctanh(0) = 0; ccosh(0) = 1 (no exceptions raised) */ testall_odd(csinh, zero, zero, ALL_STD_EXCEPT, 0, CS_BOTH); testall_odd(csin, zero, zero, ALL_STD_EXCEPT, 0, CS_BOTH); testall_even(ccosh, zero, 1.0, ALL_STD_EXCEPT, 0, CS_BOTH); testall_even(ccos, zero, CMPLXL(1.0, -0.0), ALL_STD_EXCEPT, 0, CS_BOTH); testall_odd(ctanh, zero, zero, ALL_STD_EXCEPT, 0, CS_BOTH); testall_odd(ctan, zero, zero, ALL_STD_EXCEPT, 0, CS_BOTH); } ATF_TC(test_nan_inputs); ATF_TC_HEAD(test_nan_inputs, tc) { atf_tc_set_md_var(tc, "descr", "test NaN inputs"); } ATF_TC_BODY(test_nan_inputs, tc) { long double complex nan_nan = CMPLXL(NAN, NAN); long double complex z; /* * IN CSINH CCOSH CTANH * NaN,NaN NaN,NaN NaN,NaN NaN,NaN * finite,NaN NaN,NaN [inval] NaN,NaN [inval] NaN,NaN [inval] * NaN,finite NaN,NaN [inval] NaN,NaN [inval] NaN,NaN [inval] * NaN,Inf NaN,NaN [inval] NaN,NaN [inval] NaN,NaN [inval] * Inf,NaN +-Inf,NaN Inf,NaN 1,+-0 * 0,NaN +-0,NaN NaN,+-0 NaN,NaN [inval] * NaN,0 NaN,0 NaN,+-0 NaN,0 */ z = nan_nan; testall_odd(csinh, z, nan_nan, ALL_STD_EXCEPT, 0, 0); testall_even(ccosh, z, nan_nan, ALL_STD_EXCEPT, 0, 0); testall_odd(ctanh, z, nan_nan, ALL_STD_EXCEPT, 0, 0); testall_odd(csin, z, nan_nan, ALL_STD_EXCEPT, 0, 0); testall_even(ccos, z, nan_nan, ALL_STD_EXCEPT, 0, 0); testall_odd(ctan, z, nan_nan, ALL_STD_EXCEPT, 0, 0); z = CMPLXL(42, NAN); testall_odd(csinh, z, nan_nan, OPT_INVALID, 0, 0); testall_even(ccosh, z, nan_nan, OPT_INVALID, 0, 0); /* XXX We allow a spurious inexact exception here. */ testall_odd(ctanh, z, nan_nan, OPT_INVALID & ~FE_INEXACT, 0, 0); testall_odd(csin, z, nan_nan, OPT_INVALID, 0, 0); testall_even(ccos, z, nan_nan, OPT_INVALID, 0, 0); testall_odd(ctan, z, nan_nan, OPT_INVALID, 0, 0); z = CMPLXL(NAN, 42); testall_odd(csinh, z, nan_nan, OPT_INVALID, 0, 0); testall_even(ccosh, z, nan_nan, OPT_INVALID, 0, 0); testall_odd(ctanh, z, nan_nan, OPT_INVALID, 0, 0); testall_odd(csin, z, nan_nan, OPT_INVALID, 0, 0); testall_even(ccos, z, nan_nan, OPT_INVALID, 0, 0); /* XXX We allow a spurious inexact exception here. */ testall_odd(ctan, z, nan_nan, OPT_INVALID & ~FE_INEXACT, 0, 0); z = CMPLXL(NAN, INFINITY); testall_odd(csinh, z, nan_nan, OPT_INVALID, 0, 0); testall_even(ccosh, z, nan_nan, OPT_INVALID, 0, 0); testall_odd(ctanh, z, nan_nan, OPT_INVALID, 0, 0); testall_odd(csin, z, CMPLXL(NAN, INFINITY), ALL_STD_EXCEPT, 0, 0); testall_even(ccos, z, CMPLXL(INFINITY, NAN), ALL_STD_EXCEPT, 0, CS_IMAG); testall_odd(ctan, z, CMPLXL(0, 1), ALL_STD_EXCEPT, 0, CS_IMAG); z = CMPLXL(INFINITY, NAN); testall_odd(csinh, z, CMPLXL(INFINITY, NAN), ALL_STD_EXCEPT, 0, 0); testall_even(ccosh, z, CMPLXL(INFINITY, NAN), ALL_STD_EXCEPT, 0, CS_REAL); testall_odd(ctanh, z, CMPLXL(1, 0), ALL_STD_EXCEPT, 0, CS_REAL); testall_odd(csin, z, nan_nan, OPT_INVALID, 0, 0); testall_even(ccos, z, nan_nan, OPT_INVALID, 0, 0); testall_odd(ctan, z, nan_nan, OPT_INVALID, 0, 0); z = CMPLXL(0, NAN); testall_odd(csinh, z, CMPLXL(0, NAN), ALL_STD_EXCEPT, 0, 0); testall_even(ccosh, z, CMPLXL(NAN, 0), ALL_STD_EXCEPT, 0, 0); testall_odd(ctanh, z, nan_nan, OPT_INVALID, 0, 0); testall_odd(csin, z, CMPLXL(0, NAN), ALL_STD_EXCEPT, 0, CS_REAL); testall_even(ccos, z, CMPLXL(NAN, 0), ALL_STD_EXCEPT, 0, 0); testall_odd(ctan, z, CMPLXL(0, NAN), ALL_STD_EXCEPT, 0, CS_REAL); z = CMPLXL(NAN, 0); testall_odd(csinh, z, CMPLXL(NAN, 0), ALL_STD_EXCEPT, 0, CS_IMAG); testall_even(ccosh, z, CMPLXL(NAN, 0), ALL_STD_EXCEPT, 0, 0); testall_odd(ctanh, z, CMPLXL(NAN, 0), ALL_STD_EXCEPT, 0, CS_IMAG); testall_odd(csin, z, CMPLXL(NAN, 0), ALL_STD_EXCEPT, 0, 0); testall_even(ccos, z, CMPLXL(NAN, 0), ALL_STD_EXCEPT, 0, 0); testall_odd(ctan, z, nan_nan, OPT_INVALID, 0, 0); } ATF_TC(test_inf_inputs); ATF_TC_HEAD(test_inf_inputs, tc) { atf_tc_set_md_var(tc, "descr", "test infinity inputs"); } ATF_TC_BODY(test_inf_inputs, tc) { static const long double finites[] = { 0, M_PI / 4, 3 * M_PI / 4, 5 * M_PI / 4, }; long double complex z, c, s; unsigned i; /* * IN CSINH CCOSH CTANH * Inf,Inf +-Inf,NaN inval +-Inf,NaN inval 1,+-0 * Inf,finite Inf cis(finite) Inf cis(finite) 1,0 sin(2 finite) * 0,Inf +-0,NaN inval NaN,+-0 inval NaN,NaN inval * finite,Inf NaN,NaN inval NaN,NaN inval NaN,NaN inval */ z = CMPLXL(INFINITY, INFINITY); testall_odd(csinh, z, CMPLXL(INFINITY, NAN), ALL_STD_EXCEPT, FE_INVALID, 0); testall_even(ccosh, z, CMPLXL(INFINITY, NAN), ALL_STD_EXCEPT, FE_INVALID, 0); testall_odd(ctanh, z, CMPLXL(1, 0), ALL_STD_EXCEPT, 0, CS_REAL); testall_odd(csin, z, CMPLXL(NAN, INFINITY), ALL_STD_EXCEPT, FE_INVALID, 0); testall_even(ccos, z, CMPLXL(INFINITY, NAN), ALL_STD_EXCEPT, FE_INVALID, 0); testall_odd(ctan, z, CMPLXL(0, 1), ALL_STD_EXCEPT, 0, CS_REAL); /* XXX We allow spurious inexact exceptions here (hard to avoid). */ for (i = 0; i < nitems(finites); i++) { z = CMPLXL(INFINITY, finites[i]); c = INFINITY * cosl(finites[i]); s = finites[i] == 0 ? finites[i] : INFINITY * sinl(finites[i]); testall_odd(csinh, z, CMPLXL(c, s), OPT_INEXACT, 0, CS_BOTH); testall_even(ccosh, z, CMPLXL(c, s), OPT_INEXACT, 0, CS_BOTH); testall_odd(ctanh, z, CMPLXL(1, 0 * sin(finites[i] * 2)), OPT_INEXACT, 0, CS_BOTH); z = CMPLXL(finites[i], INFINITY); testall_odd(csin, z, CMPLXL(s, c), OPT_INEXACT, 0, CS_BOTH); testall_even(ccos, z, CMPLXL(c, -s), OPT_INEXACT, 0, CS_BOTH); testall_odd(ctan, z, CMPLXL(0 * sin(finites[i] * 2), 1), OPT_INEXACT, 0, CS_BOTH); } z = CMPLXL(0, INFINITY); testall_odd(csinh, z, CMPLXL(0, NAN), ALL_STD_EXCEPT, FE_INVALID, 0); testall_even(ccosh, z, CMPLXL(NAN, 0), ALL_STD_EXCEPT, FE_INVALID, 0); testall_odd(ctanh, z, CMPLXL(NAN, NAN), ALL_STD_EXCEPT, FE_INVALID, 0); z = CMPLXL(INFINITY, 0); testall_odd(csin, z, CMPLXL(NAN, 0), ALL_STD_EXCEPT, FE_INVALID, 0); testall_even(ccos, z, CMPLXL(NAN, 0), ALL_STD_EXCEPT, FE_INVALID, 0); testall_odd(ctan, z, CMPLXL(NAN, NAN), ALL_STD_EXCEPT, FE_INVALID, 0); z = CMPLXL(42, INFINITY); testall_odd(csinh, z, CMPLXL(NAN, NAN), ALL_STD_EXCEPT, FE_INVALID, 0); testall_even(ccosh, z, CMPLXL(NAN, NAN), ALL_STD_EXCEPT, FE_INVALID, 0); /* XXX We allow a spurious inexact exception here. */ testall_odd(ctanh, z, CMPLXL(NAN, NAN), OPT_INEXACT, FE_INVALID, 0); z = CMPLXL(INFINITY, 42); testall_odd(csin, z, CMPLXL(NAN, NAN), ALL_STD_EXCEPT, FE_INVALID, 0); testall_even(ccos, z, CMPLXL(NAN, NAN), ALL_STD_EXCEPT, FE_INVALID, 0); /* XXX We allow a spurious inexact exception here. */ testall_odd(ctan, z, CMPLXL(NAN, NAN), OPT_INEXACT, FE_INVALID, 0); } ATF_TC(test_axes); ATF_TC_HEAD(test_axes, tc) { atf_tc_set_md_var(tc, "descr", "test along the real/imaginary axes"); } ATF_TC_BODY(test_axes, tc) { static const long double nums[] = { M_PI / 4, M_PI / 2, 3 * M_PI / 4, 5 * M_PI / 4, 3 * M_PI / 2, 7 * M_PI / 4, }; long double complex z; unsigned i; for (i = 0; i < nitems(nums); i++) { /* Real axis */ z = CMPLXL(nums[i], 0.0); test_odd_tol(csinh, z, CMPLXL(sinh(nums[i]), 0), DBL_ULP()); test_even_tol(ccosh, z, CMPLXL(cosh(nums[i]), 0), DBL_ULP()); test_odd_tol(ctanh, z, CMPLXL(tanh(nums[i]), 0), DBL_ULP()); test_odd_tol(csin, z, CMPLXL(sin(nums[i]), copysign(0, cos(nums[i]))), DBL_ULP()); test_even_tol(ccos, z, CMPLXL(cos(nums[i]), -copysign(0, sin(nums[i]))), DBL_ULP()); test_odd_tol(ctan, z, CMPLXL(tan(nums[i]), 0), DBL_ULP()); test_odd_tol(csinhf, z, CMPLXL(sinhf(nums[i]), 0), FLT_ULP()); test_even_tol(ccoshf, z, CMPLXL(coshf(nums[i]), 0), FLT_ULP()); printf("%a %a\n", creal(z), cimag(z)); printf("%a %a\n", creal(ctanhf(z)), cimag(ctanhf(z))); printf("%a\n", nextafterf(tanhf(nums[i]), INFINITY)); test_odd_tol(ctanhf, z, CMPLXL(tanhf(nums[i]), 0), 1.3 * FLT_ULP()); test_odd_tol(csinf, z, CMPLXL(sinf(nums[i]), copysign(0, cosf(nums[i]))), FLT_ULP()); test_even_tol(ccosf, z, CMPLXL(cosf(nums[i]), -copysign(0, sinf(nums[i]))), 2 * FLT_ULP()); test_odd_tol(ctanf, z, CMPLXL(tanf(nums[i]), 0), FLT_ULP()); /* Imaginary axis */ z = CMPLXL(0.0, nums[i]); test_odd_tol(csinh, z, CMPLXL(copysign(0, cos(nums[i])), sin(nums[i])), DBL_ULP()); test_even_tol(ccosh, z, CMPLXL(cos(nums[i]), copysign(0, sin(nums[i]))), DBL_ULP()); test_odd_tol(ctanh, z, CMPLXL(0, tan(nums[i])), DBL_ULP()); test_odd_tol(csin, z, CMPLXL(0, sinh(nums[i])), DBL_ULP()); test_even_tol(ccos, z, CMPLXL(cosh(nums[i]), -0.0), DBL_ULP()); test_odd_tol(ctan, z, CMPLXL(0, tanh(nums[i])), DBL_ULP()); test_odd_tol(csinhf, z, CMPLXL(copysign(0, cosf(nums[i])), sinf(nums[i])), FLT_ULP()); test_even_tol(ccoshf, z, CMPLXL(cosf(nums[i]), copysign(0, sinf(nums[i]))), FLT_ULP()); test_odd_tol(ctanhf, z, CMPLXL(0, tanf(nums[i])), FLT_ULP()); test_odd_tol(csinf, z, CMPLXL(0, sinhf(nums[i])), FLT_ULP()); test_even_tol(ccosf, z, CMPLXL(coshf(nums[i]), -0.0), FLT_ULP()); test_odd_tol(ctanf, z, CMPLXL(0, tanhf(nums[i])), 1.3 * FLT_ULP()); } } ATF_TC(test_small_inputs); ATF_TC_HEAD(test_small_inputs, tc) { atf_tc_set_md_var(tc, "descr", "test underflow inputs"); } ATF_TC_BODY(test_small_inputs, tc) { /* * z = 0.5 + i Pi/4 * sinh(z) = (sinh(0.5) + i cosh(0.5)) * sqrt(2)/2 * cosh(z) = (cosh(0.5) + i sinh(0.5)) * sqrt(2)/2 * tanh(z) = (2cosh(0.5)sinh(0.5) + i) / (2 cosh(0.5)**2 - 1) * z = -0.5 + i Pi/2 * sinh(z) = cosh(0.5) * cosh(z) = -i sinh(0.5) * tanh(z) = -coth(0.5) * z = 1.0 + i 3Pi/4 * sinh(z) = (-sinh(1) + i cosh(1)) * sqrt(2)/2 * cosh(z) = (-cosh(1) + i sinh(1)) * sqrt(2)/2 * tanh(z) = (2cosh(1)sinh(1) - i) / (2cosh(1)**2 - 1) */ static const struct { long double a, b; long double sinh_a, sinh_b; long double cosh_a, cosh_b; long double tanh_a, tanh_b; } tests[] = { { 0.5L, 0.78539816339744830961566084581987572L, 0.36847002415910435172083660522240710L, 0.79735196663945774996093142586179334L, 0.79735196663945774996093142586179334L, 0.36847002415910435172083660522240710L, 0.76159415595576488811945828260479359L, 0.64805427366388539957497735322615032L }, { -0.5L, 1.57079632679489661923132169163975144L, 0.0L, 1.12762596520638078522622516140267201L, 0.0L, -0.52109530549374736162242562641149156L, -2.16395341373865284877000401021802312L, 0.0L }, { 1.0L, 2.35619449019234492884698253745962716L, -0.83099273328405698212637979852748608L, 1.09112278079550143030545602018565236L, -1.09112278079550143030545602018565236L, 0.83099273328405698212637979852748609L, 0.96402758007581688394641372410092315L, -0.26580222883407969212086273981988897L } }; long double complex z; unsigned i; for (i = 0; i < nitems(tests); i++) { z = CMPLXL(tests[i].a, tests[i].b); testall_odd_tol(csinh, z, CMPLXL(tests[i].sinh_a, tests[i].sinh_b), 1.1); testall_even_tol(ccosh, z, CMPLXL(tests[i].cosh_a, tests[i].cosh_b), 1.1); testall_odd_tol(ctanh, z, CMPLXL(tests[i].tanh_a, tests[i].tanh_b), 1.4); } } ATF_TC(test_large_inputs); ATF_TC_HEAD(test_large_inputs, tc) { atf_tc_set_md_var(tc, "descr", "Test inputs that might cause overflow in a sloppy implementation"); } ATF_TC_BODY(test_large_inputs, tc) { long double complex z; -#ifdef __i386__ - atf_tc_expect_fail("test fails on i386 - bug 205446"); -#endif - /* tanh() uses a threshold around x=22, so check both sides. */ z = CMPLXL(21, 0.78539816339744830961566084581987572L); testall_odd_tol(ctanh, z, CMPLXL(1.0, 1.14990445285871196133287617611468468e-18L), 1.2); z++; testall_odd_tol(ctanh, z, CMPLXL(1.0, 1.55622644822675930314266334585597964e-19L), 1); z = CMPLXL(355, 0.78539816339744830961566084581987572L); test_odd_tol(ctanh, z, CMPLXL(1.0, 8.95257245135025991216632140458264468e-309L), DBL_ULP()); z = CMPLXL(30, 0x1p1023L); test_odd_tol(ctanh, z, CMPLXL(1.0, -1.62994325413993477997492170229268382e-26L), DBL_ULP()); z = CMPLXL(1, 0x1p1023L); test_odd_tol(ctanh, z, CMPLXL(0.878606311888306869546254022621986509L, -0.225462792499754505792678258169527424L), DBL_ULP()); z = CMPLXL(710.6, 0.78539816339744830961566084581987572L); test_odd_tol(csinh, z, CMPLXL(1.43917579766621073533185387499658944e308L, 1.43917579766621073533185387499658944e308L), DBL_ULP()); test_even_tol(ccosh, z, CMPLXL(1.43917579766621073533185387499658944e308L, 1.43917579766621073533185387499658944e308L), DBL_ULP()); z = CMPLXL(1500, 0.78539816339744830961566084581987572L); testall_odd(csinh, z, CMPLXL(INFINITY, INFINITY), OPT_INEXACT, FE_OVERFLOW, CS_BOTH); testall_even(ccosh, z, CMPLXL(INFINITY, INFINITY), OPT_INEXACT, FE_OVERFLOW, CS_BOTH); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, test_zero_input); ATF_TP_ADD_TC(tp, test_nan_inputs); ATF_TP_ADD_TC(tp, test_inf_inputs); ATF_TP_ADD_TC(tp, test_axes); ATF_TP_ADD_TC(tp, test_small_inputs); ATF_TP_ADD_TC(tp, test_large_inputs); return (atf_no_error()); } Index: stable/11/sys/sys/param.h =================================================================== --- stable/11/sys/sys/param.h (revision 324005) +++ stable/11/sys/sys/param.h (revision 324006) @@ -1,365 +1,365 @@ /*- * Copyright (c) 1982, 1986, 1989, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. * All or some portions of this file are derived from material licensed * to the University of California by American Telephone and Telegraph * Co. or Unix System Laboratories, Inc. and are reproduced herein with * the permission of UNIX System Laboratories, Inc. * * 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. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. * * @(#)param.h 8.3 (Berkeley) 4/4/95 * $FreeBSD$ */ #ifndef _SYS_PARAM_H_ #define _SYS_PARAM_H_ #include #define BSD 199506 /* System version (year & month). */ #define BSD4_3 1 #define BSD4_4 1 /* * __FreeBSD_version numbers are documented in the Porter's Handbook. * If you bump the version for any reason, you should update the documentation * there. * Currently this lives here in the doc/ repository: * * head/en_US.ISO8859-1/books/porters-handbook/versions/chapter.xml * * scheme is: Rxx * 'R' is in the range 0 to 4 if this is a release branch or * X.0-CURRENT before releng/X.0 is created, otherwise 'R' is * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1101503 /* Master, propagated to newvers */ +#define __FreeBSD_version 1101504 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, * which by definition is always true on FreeBSD. This macro is also defined * on other systems that use the kernel of FreeBSD, such as GNU/kFreeBSD. * * It is tempting to use this macro in userland code when we want to enable * kernel-specific routines, and in fact it's fine to do this in code that * is part of FreeBSD itself. However, be aware that as presence of this * macro is still not widespread (e.g. older FreeBSD versions, 3rd party * compilers, etc), it is STRONGLY DISCOURAGED to check for this macro in * external applications without also checking for __FreeBSD__ as an * alternative. */ #undef __FreeBSD_kernel__ #define __FreeBSD_kernel__ #if defined(_KERNEL) || defined(IN_RTLD) #define P_OSREL_SIGWAIT 700000 #define P_OSREL_SIGSEGV 700004 #define P_OSREL_MAP_ANON 800104 #define P_OSREL_MAP_FSTRICT 1100036 #define P_OSREL_SHUTDOWN_ENOTCONN 1100077 #define P_OSREL_MAP_GUARD 1200035 #define P_OSREL_MAP_GUARD_11 1101501 #define P_OSREL_WRFSBASE 1200041 #define P_OSREL_WRFSBASE_11 1101503 #define P_OSREL_MAJOR(x) ((x) / 100000) #endif #ifndef LOCORE #include #endif /* * Machine-independent constants (some used in following include files). * Redefined constants are from POSIX 1003.1 limits file. * * MAXCOMLEN should be >= sizeof(ac_comm) (see ) */ #include #define MAXCOMLEN 19 /* max command name remembered */ #define MAXINTERP PATH_MAX /* max interpreter file name length */ #define MAXLOGNAME 33 /* max login name length (incl. NUL) */ #define MAXUPRC CHILD_MAX /* max simultaneous processes */ #define NCARGS ARG_MAX /* max bytes for an exec function */ #define NGROUPS (NGROUPS_MAX+1) /* max number groups */ #define NOFILE OPEN_MAX /* max open files per process */ #define NOGROUP 65535 /* marker for empty group set member */ #define MAXHOSTNAMELEN 256 /* max hostname size */ #define SPECNAMELEN 63 /* max length of devicename */ /* More types and definitions used throughout the kernel. */ #ifdef _KERNEL #include #include #ifndef LOCORE #include #include #endif #ifndef FALSE #define FALSE 0 #endif #ifndef TRUE #define TRUE 1 #endif #endif #ifndef _KERNEL /* Signals. */ #include #endif /* Machine type dependent parameters. */ #include #ifndef _KERNEL #include #endif #ifndef DEV_BSHIFT #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ #endif #define DEV_BSIZE (1<>PAGE_SHIFT) #endif /* * btodb() is messy and perhaps slow because `bytes' may be an off_t. We * want to shift an unsigned type to avoid sign extension and we don't * want to widen `bytes' unnecessarily. Assume that the result fits in * a daddr_t. */ #ifndef btodb #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ (sizeof (bytes) > sizeof(long) \ ? (daddr_t)((unsigned long long)(bytes) >> DEV_BSHIFT) \ : (daddr_t)((unsigned long)(bytes) >> DEV_BSHIFT)) #endif #ifndef dbtob #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ ((off_t)(db) << DEV_BSHIFT) #endif #define PRIMASK 0x0ff #define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */ #define PDROP 0x200 /* OR'd with pri to stop re-entry of interlock mutex */ #define NZERO 0 /* default "nice" */ #define NBBY 8 /* number of bits in a byte */ #define NBPW sizeof(int) /* number of bytes per word (integer) */ #define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */ #define NODEV (dev_t)(-1) /* non-existent device */ /* * File system parameters and macros. * * MAXBSIZE - Filesystems are made out of blocks of at most MAXBSIZE bytes * per block. MAXBSIZE may be made larger without effecting * any existing filesystems as long as it does not exceed MAXPHYS, * and may be made smaller at the risk of not being able to use * filesystems which require a block size exceeding MAXBSIZE. * * MAXBCACHEBUF - Maximum size of a buffer in the buffer cache. This must * be >= MAXBSIZE and can be set differently for different * architectures by defining it in . * Making this larger allows NFS to do larger reads/writes. * * BKVASIZE - Nominal buffer space per buffer, in bytes. BKVASIZE is the * minimum KVM memory reservation the kernel is willing to make. * Filesystems can of course request smaller chunks. Actual * backing memory uses a chunk size of a page (PAGE_SIZE). * The default value here can be overridden on a per-architecture * basis by defining it in . * * If you make BKVASIZE too small you risk seriously fragmenting * the buffer KVM map which may slow things down a bit. If you * make it too big the kernel will not be able to optimally use * the KVM memory reserved for the buffer cache and will wind * up with too-few buffers. * * The default is 16384, roughly 2x the block size used by a * normal UFS filesystem. */ #define MAXBSIZE 65536 /* must be power of 2 */ #ifndef MAXBCACHEBUF #define MAXBCACHEBUF MAXBSIZE /* must be a power of 2 >= MAXBSIZE */ #endif #ifndef BKVASIZE #define BKVASIZE 16384 /* must be power of 2 */ #endif #define BKVAMASK (BKVASIZE-1) /* * MAXPATHLEN defines the longest permissible path length after expanding * symbolic links. It is used to allocate a temporary buffer from the buffer * pool in which to do the name expansion, hence should be a power of two, * and must be less than or equal to MAXBSIZE. MAXSYMLINKS defines the * maximum number of symbolic links that may be expanded in a path name. * It should be set high enough to allow all legitimate uses, but halt * infinite loops reasonably quickly. */ #define MAXPATHLEN PATH_MAX #define MAXSYMLINKS 32 /* Bit map related macros. */ #define setbit(a,i) (((unsigned char *)(a))[(i)/NBBY] |= 1<<((i)%NBBY)) #define clrbit(a,i) (((unsigned char *)(a))[(i)/NBBY] &= ~(1<<((i)%NBBY))) #define isset(a,i) \ (((const unsigned char *)(a))[(i)/NBBY] & (1<<((i)%NBBY))) #define isclr(a,i) \ ((((const unsigned char *)(a))[(i)/NBBY] & (1<<((i)%NBBY))) == 0) /* Macros for counting and rounding. */ #ifndef howmany #define howmany(x, y) (((x)+((y)-1))/(y)) #endif #define nitems(x) (sizeof((x)) / sizeof((x)[0])) #define rounddown(x, y) (((x)/(y))*(y)) #define rounddown2(x, y) ((x)&(~((y)-1))) /* if y is power of two */ #define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) /* to any y */ #define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */ #define powerof2(x) ((((x)-1)&(x))==0) /* Macros for min/max. */ #define MIN(a,b) (((a)<(b))?(a):(b)) #define MAX(a,b) (((a)>(b))?(a):(b)) #ifdef _KERNEL /* * Basic byte order function prototypes for non-inline functions. */ #ifndef LOCORE #ifndef _BYTEORDER_PROTOTYPED #define _BYTEORDER_PROTOTYPED __BEGIN_DECLS __uint32_t htonl(__uint32_t); __uint16_t htons(__uint16_t); __uint32_t ntohl(__uint32_t); __uint16_t ntohs(__uint16_t); __END_DECLS #endif #endif #ifndef lint #ifndef _BYTEORDER_FUNC_DEFINED #define _BYTEORDER_FUNC_DEFINED #define htonl(x) __htonl(x) #define htons(x) __htons(x) #define ntohl(x) __ntohl(x) #define ntohs(x) __ntohs(x) #endif /* !_BYTEORDER_FUNC_DEFINED */ #endif /* lint */ #endif /* _KERNEL */ /* * Scale factor for scaled integers used to count %cpu time and load avgs. * * The number of CPU `tick's that map to a unique `%age' can be expressed * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that * can be calculated (assuming 32 bits) can be closely approximated using * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15). * * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age', * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024. */ #define FSHIFT 11 /* bits to right of fixed binary point */ #define FSCALE (1<> (PAGE_SHIFT - DEV_BSHIFT)) #define ctodb(db) /* calculates pages to devblks */ \ ((db) << (PAGE_SHIFT - DEV_BSHIFT)) /* * Old spelling of __containerof(). */ #define member2struct(s, m, x) \ ((struct s *)(void *)((char *)(x) - offsetof(struct s, m))) /* * Access a variable length array that has been declared as a fixed * length array. */ #define __PAST_END(array, offset) (((__typeof__(*(array)) *)(array))[offset]) #endif /* _SYS_PARAM_H_ */ Index: stable/11 =================================================================== --- stable/11 (revision 324005) +++ stable/11 (revision 324006) Property changes on: stable/11 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head:r305382,305384-305385,306409-306410,306527,306709,307066,308172,313761,313863-313864,314950,317349,319047,321457,322418,322435,322921