├── .github ├── dependabot.yml └── workflows │ ├── ci.yml │ ├── cross-loongarch64.yml │ └── cross.yml ├── .gitignore ├── .mailmap ├── CMakeLists.txt ├── LICENSE.md ├── Make.inc ├── Makefile ├── README.md ├── aarch64 ├── Make.files └── fenv.c ├── amd64 ├── Make.files ├── bsd_asm.h ├── bsd_fpu.h ├── bsd_ieeefp.h ├── 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 ├── fenv.c ├── 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 ├── arm ├── Make.files └── fenv.c ├── bsdsrc ├── Make.files ├── b_exp.c ├── b_log.c ├── b_tgamma.c └── mathimpl.h ├── docs ├── CNAME ├── images │ ├── arrow-down.png │ └── octocat-small.png ├── index.html ├── javascripts │ └── scale.fix.js ├── params.json └── stylesheets │ ├── pygment_trac.css │ └── styles.css ├── i387 ├── Make.files ├── bsd_asm.h ├── bsd_ieeefp.h ├── bsd_npx.h ├── e_exp.S ├── e_fmod.S ├── e_log.S ├── e_log10.S ├── e_log10f.S ├── e_logf.S ├── e_remainder.S ├── e_remainderf.S ├── e_remainderl.S ├── e_sqrt.S ├── e_sqrtf.S ├── e_sqrtl.S ├── fenv.c ├── invtrig.c ├── osx_asm.h ├── s_ceil.S ├── s_ceilf.S ├── s_ceill.S ├── s_copysign.S ├── s_copysignf.S ├── s_copysignl.S ├── s_cos.S ├── s_floor.S ├── s_floorf.S ├── s_floorl.S ├── s_llrint.S ├── s_llrintf.S ├── s_llrintl.S ├── s_logb.S ├── s_logbf.S ├── s_logbl.S ├── s_lrint.S ├── s_lrintf.S ├── s_lrintl.S ├── s_remquo.S ├── s_remquof.S ├── s_remquol.S ├── s_rint.S ├── s_rintf.S ├── s_rintl.S ├── s_scalbn.S ├── s_scalbnf.S ├── s_scalbnl.S ├── s_sin.S ├── s_tan.S ├── s_trunc.S ├── s_truncf.S └── s_truncl.S ├── include ├── openlibm.h ├── openlibm_complex.h ├── openlibm_defs.h ├── openlibm_fenv.h ├── openlibm_fenv_aarch64.h ├── openlibm_fenv_amd64.h ├── openlibm_fenv_arm.h ├── openlibm_fenv_i387.h ├── openlibm_fenv_loongarch64.h ├── openlibm_fenv_mips.h ├── openlibm_fenv_powerpc.h ├── openlibm_fenv_riscv.h ├── openlibm_fenv_s390.h └── openlibm_math.h ├── ld128 ├── Make.files ├── e_acoshl.c ├── e_atanhl.c ├── e_coshl.c ├── e_expl.c ├── e_fmodl.c ├── e_hypotl.c ├── e_lgammal_r.c ├── e_log10l.c ├── e_log2l.c ├── e_logl.c ├── e_powl.c ├── e_rem_pio2l.h ├── e_sinhl.c ├── e_tgammal.c ├── invtrig.c ├── invtrig.h ├── k_cosl.c ├── k_sinl.c ├── k_tanl.c ├── s_asinhl.c ├── s_ceill.c ├── s_erfl.c ├── s_exp2l.c ├── s_expm1l.c ├── s_floorl.c ├── s_log1pl.c ├── s_modfl.c ├── s_nanl.c ├── s_nextafterl.c ├── s_nexttoward.c ├── s_nexttowardf.c ├── s_remquol.c ├── s_tanhl.c └── s_truncl.c ├── ld80 ├── Make.files ├── e_acoshl.c ├── e_atanhl.c ├── e_coshl.c ├── e_expl.c ├── e_fmodl.c ├── e_hypotl.c ├── e_lgammal_r.c ├── e_log10l.c ├── e_log2l.c ├── e_logl.c ├── e_powl.c ├── e_rem_pio2l.h ├── e_sinhl.c ├── e_tgammal.c ├── invtrig.c ├── invtrig.h ├── k_cosl.c ├── k_sinl.c ├── k_tanl.c ├── s_asinhl.c ├── s_ceill.c ├── s_erfl.c ├── s_exp2l.c ├── s_expm1l.c ├── s_floorl.c ├── s_log1pl.c ├── s_modfl.c ├── s_nanl.c ├── s_nextafterl.c ├── s_nexttoward.c ├── s_nexttowardf.c ├── s_remquol.c ├── s_tanhl.c └── s_truncl.c ├── loongarch64 ├── Make.files └── fenv.c ├── mips ├── Make.files ├── fenv-softfloat.h └── fenv.c ├── openlibm.pc.in ├── powerpc ├── Make.files └── fenv.c ├── riscv64 ├── Make.files └── fenv.c ├── s390 ├── Make.files └── fenv.c ├── src ├── Make.files ├── aarch64_fpmath.h ├── amd64_fpmath.h ├── bsd_cdefs.h ├── cdefs-compat.h ├── common.c ├── e_acos.c ├── e_acosf.c ├── e_acosh.c ├── e_acoshf.c ├── e_acosl.c ├── e_asin.c ├── e_asinf.c ├── e_asinl.c ├── e_atan2.c ├── e_atan2f.c ├── e_atan2l.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_fmodl.c ├── e_hypot.c ├── e_hypotf.c ├── e_hypotl.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_lgammal.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_remainderl.c ├── e_sinh.c ├── e_sinhf.c ├── e_sqrt.c ├── e_sqrtf.c ├── e_sqrtl.c ├── fpmath.h ├── i386_fpmath.h ├── k_cos.c ├── k_cosf.c ├── k_exp.c ├── k_expf.c ├── k_log.h ├── k_logf.h ├── k_rem_pio2.c ├── k_sin.c ├── k_sinf.c ├── k_tan.c ├── k_tanf.c ├── loongarch64_fpmath.h ├── math_private.h ├── math_private_openbsd.h ├── mips_fpmath.h ├── polevll.c ├── powerpc_fpmath.h ├── riscv_fpmath.h ├── s390_fpmath.h ├── s_asinh.c ├── s_asinhf.c ├── s_atan.c ├── s_atanf.c ├── s_atanl.c ├── s_cabs.c ├── s_cabsf.c ├── s_cabsl.c ├── s_cacos.c ├── s_cacosf.c ├── s_cacosh.c ├── s_cacoshf.c ├── s_cacoshl.c ├── s_cacosl.c ├── s_carg.c ├── s_cargf.c ├── s_cargl.c ├── s_casin.c ├── s_casinf.c ├── s_casinh.c ├── s_casinhf.c ├── s_casinhl.c ├── s_casinl.c ├── s_catan.c ├── s_catanf.c ├── s_catanh.c ├── s_catanhf.c ├── s_catanhl.c ├── s_catanl.c ├── s_cbrt.c ├── s_cbrtf.c ├── s_cbrtl.c ├── s_ccos.c ├── s_ccosf.c ├── s_ccosh.c ├── s_ccoshf.c ├── s_ccoshl.c ├── s_ccosl.c ├── s_ceil.c ├── s_ceilf.c ├── s_ceill.c ├── s_cexp.c ├── s_cexpf.c ├── s_cexpl.c ├── s_cimag.c ├── s_cimagf.c ├── s_cimagl.c ├── s_clog.c ├── s_clogf.c ├── s_clogl.c ├── s_conj.c ├── s_conjf.c ├── s_conjl.c ├── s_copysign.c ├── s_copysignf.c ├── s_copysignl.c ├── s_cos.c ├── s_cosf.c ├── s_cosl.c ├── s_cpow.c ├── s_cpowf.c ├── s_cpowl.c ├── s_cproj.c ├── s_cprojf.c ├── s_cprojl.c ├── s_creal.c ├── s_crealf.c ├── s_creall.c ├── s_csin.c ├── s_csinf.c ├── s_csinh.c ├── s_csinhf.c ├── s_csinhl.c ├── s_csinl.c ├── s_csqrt.c ├── s_csqrtf.c ├── s_csqrtl.c ├── s_ctan.c ├── s_ctanf.c ├── s_ctanh.c ├── s_ctanhf.c ├── s_ctanhl.c ├── s_ctanl.c ├── s_erf.c ├── s_erff.c ├── s_exp2.c ├── s_exp2f.c ├── s_expm1.c ├── s_expm1f.c ├── s_fabs.c ├── s_fabsf.c ├── s_fabsl.c ├── s_fdim.c ├── s_floor.c ├── s_floorf.c ├── s_floorl.c ├── s_fma.c ├── s_fmaf.c ├── s_fmal.c ├── s_fmax.c ├── s_fmaxf.c ├── s_fmaxl.c ├── s_fmin.c ├── s_fminf.c ├── s_fminl.c ├── s_fpclassify.c ├── s_frexp.c ├── s_frexpf.c ├── s_frexpl.c ├── s_ilogb.c ├── s_ilogbf.c ├── s_ilogbl.c ├── s_isfinite.c ├── s_isinf.c ├── s_isnan.c ├── s_isnormal.c ├── s_llrint.c ├── s_llrintf.c ├── s_llrintl.c ├── s_llround.c ├── s_llroundf.c ├── s_llroundl.c ├── s_log1p.c ├── s_log1pf.c ├── s_logb.c ├── s_logbf.c ├── s_logbl.c ├── s_lrint.c ├── s_lrintf.c ├── s_lrintl.c ├── s_lround.c ├── s_lroundf.c ├── s_lroundl.c ├── s_modf.c ├── s_modff.c ├── s_modfl.c ├── s_nan.c ├── s_nearbyint.c ├── s_nextafter.c ├── s_nextafterf.c ├── s_nextafterl.c ├── s_nexttoward.c ├── s_nexttowardf.c ├── s_remquo.c ├── s_remquof.c ├── s_remquol.c ├── s_rint.c ├── s_rintf.c ├── s_rintl.c ├── s_round.c ├── s_roundf.c ├── s_roundl.c ├── s_scalbln.c ├── s_scalbn.c ├── s_scalbnf.c ├── s_scalbnl.c ├── s_signbit.c ├── s_signgam.c ├── s_sin.c ├── s_sincos.c ├── s_sincosf.c ├── s_sincosl.c ├── s_sinf.c ├── s_sinl.c ├── s_tan.c ├── s_tanf.c ├── s_tanh.c ├── s_tanhf.c ├── s_tanl.c ├── s_tgammaf.c ├── s_trunc.c ├── s_truncf.c ├── s_truncl.c ├── types-compat.h ├── w_cabs.c ├── w_cabsf.c └── w_cabsl.c ├── test ├── .gitignore ├── Makefile ├── inf_torture.c ├── libm-bench.cpp ├── libm-test-ulps.h ├── libm-test.c ├── test-211.c ├── test-double.c └── test-float.c └── wasm32 ├── Make.files ├── assert.h ├── float.h ├── limits.h └── stdint.h /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 2 | version: 2 3 | updates: 4 | - package-ecosystem: "github-actions" 5 | directory: "/" # Location of package manifests 6 | schedule: 7 | interval: "monthly" 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *~ 3 | *.a 4 | *.dll* 5 | *.so* 6 | *.dylib* 7 | *.pc 8 | 9 | # code coverage 10 | openlibm-test 11 | cov-html/ 12 | *.gcda 13 | *.gcno 14 | -------------------------------------------------------------------------------- /aarch64/Make.files: -------------------------------------------------------------------------------- 1 | $(CUR_SRCS) = fenv.c 2 | -------------------------------------------------------------------------------- /amd64/Make.files: -------------------------------------------------------------------------------- 1 | $(CUR_SRCS) = fenv.c e_remainder.S e_remainderf.S e_remainderl.S \ 2 | e_sqrt.S e_sqrtf.S e_sqrtl.S \ 3 | s_llrint.S s_llrintf.S s_llrintl.S \ 4 | s_logbl.S s_lrint.S s_lrintf.S s_lrintl.S \ 5 | s_remquo.S s_remquof.S s_remquol.S \ 6 | s_rintl.S s_scalbn.S s_scalbnf.S s_scalbnl.S \ 7 | e_fmod.S e_fmodf.S e_fmodl.S 8 | -------------------------------------------------------------------------------- /amd64/e_fmodf.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Based on the i387 version written by J.T. Conklin . 3 | * Public domain. 4 | */ 5 | 6 | #include 7 | 8 | ENTRY(fmodf) 9 | movss %xmm0,-4(%rsp) 10 | movss %xmm1,-8(%rsp) 11 | flds -8(%rsp) 12 | flds -4(%rsp) 13 | 1: fprem 14 | fstsw %ax 15 | testw $0x400,%ax 16 | jne 1b 17 | fstps -4(%rsp) 18 | movss -4(%rsp),%xmm0 19 | fstp %st 20 | ret 21 | END(fmodf) 22 | 23 | /* Enable stack protection */ 24 | #if defined(__ELF__) 25 | .section .note.GNU-stack,"",%progbits 26 | #endif 27 | -------------------------------------------------------------------------------- /amd64/e_remainder.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Based on the i387 version written by: 3 | * J.T. Conklin (jtc@netbsd.org) 4 | * Public domain. 5 | */ 6 | 7 | #include 8 | 9 | //RCSID("from: FreeBSD: src/lib/msun/i387/e_remainder.S,v 1.8 2005/02/04 14:08:32 das Exp") 10 | //__FBSDID("$FreeBSD: src/lib/msun/amd64/e_remainder.S,v 1.2 2011/01/07 16:13:12 kib Exp $") 11 | 12 | ENTRY(remainder) 13 | movsd %xmm0,-8(%rsp) 14 | movsd %xmm1,-16(%rsp) 15 | fldl -16(%rsp) 16 | fldl -8(%rsp) 17 | 1: fprem1 18 | fstsw %ax 19 | testw $0x400,%ax 20 | jne 1b 21 | fstpl -8(%rsp) 22 | movsd -8(%rsp),%xmm0 23 | fstp %st 24 | ret 25 | 26 | 27 | /* Enable stack protection */ 28 | #if defined(__ELF__) 29 | .section .note.GNU-stack,"",%progbits 30 | #endif 31 | -------------------------------------------------------------------------------- /amd64/e_remainderf.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Based on the i387 version written by J.T. Conklin . 3 | * Public domain. 4 | */ 5 | 6 | #include 7 | 8 | //RCSID("from: $NetBSD: e_remainderf.S,v 1.2 1995/05/08 23:49:47 jtc Exp $") 9 | //__FBSDID("$FreeBSD: src/lib/msun/amd64/e_remainderf.S,v 1.2 2011/01/07 16:13:12 kib Exp $") 10 | 11 | ENTRY(remainderf) 12 | movss %xmm0,-4(%rsp) 13 | movss %xmm1,-8(%rsp) 14 | flds -8(%rsp) 15 | flds -4(%rsp) 16 | 1: fprem1 17 | fstsw %ax 18 | testw $0x400,%ax 19 | jne 1b 20 | fstps -4(%rsp) 21 | movss -4(%rsp),%xmm0 22 | fstp %st 23 | ret 24 | 25 | 26 | /* Enable stack protection */ 27 | #if defined(__ELF__) 28 | .section .note.GNU-stack,"",%progbits 29 | #endif 30 | -------------------------------------------------------------------------------- /amd64/e_remainderl.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Based on the i387 version written by: 3 | * J.T. Conklin (jtc@netbsd.org) 4 | * Public domain. 5 | */ 6 | 7 | #include 8 | 9 | //__FBSDID("$FreeBSD: src/lib/msun/amd64/e_remainderl.S,v 1.2 2011/01/07 16:13:12 kib Exp $") 10 | 11 | ENTRY(remainderl) 12 | #ifndef _WIN64 13 | fldt 24(%rsp) 14 | fldt 8(%rsp) 15 | #else 16 | fldt (%r8) 17 | fldt (%rdx) 18 | #endif 19 | 1: fprem1 20 | fstsw %ax 21 | testw $0x400,%ax 22 | jne 1b 23 | fstp %st(1) 24 | #ifdef _WIN64 25 | mov %rcx,%rax 26 | movq $0x0,0x8(%rcx) 27 | fstpt (%rcx) 28 | #endif 29 | ret 30 | 31 | 32 | /* Enable stack protection */ 33 | #if defined(__ELF__) 34 | .section .note.GNU-stack,"",%progbits 35 | #endif 36 | -------------------------------------------------------------------------------- /amd64/e_sqrt.S: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2005 David Schultz 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | //__FBSDID("$FreeBSD: src/lib/msun/amd64/e_sqrt.S,v 1.4 2011/01/07 16:13:12 kib Exp $") 29 | 30 | ENTRY(sqrt) 31 | sqrtsd %xmm0, %xmm0 32 | ret 33 | END(sqrt) 34 | 35 | 36 | 37 | /* Enable stack protection */ 38 | #if defined(__ELF__) 39 | .section .note.GNU-stack,"",%progbits 40 | #endif 41 | -------------------------------------------------------------------------------- /amd64/e_sqrtf.S: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2005 David Schultz 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | //__FBSDID("$FreeBSD: src/lib/msun/amd64/e_sqrtf.S,v 1.3 2011/01/07 16:13:12 kib Exp $") 29 | 30 | ENTRY(sqrtf) 31 | sqrtss %xmm0, %xmm0 32 | ret 33 | END(sqrtf) 34 | 35 | 36 | /* Enable stack protection */ 37 | #if defined(__ELF__) 38 | .section .note.GNU-stack,"",%progbits 39 | #endif 40 | -------------------------------------------------------------------------------- /amd64/e_sqrtl.S: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2008 David Schultz 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | //__FBSDID("$FreeBSD: src/lib/msun/amd64/e_sqrtl.S,v 1.2 2011/01/07 16:13:12 kib Exp $") 29 | 30 | ENTRY(sqrtl) 31 | #ifndef _WIN64 32 | fldt 8(%rsp) 33 | fsqrt 34 | #else 35 | fldt (%rdx) 36 | fsqrt 37 | mov %rcx,%rax 38 | movq $0x0,0x8(%rcx) 39 | fstpt (%rcx) 40 | #endif 41 | ret 42 | 43 | /* Enable stack protection */ 44 | #if defined(__ELF__) 45 | .section .note.GNU-stack,"",%progbits 46 | #endif 47 | -------------------------------------------------------------------------------- /amd64/s_llrint.S: -------------------------------------------------------------------------------- 1 | #include 2 | //__FBSDID("$FreeBSD: src/lib/msun/amd64/s_llrint.S,v 1.3 2011/02/04 21:54:06 kib Exp $") 3 | 4 | ENTRY(llrint) 5 | cvtsd2si %xmm0, %rax 6 | ret 7 | END(llrint) 8 | 9 | /* Enable stack protection */ 10 | #if defined(__ELF__) 11 | .section .note.GNU-stack,"",%progbits 12 | #endif 13 | -------------------------------------------------------------------------------- /amd64/s_llrintf.S: -------------------------------------------------------------------------------- 1 | #include 2 | //__FBSDID("$FreeBSD: src/lib/msun/amd64/s_llrintf.S,v 1.3 2011/02/04 21:54:06 kib Exp $") 3 | 4 | ENTRY(llrintf) 5 | cvtss2si %xmm0, %rax 6 | ret 7 | END(llrintf) 8 | 9 | /* Enable stack protection */ 10 | #if defined(__ELF__) 11 | .section .note.GNU-stack,"",%progbits 12 | #endif 13 | -------------------------------------------------------------------------------- /amd64/s_llrintl.S: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2005 David Schultz 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | //__FBSDID("$FreeBSD: src/lib/msun/amd64/s_llrintl.S,v 1.2 2011/01/07 16:13:12 kib Exp $"); 29 | 30 | ENTRY(llrintl) 31 | #ifndef _WIN64 32 | fldt 8(%rsp) 33 | #else 34 | fldt (%rcx) 35 | #endif 36 | subq $8,%rsp 37 | fistpll (%rsp) 38 | popq %rax 39 | ret 40 | 41 | 42 | /* Enable stack protection */ 43 | #if defined(__ELF__) 44 | .section .note.GNU-stack,"",%progbits 45 | #endif 46 | -------------------------------------------------------------------------------- /amd64/s_logbl.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by: 3 | * J.T. Conklin (jtc@netbsd.org) 4 | * Public domain. 5 | */ 6 | 7 | #include 8 | //__FBSDID("$FreeBSD: src/lib/msun/amd64/s_logbl.S,v 1.4 2011/01/07 16:13:12 kib Exp $") 9 | 10 | ENTRY(logbl) 11 | #ifndef _WIN64 12 | fldt 8(%rsp) 13 | #else 14 | fldt (%rdx) 15 | #endif 16 | fxtract 17 | fstp %st 18 | #ifdef _WIN64 19 | mov %rcx,%rax 20 | movq $0x0,0x8(%rcx) 21 | fstpt (%rcx) 22 | #endif 23 | ret 24 | 25 | 26 | /* Enable stack protection */ 27 | #if defined(__ELF__) 28 | .section .note.GNU-stack,"",%progbits 29 | #endif 30 | -------------------------------------------------------------------------------- /amd64/s_lrint.S: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2005 David Schultz 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | 29 | //__FBSDID("$FreeBSD: src/lib/msun/amd64/s_lrint.S,v 1.3 2011/01/07 16:13:12 kib Exp $") 30 | 31 | ENTRY(lrint) 32 | #ifndef _WIN64 33 | cvtsd2si %xmm0, %rax 34 | #else 35 | cvtsd2si %xmm0, %eax 36 | #endif 37 | ret 38 | END(lrint) 39 | 40 | 41 | /* Enable stack protection */ 42 | #if defined(__ELF__) 43 | .section .note.GNU-stack,"",%progbits 44 | #endif 45 | -------------------------------------------------------------------------------- /amd64/s_lrintf.S: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2005 David Schultz 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | 29 | //__FBSDID("$FreeBSD: src/lib/msun/amd64/s_lrintf.S,v 1.3 2011/01/07 16:13:12 kib Exp $") 30 | 31 | ENTRY(lrintf) 32 | #ifndef _WIN64 33 | cvtss2si %xmm0, %rax 34 | #else 35 | cvtss2si %xmm0, %eax 36 | #endif 37 | ret 38 | END(lrintf) 39 | 40 | 41 | /* Enable stack protection */ 42 | #if defined(__ELF__) 43 | .section .note.GNU-stack,"",%progbits 44 | #endif 45 | -------------------------------------------------------------------------------- /amd64/s_lrintl.S: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2008 David Schultz 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | //__FBSDID("$FreeBSD: src/lib/msun/amd64/s_lrintl.S,v 1.2 2011/01/07 16:13:12 kib Exp $"); 29 | 30 | ENTRY(lrintl) 31 | #ifndef _WIN64 32 | fldt 8(%rsp) 33 | #else 34 | fldt (%rcx) 35 | #endif 36 | subq $8,%rsp 37 | fistpll (%rsp) 38 | popq %rax 39 | ret 40 | 41 | 42 | /* Enable stack protection */ 43 | #if defined(__ELF__) 44 | .section .note.GNU-stack,"",%progbits 45 | #endif 46 | -------------------------------------------------------------------------------- /amd64/s_rintl.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by: 3 | * J.T. Conklin (jtc@netbsd.org) 4 | * Public domain. 5 | */ 6 | 7 | #include 8 | 9 | ENTRY(rintl) 10 | #ifndef _WIN64 11 | fldt 8(%rsp) 12 | frndint 13 | #else 14 | fldt (%rdx) 15 | frndint 16 | mov %rcx,%rax 17 | movq $0x0,0x8(%rcx) 18 | fstpt (%rcx) 19 | #endif 20 | ret 21 | 22 | 23 | /* Enable stack protection */ 24 | #if defined(__ELF__) 25 | .section .note.GNU-stack,"",%progbits 26 | #endif 27 | -------------------------------------------------------------------------------- /amd64/s_scalbnl.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Based on code written by J.T. Conklin . 3 | * Public domain. 4 | */ 5 | 6 | #include 7 | //__FBSDID("$FreeBSD: src/lib/msun/amd64/s_scalbnl.S,v 1.3 2011/01/07 16:13:12 kib Exp $") 8 | /* //RCSID("$NetBSD: s_scalbnf.S,v 1.4 1999/01/02 05:15:40 kristerw Exp $") */ 9 | 10 | ENTRY(scalbnl) 11 | #ifndef _WIN64 12 | movl %edi,-4(%rsp) 13 | fildl -4(%rsp) 14 | fldt 8(%rsp) 15 | #else 16 | mov %r8,%rax 17 | movl %eax,-4(%rsp) 18 | fildl -4(%rsp) 19 | fldt (%rdx) 20 | #endif 21 | fscale 22 | fstp %st(1) 23 | #ifdef _WIN64 24 | mov %rcx,%rax 25 | movq $0x0,0x8(%rcx) 26 | fstpt (%rcx) 27 | #endif 28 | ret 29 | #ifndef _WIN64 30 | END(scalbnl) 31 | .globl CNAME(ldexpl) 32 | #else 33 | .globl CNAME(ldexpl); .section .drectve; .ascii " -export:ldexpl" 34 | #endif 35 | .set CNAME(ldexpl),CNAME(scalbnl) 36 | 37 | /* Enable stack protection */ 38 | #if defined(__ELF__) 39 | .section .note.GNU-stack,"",%progbits 40 | #endif 41 | -------------------------------------------------------------------------------- /arm/Make.files: -------------------------------------------------------------------------------- 1 | $(CUR_SRCS) = fenv.c 2 | -------------------------------------------------------------------------------- /bsdsrc/Make.files: -------------------------------------------------------------------------------- 1 | $(CUR_SRCS) += b_exp.c b_log.c b_tgamma.c 2 | -------------------------------------------------------------------------------- /docs/CNAME: -------------------------------------------------------------------------------- 1 | openlibm.org -------------------------------------------------------------------------------- /docs/images/arrow-down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JuliaMath/openlibm/c9c6fd6eade60ba38427c675a7323b0d2bae6521/docs/images/arrow-down.png -------------------------------------------------------------------------------- /docs/images/octocat-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JuliaMath/openlibm/c9c6fd6eade60ba38427c675a7323b0d2bae6521/docs/images/octocat-small.png -------------------------------------------------------------------------------- /docs/javascripts/scale.fix.js: -------------------------------------------------------------------------------- 1 | fixScale = function(doc) { 2 | 3 | var addEvent = 'addEventListener', 4 | type = 'gesturestart', 5 | qsa = 'querySelectorAll', 6 | scales = [1, 1], 7 | meta = qsa in doc ? doc[qsa]('meta[name=viewport]') : []; 8 | 9 | function fix() { 10 | meta.content = 'width=device-width,minimum-scale=' + scales[0] + ',maximum-scale=' + scales[1]; 11 | doc.removeEventListener(type, fix, true); 12 | } 13 | 14 | if ((meta = meta[meta.length - 1]) && addEvent in doc) { 15 | fix(); 16 | scales = [.25, 1.6]; 17 | doc[addEvent](type, fix, true); 18 | } 19 | 20 | }; -------------------------------------------------------------------------------- /docs/params.json: -------------------------------------------------------------------------------- 1 | {"name":"OpenLibm","tagline":"A high quality system independent, portable, open source libm implementation","body":"## OpenLibm\r\n\r\n[OpenLibm](http://www.openlibm.org) is an effort to have a high quality, portable, standalone\r\nC mathematical library ([`libm`](http://en.wikipedia.org/wiki/libm)).\r\nIt can be used standalone in applications and programming language\r\nimplementations.\r\n\r\nThe project was born out of a need to have a good `libm` for the\r\n[Julia programming langage](http://www.julialang.org) that worked\r\nconsistently across compilers and operating systems, and in 32-bit and\r\n64-bit environments.\r\n\r\n### History\r\n\r\nThe OpenLibm code derives from the [FreeBSD\r\nmsun](http://svnweb.freebsd.org/base/head/lib/msun/) and [OpenBSD\r\nlibm](http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libm/src/)\r\nimplementations, which in turn derives from [FDLIBM\r\n5.3](http://www.netlib.org/fdlibm/). As a result, it includes a number\r\nof fixes and updates to FDLIBM that have accumulated over the years in\r\n`msun`, and optimized versions of many functions.\r\n\r\n### Platform support\r\n\r\nOpenLibm builds on Linux, Mac OS X, and Windows, and with little\r\neffort, should build on FreeBSD as well. It builds with both GCC and\r\nclang. Although largely tested on x86, it also includes experimental\r\nsupport for ARM. The original `msun` also includes support for mips,\r\nsparc64, powerpc, ia64, and alpha. These are present in the OpenLibm\r\nsource tree, but no attempt has been made to build any of these.\r\n\r\n### Build instructions\r\n\r\n1. `make` or `make USEGCC=1` to build with GCC. This is the default on\r\n Linux and Windows.\r\n2. `make USECLANG=1` to build with clang. This is the default on OS X.\r\n","google":"UA-28835595-4","note":"Don't delete this file! It's used internally to help with page regeneration."} -------------------------------------------------------------------------------- /i387/Make.files: -------------------------------------------------------------------------------- 1 | $(CUR_SRCS) = e_exp.S e_fmod.S e_log.S e_log10.S \ 2 | e_remainder.S e_sqrt.S s_ceil.S s_copysign.S \ 3 | s_floor.S s_llrint.S s_logb.S s_lrint.S \ 4 | s_remquo.S s_rint.S s_tan.S s_trunc.S 5 | 6 | ifneq ($(OS), WINNT) 7 | $(CUR_SRCS) += s_scalbn.S s_scalbnf.S s_scalbnl.S 8 | endif 9 | 10 | # float counterparts 11 | $(CUR_SRCS)+= e_log10f.S e_logf.S e_remainderf.S \ 12 | e_sqrtf.S s_ceilf.S s_copysignf.S s_floorf.S \ 13 | s_llrintf.S s_logbf.S s_lrintf.S \ 14 | s_remquof.S s_rintf.S s_truncf.S 15 | 16 | # long double counterparts 17 | $(CUR_SRCS)+= e_remainderl.S e_sqrtl.S s_ceill.S s_copysignl.S \ 18 | s_floorl.S s_llrintl.S \ 19 | s_logbl.S s_lrintl.S s_remquol.S s_rintl.S s_truncl.S 20 | 21 | $(CUR_SRCS)+= fenv.c 22 | -------------------------------------------------------------------------------- /i387/e_exp.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by: 3 | * J.T. Conklin (jtc@netbsd.org) 4 | * Public domain. 5 | */ 6 | 7 | #include 8 | 9 | /* e^x = 2^(x * log2(e)) */ 10 | 11 | ENTRY(exp) 12 | /* 13 | * If x is +-Inf, then the subtraction would give Inf-Inf = NaN. 14 | * Avoid this. Also avoid it if x is NaN for convenience. 15 | */ 16 | movl 8(%esp),%eax 17 | andl $0x7fffffff,%eax 18 | cmpl $0x7ff00000,%eax 19 | jae x_Inf_or_NaN 20 | 21 | fldl 4(%esp) 22 | 23 | /* 24 | * Extended precision is needed to reduce the maximum error from 25 | * hundreds of ulps to less than 1 ulp. Switch to it if necessary. 26 | * We may as well set the rounding mode to to-nearest and mask traps 27 | * if we switch. 28 | */ 29 | fstcw 4(%esp) 30 | movl 4(%esp),%eax 31 | andl $0x0300,%eax 32 | cmpl $0x0300,%eax /* RC == 0 && PC == 3? */ 33 | je 1f /* jump if mode is good */ 34 | movl $0x137f,8(%esp) 35 | fldcw 8(%esp) 36 | 1: 37 | fldl2e 38 | fmulp /* x * log2(e) */ 39 | fst %st(1) 40 | frndint /* int(x * log2(e)) */ 41 | fst %st(2) 42 | fsubrp /* fract(x * log2(e)) */ 43 | f2xm1 /* 2^(fract(x * log2(e))) - 1 */ 44 | fld1 45 | faddp /* 2^(fract(x * log2(e))) */ 46 | fscale /* e^x */ 47 | fstp %st(1) 48 | je 1f 49 | fldcw 4(%esp) 50 | 1: 51 | ret 52 | 53 | x_Inf_or_NaN: 54 | /* 55 | * Return 0 if x is -Inf. Otherwise just return x; when x is Inf 56 | * this gives Inf, and when x is a NaN this gives the same result 57 | * as (x + x) (x quieted). 58 | */ 59 | cmpl $0xfff00000,8(%esp) 60 | jne x_not_minus_Inf 61 | cmpl $0,4(%esp) 62 | jne x_not_minus_Inf 63 | fldz 64 | ret 65 | 66 | x_not_minus_Inf: 67 | fldl 4(%esp) 68 | ret 69 | END(exp) 70 | 71 | // 72 | 73 | /* Enable stack protection */ 74 | #if defined(__ELF__) 75 | .section .note.GNU-stack,"",%progbits 76 | #endif 77 | -------------------------------------------------------------------------------- /i387/e_fmod.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by: 3 | * J.T. Conklin (jtc@netbsd.org) 4 | * Public domain. 5 | */ 6 | 7 | #include 8 | //__FBSDID("$FreeBSD: src/lib/msun/i387/e_fmod.S,v 1.11 2011/01/07 16:13:12 kib Exp $") 9 | 10 | ENTRY(fmod) 11 | fldl 12(%esp) 12 | fldl 4(%esp) 13 | 1: fprem 14 | fstsw %ax 15 | sahf 16 | jp 1b 17 | fstp %st(1) 18 | ret 19 | END(fmod) 20 | 21 | 22 | /* Enable stack protection */ 23 | #if defined(__ELF__) 24 | .section .note.GNU-stack,"",%progbits 25 | #endif 26 | -------------------------------------------------------------------------------- /i387/e_log.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by: 3 | * J.T. Conklin (jtc@netbsd.org) 4 | * Public domain. 5 | */ 6 | 7 | #include 8 | //__FBSDID("$FreeBSD: src/lib/msun/i387/e_log.S,v 1.10 2011/01/07 16:13:12 kib Exp $") 9 | 10 | ENTRY(log) 11 | fldln2 12 | fldl 4(%esp) 13 | fyl2x 14 | ret 15 | END(log) 16 | 17 | 18 | /* Enable stack protection */ 19 | #if defined(__ELF__) 20 | .section .note.GNU-stack,"",%progbits 21 | #endif 22 | -------------------------------------------------------------------------------- /i387/e_log10.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by: 3 | * J.T. Conklin (jtc@netbsd.org) 4 | * Public domain. 5 | */ 6 | 7 | #include 8 | //__FBSDID("$FreeBSD: src/lib/msun/i387/e_log10.S,v 1.10 2011/01/07 16:13:12 kib Exp $") 9 | 10 | ENTRY(log10) 11 | fldlg2 12 | fldl 4(%esp) 13 | fyl2x 14 | ret 15 | END(log10) 16 | 17 | 18 | /* Enable stack protection */ 19 | #if defined(__ELF__) 20 | .section .note.GNU-stack,"",%progbits 21 | #endif 22 | -------------------------------------------------------------------------------- /i387/e_log10f.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by J.T. Conklin . 3 | * Public domain. 4 | */ 5 | 6 | #include 7 | 8 | //__FBSDID("$FreeBSD: src/lib/msun/i387/e_log10f.S,v 1.4 2011/01/07 16:13:12 kib Exp $"); 9 | /* RCSID("$NetBSD: e_log10f.S,v 1.1 1996/07/03 16:50:22 jtc Exp $") */ 10 | 11 | ENTRY(log10f) 12 | fldlg2 13 | flds 4(%esp) 14 | fyl2x 15 | ret 16 | END(log10f) 17 | 18 | 19 | /* Enable stack protection */ 20 | #if defined(__ELF__) 21 | .section .note.GNU-stack,"",%progbits 22 | #endif 23 | -------------------------------------------------------------------------------- /i387/e_logf.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by J.T. Conklin . 3 | * Public domain. 4 | */ 5 | 6 | #include 7 | 8 | //__FBSDID("$FreeBSD: src/lib/msun/i387/e_logf.S,v 1.3 2011/01/07 16:13:12 kib Exp $"); 9 | /* RCSID("$NetBSD: e_logf.S,v 1.2 1996/07/06 00:15:45 jtc Exp $") */ 10 | 11 | ENTRY(logf) 12 | fldln2 13 | flds 4(%esp) 14 | fyl2x 15 | ret 16 | 17 | 18 | /* Enable stack protection */ 19 | #if defined(__ELF__) 20 | .section .note.GNU-stack,"",%progbits 21 | #endif 22 | -------------------------------------------------------------------------------- /i387/e_remainder.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by: 3 | * J.T. Conklin (jtc@netbsd.org) 4 | * Public domain. 5 | */ 6 | 7 | #include 8 | //__FBSDID("$FreeBSD: src/lib/msun/i387/e_remainder.S,v 1.11 2011/01/07 16:13:12 kib Exp $") 9 | 10 | ENTRY(remainder) 11 | fldl 12(%esp) 12 | fldl 4(%esp) 13 | 1: fprem1 14 | fstsw %ax 15 | sahf 16 | jp 1b 17 | fstp %st(1) 18 | ret 19 | END(remainder) 20 | 21 | 22 | /* Enable stack protection */ 23 | #if defined(__ELF__) 24 | .section .note.GNU-stack,"",%progbits 25 | #endif 26 | -------------------------------------------------------------------------------- /i387/e_remainderf.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by J.T. Conklin . 3 | * Public domain. 4 | */ 5 | 6 | #include 7 | 8 | //__FBSDID("$FreeBSD: src/lib/msun/i387/e_remainderf.S,v 1.4 2011/01/07 16:13:12 kib Exp $"); 9 | /* RCSID("$NetBSD: e_remainderf.S,v 1.2 1995/05/08 23:49:47 jtc Exp $") */ 10 | 11 | ENTRY(remainderf) 12 | flds 8(%esp) 13 | flds 4(%esp) 14 | 1: fprem1 15 | fstsw %ax 16 | sahf 17 | jp 1b 18 | fstp %st(1) 19 | ret 20 | END(remainderf) 21 | 22 | 23 | /* Enable stack protection */ 24 | #if defined(__ELF__) 25 | .section .note.GNU-stack,"",%progbits 26 | #endif 27 | -------------------------------------------------------------------------------- /i387/e_remainderl.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by: 3 | * J.T. Conklin (jtc@netbsd.org) 4 | * Public domain. 5 | */ 6 | 7 | #include 8 | 9 | //__FBSDID("$FreeBSD: src/lib/msun/i387/e_remainderl.S,v 1.2 2011/01/07 16:13:12 kib Exp $") 10 | 11 | ENTRY(remainderl) 12 | fldt 16(%esp) 13 | fldt 4(%esp) 14 | 1: fprem1 15 | fstsw %ax 16 | sahf 17 | jp 1b 18 | fstp %st(1) 19 | ret 20 | 21 | 22 | /* Enable stack protection */ 23 | #if defined(__ELF__) 24 | .section .note.GNU-stack,"",%progbits 25 | #endif 26 | -------------------------------------------------------------------------------- /i387/e_sqrt.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by: 3 | * J.T. Conklin (jtc@netbsd.org) 4 | * Public domain. 5 | */ 6 | 7 | #include 8 | //__FBSDID("$FreeBSD: src/lib/msun/i387/e_sqrt.S,v 1.10 2011/01/07 16:13:12 kib Exp $") 9 | 10 | ENTRY(sqrt) 11 | pushl %ebp 12 | movl %esp,%ebp 13 | subl $8,%esp 14 | 15 | fstcw -4(%ebp) /* store fpu control word */ 16 | movw -4(%ebp),%dx 17 | andw $0xfeff,%dx /* Set precision field to 64 bits (53 bit mantissa). 18 | We assume it's set to 0b11 (extended precision), 19 | so zeroing out the low bit of the precision field, 20 | will correctly set the precision */ 21 | movw %dx,-8(%ebp) 22 | fldcw -8(%ebp) /* load modfied control word */ 23 | 24 | fldl 8(%ebp) 25 | fsqrt 26 | 27 | fldcw -4(%ebp) /* restore original control word */ 28 | 29 | leave 30 | ret 31 | END(sqrt) 32 | 33 | 34 | /* Enable stack protection */ 35 | #if defined(__ELF__) 36 | .section .note.GNU-stack,"",%progbits 37 | #endif 38 | -------------------------------------------------------------------------------- /i387/e_sqrtf.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by J.T. Conklin . 3 | * Public domain. 4 | */ 5 | 6 | #include 7 | 8 | //__FBSDID("$FreeBSD: src/lib/msun/i387/e_sqrtf.S,v 1.4 2011/01/07 16:13:12 kib Exp $"); 9 | /* RCSID("$NetBSD: e_sqrtf.S,v 1.2 1995/05/08 23:50:14 jtc Exp $") */ 10 | 11 | ENTRY(sqrtf) 12 | flds 4(%esp) 13 | fsqrt 14 | ret 15 | END(sqrtf) 16 | 17 | 18 | /* Enable stack protection */ 19 | #if defined(__ELF__) 20 | .section .note.GNU-stack,"",%progbits 21 | #endif 22 | -------------------------------------------------------------------------------- /i387/e_sqrtl.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by: 3 | * J.T. Conklin (jtc@netbsd.org) 4 | * Public domain. 5 | */ 6 | 7 | #include 8 | //__FBSDID("$FreeBSD: src/lib/msun/i387/e_sqrtl.S,v 1.3 2011/01/07 16:13:12 kib Exp $") 9 | 10 | ENTRY(sqrtl) 11 | fldt 4(%esp) 12 | fsqrt 13 | ret 14 | 15 | 16 | /* Enable stack protection */ 17 | #if defined(__ELF__) 18 | .section .note.GNU-stack,"",%progbits 19 | #endif 20 | -------------------------------------------------------------------------------- /i387/s_ceil.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by: 3 | * J.T. Conklin (jtc@netbsd.org) 4 | * Public domain. 5 | */ 6 | 7 | #include 8 | 9 | ENTRY(ceil) 10 | pushl %ebp 11 | movl %esp,%ebp 12 | subl $8,%esp 13 | 14 | fstcw -4(%ebp) /* store fpu control word */ 15 | movw -4(%ebp),%dx 16 | orw $0x0800,%dx /* round towards +oo */ 17 | andw $0xfbff,%dx 18 | movw %dx,-8(%ebp) 19 | fldcw -8(%ebp) /* load modfied control word */ 20 | 21 | fldl 8(%ebp); /* round */ 22 | frndint 23 | 24 | fldcw -4(%ebp) /* restore original control word */ 25 | 26 | leave 27 | ret 28 | END(ceil) 29 | 30 | 31 | /* Enable stack protection */ 32 | #if defined(__ELF__) 33 | .section .note.GNU-stack,"",%progbits 34 | #endif 35 | -------------------------------------------------------------------------------- /i387/s_ceilf.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by J.T. Conklin . 3 | * Public domain. 4 | */ 5 | 6 | #include 7 | 8 | //__FBSDID("$FreeBSD: src/lib/msun/i387/s_ceilf.S,v 1.4 2011/01/07 16:13:12 kib Exp $"); 9 | /* RCSID("$NetBSD: s_ceilf.S,v 1.3 1995/05/08 23:52:44 jtc Exp $") */ 10 | 11 | ENTRY(ceilf) 12 | pushl %ebp 13 | movl %esp,%ebp 14 | subl $8,%esp 15 | 16 | fstcw -4(%ebp) /* store fpu control word */ 17 | movw -4(%ebp),%dx 18 | orw $0x0800,%dx /* round towards +oo */ 19 | andw $0xfbff,%dx 20 | movw %dx,-8(%ebp) 21 | fldcw -8(%ebp) /* load modfied control word */ 22 | 23 | flds 8(%ebp); /* round */ 24 | frndint 25 | 26 | fldcw -4(%ebp) /* restore original control word */ 27 | 28 | leave 29 | ret 30 | END(ceilf) 31 | 32 | 33 | /* Enable stack protection */ 34 | #if defined(__ELF__) 35 | .section .note.GNU-stack,"",%progbits 36 | #endif 37 | -------------------------------------------------------------------------------- /i387/s_ceill.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Based on code written by J.T. Conklin . 3 | * Public domain. 4 | */ 5 | 6 | #include 7 | //__FBSDID("$FreeBSD: src/lib/msun/i387/s_ceill.S,v 1.3 2011/01/07 16:13:12 kib Exp $") 8 | 9 | ENTRY(ceill) 10 | pushl %ebp 11 | movl %esp,%ebp 12 | subl $8,%esp 13 | 14 | fstcw -4(%ebp) /* store fpu control word */ 15 | movw -4(%ebp),%dx 16 | orw $0x0800,%dx /* round towards +oo */ 17 | andw $0xfbff,%dx 18 | movw %dx,-8(%ebp) 19 | fldcw -8(%ebp) /* load modfied control word */ 20 | 21 | fldt 8(%ebp) /* round */ 22 | frndint 23 | 24 | fldcw -4(%ebp) /* restore original control word */ 25 | 26 | leave 27 | ret 28 | END(ceill) 29 | 30 | 31 | /* Enable stack protection */ 32 | #if defined(__ELF__) 33 | .section .note.GNU-stack,"",%progbits 34 | #endif 35 | -------------------------------------------------------------------------------- /i387/s_copysign.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by: 3 | * J.T. Conklin (jtc@netbsd.org) 4 | * Public domain. 5 | */ 6 | 7 | #include 8 | //__FBSDID("$FreeBSD: src/lib/msun/i387/s_copysign.S,v 1.9 2011/01/07 16:13:12 kib Exp $") 9 | 10 | ENTRY(copysign) 11 | movl 16(%esp),%edx 12 | andl $0x80000000,%edx 13 | movl 8(%esp),%eax 14 | andl $0x7fffffff,%eax 15 | orl %edx,%eax 16 | movl %eax,8(%esp) 17 | fldl 4(%esp) 18 | ret 19 | END(copysign) 20 | 21 | 22 | /* Enable stack protection */ 23 | #if defined(__ELF__) 24 | .section .note.GNU-stack,"",%progbits 25 | #endif 26 | -------------------------------------------------------------------------------- /i387/s_copysignf.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by J.T. Conklin . 3 | * Public domain. 4 | */ 5 | 6 | #include 7 | 8 | //__FBSDID("$FreeBSD: src/lib/msun/i387/s_copysignf.S,v 1.3 2011/01/07 16:13:12 kib Exp $"); 9 | /* RCSID("$NetBSD: s_copysignf.S,v 1.3 1995/05/08 23:53:25 jtc Exp $") */ 10 | 11 | ENTRY(copysignf) 12 | movl 8(%esp),%edx 13 | andl $0x80000000,%edx 14 | movl 4(%esp),%eax 15 | andl $0x7fffffff,%eax 16 | orl %edx,%eax 17 | movl %eax,4(%esp) 18 | flds 4(%esp) 19 | ret 20 | END(copysignf) 21 | 22 | 23 | /* Enable stack protection */ 24 | #if defined(__ELF__) 25 | .section .note.GNU-stack,"",%progbits 26 | #endif 27 | -------------------------------------------------------------------------------- /i387/s_copysignl.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Based on code written by J.T. Conklin . 3 | * Public domain. 4 | */ 5 | 6 | #include 7 | //__FBSDID("$FreeBSD: src/lib/msun/i387/s_copysignl.S,v 1.3 2011/01/07 16:13:12 kib Exp $") 8 | 9 | ENTRY(copysignl) 10 | movl 24(%esp),%edx 11 | andl $0x8000,%edx 12 | movl 12(%esp),%eax 13 | andl $0x7fff,%eax 14 | orl %edx,%eax 15 | movl %eax,12(%esp) 16 | fldt 4(%esp) 17 | ret 18 | END(copysignl) 19 | 20 | 21 | /* Enable stack protection */ 22 | #if defined(__ELF__) 23 | .section .note.GNU-stack,"",%progbits 24 | #endif 25 | -------------------------------------------------------------------------------- /i387/s_cos.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by: 3 | * J.T. Conklin (jtc@netbsd.org) 4 | * Public domain. 5 | */ 6 | 7 | #include 8 | //__FBSDID("$FreeBSD: src/lib/msun/i387/s_cos.S,v 1.9 2011/01/07 16:13:12 kib Exp $") 9 | 10 | ENTRY(cos) 11 | fldl 4(%esp) 12 | fcos 13 | fnstsw %ax 14 | andw $0x400,%ax 15 | jnz 1f 16 | ret 17 | 1: fldpi 18 | fadd %st(0) 19 | fxch %st(1) 20 | 2: fprem1 21 | fnstsw %ax 22 | andw $0x400,%ax 23 | jnz 2b 24 | fstp %st(1) 25 | fcos 26 | ret 27 | END(cos) 28 | 29 | 30 | /* Enable stack protection */ 31 | #if defined(__ELF__) 32 | .section .note.GNU-stack,"",%progbits 33 | #endif 34 | -------------------------------------------------------------------------------- /i387/s_floor.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by: 3 | * J.T. Conklin (jtc@netbsd.org) 4 | * Public domain. 5 | */ 6 | 7 | #include 8 | //__FBSDID("$FreeBSD: src/lib/msun/i387/s_floor.S,v 1.10 2011/01/07 16:13:12 kib Exp $") 9 | 10 | ENTRY(floor) 11 | pushl %ebp 12 | movl %esp,%ebp 13 | subl $8,%esp 14 | 15 | fstcw -4(%ebp) /* store fpu control word */ 16 | movw -4(%ebp),%dx 17 | orw $0x0400,%dx /* round towards -oo */ 18 | andw $0xf7ff,%dx 19 | movw %dx,-8(%ebp) 20 | fldcw -8(%ebp) /* load modfied control word */ 21 | 22 | fldl 8(%ebp); /* round */ 23 | frndint 24 | 25 | fldcw -4(%ebp) /* restore original control word */ 26 | 27 | leave 28 | ret 29 | END(floor) 30 | 31 | 32 | /* Enable stack protection */ 33 | #if defined(__ELF__) 34 | .section .note.GNU-stack,"",%progbits 35 | #endif 36 | -------------------------------------------------------------------------------- /i387/s_floorf.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by J.T. Conklin . 3 | * Public domain. 4 | */ 5 | 6 | #include 7 | 8 | //__FBSDID("$FreeBSD: src/lib/msun/i387/s_floorf.S,v 1.4 2011/01/07 16:13:12 kib Exp $"); 9 | /* RCSID("$NetBSD: s_floorf.S,v 1.3 1995/05/09 00:04:32 jtc Exp $") */ 10 | 11 | ENTRY(floorf) 12 | pushl %ebp 13 | movl %esp,%ebp 14 | subl $8,%esp 15 | 16 | fstcw -4(%ebp) /* store fpu control word */ 17 | movw -4(%ebp),%dx 18 | orw $0x0400,%dx /* round towards -oo */ 19 | andw $0xf7ff,%dx 20 | movw %dx,-8(%ebp) 21 | fldcw -8(%ebp) /* load modfied control word */ 22 | 23 | flds 8(%ebp); /* round */ 24 | frndint 25 | 26 | fldcw -4(%ebp) /* restore original control word */ 27 | 28 | leave 29 | ret 30 | END(floorf) 31 | 32 | 33 | /* Enable stack protection */ 34 | #if defined(__ELF__) 35 | .section .note.GNU-stack,"",%progbits 36 | #endif 37 | -------------------------------------------------------------------------------- /i387/s_floorl.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Based on code written by J.T. Conklin . 3 | * Public domain. 4 | */ 5 | 6 | #include 7 | //__FBSDID("$FreeBSD: src/lib/msun/i387/s_floorl.S,v 1.3 2011/01/07 16:13:12 kib Exp $") 8 | 9 | ENTRY(floorl) 10 | pushl %ebp 11 | movl %esp,%ebp 12 | subl $8,%esp 13 | 14 | fstcw -4(%ebp) /* store fpu control word */ 15 | movw -4(%ebp),%dx 16 | orw $0x0400,%dx /* round towards -oo */ 17 | andw $0xf7ff,%dx 18 | movw %dx,-8(%ebp) 19 | fldcw -8(%ebp) /* load modfied control word */ 20 | 21 | fldt 8(%ebp) /* round */ 22 | frndint 23 | 24 | fldcw -4(%ebp) /* restore original control word */ 25 | 26 | leave 27 | ret 28 | END(floorl) 29 | 30 | 31 | /* Enable stack protection */ 32 | #if defined(__ELF__) 33 | .section .note.GNU-stack,"",%progbits 34 | #endif 35 | -------------------------------------------------------------------------------- /i387/s_llrint.S: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2005 David Schultz 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | //__FBSDID("$FreeBSD: src/lib/msun/i387/s_llrint.S,v 1.3 2011/01/07 16:13:12 kib Exp $"); 29 | 30 | ENTRY(llrint) 31 | fldl 4(%esp) 32 | subl $8,%esp 33 | fistpll (%esp) 34 | popl %eax 35 | popl %edx 36 | ret 37 | END(llrint) 38 | 39 | 40 | /* Enable stack protection */ 41 | #if defined(__ELF__) 42 | .section .note.GNU-stack,"",%progbits 43 | #endif 44 | -------------------------------------------------------------------------------- /i387/s_llrintf.S: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2005 David Schultz 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | //__FBSDID("$FreeBSD: src/lib/msun/i387/s_llrintf.S,v 1.3 2011/01/07 16:13:12 kib Exp $") 29 | 30 | ENTRY(llrintf) 31 | flds 4(%esp) 32 | subl $8,%esp 33 | fistpll (%esp) 34 | popl %eax 35 | popl %edx 36 | ret 37 | END(llrintf) 38 | 39 | 40 | /* Enable stack protection */ 41 | #if defined(__ELF__) 42 | .section .note.GNU-stack,"",%progbits 43 | #endif 44 | -------------------------------------------------------------------------------- /i387/s_llrintl.S: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2005 David Schultz 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | //__FBSDID("$FreeBSD: src/lib/msun/i387/s_llrintl.S,v 1.2 2011/01/07 16:13:12 kib Exp $"); 29 | 30 | ENTRY(llrintl) 31 | fldt 4(%esp) 32 | subl $8,%esp 33 | fistpll (%esp) 34 | popl %eax 35 | popl %edx 36 | ret 37 | 38 | 39 | /* Enable stack protection */ 40 | #if defined(__ELF__) 41 | .section .note.GNU-stack,"",%progbits 42 | #endif 43 | -------------------------------------------------------------------------------- /i387/s_logb.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by: 3 | * J.T. Conklin (jtc@netbsd.org) 4 | * Public domain. 5 | */ 6 | 7 | #include 8 | //__FBSDID("$FreeBSD: src/lib/msun/i387/s_logb.S,v 1.10 2011/01/07 16:13:12 kib Exp $") 9 | 10 | ENTRY(logb) 11 | fldl 4(%esp) 12 | fxtract 13 | fstp %st 14 | ret 15 | END(logb) 16 | 17 | 18 | /* Enable stack protection */ 19 | #if defined(__ELF__) 20 | .section .note.GNU-stack,"",%progbits 21 | #endif 22 | -------------------------------------------------------------------------------- /i387/s_logbf.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by J.T. Conklin . 3 | * Public domain. 4 | */ 5 | 6 | #include 7 | 8 | //__FBSDID("$FreeBSD: src/lib/msun/i387/s_logbf.S,v 1.3 2011/01/07 16:13:12 kib Exp $"); 9 | /* RCSID("$NetBSD: s_logbf.S,v 1.3 1995/05/09 00:15:12 jtc Exp $") */ 10 | 11 | ENTRY(logbf) 12 | flds 4(%esp) 13 | fxtract 14 | fstp %st 15 | ret 16 | END(logbf) 17 | 18 | 19 | /* Enable stack protection */ 20 | #if defined(__ELF__) 21 | .section .note.GNU-stack,"",%progbits 22 | #endif 23 | -------------------------------------------------------------------------------- /i387/s_logbl.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by: 3 | * J.T. Conklin (jtc@netbsd.org) 4 | * Public domain. 5 | */ 6 | 7 | #include 8 | //__FBSDID("$FreeBSD: src/lib/msun/i387/s_logbl.S,v 1.3 2011/01/07 16:13:12 kib Exp $") 9 | 10 | ENTRY(logbl) 11 | fldt 4(%esp) 12 | fxtract 13 | fstp %st 14 | ret 15 | 16 | 17 | /* Enable stack protection */ 18 | #if defined(__ELF__) 19 | .section .note.GNU-stack,"",%progbits 20 | #endif 21 | -------------------------------------------------------------------------------- /i387/s_lrint.S: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2005 David Schultz 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | //__FBSDID("$FreeBSD: src/lib/msun/i387/s_lrint.S,v 1.3 2011/01/07 16:13:12 kib Exp $"); 29 | 30 | ENTRY(lrint) 31 | fldl 4(%esp) 32 | subl $4,%esp 33 | fistpl (%esp) 34 | popl %eax 35 | ret 36 | END(lrint) 37 | 38 | 39 | /* Enable stack protection */ 40 | #if defined(__ELF__) 41 | .section .note.GNU-stack,"",%progbits 42 | #endif 43 | -------------------------------------------------------------------------------- /i387/s_lrintf.S: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2005 David Schultz 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | //__FBSDID("$FreeBSD: src/lib/msun/i387/s_lrintf.S,v 1.3 2011/01/07 16:13:12 kib Exp $") 29 | 30 | ENTRY(lrintf) 31 | flds 4(%esp) 32 | subl $4,%esp 33 | fistpl (%esp) 34 | popl %eax 35 | ret 36 | END(lrintf) 37 | 38 | 39 | /* Enable stack protection */ 40 | #if defined(__ELF__) 41 | .section .note.GNU-stack,"",%progbits 42 | #endif 43 | -------------------------------------------------------------------------------- /i387/s_lrintl.S: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2008 David Schultz 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | //__FBSDID("$FreeBSD: src/lib/msun/i387/s_lrintl.S,v 1.2 2011/01/07 16:13:12 kib Exp $"); 29 | 30 | ENTRY(lrintl) 31 | fldt 4(%esp) 32 | subl $4,%esp 33 | fistpl (%esp) 34 | popl %eax 35 | ret 36 | 37 | 38 | /* Enable stack protection */ 39 | #if defined(__ELF__) 40 | .section .note.GNU-stack,"",%progbits 41 | #endif 42 | -------------------------------------------------------------------------------- /i387/s_rint.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by: 3 | * J.T. Conklin (jtc@netbsd.org) 4 | * Public domain. 5 | */ 6 | 7 | #include 8 | //__FBSDID("$FreeBSD: src/lib/msun/i387/s_rint.S,v 1.9 2011/01/07 16:13:12 kib Exp $") 9 | 10 | ENTRY(rint) 11 | fldl 4(%esp) 12 | frndint 13 | ret 14 | END(rint) 15 | 16 | 17 | /* Enable stack protection */ 18 | #if defined(__ELF__) 19 | .section .note.GNU-stack,"",%progbits 20 | #endif 21 | -------------------------------------------------------------------------------- /i387/s_rintf.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by J.T. Conklin . 3 | * Public domain. 4 | */ 5 | 6 | #include 7 | 8 | //__FBSDID("$FreeBSD: src/lib/msun/i387/s_rintf.S,v 1.3 2011/01/07 16:13:12 kib Exp $"); 9 | /* RCSID("$NetBSD: s_rintf.S,v 1.3 1995/05/09 00:17:22 jtc Exp $") */ 10 | 11 | ENTRY(rintf) 12 | flds 4(%esp) 13 | frndint 14 | ret 15 | END(rintf) 16 | 17 | 18 | /* Enable stack protection */ 19 | #if defined(__ELF__) 20 | .section .note.GNU-stack,"",%progbits 21 | #endif 22 | -------------------------------------------------------------------------------- /i387/s_rintl.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by: 3 | * J.T. Conklin (jtc@netbsd.org) 4 | * Public domain. 5 | */ 6 | 7 | #include 8 | //__FBSDID("$FreeBSD: src/lib/msun/i387/s_rintl.S,v 1.3 2011/01/07 16:13:12 kib Exp $") 9 | 10 | ENTRY(rintl) 11 | fldt 4(%esp) 12 | frndint 13 | ret 14 | 15 | 16 | /* Enable stack protection */ 17 | #if defined(__ELF__) 18 | .section .note.GNU-stack,"",%progbits 19 | #endif 20 | -------------------------------------------------------------------------------- /i387/s_scalbn.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by: 3 | * J.T. Conklin (jtc@netbsd.org) 4 | * Public domain. 5 | */ 6 | 7 | #include 8 | //__FBSDID("$FreeBSD: src/lib/msun/i387/s_scalbn.S,v 1.10 2011/01/07 16:13:12 kib Exp $") 9 | 10 | ENTRY(scalbn) 11 | fildl 12(%esp) 12 | fldl 4(%esp) 13 | fscale 14 | fstp %st(1) 15 | ret 16 | END(scalbn) 17 | 18 | .globl CNAME(ldexp) 19 | .set CNAME(ldexp),CNAME(scalbn) 20 | /* Enable stack protection */ 21 | #if defined(__ELF__) 22 | .section .note.GNU-stack,"",%progbits 23 | #endif 24 | -------------------------------------------------------------------------------- /i387/s_scalbnf.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by J.T. Conklin . 3 | * Public domain. 4 | */ 5 | 6 | #include 7 | 8 | //__FBSDID("$FreeBSD: src/lib/msun/i387/s_scalbnf.S,v 1.4 2011/01/07 16:13:12 kib Exp $"); 9 | /* RCSID("$NetBSD: s_scalbnf.S,v 1.4 1999/01/02 05:15:40 kristerw Exp $") */ 10 | 11 | ENTRY(scalbnf) 12 | fildl 8(%esp) 13 | flds 4(%esp) 14 | fscale 15 | fstp %st(1) /* bug fix for fp stack overflow */ 16 | ret 17 | END(scalbnf) 18 | 19 | .globl CNAME(ldexpf) 20 | .set CNAME(ldexpf),CNAME(scalbnf) 21 | 22 | 23 | /* Enable stack protection */ 24 | #if defined(__ELF__) 25 | .section .note.GNU-stack,"",%progbits 26 | #endif 27 | -------------------------------------------------------------------------------- /i387/s_scalbnl.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by J.T. Conklin . 3 | * Public domain. 4 | */ 5 | 6 | #include 7 | 8 | //__FBSDID("$FreeBSD: src/lib/msun/i387/s_scalbnl.S,v 1.3 2011/01/07 16:13:12 kib Exp $"); 9 | /* RCSID("$NetBSD: s_scalbnf.S,v 1.4 1999/01/02 05:15:40 kristerw Exp $") */ 10 | 11 | ENTRY(scalbnl) 12 | fildl 16(%esp) 13 | fldt 4(%esp) 14 | fscale 15 | fstp %st(1) 16 | ret 17 | END(scalbnl) 18 | 19 | .globl CNAME(ldexpl) 20 | .set CNAME(ldexpl),CNAME(scalbnl) 21 | 22 | 23 | /* Enable stack protection */ 24 | #if defined(__ELF__) 25 | .section .note.GNU-stack,"",%progbits 26 | #endif 27 | -------------------------------------------------------------------------------- /i387/s_sin.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by: 3 | * J.T. Conklin (jtc@netbsd.org) 4 | * Public domain. 5 | */ 6 | 7 | #include 8 | //__FBSDID("$FreeBSD: src/lib/msun/i387/s_sin.S,v 1.9 2011/01/07 16:13:12 kib Exp $") 9 | 10 | ENTRY(sin) 11 | fldl 4(%esp) 12 | fsin 13 | fnstsw %ax 14 | andw $0x400,%ax 15 | jnz 1f 16 | ret 17 | 1: fldpi 18 | fadd %st(0) 19 | fxch %st(1) 20 | 2: fprem1 21 | fnstsw %ax 22 | andw $0x400,%ax 23 | jnz 2b 24 | fstp %st(1) 25 | fsin 26 | ret 27 | END(sin) 28 | 29 | 30 | /* Enable stack protection */ 31 | #if defined(__ELF__) 32 | .section .note.GNU-stack,"",%progbits 33 | #endif 34 | -------------------------------------------------------------------------------- /i387/s_tan.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by: 3 | * J.T. Conklin (jtc@netbsd.org) 4 | * Public domain. 5 | */ 6 | 7 | #include 8 | //__FBSDID("$FreeBSD: src/lib/msun/i387/s_tan.S,v 1.9 2011/01/07 16:13:12 kib Exp $") 9 | 10 | ENTRY(tan) 11 | fldl 4(%esp) 12 | fptan 13 | fnstsw %ax 14 | andw $0x400,%ax 15 | jnz 1f 16 | fstp %st(0) 17 | ret 18 | 1: fldpi 19 | fadd %st(0) 20 | fxch %st(1) 21 | 2: fprem1 22 | fstsw %ax 23 | andw $0x400,%ax 24 | jnz 2b 25 | fstp %st(1) 26 | fptan 27 | fstp %st(0) 28 | ret 29 | END(tan) 30 | 31 | 32 | /* Enable stack protection */ 33 | #if defined(__ELF__) 34 | .section .note.GNU-stack,"",%progbits 35 | #endif 36 | -------------------------------------------------------------------------------- /i387/s_trunc.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Based on code written by J.T. Conklin . 3 | * Public domain. 4 | */ 5 | 6 | #include 7 | //__FBSDID("$FreeBSD: src/lib/msun/i387/s_trunc.S,v 1.3 2011/01/07 16:13:12 kib Exp $") 8 | 9 | ENTRY(trunc) 10 | pushl %ebp 11 | movl %esp,%ebp 12 | subl $8,%esp 13 | 14 | fstcw -4(%ebp) /* store fpu control word */ 15 | movw -4(%ebp),%dx 16 | orw $0x0c00,%dx /* round towards -oo */ 17 | movw %dx,-8(%ebp) 18 | fldcw -8(%ebp) /* load modfied control word */ 19 | 20 | fldl 8(%ebp) /* round */ 21 | frndint 22 | 23 | fldcw -4(%ebp) /* restore original control word */ 24 | 25 | leave 26 | ret 27 | END(trunc) 28 | 29 | 30 | /* Enable stack protection */ 31 | #if defined(__ELF__) 32 | .section .note.GNU-stack,"",%progbits 33 | #endif 34 | -------------------------------------------------------------------------------- /i387/s_truncf.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Based on code written by J.T. Conklin . 3 | * Public domain. 4 | */ 5 | 6 | #include 7 | //__FBSDID("$FreeBSD: src/lib/msun/i387/s_truncf.S,v 1.4 2011/01/07 16:13:12 kib Exp $") 8 | 9 | ENTRY(truncf) 10 | pushl %ebp 11 | movl %esp,%ebp 12 | subl $8,%esp 13 | 14 | fstcw -4(%ebp) /* store fpu control word */ 15 | movw -4(%ebp),%dx 16 | orw $0x0c00,%dx /* round towards -oo */ 17 | movw %dx,-8(%ebp) 18 | fldcw -8(%ebp) /* load modfied control word */ 19 | 20 | flds 8(%ebp) /* round */ 21 | frndint 22 | 23 | fldcw -4(%ebp) /* restore original control word */ 24 | 25 | leave 26 | ret 27 | END(truncf) 28 | 29 | 30 | /* Enable stack protection */ 31 | #if defined(__ELF__) 32 | .section .note.GNU-stack,"",%progbits 33 | #endif 34 | -------------------------------------------------------------------------------- /i387/s_truncl.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Based on code written by J.T. Conklin . 3 | * Public domain. 4 | */ 5 | 6 | #include 7 | //__FBSDID("$FreeBSD: src/lib/msun/i387/s_truncl.S,v 1.3 2011/01/07 16:13:12 kib Exp $") 8 | 9 | ENTRY(truncl) 10 | pushl %ebp 11 | movl %esp,%ebp 12 | subl $8,%esp 13 | 14 | fstcw -4(%ebp) /* store fpu control word */ 15 | movw -4(%ebp),%dx 16 | orw $0x0c00,%dx /* round towards -oo */ 17 | movw %dx,-8(%ebp) 18 | fldcw -8(%ebp) /* load modfied control word */ 19 | 20 | fldt 8(%ebp) /* round */ 21 | frndint 22 | 23 | fldcw -4(%ebp) /* restore original control word */ 24 | 25 | leave 26 | ret 27 | END(truncl) 28 | 29 | 30 | /* Enable stack protection */ 31 | #if defined(__ELF__) 32 | .section .note.GNU-stack,"",%progbits 33 | #endif 34 | -------------------------------------------------------------------------------- /include/openlibm.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENLIBM_H 2 | #define OPENLIBM_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #endif /* !OPENLIBM_H */ 9 | -------------------------------------------------------------------------------- /include/openlibm_defs.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENLIBM_DEFS_H_ 2 | #define OPENLIBM_DEFS_H_ 3 | 4 | #ifdef _WIN32 5 | # ifdef IMPORT_EXPORTS 6 | # define OLM_DLLEXPORT __declspec(dllimport) 7 | # else 8 | # define OLM_DLLEXPORT __declspec(dllexport) 9 | # endif 10 | #else 11 | #define OLM_DLLEXPORT __attribute__ ((visibility("default"))) 12 | #endif 13 | 14 | #endif // OPENLIBM_DEFS_H_ 15 | -------------------------------------------------------------------------------- /include/openlibm_fenv.h: -------------------------------------------------------------------------------- 1 | #ifdef OPENLIBM_USE_HOST_FENV_H 2 | #include 3 | #else /* !OPENLIBM_USE_HOST_FENV_H */ 4 | 5 | #if defined(__aarch64__) 6 | #include 7 | #elif defined(__arm__) 8 | #include 9 | #elif defined(__x86_64__) 10 | #include 11 | #elif defined(__i386__) 12 | #include 13 | #elif defined(__powerpc__) || defined(__POWERPC__) 14 | #include 15 | #elif defined(__mips__) 16 | #include 17 | #elif defined(__s390__) 18 | #include 19 | #elif defined(__riscv) 20 | #include 21 | #elif defined(__loongarch64) 22 | #include 23 | #else 24 | #error "Unsupported platform" 25 | #endif 26 | 27 | #endif /* OPENLIBM_USE_HOST_FENV_H */ 28 | -------------------------------------------------------------------------------- /ld128/Make.files: -------------------------------------------------------------------------------- 1 | $(CUR_SRCS) += invtrig.c \ 2 | e_acoshl.c e_powl.c k_tanl.c s_exp2l.c \ 3 | e_atanhl.c e_lgammal_r.c e_sinhl.c s_asinhl.c s_expm1l.c \ 4 | e_coshl.c e_log10l.c e_tgammal.c \ 5 | e_expl.c e_log2l.c k_cosl.c s_log1pl.c s_tanhl.c \ 6 | e_logl.c k_sinl.c s_erfl.c 7 | 8 | # s_remquol.c e_fmodl.c s_truncl.c 9 | # e_hypotl.c s_floorl.c s_nextafterl.c s_ceill.c s_modfl.c 10 | 11 | ifneq ($(OS), WINNT) 12 | $(CUR_SRCS) += s_nanl.c 13 | endif 14 | -------------------------------------------------------------------------------- /ld128/e_acoshl.c: -------------------------------------------------------------------------------- 1 | /* @(#)e_acosh.c 5.1 93/09/24 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunPro, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | */ 12 | 13 | /* acoshl(x) 14 | * Method : 15 | * Based on 16 | * acoshl(x) = logl [ x + sqrtl(x*x-1) ] 17 | * we have 18 | * acoshl(x) := logl(x)+ln2, if x is large; else 19 | * acoshl(x) := logl(2x-1/(sqrtl(x*x-1)+x)) if x>2; else 20 | * acoshl(x) := log1pl(t+sqrtl(2.0*t+t*t)); where t=x-1. 21 | * 22 | * Special cases: 23 | * acoshl(x) is NaN with signal if x<1. 24 | * acoshl(NaN) is NaN without signal. 25 | */ 26 | 27 | #include 28 | 29 | #include "math_private.h" 30 | 31 | static const long double 32 | one = 1.0, 33 | ln2 = 0.6931471805599453094172321214581766L; 34 | 35 | long double 36 | acoshl(long double x) 37 | { 38 | long double t; 39 | u_int64_t lx; 40 | int64_t hx; 41 | GET_LDOUBLE_WORDS64(hx,lx,x); 42 | if(hx<0x3fff000000000000LL) { /* x < 1 */ 43 | return (x-x)/(x-x); 44 | } else if(hx >=0x4035000000000000LL) { /* x > 2**54 */ 45 | if(hx >=0x7fff000000000000LL) { /* x is inf of NaN */ 46 | return x+x; 47 | } else 48 | return logl(x)+ln2; /* acoshl(huge)=logl(2x) */ 49 | } else if(((hx-0x3fff000000000000LL)|lx)==0) { 50 | return 0.0L; /* acosh(1) = 0 */ 51 | } else if (hx > 0x4000000000000000LL) { /* 2**28 > x > 2 */ 52 | t=x*x; 53 | return logl(2.0L*x-one/(x+sqrtl(t-one))); 54 | } else { /* 1=0.5 17 | * 1 2x x 18 | * atanhl(x) = --- * log(1 + -------) = 0.5 * log1p(2 * --------) 19 | * 2 1 - x 1 - x 20 | * 21 | * For x<0.5 22 | * atanhl(x) = 0.5*log1pl(2x+2x*x/(1-x)) 23 | * 24 | * Special cases: 25 | * atanhl(x) is NaN if |x| > 1 with signal; 26 | * atanhl(NaN) is that NaN with no signal; 27 | * atanhl(+-1) is +-INF with signal. 28 | * 29 | */ 30 | 31 | #include 32 | 33 | #include "math_private.h" 34 | 35 | static const long double one = 1.0L, huge = 1e4900L; 36 | 37 | static const long double zero = 0.0L; 38 | 39 | long double 40 | atanhl(long double x) 41 | { 42 | long double t; 43 | u_int32_t jx, ix; 44 | ieee_quad_shape_type u; 45 | 46 | u.value = x; 47 | jx = u.parts32.mswhi; 48 | ix = jx & 0x7fffffff; 49 | u.parts32.mswhi = ix; 50 | if (ix >= 0x3fff0000) /* |x| >= 1.0 or infinity or NaN */ 51 | { 52 | if (u.value == one) 53 | return x/zero; 54 | else 55 | return (x-x)/(x-x); 56 | } 57 | if(ix<0x3fc60000 && (huge+x)>zero) return x; /* x < 2^-57 */ 58 | 59 | if(ix<0x3ffe0000) { /* x < 0.5 */ 60 | t = u.value+u.value; 61 | t = 0.5*log1pl(t+t*u.value/(one-u.value)); 62 | } else 63 | t = 0.5*log1pl((u.value+u.value)/(one-u.value)); 64 | if(jx & 0x80000000) return -t; else return t; 65 | } 66 | -------------------------------------------------------------------------------- /ld128/e_tgammal.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: e_tgammal.c,v 1.1 2011/07/06 00:02:42 martynas Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 2011 Martynas Venckus 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | #include 20 | 21 | #include "math_private.h" 22 | 23 | long double 24 | tgammal(long double x) 25 | { 26 | int64_t i0,i1; 27 | 28 | GET_LDOUBLE_WORDS64(i0,i1,x); 29 | if (((i0&0x7fffffffffffffffLL)|i1) == 0) 30 | return (1.0/x); 31 | 32 | if (i0<0 && (u_int64_t)i0<0xffff000000000000ULL && rintl(x)==x) 33 | return (x-x)/(x-x); 34 | 35 | if (i0==0xffff000000000000ULL && i1==0) 36 | return (x-x); 37 | 38 | return expl(lgammal(x)); 39 | } 40 | -------------------------------------------------------------------------------- /ld128/s_floorl.c: -------------------------------------------------------------------------------- 1 | /* @(#)s_floor.c 5.1 93/09/24 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunPro, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | */ 12 | 13 | /* 14 | * floorl(x) 15 | * Return x rounded toward -inf to integral value 16 | * Method: 17 | * Bit twiddling. 18 | * Exception: 19 | * Inexact flag raised if x not equal to floor(x). 20 | */ 21 | 22 | #include 23 | 24 | #include "math_private.h" 25 | 26 | static const long double huge = 1.0e4930L; 27 | 28 | long double 29 | floorl(long double x) 30 | { 31 | int64_t i0,i1,jj0; 32 | u_int64_t i,j; 33 | GET_LDOUBLE_WORDS64(i0,i1,x); 34 | jj0 = ((i0>>48)&0x7fff)-0x3fff; 35 | if(jj0<48) { 36 | if(jj0<0) { /* raise inexact if x != 0 */ 37 | if(huge+x>0.0) { 38 | if(i0>=0) 39 | return 0.0L; 40 | else if(((i0&0x7fffffffffffffffLL)|i1)!=0) 41 | return -1.0L; 42 | } 43 | } else { 44 | i = (0x0000ffffffffffffULL)>>jj0; 45 | if(((i0&i)|i1)==0) return x; /* x is integral */ 46 | if(huge+x>0.0) { /* raise inexact flag */ 47 | if(i0<0) i0 += (0x0001000000000000LL)>>jj0; 48 | i0 &= (~i); i1=0; 49 | } 50 | } 51 | } else if (jj0>111) { 52 | if(jj0==0x4000) return x+x; /* inf or NaN */ 53 | else return x; /* x is integral */ 54 | } else { 55 | i = -1ULL>>(jj0-48); 56 | if((i1&i)==0) return x; /* x is integral */ 57 | if(huge+x>0.0) { /* raise inexact flag */ 58 | if(i0<0) { 59 | if(jj0==48) i0+=1; 60 | else { 61 | j = i1+(1LL<<(112-jj0)); 62 | if(j 30 | 31 | #include "fpmath.h" 32 | #include "math_private.h" 33 | 34 | OLM_DLLEXPORT long double 35 | nanl(const char *s) 36 | { 37 | union { 38 | union IEEEl2bits ieee; 39 | uint32_t bits[4]; 40 | } u; 41 | 42 | __scan_nan(u.bits, 4, s); 43 | u.ieee.bits.exp = 0x7fff; 44 | u.ieee.bits.manh |= 1ULL << 47; /* make it a quiet NaN */ 45 | return (u.ieee.e); 46 | } 47 | -------------------------------------------------------------------------------- /ld80/Make.files: -------------------------------------------------------------------------------- 1 | $(CUR_SRCS) += invtrig.c \ 2 | e_acoshl.c e_powl.c k_tanl.c s_exp2l.c \ 3 | e_atanhl.c e_lgammal_r.c e_sinhl.c s_asinhl.c s_expm1l.c \ 4 | e_coshl.c e_log10l.c e_tgammal.c \ 5 | e_expl.c e_log2l.c k_cosl.c s_log1pl.c s_tanhl.c \ 6 | e_logl.c k_sinl.c s_erfl.c 7 | 8 | # s_remquol.c e_fmodl.c s_truncl.c 9 | # e_hypotl.c s_floorl.c s_nextafterl.c s_ceill.c s_modfl.c 10 | 11 | ifneq ($(OS), WINNT) 12 | $(CUR_SRCS) += s_nanl.c 13 | endif 14 | -------------------------------------------------------------------------------- /ld80/e_acoshl.c: -------------------------------------------------------------------------------- 1 | /* @(#)e_acosh.c 5.1 93/09/24 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunPro, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | */ 12 | 13 | /* acoshl(x) 14 | * Method : 15 | * Based on 16 | * acoshl(x) = logl [ x + sqrtl(x*x-1) ] 17 | * we have 18 | * acoshl(x) := logl(x)+ln2, if x is large; else 19 | * acoshl(x) := logl(2x-1/(sqrtl(x*x-1)+x)) if x>2; else 20 | * acoshl(x) := log1pl(t+sqrtl(2.0*t+t*t)); where t=x-1. 21 | * 22 | * Special cases: 23 | * acoshl(x) is NaN with signal if x<1. 24 | * acoshl(NaN) is NaN without signal. 25 | */ 26 | 27 | #include 28 | 29 | #include "math_private.h" 30 | 31 | static const long double 32 | one = 1.0, 33 | ln2 = 6.931471805599453094287e-01L; /* 0x3FFE, 0xB17217F7, 0xD1CF79AC */ 34 | 35 | long double 36 | acoshl(long double x) 37 | { 38 | long double t; 39 | u_int32_t se,i0,i1; 40 | GET_LDOUBLE_WORDS(se,i0,i1,x); 41 | if(se<0x3fff || se & 0x8000) { /* x < 1 */ 42 | return (x-x)/(x-x); 43 | } else if(se >=0x401d) { /* x > 2**30 */ 44 | if(se >=0x7fff) { /* x is inf of NaN */ 45 | return x+x; 46 | } else 47 | return logl(x)+ln2; /* acoshl(huge)=logl(2x) */ 48 | } else if(((se-0x3fff)|i0|i1)==0) { 49 | return 0.0; /* acosh(1) = 0 */ 50 | } else if (se > 0x4000) { /* 2**28 > x > 2 */ 51 | t=x*x; 52 | return logl(2.0*x-one/(x+sqrtl(t-one))); 53 | } else { /* 1=0.5 17 | * 1 2x x 18 | * atanhl(x) = --- * log(1 + -------) = 0.5 * log1p(2 * --------) 19 | * 2 1 - x 1 - x 20 | * 21 | * For x<0.5 22 | * atanhl(x) = 0.5*log1pl(2x+2x*x/(1-x)) 23 | * 24 | * Special cases: 25 | * atanhl(x) is NaN if |x| > 1 with signal; 26 | * atanhl(NaN) is that NaN with no signal; 27 | * atanhl(+-1) is +-INF with signal. 28 | * 29 | */ 30 | 31 | #include 32 | 33 | #include "math_private.h" 34 | 35 | static const long double one = 1.0, huge = 1e4900L; 36 | 37 | static const long double zero = 0.0; 38 | 39 | long double 40 | atanhl(long double x) 41 | { 42 | long double t; 43 | int32_t ix; 44 | u_int32_t se,i0,i1; 45 | GET_LDOUBLE_WORDS(se,i0,i1,x); 46 | ix = se&0x7fff; 47 | if ((ix+((((i0&0x7fffffff)|i1)|(-((i0&0x7fffffff)|i1)))>>31))>0x3fff) 48 | /* |x|>1 */ 49 | return (x-x)/(x-x); 50 | if(ix==0x3fff) 51 | return x/zero; 52 | if(ix<0x3fe3&&(huge+x)>zero) return x; /* x<2**-28 */ 53 | SET_LDOUBLE_EXP(x,ix); 54 | if(ix<0x3ffe) { /* x < 0.5 */ 55 | t = x+x; 56 | t = 0.5*log1pl(t+t*x/(one-x)); 57 | } else 58 | t = 0.5*log1pl((x+x)/(one-x)); 59 | if(se<=0x7fff) return t; else return -t; 60 | } 61 | -------------------------------------------------------------------------------- /ld80/s_asinhl.c: -------------------------------------------------------------------------------- 1 | /* @(#)s_asinh.c 5.1 93/09/24 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunPro, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | */ 12 | 13 | /* asinhl(x) 14 | * Method : 15 | * Based on 16 | * asinhl(x) = signl(x) * logl [ |x| + sqrtl(x*x+1) ] 17 | * we have 18 | * asinhl(x) := x if 1+x*x=1, 19 | * := signl(x)*(logl(x)+ln2)) for large |x|, else 20 | * := signl(x)*logl(2|x|+1/(|x|+sqrtl(x*x+1))) if|x|>2, else 21 | * := signl(x)*log1pl(|x| + x^2/(1 + sqrtl(1+x^2))) 22 | */ 23 | 24 | #include 25 | 26 | #include "math_private.h" 27 | 28 | static const long double 29 | one = 1.000000000000000000000e+00L, /* 0x3FFF, 0x00000000, 0x00000000 */ 30 | ln2 = 6.931471805599453094287e-01L, /* 0x3FFE, 0xB17217F7, 0xD1CF79AC */ 31 | huge= 1.000000000000000000e+4900L; 32 | 33 | long double 34 | asinhl(long double x) 35 | { 36 | long double t,w; 37 | int32_t hx,ix; 38 | GET_LDOUBLE_EXP(hx,x); 39 | ix = hx&0x7fff; 40 | if(ix==0x7fff) return x+x; /* x is inf or NaN */ 41 | if(ix< 0x3fde) { /* |x|<2**-34 */ 42 | if(huge+x>one) return x; /* return x inexact except 0 */ 43 | } 44 | if(ix>0x4020) { /* |x| > 2**34 */ 45 | w = logl(fabsl(x))+ln2; 46 | } else if (ix>0x4000) { /* 2**34 > |x| > 2.0 */ 47 | t = fabsl(x); 48 | w = logl(2.0*t+one/(sqrtl(x*x+one)+t)); 49 | } else { /* 2.0 > |x| > 2**-28 */ 50 | t = x*x; 51 | w =log1pl(fabsl(x)+t/(one+sqrtl(one+t))); 52 | } 53 | if(hx&0x8000) return -w; else return w; 54 | } 55 | -------------------------------------------------------------------------------- /ld80/s_nanl.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2007 David Schultz 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: src/lib/msun/ld80/s_nanl.c,v 1.2 2007/12/18 23:46:31 das Exp $ 27 | */ 28 | 29 | #include 30 | 31 | #include "math_private.h" 32 | 33 | OLM_DLLEXPORT long double 34 | nanl(const char *s) 35 | { 36 | union { 37 | union IEEEl2bits ieee; 38 | uint32_t bits[3]; 39 | } u; 40 | 41 | __scan_nan(u.bits, 3, s); 42 | u.ieee.bits.exp = 0x7fff; 43 | u.ieee.bits.manh |= 0xc0000000; /* make it a quiet NaN */ 44 | return (u.ieee.e); 45 | } 46 | -------------------------------------------------------------------------------- /ld80/s_truncl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ==================================================== 3 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 4 | * 5 | * Developed at SunPro, a Sun Microsystems, Inc. business. 6 | * Permission to use, copy, modify, and distribute this 7 | * software is freely granted, provided that this notice 8 | * is preserved. 9 | * ==================================================== 10 | * 11 | * From: @(#)s_floor.c 5.1 93/09/24 12 | */ 13 | 14 | /* 15 | * truncl(x) 16 | * Return x rounded toward 0 to integral value 17 | * Method: 18 | * Bit twiddling. 19 | * Exception: 20 | * Inexact flag raised if x not equal to truncl(x). 21 | */ 22 | 23 | #include 24 | //#include 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #include "math_private.h" 31 | 32 | #ifdef LDBL_IMPLICIT_NBIT 33 | #define MANH_SIZE (EXT_FRACHBITS + 1) 34 | #else 35 | #define MANH_SIZE EXT_FRACHBITS 36 | #endif 37 | 38 | static const long double huge = 1.0e300; 39 | static const float zero[] = { 0.0, -0.0 }; 40 | 41 | long double 42 | truncl(long double x) 43 | { 44 | int e, es; 45 | uint32_t ix0, ix1; 46 | 47 | GET_LDOUBLE_WORDS(es,ix0,ix1,x); 48 | e = (es&0x7fff) - LDBL_MAX_EXP + 1; 49 | 50 | if (e < MANH_SIZE - 1) { 51 | if (e < 0) { /* raise inexact if x != 0 */ 52 | if (huge + x > 0.0) 53 | return (zero[(es&0x8000)!=0]); 54 | } else { 55 | uint64_t m = ((1llu << MANH_SIZE) - 1) >> (e + 1); 56 | if (((ix0 & m) | ix1) == 0) 57 | return (x); /* x is integral */ 58 | if (huge + x > 0.0) { /* raise inexact flag */ 59 | ix0 &= ~m; 60 | ix1 = 0; 61 | } 62 | } 63 | } else if (e < LDBL_MANT_DIG - 1) { 64 | uint64_t m = (uint64_t)-1 >> (64 - LDBL_MANT_DIG + e + 1); 65 | if ((ix1 & m) == 0) 66 | return (x); /* x is integral */ 67 | if (huge + x > 0.0) /* raise inexact flag */ 68 | ix1 &= ~m; 69 | } 70 | SET_LDOUBLE_WORDS(x,es,ix0,ix1); 71 | return (x); 72 | } 73 | -------------------------------------------------------------------------------- /loongarch64/Make.files: -------------------------------------------------------------------------------- 1 | $(CUR_SRCS) = fenv.c 2 | -------------------------------------------------------------------------------- /loongarch64/fenv.c: -------------------------------------------------------------------------------- 1 | #define __fenv_static 2 | #include 3 | 4 | #ifdef __GNUC_GNU_INLINE__ 5 | #error "This file must be compiled with C99 'inline' semantics" 6 | #endif 7 | 8 | /* 9 | * Hopefully the system ID byte is immutable, so it's valid to use 10 | * this as a default environment. 11 | */ 12 | const fenv_t __fe_dfl_env = 0; 13 | 14 | extern inline int feclearexcept(int __excepts); 15 | extern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts); 16 | extern inline int fesetexceptflag(const fexcept_t *__flagp, int __excepts); 17 | extern inline int feraiseexcept(int __excepts); 18 | extern inline int fetestexcept(int __excepts); 19 | extern inline int fegetround(void); 20 | extern inline int fesetround(int __round); 21 | extern inline int fegetenv(fenv_t *__envp); 22 | extern inline int feholdexcept(fenv_t *__envp); 23 | extern inline int fesetenv(const fenv_t *__envp); 24 | extern inline int feupdateenv(const fenv_t *__envp); 25 | extern inline int feenableexcept(int __mask); 26 | extern inline int fedisableexcept(int __mask); 27 | extern inline int fegetexcept(void); -------------------------------------------------------------------------------- /mips/Make.files: -------------------------------------------------------------------------------- 1 | $(CUR_SRCS) = fenv.c 2 | -------------------------------------------------------------------------------- /openlibm.pc.in: -------------------------------------------------------------------------------- 1 | Name: openlibm 2 | Version: ${version} 3 | URL: https://github.com/JuliaMath/openlibm 4 | Description: High quality system independent, open source libm. 5 | Cflags: -I${includedir} 6 | Libs: -L${libdir} -lopenlibm 7 | -------------------------------------------------------------------------------- /powerpc/Make.files: -------------------------------------------------------------------------------- 1 | $(CUR_SRCS) = fenv.c 2 | -------------------------------------------------------------------------------- /riscv64/Make.files: -------------------------------------------------------------------------------- 1 | $(CUR_SRCS) = fenv.c 2 | -------------------------------------------------------------------------------- /s390/Make.files: -------------------------------------------------------------------------------- 1 | $(CUR_SRCS) = fenv.c 2 | -------------------------------------------------------------------------------- /src/common.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "math_private.h" 4 | 5 | OLM_DLLEXPORT int isopenlibm(void) { 6 | return 1; 7 | } 8 | -------------------------------------------------------------------------------- /src/e_acoshf.c: -------------------------------------------------------------------------------- 1 | /* e_acoshf.c -- float version of e_acosh.c. 2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 | */ 4 | 5 | /* 6 | * ==================================================== 7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8 | * 9 | * Developed at SunPro, a Sun Microsystems, Inc. business. 10 | * Permission to use, copy, modify, and distribute this 11 | * software is freely granted, provided that this notice 12 | * is preserved. 13 | * ==================================================== 14 | */ 15 | 16 | #include "cdefs-compat.h" 17 | //__FBSDID("$FreeBSD: src/lib/msun/src/e_acoshf.c,v 1.8 2008/02/22 02:30:34 das Exp $"); 18 | 19 | #include 20 | 21 | #include "math_private.h" 22 | 23 | static const float 24 | one = 1.0, 25 | ln2 = 6.9314718246e-01; /* 0x3f317218 */ 26 | 27 | OLM_DLLEXPORT float 28 | __ieee754_acoshf(float x) 29 | { 30 | float t; 31 | int32_t hx; 32 | GET_FLOAT_WORD(hx,x); 33 | if(hx<0x3f800000) { /* x < 1 */ 34 | return (x-x)/(x-x); 35 | } else if(hx >=0x4d800000) { /* x > 2**28 */ 36 | if(hx >=0x7f800000) { /* x is inf of NaN */ 37 | return x+x; 38 | } else 39 | return __ieee754_logf(x)+ln2; /* acosh(huge)=log(2x) */ 40 | } else if (hx==0x3f800000) { 41 | return 0.0; /* acosh(1) = 0 */ 42 | } else if (hx > 0x40000000) { /* 2**28 > x > 2 */ 43 | t=x*x; 44 | return __ieee754_logf((float)2.0*x-one/(x+__ieee754_sqrtf(t-one))); 45 | } else { /* 1 20 | 21 | #include "math_private.h" 22 | 23 | static const float 24 | one = 1.0000000000e+00, /* 0x3F800000 */ 25 | huge = 1.000e+30, 26 | /* coefficient for R(x^2) */ 27 | pS0 = 1.6666586697e-01, 28 | pS1 = -4.2743422091e-02, 29 | pS2 = -8.6563630030e-03, 30 | qS1 = -7.0662963390e-01; 31 | 32 | static const double 33 | pio2 = 1.570796326794896558e+00; 34 | 35 | OLM_DLLEXPORT float 36 | __ieee754_asinf(float x) 37 | { 38 | double s; 39 | float t,w,p,q; 40 | int32_t hx,ix; 41 | GET_FLOAT_WORD(hx,x); 42 | ix = hx&0x7fffffff; 43 | if(ix>=0x3f800000) { /* |x| >= 1 */ 44 | if(ix==0x3f800000) /* |x| == 1 */ 45 | return x*pio2; /* asin(+-1) = +-pi/2 with inexact */ 46 | return (x-x)/(x-x); /* asin(|x|>1) is NaN */ 47 | } else if (ix<0x3f000000) { /* |x|<0.5 */ 48 | if(ix<0x39800000) { /* |x| < 2**-12 */ 49 | if(huge+x>one) return x;/* return x with inexact if x!=0*/ 50 | } 51 | t = x*x; 52 | p = t*(pS0+t*(pS1+t*pS2)); 53 | q = one+t*qS1; 54 | w = p/q; 55 | return x+x*w; 56 | } 57 | /* 1> |x|>= 0.5 */ 58 | w = one-fabsf(x); 59 | t = w*(float)0.5; 60 | p = t*(pS0+t*(pS1+t*pS2)); 61 | q = one+t*qS1; 62 | s = sqrt(t); 63 | w = p/q; 64 | t = pio2-2.0*(s+s*w); 65 | if(hx>0) return t; else return -t; 66 | } 67 | -------------------------------------------------------------------------------- /src/e_atanhf.c: -------------------------------------------------------------------------------- 1 | /* e_atanhf.c -- float version of e_atanh.c. 2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 | */ 4 | 5 | /* 6 | * ==================================================== 7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8 | * 9 | * Developed at SunPro, a Sun Microsystems, Inc. business. 10 | * Permission to use, copy, modify, and distribute this 11 | * software is freely granted, provided that this notice 12 | * is preserved. 13 | * ==================================================== 14 | */ 15 | 16 | #include "cdefs-compat.h" 17 | //__FBSDID("$FreeBSD: src/lib/msun/src/e_atanhf.c,v 1.7 2008/02/22 02:30:34 das Exp $"); 18 | 19 | #include 20 | 21 | #include "math_private.h" 22 | 23 | static const float one = 1.0, huge = 1e30; 24 | 25 | static const float zero = 0.0; 26 | 27 | OLM_DLLEXPORT float 28 | __ieee754_atanhf(float x) 29 | { 30 | float t; 31 | int32_t hx,ix; 32 | GET_FLOAT_WORD(hx,x); 33 | ix = hx&0x7fffffff; 34 | if (ix>0x3f800000) /* |x|>1 */ 35 | return (x-x)/(x-x); 36 | if(ix==0x3f800000) 37 | return x/zero; 38 | if(ix<0x31800000&&(huge+x)>zero) return x; /* x<2**-28 */ 39 | SET_FLOAT_WORD(x,ix); 40 | if(ix<0x3f000000) { /* x < 0.5 */ 41 | t = x+x; 42 | t = (float)0.5*log1pf(t+t*x/(one-x)); 43 | } else 44 | t = (float)0.5*log1pf((x+x)/(one-x)); 45 | if(hx>=0) return t; else return -t; 46 | } 47 | -------------------------------------------------------------------------------- /src/e_coshf.c: -------------------------------------------------------------------------------- 1 | /* e_coshf.c -- float version of e_cosh.c. 2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 | */ 4 | 5 | /* 6 | * ==================================================== 7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8 | * 9 | * Developed at SunPro, a Sun Microsystems, Inc. business. 10 | * Permission to use, copy, modify, and distribute this 11 | * software is freely granted, provided that this notice 12 | * is preserved. 13 | * ==================================================== 14 | */ 15 | 16 | #include "cdefs-compat.h" 17 | //__FBSDID("$FreeBSD: src/lib/msun/src/e_coshf.c,v 1.9 2011/10/21 06:28:47 das Exp $"); 18 | 19 | #include 20 | 21 | #include "math_private.h" 22 | 23 | static const float one = 1.0, half=0.5, huge = 1.0e30; 24 | 25 | OLM_DLLEXPORT float 26 | __ieee754_coshf(float x) 27 | { 28 | float t,w; 29 | int32_t ix; 30 | 31 | GET_FLOAT_WORD(ix,x); 32 | ix &= 0x7fffffff; 33 | 34 | /* x is INF or NaN */ 35 | if(ix>=0x7f800000) return x*x; 36 | 37 | /* |x| in [0,0.5*ln2], return 1+expm1(|x|)^2/(2*exp(|x|)) */ 38 | if(ix<0x3eb17218) { 39 | t = expm1f(fabsf(x)); 40 | w = one+t; 41 | if (ix<0x39800000) return one; /* cosh(tiny) = 1 */ 42 | return one+(t*t)/(w+w); 43 | } 44 | 45 | /* |x| in [0.5*ln2,9], return (exp(|x|)+1/exp(|x|))/2; */ 46 | if (ix < 0x41100000) { 47 | t = __ieee754_expf(fabsf(x)); 48 | return half*t+half/t; 49 | } 50 | 51 | /* |x| in [9, log(maxfloat)] return half*exp(|x|) */ 52 | if (ix < 0x42b17217) return half*__ieee754_expf(fabsf(x)); 53 | 54 | /* |x| in [log(maxfloat), overflowthresold] */ 55 | if (ix<=0x42b2d4fc) 56 | return __ldexp_expf(fabsf(x), -1); 57 | 58 | /* |x| > overflowthresold, cosh(x) overflow */ 59 | return huge*huge; 60 | } 61 | -------------------------------------------------------------------------------- /src/e_lgamma.c: -------------------------------------------------------------------------------- 1 | 2 | /* @(#)e_lgamma.c 1.3 95/01/18 */ 3 | /* 4 | * ==================================================== 5 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 6 | * 7 | * Developed at SunSoft, a Sun Microsystems, Inc. business. 8 | * Permission to use, copy, modify, and distribute this 9 | * software is freely granted, provided that this notice 10 | * is preserved. 11 | * ==================================================== 12 | * 13 | */ 14 | 15 | #include "cdefs-compat.h" 16 | //__FBSDID("$FreeBSD: src/lib/msun/src/e_lgamma.c,v 1.9 2008/02/22 02:30:35 das Exp $"); 17 | 18 | /* __ieee754_lgamma(x) 19 | * Return the logarithm of the Gamma function of x. 20 | * 21 | * Method: call __ieee754_lgamma_r 22 | */ 23 | 24 | #include 25 | 26 | #include "math_private.h" 27 | 28 | OLM_DLLEXPORT double 29 | __ieee754_lgamma(double x) 30 | { 31 | #ifdef OPENLIBM_ONLY_THREAD_SAFE 32 | int signgam; 33 | #endif 34 | 35 | return __ieee754_lgamma_r(x,&signgam); 36 | } 37 | -------------------------------------------------------------------------------- /src/e_lgammaf.c: -------------------------------------------------------------------------------- 1 | /* e_lgammaf.c -- float version of e_lgamma.c. 2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 | */ 4 | 5 | /* 6 | * ==================================================== 7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8 | * 9 | * Developed at SunPro, a Sun Microsystems, Inc. business. 10 | * Permission to use, copy, modify, and distribute this 11 | * software is freely granted, provided that this notice 12 | * is preserved. 13 | * ==================================================== 14 | */ 15 | 16 | #include "cdefs-compat.h" 17 | //__FBSDID("$FreeBSD: src/lib/msun/src/e_lgammaf.c,v 1.8 2008/02/22 02:30:35 das Exp $"); 18 | 19 | /* __ieee754_lgammaf(x) 20 | * Return the logarithm of the Gamma function of x. 21 | * 22 | * Method: call __ieee754_lgammaf_r 23 | */ 24 | 25 | #include 26 | 27 | #include "math_private.h" 28 | 29 | OLM_DLLEXPORT float 30 | __ieee754_lgammaf(float x) 31 | { 32 | #ifdef OPENLIBM_ONLY_THREAD_SAFE 33 | int signgam; 34 | #endif 35 | 36 | return __ieee754_lgammaf_r(x,&signgam); 37 | } 38 | -------------------------------------------------------------------------------- /src/e_lgammal.c: -------------------------------------------------------------------------------- 1 | #include "cdefs-compat.h" 2 | 3 | #include 4 | 5 | #include "math_private.h" 6 | 7 | OLM_DLLEXPORT long double 8 | lgammal(long double x) 9 | { 10 | #ifdef OPENLIBM_ONLY_THREAD_SAFE 11 | int signgam; 12 | #endif 13 | 14 | return (lgammal_r(x, &signgam)); 15 | } 16 | -------------------------------------------------------------------------------- /src/e_remainderf.c: -------------------------------------------------------------------------------- 1 | /* e_remainderf.c -- float version of e_remainder.c. 2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 | */ 4 | 5 | /* 6 | * ==================================================== 7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8 | * 9 | * Developed at SunPro, a Sun Microsystems, Inc. business. 10 | * Permission to use, copy, modify, and distribute this 11 | * software is freely granted, provided that this notice 12 | * is preserved. 13 | * ==================================================== 14 | */ 15 | 16 | #include "cdefs-compat.h" 17 | //__FBSDID("$FreeBSD: src/lib/msun/src/e_remainderf.c,v 1.8 2008/02/12 17:11:36 bde Exp $"); 18 | 19 | #include 20 | 21 | #include "math_private.h" 22 | 23 | static const float zero = 0.0; 24 | 25 | 26 | OLM_DLLEXPORT float 27 | __ieee754_remainderf(float x, float p) 28 | { 29 | int32_t hx,hp; 30 | u_int32_t sx; 31 | float p_half; 32 | 33 | GET_FLOAT_WORD(hx,x); 34 | GET_FLOAT_WORD(hp,p); 35 | sx = hx&0x80000000; 36 | hp &= 0x7fffffff; 37 | hx &= 0x7fffffff; 38 | 39 | /* purge off exception values */ 40 | if(hp==0) return (x*p)/(x*p); /* p = 0 */ 41 | if((hx>=0x7f800000)|| /* x not finite */ 42 | ((hp>0x7f800000))) /* p is NaN */ 43 | return ((long double)x*p)/((long double)x*p); 44 | 45 | 46 | if (hp<=0x7effffff) x = __ieee754_fmodf(x,p+p); /* now x < 2p */ 47 | if ((hx-hp)==0) return zero*x; 48 | x = fabsf(x); 49 | p = fabsf(p); 50 | if (hp<0x01000000) { 51 | if(x+x>p) { 52 | x-=p; 53 | if(x+x>=p) x -= p; 54 | } 55 | } else { 56 | p_half = (float)0.5*p; 57 | if(x>p_half) { 58 | x-=p; 59 | if(x>=p_half) x -= p; 60 | } 61 | } 62 | GET_FLOAT_WORD(hx,x); 63 | if ((hx&0x7fffffff)==0) hx = 0; 64 | SET_FLOAT_WORD(x,hx^sx); 65 | return x; 66 | } 67 | -------------------------------------------------------------------------------- /src/e_remainderl.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2008 David Schultz 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #include "cdefs-compat.h" 28 | //__FBSDID("$FreeBSD: src/lib/msun/src/e_remainderl.c,v 1.1 2008/03/30 20:47:42 das Exp $"); 29 | 30 | #include 31 | #include "math_private.h" 32 | 33 | OLM_DLLEXPORT long double 34 | remainderl(long double x, long double y) 35 | { 36 | int quo; 37 | 38 | return (remquol(x, y, &quo)); 39 | } 40 | -------------------------------------------------------------------------------- /src/e_sinhf.c: -------------------------------------------------------------------------------- 1 | /* e_sinhf.c -- float version of e_sinh.c. 2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 | */ 4 | 5 | /* 6 | * ==================================================== 7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8 | * 9 | * Developed at SunPro, a Sun Microsystems, Inc. business. 10 | * Permission to use, copy, modify, and distribute this 11 | * software is freely granted, provided that this notice 12 | * is preserved. 13 | * ==================================================== 14 | */ 15 | 16 | #include "cdefs-compat.h" 17 | //__FBSDID("$FreeBSD: src/lib/msun/src/e_sinhf.c,v 1.10 2011/10/21 06:28:47 das Exp $"); 18 | 19 | #include 20 | 21 | #include "math_private.h" 22 | 23 | static const float one = 1.0, shuge = 1.0e37; 24 | 25 | OLM_DLLEXPORT float 26 | __ieee754_sinhf(float x) 27 | { 28 | float t,h; 29 | int32_t ix,jx; 30 | 31 | GET_FLOAT_WORD(jx,x); 32 | ix = jx&0x7fffffff; 33 | 34 | /* x is INF or NaN */ 35 | if(ix>=0x7f800000) return x+x; 36 | 37 | h = 0.5; 38 | if (jx<0) h = -h; 39 | /* |x| in [0,9], return sign(x)*0.5*(E+E/(E+1))) */ 40 | if (ix < 0x41100000) { /* |x|<9 */ 41 | if (ix<0x39800000) /* |x|<2**-12 */ 42 | if(shuge+x>one) return x;/* sinh(tiny) = tiny with inexact */ 43 | t = expm1f(fabsf(x)); 44 | if(ix<0x3f800000) return h*((float)2.0*t-t*t/(t+one)); 45 | return h*(t+t/(t+one)); 46 | } 47 | 48 | /* |x| in [9, logf(maxfloat)] return 0.5*exp(|x|) */ 49 | if (ix < 0x42b17217) return h*__ieee754_expf(fabsf(x)); 50 | 51 | /* |x| in [logf(maxfloat), overflowthresold] */ 52 | if (ix<=0x42b2d4fc) 53 | return h*2.0F*__ldexp_expf(fabsf(x), -1); 54 | 55 | /* |x| > overflowthresold, sinh(x) overflow */ 56 | return x*shuge; 57 | } 58 | -------------------------------------------------------------------------------- /src/k_cosf.c: -------------------------------------------------------------------------------- 1 | /* k_cosf.c -- float version of k_cos.c 2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 | * Debugged and optimized by Bruce D. Evans. 4 | */ 5 | 6 | /* 7 | * ==================================================== 8 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 9 | * 10 | * Developed at SunPro, a Sun Microsystems, Inc. business. 11 | * Permission to use, copy, modify, and distribute this 12 | * software is freely granted, provided that this notice 13 | * is preserved. 14 | * ==================================================== 15 | */ 16 | 17 | #ifndef INLINE_KERNEL_COSDF 18 | #include "cdefs-compat.h" 19 | //__FBSDID("$FreeBSD: src/lib/msun/src/k_cosf.c,v 1.18 2009/06/03 08:16:34 ed Exp $"); 20 | #endif 21 | 22 | #include 23 | 24 | #include "math_private.h" 25 | 26 | /* |cos(x) - c(x)| < 2**-34.1 (~[-5.37e-11, 5.295e-11]). */ 27 | static const double 28 | one = 1.0, 29 | C0 = -0x1ffffffd0c5e81.0p-54, /* -0.499999997251031003120 */ 30 | C1 = 0x155553e1053a42.0p-57, /* 0.0416666233237390631894 */ 31 | C2 = -0x16c087e80f1e27.0p-62, /* -0.00138867637746099294692 */ 32 | C3 = 0x199342e0ee5069.0p-68; /* 0.0000243904487962774090654 */ 33 | 34 | #ifndef INLINE_KERNEL_COSDF 35 | extern 36 | #endif 37 | //__inline float 38 | OLM_DLLEXPORT float 39 | __kernel_cosdf(double x) 40 | { 41 | double r, w, z; 42 | 43 | /* Try to optimize for parallel evaluation as in k_tanf.c. */ 44 | z = x*x; 45 | w = z*z; 46 | r = C2+z*C3; 47 | return ((one+z*C0) + w*C1) + (w*z)*r; 48 | } 49 | -------------------------------------------------------------------------------- /src/k_logf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ==================================================== 3 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 4 | * 5 | * Developed at SunPro, a Sun Microsystems, Inc. business. 6 | * Permission to use, copy, modify, and distribute this 7 | * software is freely granted, provided that this notice 8 | * is preserved. 9 | * ==================================================== 10 | */ 11 | 12 | #include "cdefs-compat.h" 13 | //__FBSDID("$FreeBSD: src/lib/msun/src/k_logf.h,v 1.3 2011/10/15 05:23:28 das Exp $"); 14 | 15 | /* 16 | * Float version of k_log.h. See the latter for most comments. 17 | */ 18 | 19 | static const float 20 | /* |(log(1+s)-log(1-s))/s - Lg(s)| < 2**-34.24 (~[-4.95e-11, 4.97e-11]). */ 21 | Lg1 = 0xaaaaaa.0p-24, /* 0.66666662693 */ 22 | Lg2 = 0xccce13.0p-25, /* 0.40000972152 */ 23 | Lg3 = 0x91e9ee.0p-25, /* 0.28498786688 */ 24 | Lg4 = 0xf89e26.0p-26; /* 0.24279078841 */ 25 | 26 | static inline float 27 | k_log1pf(float f) 28 | { 29 | float hfsq,s,z,R,w,t1,t2; 30 | 31 | s = f/((float)2.0+f); 32 | z = s*s; 33 | w = z*z; 34 | t1= w*(Lg2+w*Lg4); 35 | t2= z*(Lg1+w*Lg3); 36 | R = t2+t1; 37 | hfsq=(float)0.5*f*f; 38 | return s*(hfsq+R); 39 | } 40 | -------------------------------------------------------------------------------- /src/k_sinf.c: -------------------------------------------------------------------------------- 1 | /* k_sinf.c -- float version of k_sin.c 2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 | * Optimized by Bruce D. Evans. 4 | */ 5 | 6 | /* 7 | * ==================================================== 8 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 9 | * 10 | * Developed at SunPro, a Sun Microsystems, Inc. business. 11 | * Permission to use, copy, modify, and distribute this 12 | * software is freely granted, provided that this notice 13 | * is preserved. 14 | * ==================================================== 15 | */ 16 | 17 | #ifndef INLINE_KERNEL_SINDF 18 | #include "cdefs-compat.h" 19 | //__FBSDID("$FreeBSD: src/lib/msun/src/k_sinf.c,v 1.16 2009/06/03 08:16:34 ed Exp $"); 20 | #endif 21 | 22 | #include 23 | 24 | #include "math_private.h" 25 | 26 | /* |sin(x)/x - s(x)| < 2**-37.5 (~[-4.89e-12, 4.824e-12]). */ 27 | static const double 28 | S1 = -0x15555554cbac77.0p-55, /* -0.166666666416265235595 */ 29 | S2 = 0x111110896efbb2.0p-59, /* 0.0083333293858894631756 */ 30 | S3 = -0x1a00f9e2cae774.0p-65, /* -0.000198393348360966317347 */ 31 | S4 = 0x16cd878c3b46a7.0p-71; /* 0.0000027183114939898219064 */ 32 | 33 | #ifndef INLINE_KERNEL_SINDF 34 | extern 35 | #endif 36 | //__inline float 37 | OLM_DLLEXPORT float 38 | __kernel_sindf(double x) 39 | { 40 | double r, s, w, z; 41 | 42 | /* Try to optimize for parallel evaluation as in k_tanf.c. */ 43 | z = x*x; 44 | w = z*z; 45 | r = S3+z*S4; 46 | s = z*x; 47 | return (x + s*(S1+z*S2)) + s*w*r; 48 | } 49 | -------------------------------------------------------------------------------- /src/s_asinhf.c: -------------------------------------------------------------------------------- 1 | /* s_asinhf.c -- float version of s_asinh.c. 2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 | */ 4 | 5 | /* 6 | * ==================================================== 7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8 | * 9 | * Developed at SunPro, a Sun Microsystems, Inc. business. 10 | * Permission to use, copy, modify, and distribute this 11 | * software is freely granted, provided that this notice 12 | * is preserved. 13 | * ==================================================== 14 | */ 15 | 16 | #include "cdefs-compat.h" 17 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_asinhf.c,v 1.9 2008/02/22 02:30:35 das Exp $"); 18 | 19 | #include 20 | 21 | #include "math_private.h" 22 | 23 | static const float 24 | one = 1.0000000000e+00, /* 0x3F800000 */ 25 | ln2 = 6.9314718246e-01, /* 0x3f317218 */ 26 | huge= 1.0000000000e+30; 27 | 28 | OLM_DLLEXPORT float 29 | asinhf(float x) 30 | { 31 | float t,w; 32 | int32_t hx,ix; 33 | GET_FLOAT_WORD(hx,x); 34 | ix = hx&0x7fffffff; 35 | if(ix>=0x7f800000) return x+x; /* x is inf or NaN */ 36 | if(ix< 0x31800000) { /* |x|<2**-28 */ 37 | if(huge+x>one) return x; /* return x inexact except 0 */ 38 | } 39 | if(ix>0x4d800000) { /* |x| > 2**28 */ 40 | w = __ieee754_logf(fabsf(x))+ln2; 41 | } else if (ix>0x40000000) { /* 2**28 > |x| > 2.0 */ 42 | t = fabsf(x); 43 | w = __ieee754_logf((float)2.0*t+one/(__ieee754_sqrtf(x*x+one)+t)); 44 | } else { /* 2.0 > |x| > 2**-28 */ 45 | t = x*x; 46 | w =log1pf(fabsf(x)+t/(one+__ieee754_sqrtf(one+t))); 47 | } 48 | if(hx>0) return w; else return -w; 49 | } 50 | -------------------------------------------------------------------------------- /src/s_cabs.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: s_cabs.c,v 1.6 2013/07/03 04:46:36 espie Exp $ */ 2 | /* 3 | * Copyright (c) 2008 Martynas Venckus 4 | * 5 | * Permission to use, copy, modify, and distribute this software for any 6 | * purpose with or without fee is hereby granted, provided that the above 7 | * copyright notice and this permission notice appear in all copies. 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "math_private.h" 23 | 24 | double 25 | cabs(double complex z) 26 | { 27 | return hypot(__real__ z, __imag__ z); 28 | } 29 | 30 | #if LDBL_MANT_DIG == DBL_MANT_DIG 31 | openlibm_strong_reference(cabs, cabsl); 32 | #endif /* LDBL_MANT_DIG == DBL_MANT_DIG */ 33 | -------------------------------------------------------------------------------- /src/s_cabsf.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: s_cabsf.c,v 1.1 2008/09/07 20:36:09 martynas Exp $ */ 2 | /* 3 | * Copyright (c) 2008 Martynas Venckus 4 | * 5 | * Permission to use, copy, modify, and distribute this software for any 6 | * purpose with or without fee is hereby granted, provided that the above 7 | * copyright notice and this permission notice appear in all copies. 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | float 22 | cabsf(float complex z) 23 | { 24 | return hypotf(__real__ z, __imag__ z); 25 | } 26 | -------------------------------------------------------------------------------- /src/s_cabsl.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: s_cabsl.c,v 1.1 2011/07/08 19:25:31 martynas Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 2011 Martynas Venckus 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | #include 20 | #include 21 | 22 | long double 23 | cabsl(long double complex z) 24 | { 25 | return hypotl(__real__ z, __imag__ z); 26 | } 27 | -------------------------------------------------------------------------------- /src/s_cacos.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: s_cacos.c,v 1.6 2013/07/03 04:46:36 espie Exp $ */ 2 | /* 3 | * Copyright (c) 2008 Stephen L. Moshier 4 | * 5 | * Permission to use, copy, modify, and distribute this software for any 6 | * purpose with or without fee is hereby granted, provided that the above 7 | * copyright notice and this permission notice appear in all copies. 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | */ 17 | 18 | /* cacos() 19 | * 20 | * Complex circular arc cosine 21 | * 22 | * 23 | * 24 | * SYNOPSIS: 25 | * 26 | * double complex cacos(); 27 | * double complex z, w; 28 | * 29 | * w = cacos (z); 30 | * 31 | * 32 | * 33 | * DESCRIPTION: 34 | * 35 | * 36 | * w = arccos z = PI/2 - arcsin z. 37 | * 38 | * 39 | * 40 | * 41 | * ACCURACY: 42 | * 43 | * Relative error: 44 | * arithmetic domain # trials peak rms 45 | * DEC -10,+10 5200 1.6e-15 2.8e-16 46 | * IEEE -10,+10 30000 1.8e-14 2.2e-15 47 | */ 48 | 49 | #include 50 | #include 51 | #include 52 | 53 | #include "math_private.h" 54 | 55 | double complex 56 | cacos(double complex z) 57 | { 58 | double complex w; 59 | 60 | w = casin (z); 61 | w = (M_PI_2 - creal (w)) - cimag (w) * I; 62 | return (w); 63 | } 64 | 65 | #if LDBL_MANT_DIG == DBL_MANT_DIG 66 | openlibm_strong_reference(cacos, cacosl); 67 | #endif /* LDBL_MANT_DIG == DBL_MANT_DIG */ 68 | -------------------------------------------------------------------------------- /src/s_cacosf.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: s_cacosf.c,v 1.2 2011/07/20 19:28:33 martynas Exp $ */ 2 | /* 3 | * Copyright (c) 2008 Stephen L. Moshier 4 | * 5 | * Permission to use, copy, modify, and distribute this software for any 6 | * purpose with or without fee is hereby granted, provided that the above 7 | * copyright notice and this permission notice appear in all copies. 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | */ 17 | 18 | /* cacosf() 19 | * 20 | * Complex circular arc cosine 21 | * 22 | * 23 | * 24 | * SYNOPSIS: 25 | * 26 | * void cacosf(); 27 | * cmplxf z, w; 28 | * 29 | * cacosf( &z, &w ); 30 | * 31 | * 32 | * 33 | * DESCRIPTION: 34 | * 35 | * 36 | * w = arccos z = PI/2 - arcsin z. 37 | * 38 | * 39 | * 40 | * 41 | * ACCURACY: 42 | * 43 | * Relative error: 44 | * arithmetic domain # trials peak rms 45 | * IEEE -10,+10 30000 9.2e-6 1.2e-6 46 | * 47 | */ 48 | 49 | #include 50 | #include 51 | 52 | float complex 53 | cacosf(float complex z) 54 | { 55 | float complex w; 56 | 57 | w = casinf( z ); 58 | w = ((float)M_PI_2 - crealf (w)) - cimagf (w) * I; 59 | return (w); 60 | } 61 | -------------------------------------------------------------------------------- /src/s_cacosh.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: s_cacosh.c,v 1.6 2013/07/03 04:46:36 espie Exp $ */ 2 | /* 3 | * Copyright (c) 2008 Stephen L. Moshier 4 | * 5 | * Permission to use, copy, modify, and distribute this software for any 6 | * purpose with or without fee is hereby granted, provided that the above 7 | * copyright notice and this permission notice appear in all copies. 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | */ 17 | 18 | /* cacosh 19 | * 20 | * Complex inverse hyperbolic cosine 21 | * 22 | * 23 | * 24 | * SYNOPSIS: 25 | * 26 | * double complex cacosh(); 27 | * double complex z, w; 28 | * 29 | * w = cacosh (z); 30 | * 31 | * 32 | * 33 | * DESCRIPTION: 34 | * 35 | * acosh z = i acos z . 36 | * 37 | * ACCURACY: 38 | * 39 | * Relative error: 40 | * arithmetic domain # trials peak rms 41 | * IEEE -10,+10 30000 1.6e-14 2.1e-15 42 | * 43 | */ 44 | 45 | #include 46 | #include 47 | #include 48 | 49 | #include "math_private.h" 50 | 51 | double complex 52 | cacosh(double complex z) 53 | { 54 | double complex w; 55 | 56 | w = I * cacos (z); 57 | return (w); 58 | } 59 | 60 | #if LDBL_MANT_DIG == DBL_MANT_DIG 61 | openlibm_strong_reference(cacosh, cacoshl); 62 | #endif /* LDBL_MANT_DIG == DBL_MANT_DIG */ 63 | -------------------------------------------------------------------------------- /src/s_cacoshf.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: s_cacoshf.c,v 1.1 2008/09/07 20:36:09 martynas Exp $ */ 2 | /* 3 | * Copyright (c) 2008 Stephen L. Moshier 4 | * 5 | * Permission to use, copy, modify, and distribute this software for any 6 | * purpose with or without fee is hereby granted, provided that the above 7 | * copyright notice and this permission notice appear in all copies. 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | */ 17 | 18 | /* cacoshf 19 | * 20 | * Complex inverse hyperbolic cosine 21 | * 22 | * 23 | * 24 | * SYNOPSIS: 25 | * 26 | * float complex cacoshf(); 27 | * float complex z, w; 28 | * 29 | * w = cacoshf (z); 30 | * 31 | * 32 | * 33 | * DESCRIPTION: 34 | * 35 | * acosh z = i acos z . 36 | * 37 | * ACCURACY: 38 | * 39 | * Relative error: 40 | * arithmetic domain # trials peak rms 41 | * IEEE -10,+10 30000 1.6e-14 2.1e-15 42 | * 43 | */ 44 | 45 | #include 46 | #include 47 | 48 | float complex 49 | cacoshf(float complex z) 50 | { 51 | float complex w; 52 | 53 | w = I * cacosf (z); 54 | return (w); 55 | } 56 | -------------------------------------------------------------------------------- /src/s_cacoshl.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: s_cacoshl.c,v 1.1 2011/07/08 19:25:31 martynas Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 2008 Stephen L. Moshier 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | /* cacoshl 20 | * 21 | * Complex inverse hyperbolic cosine 22 | * 23 | * 24 | * 25 | * SYNOPSIS: 26 | * 27 | * long double complex cacoshl(); 28 | * long double complex z, w; 29 | * 30 | * w = cacoshl (z); 31 | * 32 | * 33 | * 34 | * DESCRIPTION: 35 | * 36 | * acosh z = i acos z . 37 | * 38 | * ACCURACY: 39 | * 40 | * Relative error: 41 | * arithmetic domain # trials peak rms 42 | * IEEE -10,+10 30000 1.6e-14 2.1e-15 43 | * 44 | */ 45 | 46 | #include 47 | #include 48 | 49 | long double complex 50 | cacoshl(long double complex z) 51 | { 52 | long double complex w; 53 | 54 | w = I * cacosl(z); 55 | return (w); 56 | } 57 | -------------------------------------------------------------------------------- /src/s_cacosl.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: s_cacosl.c,v 1.3 2011/07/20 21:02:51 martynas Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 2008 Stephen L. Moshier 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | /* cacosl() 20 | * 21 | * Complex circular arc cosine 22 | * 23 | * 24 | * 25 | * SYNOPSIS: 26 | * 27 | * long double complex cacosl(); 28 | * long double complex z, w; 29 | * 30 | * w = cacosl( z ); 31 | * 32 | * 33 | * 34 | * DESCRIPTION: 35 | * 36 | * 37 | * w = arccos z = PI/2 - arcsin z. 38 | * 39 | * 40 | * 41 | * 42 | * ACCURACY: 43 | * 44 | * Relative error: 45 | * arithmetic domain # trials peak rms 46 | * DEC -10,+10 5200 1.6e-15 2.8e-16 47 | * IEEE -10,+10 30000 1.8e-14 2.2e-15 48 | */ 49 | 50 | #include 51 | #include 52 | 53 | static const long double PIO2L = 1.570796326794896619231321691639751442098585L; 54 | 55 | long double complex 56 | cacosl(long double complex z) 57 | { 58 | long double complex w; 59 | 60 | w = casinl(z); 61 | w = (PIO2L - creall(w)) - cimagl(w) * I; 62 | return (w); 63 | } 64 | -------------------------------------------------------------------------------- /src/s_carg.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2005 David Schultz 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #include "cdefs-compat.h" 28 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_carg.c,v 1.1 2007/12/12 23:43:51 das Exp $"); 29 | 30 | #include 31 | #include 32 | 33 | #include "math_private.h" 34 | 35 | OLM_DLLEXPORT double 36 | carg(double complex z) 37 | { 38 | 39 | return (atan2(cimag(z), creal(z))); 40 | } 41 | -------------------------------------------------------------------------------- /src/s_cargf.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2005 David Schultz 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #include "cdefs-compat.h" 28 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_cargf.c,v 1.1 2007/12/12 23:43:51 das Exp $"); 29 | 30 | #include 31 | #include 32 | 33 | #include "math_private.h" 34 | 35 | OLM_DLLEXPORT float 36 | cargf(float complex z) 37 | { 38 | 39 | return (atan2f(cimagf(z), crealf(z))); 40 | } 41 | -------------------------------------------------------------------------------- /src/s_cargl.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2005-2008 David Schultz 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #include "cdefs-compat.h" 28 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_cargl.c,v 1.1 2008/07/31 22:41:26 das Exp $"); 29 | 30 | #include 31 | #include 32 | 33 | #include "math_private.h" 34 | 35 | OLM_DLLEXPORT long double 36 | cargl(long double complex z) 37 | { 38 | 39 | return (atan2l(cimagl(z), creall(z))); 40 | } 41 | -------------------------------------------------------------------------------- /src/s_casinh.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: s_casinh.c,v 1.6 2013/07/03 04:46:36 espie Exp $ */ 2 | /* 3 | * Copyright (c) 2008 Stephen L. Moshier 4 | * 5 | * Permission to use, copy, modify, and distribute this software for any 6 | * purpose with or without fee is hereby granted, provided that the above 7 | * copyright notice and this permission notice appear in all copies. 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | */ 17 | 18 | /* casinh 19 | * 20 | * Complex inverse hyperbolic sine 21 | * 22 | * 23 | * 24 | * SYNOPSIS: 25 | * 26 | * double complex casinh(); 27 | * double complex z, w; 28 | * 29 | * w = casinh (z); 30 | * 31 | * 32 | * 33 | * DESCRIPTION: 34 | * 35 | * casinh z = -i casin iz . 36 | * 37 | * ACCURACY: 38 | * 39 | * Relative error: 40 | * arithmetic domain # trials peak rms 41 | * IEEE -10,+10 30000 1.8e-14 2.6e-15 42 | * 43 | */ 44 | 45 | #include 46 | #include 47 | #include 48 | 49 | #include "math_private.h" 50 | 51 | double complex 52 | casinh(double complex z) 53 | { 54 | double complex w; 55 | 56 | w = -1.0 * I * casin (z * I); 57 | return (w); 58 | } 59 | 60 | #if LDBL_MANT_DIG == DBL_MANT_DIG 61 | openlibm_strong_reference(casinh, casinhl); 62 | #endif /* LDBL_MANT_DIG == DBL_MANT_DIG */ 63 | -------------------------------------------------------------------------------- /src/s_casinhf.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: s_casinhf.c,v 1.1 2008/09/07 20:36:09 martynas Exp $ */ 2 | /* 3 | * Copyright (c) 2008 Stephen L. Moshier 4 | * 5 | * Permission to use, copy, modify, and distribute this software for any 6 | * purpose with or without fee is hereby granted, provided that the above 7 | * copyright notice and this permission notice appear in all copies. 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | */ 17 | 18 | /* casinhf 19 | * 20 | * Complex inverse hyperbolic sine 21 | * 22 | * 23 | * 24 | * SYNOPSIS: 25 | * 26 | * float complex casinhf(); 27 | * float complex z, w; 28 | * 29 | * w = casinhf (z); 30 | * 31 | * 32 | * 33 | * DESCRIPTION: 34 | * 35 | * casinh z = -i casin iz . 36 | * 37 | * ACCURACY: 38 | * 39 | * Relative error: 40 | * arithmetic domain # trials peak rms 41 | * IEEE -10,+10 30000 1.8e-14 2.6e-15 42 | * 43 | */ 44 | 45 | #include 46 | #include 47 | 48 | float complex 49 | casinhf(float complex z) 50 | { 51 | float complex w; 52 | 53 | w = -1.0f * I * casinf (z * I); 54 | return (w); 55 | } 56 | -------------------------------------------------------------------------------- /src/s_casinhl.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: s_casinhl.c,v 1.1 2011/07/08 19:25:31 martynas Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 2008 Stephen L. Moshier 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | /* casinhl 20 | * 21 | * Complex inverse hyperbolic sine 22 | * 23 | * 24 | * 25 | * SYNOPSIS: 26 | * 27 | * long double complex casinhf(); 28 | * long double complex z, w; 29 | * 30 | * w = casinhl (z); 31 | * 32 | * 33 | * 34 | * DESCRIPTION: 35 | * 36 | * casinh z = -i casin iz . 37 | * 38 | * ACCURACY: 39 | * 40 | * Relative error: 41 | * arithmetic domain # trials peak rms 42 | * IEEE -10,+10 30000 1.8e-14 2.6e-15 43 | * 44 | */ 45 | 46 | #include 47 | #include 48 | 49 | long double complex 50 | casinhl(long double complex z) 51 | { 52 | long double complex w; 53 | 54 | w = -1.0L * I * casinl(z * I); 55 | return (w); 56 | } 57 | -------------------------------------------------------------------------------- /src/s_catanh.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: s_catanh.c,v 1.6 2013/07/03 04:46:36 espie Exp $ */ 2 | /* 3 | * Copyright (c) 2008 Stephen L. Moshier 4 | * 5 | * Permission to use, copy, modify, and distribute this software for any 6 | * purpose with or without fee is hereby granted, provided that the above 7 | * copyright notice and this permission notice appear in all copies. 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | */ 17 | 18 | /* catanh 19 | * 20 | * Complex inverse hyperbolic tangent 21 | * 22 | * 23 | * 24 | * SYNOPSIS: 25 | * 26 | * double complex catanh(); 27 | * double complex z, w; 28 | * 29 | * w = catanh (z); 30 | * 31 | * 32 | * 33 | * DESCRIPTION: 34 | * 35 | * Inverse tanh, equal to -i catan (iz); 36 | * 37 | * ACCURACY: 38 | * 39 | * Relative error: 40 | * arithmetic domain # trials peak rms 41 | * IEEE -10,+10 30000 2.3e-16 6.2e-17 42 | * 43 | */ 44 | 45 | #include 46 | #include 47 | #include 48 | 49 | #include "math_private.h" 50 | 51 | double complex 52 | catanh(double complex z) 53 | { 54 | double complex w; 55 | 56 | w = -1.0 * I * catan (z * I); 57 | return (w); 58 | } 59 | 60 | #if LDBL_MANT_DIG == DBL_MANT_DIG 61 | openlibm_strong_reference(catanh, catanhl); 62 | #endif /* LDBL_MANT_DIG == DBL_MANT_DIG */ 63 | -------------------------------------------------------------------------------- /src/s_catanhf.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: s_catanhf.c,v 1.1 2008/09/07 20:36:09 martynas Exp $ */ 2 | /* 3 | * Copyright (c) 2008 Stephen L. Moshier 4 | * 5 | * Permission to use, copy, modify, and distribute this software for any 6 | * purpose with or without fee is hereby granted, provided that the above 7 | * copyright notice and this permission notice appear in all copies. 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | */ 17 | 18 | /* catanhf 19 | * 20 | * Complex inverse hyperbolic tangent 21 | * 22 | * 23 | * 24 | * SYNOPSIS: 25 | * 26 | * float complex catanhf(); 27 | * float complex z, w; 28 | * 29 | * w = catanhf (z); 30 | * 31 | * 32 | * 33 | * DESCRIPTION: 34 | * 35 | * Inverse tanh, equal to -i catan (iz); 36 | * 37 | * ACCURACY: 38 | * 39 | * Relative error: 40 | * arithmetic domain # trials peak rms 41 | * IEEE -10,+10 30000 2.3e-16 6.2e-17 42 | * 43 | */ 44 | 45 | #include 46 | #include 47 | 48 | float complex 49 | catanhf(float complex z) 50 | { 51 | float complex w; 52 | 53 | w = -1.0f * I * catanf (z * I); 54 | return (w); 55 | } 56 | -------------------------------------------------------------------------------- /src/s_catanhl.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: s_catanhl.c,v 1.1 2011/07/08 19:25:31 martynas Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 2008 Stephen L. Moshier 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | /* catanhl 20 | * 21 | * Complex inverse hyperbolic tangent 22 | * 23 | * 24 | * 25 | * SYNOPSIS: 26 | * 27 | * long double complex catanhl(); 28 | * long double complex z, w; 29 | * 30 | * w = catanhl (z); 31 | * 32 | * 33 | * 34 | * DESCRIPTION: 35 | * 36 | * Inverse tanh, equal to -i catan (iz); 37 | * 38 | * ACCURACY: 39 | * 40 | * Relative error: 41 | * arithmetic domain # trials peak rms 42 | * IEEE -10,+10 30000 2.3e-16 6.2e-17 43 | * 44 | */ 45 | 46 | #include 47 | #include 48 | 49 | long double complex 50 | catanhl(long double complex z) 51 | { 52 | long double complex w; 53 | 54 | w = -1.0L * I * catanl(z * I); 55 | return (w); 56 | } 57 | -------------------------------------------------------------------------------- /src/s_ccoshl.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: s_ccoshl.c,v 1.2 2011/07/20 19:28:33 martynas Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 2008 Stephen L. Moshier 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | /* ccoshl 20 | * 21 | * Complex hyperbolic cosine 22 | * 23 | * 24 | * 25 | * SYNOPSIS: 26 | * 27 | * long double complex ccoshl(); 28 | * long double complex z, w; 29 | * 30 | * w = ccoshl (z); 31 | * 32 | * 33 | * 34 | * DESCRIPTION: 35 | * 36 | * ccosh(z) = cosh x cos y + i sinh x sin y . 37 | * 38 | * ACCURACY: 39 | * 40 | * Relative error: 41 | * arithmetic domain # trials peak rms 42 | * IEEE -10,+10 30000 2.9e-16 8.1e-17 43 | * 44 | */ 45 | 46 | #include 47 | #include 48 | 49 | long double complex 50 | ccoshl(long double complex z) 51 | { 52 | long double complex w; 53 | long double x, y; 54 | 55 | x = creall(z); 56 | y = cimagl(z); 57 | w = coshl(x) * cosl(y) + (sinhl(x) * sinl(y)) * I; 58 | return (w); 59 | } 60 | -------------------------------------------------------------------------------- /src/s_ceilf.c: -------------------------------------------------------------------------------- 1 | /* s_ceilf.c -- float version of s_ceil.c. 2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 | */ 4 | 5 | /* 6 | * ==================================================== 7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8 | * 9 | * Developed at SunPro, a Sun Microsystems, Inc. business. 10 | * Permission to use, copy, modify, and distribute this 11 | * software is freely granted, provided that this notice 12 | * is preserved. 13 | * ==================================================== 14 | */ 15 | 16 | #include "cdefs-compat.h" 17 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_ceilf.c,v 1.8 2008/02/22 02:30:35 das Exp $"); 18 | 19 | #include 20 | 21 | #include "math_private.h" 22 | 23 | static const float huge = 1.0e30; 24 | 25 | OLM_DLLEXPORT float 26 | ceilf(float x) 27 | { 28 | int32_t i0,j0; 29 | u_int32_t i; 30 | 31 | GET_FLOAT_WORD(i0,x); 32 | j0 = ((i0>>23)&0xff)-0x7f; 33 | if(j0<23) { 34 | if(j0<0) { /* raise inexact if x != 0 */ 35 | if(huge+x>(float)0.0) {/* return 0*sign(x) if |x|<1 */ 36 | if(i0<0) {i0=0x80000000;} 37 | else if(i0!=0) { i0=0x3f800000;} 38 | } 39 | } else { 40 | i = (0x007fffff)>>j0; 41 | if((i0&i)==0) return x; /* x is integral */ 42 | if(huge+x>(float)0.0) { /* raise inexact flag */ 43 | if(i0>0) i0 += (0x00800000)>>j0; 44 | i0 &= (~i); 45 | } 46 | } 47 | } else { 48 | if(j0==0x80) return x+x; /* inf or NaN */ 49 | else return x; /* x is integral */ 50 | } 51 | SET_FLOAT_WORD(x,i0); 52 | return x; 53 | } 54 | -------------------------------------------------------------------------------- /src/s_cimag.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2004 Stefan Farfeleder 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: src/lib/msun/src/s_cimag.c,v 1.3 2009/03/14 18:24:15 das Exp $ 27 | */ 28 | 29 | #include 30 | 31 | #include "math_private.h" 32 | 33 | OLM_DLLEXPORT double 34 | cimag(double complex z) 35 | { 36 | return (__imag__ z); 37 | } 38 | -------------------------------------------------------------------------------- /src/s_cimagf.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2004 Stefan Farfeleder 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: src/lib/msun/src/s_cimagf.c,v 1.3 2009/03/14 18:24:15 das Exp $ 27 | */ 28 | 29 | #include 30 | 31 | #include "math_private.h" 32 | 33 | OLM_DLLEXPORT float 34 | cimagf(float complex z) 35 | { 36 | return (__imag__ z); 37 | } 38 | -------------------------------------------------------------------------------- /src/s_cimagl.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2004 Stefan Farfeleder 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: src/lib/msun/src/s_cimagl.c,v 1.3 2009/03/14 18:24:15 das Exp $ 27 | */ 28 | 29 | #include 30 | 31 | #include "math_private.h" 32 | 33 | OLM_DLLEXPORT long double 34 | cimagl(long double complex z) 35 | { 36 | return (__imag__ z); 37 | } 38 | -------------------------------------------------------------------------------- /src/s_conj.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2004 Stefan Farfeleder 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: src/lib/msun/src/s_conj.c,v 1.2 2008/08/07 14:39:56 das Exp $ 27 | */ 28 | 29 | #include 30 | 31 | #include "math_private.h" 32 | 33 | OLM_DLLEXPORT double complex 34 | conj(double complex z) 35 | { 36 | 37 | return (CMPLX(creal(z), -cimag(z))); 38 | } 39 | -------------------------------------------------------------------------------- /src/s_conjf.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2004 Stefan Farfeleder 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: src/lib/msun/src/s_conjf.c,v 1.2 2008/08/07 14:39:56 das Exp $ 27 | */ 28 | 29 | #include 30 | 31 | #include "math_private.h" 32 | 33 | OLM_DLLEXPORT float complex 34 | conjf(float complex z) 35 | { 36 | 37 | return (CMPLXF(crealf(z), -cimagf(z))); 38 | } 39 | -------------------------------------------------------------------------------- /src/s_conjl.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2004 Stefan Farfeleder 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: src/lib/msun/src/s_conjl.c,v 1.2 2008/08/07 14:39:56 das Exp $ 27 | */ 28 | 29 | #include 30 | 31 | #include "math_private.h" 32 | 33 | OLM_DLLEXPORT long double complex 34 | conjl(long double complex z) 35 | { 36 | 37 | return (CMPLXL(creall(z), -cimagl(z))); 38 | } 39 | -------------------------------------------------------------------------------- /src/s_copysign.c: -------------------------------------------------------------------------------- 1 | /* @(#)s_copysign.c 5.1 93/09/24 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunPro, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | */ 12 | 13 | #include "cdefs-compat.h" 14 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_copysign.c,v 1.10 2008/02/22 02:30:35 das Exp $"); 15 | 16 | /* 17 | * copysign(double x, double y) 18 | * copysign(x,y) returns a value with the magnitude of x and 19 | * with the sign bit of y. 20 | */ 21 | 22 | #include 23 | 24 | #include "math_private.h" 25 | 26 | OLM_DLLEXPORT double 27 | copysign(double x, double y) 28 | { 29 | u_int32_t hx,hy; 30 | GET_HIGH_WORD(hx,x); 31 | GET_HIGH_WORD(hy,y); 32 | SET_HIGH_WORD(x,(hx&0x7fffffff)|(hy&0x80000000)); 33 | return x; 34 | } 35 | -------------------------------------------------------------------------------- /src/s_copysignf.c: -------------------------------------------------------------------------------- 1 | /* s_copysignf.c -- float version of s_copysign.c. 2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 | */ 4 | 5 | /* 6 | * ==================================================== 7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8 | * 9 | * Developed at SunPro, a Sun Microsystems, Inc. business. 10 | * Permission to use, copy, modify, and distribute this 11 | * software is freely granted, provided that this notice 12 | * is preserved. 13 | * ==================================================== 14 | */ 15 | 16 | #include "cdefs-compat.h" 17 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_copysignf.c,v 1.10 2008/02/22 02:30:35 das Exp $"); 18 | 19 | /* 20 | * copysignf(float x, float y) 21 | * copysignf(x,y) returns a value with the magnitude of x and 22 | * with the sign bit of y. 23 | */ 24 | 25 | #include 26 | 27 | #include "math_private.h" 28 | 29 | OLM_DLLEXPORT float 30 | copysignf(float x, float y) 31 | { 32 | u_int32_t ix,iy; 33 | GET_FLOAT_WORD(ix,x); 34 | GET_FLOAT_WORD(iy,y); 35 | SET_FLOAT_WORD(x,(ix&0x7fffffff)|(iy&0x80000000)); 36 | return x; 37 | } 38 | -------------------------------------------------------------------------------- /src/s_copysignl.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2004 Stefan Farfeleder 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: src/lib/msun/src/s_copysignl.c,v 1.2 2007/01/07 07:54:21 das Exp $ 27 | */ 28 | 29 | #include 30 | 31 | #include "fpmath.h" 32 | #include "math_private.h" 33 | 34 | OLM_DLLEXPORT long double 35 | copysignl(long double x, long double y) 36 | { 37 | union IEEEl2bits ux, uy; 38 | 39 | ux.e = x; 40 | uy.e = y; 41 | ux.bits.sign = uy.bits.sign; 42 | return (ux.e); 43 | } 44 | -------------------------------------------------------------------------------- /src/s_cproj.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2008 David Schultz 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #include "cdefs-compat.h" 28 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_cproj.c,v 1.1 2008/08/07 15:07:48 das Exp $"); 29 | 30 | #include 31 | #include 32 | 33 | #include "math_private.h" 34 | 35 | OLM_DLLEXPORT double complex 36 | cproj(double complex z) 37 | { 38 | 39 | if (!isinf(creal(z)) && !isinf(cimag(z))) 40 | return (z); 41 | else 42 | return (CMPLX(INFINITY, copysign(0.0, cimag(z)))); 43 | } 44 | 45 | #if LDBL_MANT_DIG == 53 46 | openlibm_weak_reference(cproj, cprojl); 47 | #endif 48 | -------------------------------------------------------------------------------- /src/s_cprojf.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2008 David Schultz 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #include "cdefs-compat.h" 28 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_cprojf.c,v 1.1 2008/08/07 15:07:48 das Exp $"); 29 | 30 | #include 31 | #include 32 | 33 | #include "math_private.h" 34 | 35 | OLM_DLLEXPORT float complex 36 | cprojf(float complex z) 37 | { 38 | 39 | if (!isinf(crealf(z)) && !isinf(cimagf(z))) 40 | return (z); 41 | else 42 | return (CMPLXF(INFINITY, copysignf(0.0, cimagf(z)))); 43 | } 44 | -------------------------------------------------------------------------------- /src/s_cprojl.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2008 David Schultz 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #include "cdefs-compat.h" 28 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_cprojl.c,v 1.1 2008/08/07 15:07:48 das Exp $"); 29 | 30 | #include 31 | #include 32 | 33 | #include "math_private.h" 34 | 35 | OLM_DLLEXPORT long double complex 36 | cprojl(long double complex z) 37 | { 38 | 39 | if (!isinf(creall(z)) && !isinf(cimagl(z))) 40 | return (z); 41 | else 42 | return (CMPLXL(INFINITY, copysignl(0.0, cimagl(z)))); 43 | } 44 | -------------------------------------------------------------------------------- /src/s_creal.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2004 Stefan Farfeleder 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: src/lib/msun/src/s_creal.c,v 1.1 2004/05/30 09:21:56 stefanf Exp $ 27 | */ 28 | 29 | #include 30 | 31 | #include "math_private.h" 32 | 33 | OLM_DLLEXPORT double 34 | creal(double complex z) 35 | { 36 | return z; 37 | } 38 | -------------------------------------------------------------------------------- /src/s_crealf.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2004 Stefan Farfeleder 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: src/lib/msun/src/s_crealf.c,v 1.1 2004/05/30 09:21:56 stefanf Exp $ 27 | */ 28 | 29 | #include 30 | 31 | #include "math_private.h" 32 | 33 | OLM_DLLEXPORT float 34 | crealf(float complex z) 35 | { 36 | return z; 37 | } 38 | -------------------------------------------------------------------------------- /src/s_creall.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2004 Stefan Farfeleder 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: src/lib/msun/src/s_creall.c,v 1.1 2004/05/30 09:21:56 stefanf Exp $ 27 | */ 28 | 29 | #include 30 | 31 | #include "math_private.h" 32 | 33 | OLM_DLLEXPORT long double 34 | creall(long double complex z) 35 | { 36 | return z; 37 | } 38 | -------------------------------------------------------------------------------- /src/s_csinhl.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: s_csinhl.c,v 1.2 2011/07/20 19:28:33 martynas Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 2008 Stephen L. Moshier 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | /* csinhl 20 | * 21 | * Complex hyperbolic sine 22 | * 23 | * 24 | * 25 | * SYNOPSIS: 26 | * 27 | * long double complex csinhl(); 28 | * long double complex z, w; 29 | * 30 | * w = csinhl (z); 31 | * 32 | * DESCRIPTION: 33 | * 34 | * csinh z = (cexp(z) - cexp(-z))/2 35 | * = sinh x * cos y + i cosh x * sin y . 36 | * 37 | * ACCURACY: 38 | * 39 | * Relative error: 40 | * arithmetic domain # trials peak rms 41 | * IEEE -10,+10 30000 3.1e-16 8.2e-17 42 | * 43 | */ 44 | 45 | #include 46 | #include 47 | 48 | long double complex 49 | csinhl(long double complex z) 50 | { 51 | long double complex w; 52 | long double x, y; 53 | 54 | x = creall(z); 55 | y = cimagl(z); 56 | w = sinhl(x) * cosl(y) + (coshl(x) * sinl(y)) * I; 57 | return (w); 58 | } 59 | -------------------------------------------------------------------------------- /src/s_ctanhl.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: s_ctanhl.c,v 1.2 2011/07/20 19:28:33 martynas Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 2008 Stephen L. Moshier 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | /* ctanhl 20 | * 21 | * Complex hyperbolic tangent 22 | * 23 | * 24 | * 25 | * SYNOPSIS: 26 | * 27 | * long double complex ctanhl(); 28 | * long double complex z, w; 29 | * 30 | * w = ctanhl (z); 31 | * 32 | * 33 | * 34 | * DESCRIPTION: 35 | * 36 | * tanh z = (sinh 2x + i sin 2y) / (cosh 2x + cos 2y) . 37 | * 38 | * ACCURACY: 39 | * 40 | * Relative error: 41 | * arithmetic domain # trials peak rms 42 | * IEEE -10,+10 30000 1.7e-14 2.4e-16 43 | * 44 | */ 45 | 46 | #include 47 | #include 48 | 49 | long double complex 50 | ctanhl(long double complex z) 51 | { 52 | long double complex w; 53 | long double x, y, d; 54 | 55 | x = creall(z); 56 | y = cimagl(z); 57 | d = coshl(2.0L * x) + cosl(2.0L * y); 58 | w = sinhl(2.0L * x) / d + (sinl(2.0L * y) / d) * I; 59 | return (w); 60 | } 61 | -------------------------------------------------------------------------------- /src/s_fabs.c: -------------------------------------------------------------------------------- 1 | /* @(#)s_fabs.c 5.1 93/09/24 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunPro, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | */ 12 | 13 | /* 14 | * fabs(x) returns the absolute value of x. 15 | */ 16 | 17 | #include 18 | 19 | #include "math_private.h" 20 | 21 | OLM_DLLEXPORT double 22 | fabs(double x) 23 | { 24 | u_int32_t high; 25 | GET_HIGH_WORD(high,x); 26 | SET_HIGH_WORD(x,high&0x7fffffff); 27 | return x; 28 | } 29 | -------------------------------------------------------------------------------- /src/s_fabsf.c: -------------------------------------------------------------------------------- 1 | /* s_fabsf.c -- float version of s_fabs.c. 2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 | */ 4 | 5 | /* 6 | * ==================================================== 7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8 | * 9 | * Developed at SunPro, a Sun Microsystems, Inc. business. 10 | * Permission to use, copy, modify, and distribute this 11 | * software is freely granted, provided that this notice 12 | * is preserved. 13 | * ==================================================== 14 | */ 15 | 16 | #include "cdefs-compat.h" 17 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_fabsf.c,v 1.8 2008/02/22 02:30:35 das Exp $"); 18 | 19 | /* 20 | * fabsf(x) returns the absolute value of x. 21 | */ 22 | 23 | #include 24 | 25 | #include "math_private.h" 26 | 27 | OLM_DLLEXPORT float 28 | fabsf(float x) 29 | { 30 | u_int32_t ix; 31 | GET_FLOAT_WORD(ix,x); 32 | SET_FLOAT_WORD(x,ix&0x7fffffff); 33 | return x; 34 | } 35 | -------------------------------------------------------------------------------- /src/s_fabsl.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JuliaMath/openlibm/c9c6fd6eade60ba38427c675a7323b0d2bae6521/src/s_fabsl.c -------------------------------------------------------------------------------- /src/s_floorf.c: -------------------------------------------------------------------------------- 1 | /* s_floorf.c -- float version of s_floor.c. 2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 | */ 4 | 5 | /* 6 | * ==================================================== 7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8 | * 9 | * Developed at SunPro, a Sun Microsystems, Inc. business. 10 | * Permission to use, copy, modify, and distribute this 11 | * software is freely granted, provided that this notice 12 | * is preserved. 13 | * ==================================================== 14 | */ 15 | 16 | #include "cdefs-compat.h" 17 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_floorf.c,v 1.8 2008/02/22 02:30:35 das Exp $"); 18 | 19 | /* 20 | * floorf(x) 21 | * Return x rounded toward -inf to integral value 22 | * Method: 23 | * Bit twiddling. 24 | * Exception: 25 | * Inexact flag raised if x not equal to floorf(x). 26 | */ 27 | 28 | #include 29 | 30 | #include "math_private.h" 31 | 32 | static const float huge = 1.0e30; 33 | 34 | OLM_DLLEXPORT float 35 | floorf(float x) 36 | { 37 | int32_t i0,j0; 38 | u_int32_t i; 39 | GET_FLOAT_WORD(i0,x); 40 | j0 = ((i0>>23)&0xff)-0x7f; 41 | if(j0<23) { 42 | if(j0<0) { /* raise inexact if x != 0 */ 43 | if(huge+x>(float)0.0) {/* return 0*sign(x) if |x|<1 */ 44 | if(i0>=0) {i0=0;} 45 | else if((i0&0x7fffffff)!=0) 46 | { i0=0xbf800000;} 47 | } 48 | } else { 49 | i = (0x007fffff)>>j0; 50 | if((i0&i)==0) return x; /* x is integral */ 51 | if(huge+x>(float)0.0) { /* raise inexact flag */ 52 | if(i0<0) i0 += (0x00800000)>>j0; 53 | i0 &= (~i); 54 | } 55 | } 56 | } else { 57 | if(j0==0x80) return x+x; /* inf or NaN */ 58 | else return x; /* x is integral */ 59 | } 60 | SET_FLOAT_WORD(x,i0); 61 | return x; 62 | } 63 | -------------------------------------------------------------------------------- /src/s_frexp.c: -------------------------------------------------------------------------------- 1 | /* @(#)s_frexp.c 5.1 93/09/24 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunPro, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | */ 12 | 13 | #include "cdefs-compat.h" 14 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_frexp.c,v 1.11 2008/02/22 02:30:35 das Exp $"); 15 | 16 | /* 17 | * for non-zero x 18 | * x = frexp(arg,&exp); 19 | * return a double fp quantity x such that 0.5 <= |x| <1.0 20 | * and the corresponding binary exponent "exp". That is 21 | * arg = x*2^exp. 22 | * If arg is inf, 0.0, or NaN, then frexp(arg,&exp) returns arg 23 | * with *exp=0. 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | #include "math_private.h" 30 | 31 | static const double 32 | two54 = 1.80143985094819840000e+16; /* 0x43500000, 0x00000000 */ 33 | 34 | OLM_DLLEXPORT double 35 | frexp(double x, int *eptr) 36 | { 37 | int32_t hx, ix, lx; 38 | EXTRACT_WORDS(hx,lx,x); 39 | ix = 0x7fffffff&hx; 40 | *eptr = 0; 41 | if(ix>=0x7ff00000||((ix|lx)==0)) return x; /* 0,inf,nan */ 42 | if (ix<0x00100000) { /* subnormal */ 43 | x *= two54; 44 | GET_HIGH_WORD(hx,x); 45 | ix = hx&0x7fffffff; 46 | *eptr = -54; 47 | } 48 | *eptr += (ix>>20)-1022; 49 | hx = (hx&0x800fffff)|0x3fe00000; 50 | SET_HIGH_WORD(x,hx); 51 | return x; 52 | } 53 | 54 | #if (LDBL_MANT_DIG == 53) 55 | openlibm_weak_reference(frexp, frexpl); 56 | #endif 57 | -------------------------------------------------------------------------------- /src/s_frexpf.c: -------------------------------------------------------------------------------- 1 | /* s_frexpf.c -- float version of s_frexp.c. 2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 | */ 4 | 5 | /* 6 | * ==================================================== 7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8 | * 9 | * Developed at SunPro, a Sun Microsystems, Inc. business. 10 | * Permission to use, copy, modify, and distribute this 11 | * software is freely granted, provided that this notice 12 | * is preserved. 13 | * ==================================================== 14 | */ 15 | 16 | #include "cdefs-compat.h" 17 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_frexpf.c,v 1.10 2008/02/22 02:30:35 das Exp $"); 18 | 19 | #include 20 | 21 | #include "math_private.h" 22 | 23 | static const float 24 | two25 = 3.3554432000e+07; /* 0x4c000000 */ 25 | 26 | OLM_DLLEXPORT float 27 | frexpf(float x, int *eptr) 28 | { 29 | int32_t hx,ix; 30 | GET_FLOAT_WORD(hx,x); 31 | ix = 0x7fffffff&hx; 32 | *eptr = 0; 33 | if(ix>=0x7f800000||(ix==0)) return x; /* 0,inf,nan */ 34 | if (ix<0x00800000) { /* subnormal */ 35 | x *= two25; 36 | GET_FLOAT_WORD(hx,x); 37 | ix = hx&0x7fffffff; 38 | *eptr = -25; 39 | } 40 | *eptr += (ix>>23)-126; 41 | hx = (hx&0x807fffff)|0x3f000000; 42 | SET_FLOAT_WORD(x,hx); 43 | return x; 44 | } 45 | -------------------------------------------------------------------------------- /src/s_ilogb.c: -------------------------------------------------------------------------------- 1 | /* @(#)s_ilogb.c 5.1 93/09/24 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunPro, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | */ 12 | 13 | #include "cdefs-compat.h" 14 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_ilogb.c,v 1.10 2008/02/22 02:30:35 das Exp $"); 15 | 16 | /* ilogb(double x) 17 | * return the binary exponent of non-zero x 18 | * ilogb(0) = FP_ILOGB0 19 | * ilogb(NaN) = FP_ILOGBNAN (no signal is raised) 20 | * ilogb(inf) = INT_MAX (no signal is raised) 21 | */ 22 | 23 | #include 24 | #include 25 | 26 | #include "math_private.h" 27 | 28 | OLM_DLLEXPORT int 29 | ilogb(double x) 30 | { 31 | int32_t hx,lx,ix; 32 | 33 | EXTRACT_WORDS(hx,lx,x); 34 | hx &= 0x7fffffff; 35 | if(hx<0x00100000) { 36 | if((hx|lx)==0) 37 | return FP_ILOGB0; 38 | else /* subnormal x */ 39 | if(hx==0) { 40 | for (ix = -1043; lx>0; lx<<=1) ix -=1; 41 | } else { 42 | for (ix = -1022,hx<<=11; hx>0; hx<<=1) ix -=1; 43 | } 44 | return ix; 45 | } 46 | else if (hx<0x7ff00000) return (hx>>20)-1023; 47 | else if (hx>0x7ff00000 || lx!=0) return FP_ILOGBNAN; 48 | else return INT_MAX; 49 | } 50 | -------------------------------------------------------------------------------- /src/s_ilogbf.c: -------------------------------------------------------------------------------- 1 | /* s_ilogbf.c -- float version of s_ilogb.c. 2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 | */ 4 | 5 | /* 6 | * ==================================================== 7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8 | * 9 | * Developed at SunPro, a Sun Microsystems, Inc. business. 10 | * Permission to use, copy, modify, and distribute this 11 | * software is freely granted, provided that this notice 12 | * is preserved. 13 | * ==================================================== 14 | */ 15 | 16 | #include "cdefs-compat.h" 17 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_ilogbf.c,v 1.8 2008/02/22 02:30:35 das Exp $"); 18 | 19 | #include 20 | #include 21 | 22 | #include "math_private.h" 23 | 24 | OLM_DLLEXPORT int 25 | ilogbf(float x) 26 | { 27 | int32_t hx,ix; 28 | 29 | GET_FLOAT_WORD(hx,x); 30 | hx &= 0x7fffffff; 31 | if(hx<0x00800000) { 32 | if(hx==0) 33 | return FP_ILOGB0; 34 | else /* subnormal x */ 35 | for (ix = -126,hx<<=8; hx>0; hx<<=1) ix -=1; 36 | return ix; 37 | } 38 | else if (hx<0x7f800000) return (hx>>23)-127; 39 | else if (hx>0x7f800000) return FP_ILOGBNAN; 40 | else return INT_MAX; 41 | } 42 | -------------------------------------------------------------------------------- /src/s_ilogbl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * From: @(#)s_ilogb.c 5.1 93/09/24 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunPro, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | */ 12 | 13 | #include "cdefs-compat.h" 14 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_ilogbl.c,v 1.2 2008/02/22 02:30:35 das Exp $"); 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | #include "fpmath.h" 21 | #include "math_private.h" 22 | 23 | OLM_DLLEXPORT int 24 | ilogbl(long double x) 25 | { 26 | union IEEEl2bits u; 27 | unsigned long m; 28 | int b; 29 | 30 | u.e = x; 31 | if (u.bits.exp == 0) { 32 | if ((u.bits.manl | u.bits.manh) == 0) 33 | return (FP_ILOGB0); 34 | /* denormalized */ 35 | if (u.bits.manh == 0) { 36 | m = 1lu << (LDBL_MANL_SIZE - 1); 37 | for (b = LDBL_MANH_SIZE; !(u.bits.manl & m); m >>= 1) 38 | b++; 39 | } else { 40 | m = 1lu << (LDBL_MANH_SIZE - 1); 41 | for (b = 0; !(u.bits.manh & m); m >>= 1) 42 | b++; 43 | } 44 | #ifdef LDBL_IMPLICIT_NBIT 45 | b++; 46 | #endif 47 | return (LDBL_MIN_EXP - b - 1); 48 | } else if (u.bits.exp < (LDBL_MAX_EXP << 1) - 1) 49 | return (u.bits.exp - LDBL_MAX_EXP + 1); 50 | else if (u.bits.manl != 0 || u.bits.manh != 0) 51 | return (FP_ILOGBNAN); 52 | else 53 | return (INT_MAX); 54 | } 55 | -------------------------------------------------------------------------------- /src/s_llrint.c: -------------------------------------------------------------------------------- 1 | #include "cdefs-compat.h" 2 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_llrint.c,v 1.1 2005/01/11 23:12:55 das Exp $"); 3 | 4 | #define type double 5 | #define roundit rint 6 | #define dtype long long 7 | #define fn llrint 8 | 9 | #include "s_lrint.c" 10 | -------------------------------------------------------------------------------- /src/s_llrintf.c: -------------------------------------------------------------------------------- 1 | #include "cdefs-compat.h" 2 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_llrintf.c,v 1.1 2005/01/11 23:12:55 das Exp $"); 3 | 4 | #define type float 5 | #define roundit rintf 6 | #define dtype long long 7 | #define fn llrintf 8 | 9 | #include "s_lrint.c" 10 | -------------------------------------------------------------------------------- /src/s_llrintl.c: -------------------------------------------------------------------------------- 1 | #include "cdefs-compat.h" 2 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_llrintl.c,v 1.1 2008/01/14 02:12:06 das Exp $"); 3 | 4 | #define type long double 5 | #define roundit rintl 6 | #define dtype long long 7 | #define fn llrintl 8 | 9 | #include "s_lrint.c" 10 | -------------------------------------------------------------------------------- /src/s_llround.c: -------------------------------------------------------------------------------- 1 | #include "cdefs-compat.h" 2 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_llround.c,v 1.2 2005/04/08 00:52:27 das Exp $"); 3 | 4 | #define type double 5 | #define roundit round 6 | #define dtype long long 7 | #define DTYPE_MIN LLONG_MIN 8 | #define DTYPE_MAX LLONG_MAX 9 | #define fn llround 10 | 11 | #include "s_lround.c" 12 | -------------------------------------------------------------------------------- /src/s_llroundf.c: -------------------------------------------------------------------------------- 1 | #include "cdefs-compat.h" 2 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_llroundf.c,v 1.2 2005/04/08 00:52:27 das Exp $"); 3 | 4 | #define type float 5 | #define roundit roundf 6 | #define dtype long long 7 | #define DTYPE_MIN LLONG_MIN 8 | #define DTYPE_MAX LLONG_MAX 9 | #define fn llroundf 10 | 11 | #include "s_lround.c" 12 | -------------------------------------------------------------------------------- /src/s_llroundl.c: -------------------------------------------------------------------------------- 1 | #include "cdefs-compat.h" 2 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_llroundl.c,v 1.1 2005/04/08 01:24:08 das Exp $"); 3 | 4 | #define type long double 5 | #define roundit roundl 6 | #define dtype long long 7 | #define DTYPE_MIN LLONG_MIN 8 | #define DTYPE_MAX LLONG_MAX 9 | #define fn llroundl 10 | 11 | #include "s_lround.c" 12 | -------------------------------------------------------------------------------- /src/s_logb.c: -------------------------------------------------------------------------------- 1 | /* @(#)s_logb.c 5.1 93/09/24 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunPro, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | */ 12 | 13 | #include "cdefs-compat.h" 14 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_logb.c,v 1.12 2008/02/08 01:22:13 bde Exp $"); 15 | 16 | /* 17 | * double logb(x) 18 | * IEEE 754 logb. Included to pass IEEE test suite. Not recommend. 19 | * Use ilogb instead. 20 | */ 21 | 22 | #include 23 | #include 24 | 25 | #include "math_private.h" 26 | 27 | static const double 28 | two54 = 1.80143985094819840000e+16; /* 43500000 00000000 */ 29 | 30 | OLM_DLLEXPORT double 31 | logb(double x) 32 | { 33 | int32_t lx,ix; 34 | EXTRACT_WORDS(ix,lx,x); 35 | ix &= 0x7fffffff; /* high |x| */ 36 | if((ix|lx)==0) return -1.0/fabs(x); 37 | if(ix>=0x7ff00000) return x*x; 38 | if(ix<0x00100000) { 39 | x *= two54; /* convert subnormal x to normal */ 40 | GET_HIGH_WORD(ix,x); 41 | ix &= 0x7fffffff; 42 | return (double) ((ix>>20)-1023-54); 43 | } else 44 | return (double) ((ix>>20)-1023); 45 | } 46 | 47 | #if (LDBL_MANT_DIG == 53) 48 | openlibm_weak_reference(logb, logbl); 49 | #endif 50 | -------------------------------------------------------------------------------- /src/s_logbf.c: -------------------------------------------------------------------------------- 1 | /* s_logbf.c -- float version of s_logb.c. 2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 | */ 4 | 5 | /* 6 | * ==================================================== 7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8 | * 9 | * Developed at SunPro, a Sun Microsystems, Inc. business. 10 | * Permission to use, copy, modify, and distribute this 11 | * software is freely granted, provided that this notice 12 | * is preserved. 13 | * ==================================================== 14 | */ 15 | 16 | #include "cdefs-compat.h" 17 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_logbf.c,v 1.9 2008/02/22 02:30:35 das Exp $"); 18 | 19 | #include 20 | 21 | #include "math_private.h" 22 | 23 | static const float 24 | two25 = 3.355443200e+07; /* 0x4c000000 */ 25 | 26 | OLM_DLLEXPORT float 27 | logbf(float x) 28 | { 29 | int32_t ix; 30 | GET_FLOAT_WORD(ix,x); 31 | ix &= 0x7fffffff; /* high |x| */ 32 | if(ix==0) return (float)-1.0/fabsf(x); 33 | if(ix>=0x7f800000) return x*x; 34 | if(ix<0x00800000) { 35 | x *= two25; /* convert subnormal x to normal */ 36 | GET_FLOAT_WORD(ix,x); 37 | ix &= 0x7fffffff; 38 | return (float) ((ix>>23)-127-25); 39 | } else 40 | return (float) ((ix>>23)-127); 41 | } 42 | -------------------------------------------------------------------------------- /src/s_logbl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * From: @(#)s_ilogb.c 5.1 93/09/24 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunPro, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #include "fpmath.h" 18 | #include "math_private.h" 19 | 20 | OLM_DLLEXPORT long double 21 | logbl(long double x) 22 | { 23 | union IEEEl2bits u; 24 | unsigned long m; 25 | int b; 26 | 27 | u.e = x; 28 | if (u.bits.exp == 0) { 29 | if ((u.bits.manl | u.bits.manh) == 0) { /* x == 0 */ 30 | u.bits.sign = 1; 31 | return (1.0L / u.e); 32 | } 33 | /* denormalized */ 34 | if (u.bits.manh == 0) { 35 | m = 1lu << (LDBL_MANL_SIZE - 1); 36 | for (b = LDBL_MANH_SIZE; !(u.bits.manl & m); m >>= 1) 37 | b++; 38 | } else { 39 | m = 1lu << (LDBL_MANH_SIZE - 1); 40 | for (b = 0; !(u.bits.manh & m); m >>= 1) 41 | b++; 42 | } 43 | #ifdef LDBL_IMPLICIT_NBIT 44 | b++; 45 | #endif 46 | return ((long double)(LDBL_MIN_EXP - b - 1)); 47 | } 48 | if (u.bits.exp < (LDBL_MAX_EXP << 1) - 1) /* normal */ 49 | return ((long double)(u.bits.exp - LDBL_MAX_EXP + 1)); 50 | else /* +/- inf or nan */ 51 | return (x * x); 52 | } 53 | -------------------------------------------------------------------------------- /src/s_lrintf.c: -------------------------------------------------------------------------------- 1 | #include "cdefs-compat.h" 2 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_lrintf.c,v 1.1 2005/01/11 23:12:55 das Exp $"); 3 | 4 | #define type float 5 | #define roundit rintf 6 | #define dtype long 7 | #define fn lrintf 8 | 9 | #include "s_lrint.c" 10 | -------------------------------------------------------------------------------- /src/s_lrintl.c: -------------------------------------------------------------------------------- 1 | #include "cdefs-compat.h" 2 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_lrintl.c,v 1.1 2008/01/14 02:12:06 das Exp $"); 3 | 4 | #define type long double 5 | #define roundit rintl 6 | #define dtype long 7 | #define fn lrintl 8 | 9 | #include "s_lrint.c" 10 | -------------------------------------------------------------------------------- /src/s_lroundf.c: -------------------------------------------------------------------------------- 1 | #include "cdefs-compat.h" 2 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_lroundf.c,v 1.2 2005/04/08 00:52:27 das Exp $"); 3 | 4 | #define type float 5 | #define roundit roundf 6 | #define dtype long 7 | #define DTYPE_MIN LONG_MIN 8 | #define DTYPE_MAX LONG_MAX 9 | #define fn lroundf 10 | 11 | #include "s_lround.c" 12 | -------------------------------------------------------------------------------- /src/s_lroundl.c: -------------------------------------------------------------------------------- 1 | #include "cdefs-compat.h" 2 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_lroundl.c,v 1.1 2005/04/08 01:24:08 das Exp $"); 3 | 4 | #define type long double 5 | #define roundit roundl 6 | #define dtype long 7 | #define DTYPE_MIN LONG_MIN 8 | #define DTYPE_MAX LONG_MAX 9 | #define fn lroundl 10 | 11 | #include "s_lround.c" 12 | -------------------------------------------------------------------------------- /src/s_modff.c: -------------------------------------------------------------------------------- 1 | /* s_modff.c -- float version of s_modf.c. 2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 | */ 4 | 5 | /* 6 | * ==================================================== 7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8 | * 9 | * Developed at SunPro, a Sun Microsystems, Inc. business. 10 | * Permission to use, copy, modify, and distribute this 11 | * software is freely granted, provided that this notice 12 | * is preserved. 13 | * ==================================================== 14 | */ 15 | 16 | #include "cdefs-compat.h" 17 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_modff.c,v 1.9 2008/02/22 02:30:35 das Exp $"); 18 | 19 | #include 20 | 21 | #include "math_private.h" 22 | 23 | static const float one = 1.0; 24 | 25 | OLM_DLLEXPORT float 26 | modff(float x, float *iptr) 27 | { 28 | int32_t i0,j0; 29 | u_int32_t i; 30 | GET_FLOAT_WORD(i0,x); 31 | j0 = ((i0>>23)&0xff)-0x7f; /* exponent of x */ 32 | if(j0<23) { /* integer part in x */ 33 | if(j0<0) { /* |x|<1 */ 34 | SET_FLOAT_WORD(*iptr,i0&0x80000000); /* *iptr = +-0 */ 35 | return x; 36 | } else { 37 | i = (0x007fffff)>>j0; 38 | if((i0&i)==0) { /* x is integral */ 39 | u_int32_t ix; 40 | *iptr = x; 41 | GET_FLOAT_WORD(ix,x); 42 | SET_FLOAT_WORD(x,ix&0x80000000); /* return +-0 */ 43 | return x; 44 | } else { 45 | SET_FLOAT_WORD(*iptr,i0&(~i)); 46 | return x - *iptr; 47 | } 48 | } 49 | } else { /* no fraction part */ 50 | u_int32_t ix; 51 | *iptr = x*one; 52 | if (x != x) /* NaN */ 53 | return x; 54 | GET_FLOAT_WORD(ix,x); 55 | SET_FLOAT_WORD(x,ix&0x80000000); /* return +-0 */ 56 | return x; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/s_nexttowardf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ==================================================== 3 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 4 | * 5 | * Developed at SunPro, a Sun Microsystems, Inc. business. 6 | * Permission to use, copy, modify, and distribute this 7 | * software is freely granted, provided that this notice 8 | * is preserved. 9 | * ==================================================== 10 | */ 11 | 12 | #include "cdefs-compat.h" 13 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_nexttowardf.c,v 1.3 2011/02/10 07:38:38 das Exp $"); 14 | 15 | #include 16 | #include 17 | 18 | #include "fpmath.h" 19 | #include "math_private.h" 20 | 21 | #define LDBL_INFNAN_EXP (LDBL_MAX_EXP * 2 - 1) 22 | 23 | #ifdef OLM_LONG_DOUBLE 24 | OLM_DLLEXPORT float 25 | nexttowardf(float x, long double y) 26 | { 27 | union IEEEl2bits uy; 28 | volatile float t; 29 | int32_t hx,ix; 30 | 31 | GET_FLOAT_WORD(hx,x); 32 | ix = hx&0x7fffffff; /* |x| */ 33 | uy.e = y; 34 | 35 | if((ix>0x7f800000) || 36 | (uy.bits.exp == LDBL_INFNAN_EXP && 37 | ((uy.bits.manh&~LDBL_NBIT)|uy.bits.manl) != 0)) 38 | return x+y; /* x or y is nan */ 39 | if(x==y) return (float)y; /* x=y, return y */ 40 | if(ix==0) { /* x == 0 */ 41 | SET_FLOAT_WORD(x,(uy.bits.sign<<31)|1);/* return +-minsubnormal */ 42 | t = x*x; 43 | if(t==x) return t; else return x; /* raise underflow flag */ 44 | } 45 | if((hx>=0) ^ (x < y)) /* x -= ulp */ 46 | hx -= 1; 47 | else /* x += ulp */ 48 | hx += 1; 49 | ix = hx&0x7f800000; 50 | if(ix>=0x7f800000) return x+x; /* overflow */ 51 | if(ix<0x00800000) { /* underflow */ 52 | t = x*x; 53 | if(t!=x) { /* raise underflow flag */ 54 | SET_FLOAT_WORD(x,hx); 55 | return x; 56 | } 57 | } 58 | SET_FLOAT_WORD(x,hx); 59 | return x; 60 | } 61 | #endif 62 | -------------------------------------------------------------------------------- /src/s_rintf.c: -------------------------------------------------------------------------------- 1 | /* s_rintf.c -- float version of s_rint.c. 2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 | */ 4 | 5 | /* 6 | * ==================================================== 7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8 | * 9 | * Developed at SunPro, a Sun Microsystems, Inc. business. 10 | * Permission to use, copy, modify, and distribute this 11 | * software is freely granted, provided that this notice 12 | * is preserved. 13 | * ==================================================== 14 | */ 15 | 16 | #include "cdefs-compat.h" 17 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_rintf.c,v 1.12 2008/02/22 02:30:35 das Exp $"); 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include "math_private.h" 24 | 25 | static const float 26 | TWO23[2]={ 27 | 8.3886080000e+06, /* 0x4b000000 */ 28 | -8.3886080000e+06, /* 0xcb000000 */ 29 | }; 30 | 31 | OLM_DLLEXPORT float 32 | rintf(float x) 33 | { 34 | int32_t i0,j0,sx; 35 | float w,t; 36 | GET_FLOAT_WORD(i0,x); 37 | sx = (i0>>31)&1; 38 | j0 = ((i0>>23)&0xff)-0x7f; 39 | if(j0<23) { 40 | if(j0<0) { 41 | if((i0&0x7fffffff)==0) return x; 42 | STRICT_ASSIGN(float,w,TWO23[sx]+x); 43 | t = w-TWO23[sx]; 44 | GET_FLOAT_WORD(i0,t); 45 | SET_FLOAT_WORD(t,(i0&0x7fffffff)|(sx<<31)); 46 | return t; 47 | } 48 | STRICT_ASSIGN(float,w,TWO23[sx]+x); 49 | return w-TWO23[sx]; 50 | } 51 | if(j0==0x80) return x+x; /* inf or NaN */ 52 | else return x; /* x is integral */ 53 | } 54 | -------------------------------------------------------------------------------- /src/s_roundf.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2003, Steven G. Kargl 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice unmodified, this list of conditions, and the following 10 | * disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #include "cdefs-compat.h" 28 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_roundf.c,v 1.4 2005/12/02 13:45:06 bde Exp $"); 29 | 30 | #include 31 | 32 | #include "math_private.h" 33 | 34 | OLM_DLLEXPORT float 35 | roundf(float x) 36 | { 37 | float t; 38 | 39 | if (!isfinite(x)) 40 | return (x); 41 | 42 | if (x >= 0.0) { 43 | t = floorf(x); 44 | if (t - x <= -0.5) 45 | t += 1.0; 46 | return (t); 47 | } else { 48 | t = floorf(-x); 49 | if (t + x <= -0.5) 50 | t += 1.0; 51 | return (-t); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/s_roundl.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2003, Steven G. Kargl 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice unmodified, this list of conditions, and the following 10 | * disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #include "cdefs-compat.h" 28 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_roundl.c,v 1.2 2005/12/02 13:45:06 bde Exp $"); 29 | 30 | #include 31 | 32 | #include "math_private.h" 33 | 34 | OLM_DLLEXPORT long double 35 | roundl(long double x) 36 | { 37 | long double t; 38 | 39 | if (!isfinite(x)) 40 | return (x); 41 | 42 | if (x >= 0.0) { 43 | t = floorl(x); 44 | if (t - x <= -0.5) 45 | t += 1.0; 46 | return (t); 47 | } else { 48 | t = floorl(-x); 49 | if (t + x <= -0.5) 50 | t += 1.0; 51 | return (-t); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/s_scalbnf.c: -------------------------------------------------------------------------------- 1 | /* s_scalbnf.c -- float version of s_scalbn.c. 2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 | */ 4 | 5 | /* 6 | * ==================================================== 7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8 | * 9 | * Developed at SunPro, a Sun Microsystems, Inc. business. 10 | * Permission to use, copy, modify, and distribute this 11 | * software is freely granted, provided that this notice 12 | * is preserved. 13 | * ==================================================== 14 | */ 15 | 16 | 17 | #include "cdefs-compat.h" 18 | 19 | #include 20 | 21 | #include "math_private.h" 22 | 23 | static const float 24 | two25 = 3.355443200e+07, /* 0x4c000000 */ 25 | twom25 = 2.9802322388e-08, /* 0x33000000 */ 26 | huge = 1.0e+30, 27 | tiny = 1.0e-30; 28 | 29 | OLM_DLLEXPORT float 30 | scalbnf (float x, int n) 31 | { 32 | int32_t k,ix; 33 | GET_FLOAT_WORD(ix,x); 34 | k = (ix&0x7f800000)>>23; /* extract exponent */ 35 | if (k==0) { /* 0 or subnormal x */ 36 | if ((ix&0x7fffffff)==0) return x; /* +-0 */ 37 | x *= two25; 38 | GET_FLOAT_WORD(ix,x); 39 | k = ((ix&0x7f800000)>>23) - 25; 40 | if (n< -50000) return tiny*x; /*underflow*/ 41 | } 42 | if (k==0xff) return x+x; /* NaN or Inf */ 43 | k = k+n; 44 | if (k > 0xfe) return huge*copysignf(huge,x); /* overflow */ 45 | if (k > 0) /* normal result */ 46 | {SET_FLOAT_WORD(x,(ix&0x807fffff)|(k<<23)); return x;} 47 | if (k <= -25) { 48 | if (n > 50000) /* in case integer overflow in n+k */ 49 | return huge*copysignf(huge,x); /*overflow*/ 50 | else return tiny*copysignf(tiny,x); /*underflow*/ 51 | } 52 | k += 25; /* subnormal result */ 53 | SET_FLOAT_WORD(x,(ix&0x807fffff)|(k<<23)); 54 | return x*twom25; 55 | } 56 | 57 | openlibm_strong_reference(scalbnf, ldexpf); 58 | -------------------------------------------------------------------------------- /src/s_signgam.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "math_private.h" 4 | 5 | #ifndef OPENLIBM_ONLY_THREAD_SAFE 6 | int signgam = 0; 7 | #endif 8 | -------------------------------------------------------------------------------- /src/s_sincosl.c: -------------------------------------------------------------------------------- 1 | /* s_sincosl.c -- long double version of s_sincos.c 2 | * 3 | * Copyright (C) 2013 Elliot Saba 4 | * Developed at the University of Washington 5 | * 6 | * Permission to use, copy, modify, and distribute this 7 | * software is freely granted, provided that this notice 8 | * is preserved. 9 | * ==================================================== 10 | */ 11 | 12 | #include "cdefs-compat.h" 13 | 14 | #include 15 | #include 16 | 17 | #include "math_private.h" 18 | #if LDBL_MANT_DIG == 64 19 | #include "../ld80/e_rem_pio2l.h" 20 | #elif LDBL_MANT_DIG == 113 21 | #include "../ld128/e_rem_pio2l.h" 22 | #else 23 | #error "Unsupported long double format" 24 | #endif 25 | 26 | OLM_DLLEXPORT void 27 | sincosl( long double x, long double * s, long double * c ) 28 | { 29 | *s = sinl( x ); 30 | *c = cosl( x ); 31 | } 32 | -------------------------------------------------------------------------------- /src/s_tanhf.c: -------------------------------------------------------------------------------- 1 | /* s_tanhf.c -- float version of s_tanh.c. 2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 | */ 4 | 5 | /* 6 | * ==================================================== 7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8 | * 9 | * Developed at SunPro, a Sun Microsystems, Inc. business. 10 | * Permission to use, copy, modify, and distribute this 11 | * software is freely granted, provided that this notice 12 | * is preserved. 13 | * ==================================================== 14 | */ 15 | 16 | #include "cdefs-compat.h" 17 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_tanhf.c,v 1.9 2008/02/22 02:30:36 das Exp $"); 18 | 19 | #include 20 | 21 | #include "math_private.h" 22 | 23 | static const float one=1.0, two=2.0, tiny = 1.0e-30, huge = 1.0e30; 24 | OLM_DLLEXPORT float 25 | tanhf(float x) 26 | { 27 | float t,z; 28 | int32_t jx,ix; 29 | 30 | GET_FLOAT_WORD(jx,x); 31 | ix = jx&0x7fffffff; 32 | 33 | /* x is INF or NaN */ 34 | if(ix>=0x7f800000) { 35 | if (jx>=0) return one/x+one; /* tanh(+-inf)=+-1 */ 36 | else return one/x-one; /* tanh(NaN) = NaN */ 37 | } 38 | 39 | /* |x| < 9 */ 40 | if (ix < 0x41100000) { /* |x|<9 */ 41 | if (ix<0x39800000) { /* |x|<2**-12 */ 42 | if(huge+x>one) return x; /* tanh(tiny) = tiny with inexact */ 43 | } 44 | if (ix>=0x3f800000) { /* |x|>=1 */ 45 | t = expm1f(two*fabsf(x)); 46 | z = one - two/(t+two); 47 | } else { 48 | t = expm1f(-two*fabsf(x)); 49 | z= -t/(t+two); 50 | } 51 | /* |x| >= 9, return +-1 */ 52 | } else { 53 | z = one - tiny; /* raise inexact flag */ 54 | } 55 | return (jx>=0)? z: -z; 56 | } 57 | -------------------------------------------------------------------------------- /src/s_trunc.c: -------------------------------------------------------------------------------- 1 | /* @(#)s_floor.c 5.1 93/09/24 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunPro, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | */ 12 | 13 | #include "cdefs-compat.h" 14 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_trunc.c,v 1.4 2008/02/22 02:27:34 das Exp $"); 15 | 16 | /* 17 | * trunc(x) 18 | * Return x rounded toward 0 to integral value 19 | * Method: 20 | * Bit twiddling. 21 | * Exception: 22 | * Inexact flag raised if x not equal to trunc(x). 23 | */ 24 | 25 | #include 26 | #include 27 | 28 | #include "math_private.h" 29 | 30 | static const double huge = 1.0e300; 31 | 32 | OLM_DLLEXPORT double 33 | trunc(double x) 34 | { 35 | int32_t i0,i1,j0; 36 | u_int32_t i; 37 | EXTRACT_WORDS(i0,i1,x); 38 | j0 = ((i0>>20)&0x7ff)-0x3ff; 39 | if(j0<20) { 40 | if(j0<0) { /* raise inexact if x != 0 */ 41 | if(huge+x>0.0) {/* |x|<1, so return 0*sign(x) */ 42 | i0 &= 0x80000000U; 43 | i1 = 0; 44 | } 45 | } else { 46 | i = (0x000fffff)>>j0; 47 | if(((i0&i)|i1)==0) return x; /* x is integral */ 48 | if(huge+x>0.0) { /* raise inexact flag */ 49 | i0 &= (~i); i1=0; 50 | } 51 | } 52 | } else if (j0>51) { 53 | if(j0==0x400) return x+x; /* inf or NaN */ 54 | else return x; /* x is integral */ 55 | } else { 56 | i = ((u_int32_t)(0xffffffff))>>(j0-20); 57 | if((i1&i)==0) return x; /* x is integral */ 58 | if(huge+x>0.0) /* raise inexact flag */ 59 | i1 &= (~i); 60 | } 61 | INSERT_WORDS(x,i0,i1); 62 | return x; 63 | } 64 | 65 | #if LDBL_MANT_DIG == 53 66 | openlibm_weak_reference(trunc, truncl); 67 | #endif 68 | -------------------------------------------------------------------------------- /src/s_truncf.c: -------------------------------------------------------------------------------- 1 | /* @(#)s_floor.c 5.1 93/09/24 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunPro, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | */ 12 | 13 | #include "cdefs-compat.h" 14 | //__FBSDID("$FreeBSD: src/lib/msun/src/s_truncf.c,v 1.1 2004/06/20 09:25:43 das Exp $"); 15 | 16 | /* 17 | * truncf(x) 18 | * Return x rounded toward 0 to integral value 19 | * Method: 20 | * Bit twiddling. 21 | * Exception: 22 | * Inexact flag raised if x not equal to truncf(x). 23 | */ 24 | 25 | #include 26 | 27 | #include "math_private.h" 28 | 29 | static const float huge = 1.0e30F; 30 | 31 | OLM_DLLEXPORT float 32 | truncf(float x) 33 | { 34 | int32_t i0,j0; 35 | u_int32_t i; 36 | GET_FLOAT_WORD(i0,x); 37 | j0 = ((i0>>23)&0xff)-0x7f; 38 | if(j0<23) { 39 | if(j0<0) { /* raise inexact if x != 0 */ 40 | if(huge+x>0.0F) /* |x|<1, so return 0*sign(x) */ 41 | i0 &= 0x80000000; 42 | } else { 43 | i = (0x007fffff)>>j0; 44 | if((i0&i)==0) return x; /* x is integral */ 45 | if(huge+x>0.0F) /* raise inexact flag */ 46 | i0 &= (~i); 47 | } 48 | } else { 49 | if(j0==0x80) return x+x; /* inf or NaN */ 50 | else return x; /* x is integral */ 51 | } 52 | SET_FLOAT_WORD(x,i0); 53 | return x; 54 | } 55 | -------------------------------------------------------------------------------- /src/types-compat.h: -------------------------------------------------------------------------------- 1 | #ifndef _TYPES_COMPAT_H_ 2 | #define _TYPES_COMPAT_H_ 3 | 4 | #include 5 | #include 6 | 7 | typedef uint8_t u_int8_t; 8 | typedef uint16_t u_int16_t; 9 | typedef uint32_t u_int32_t; 10 | typedef uint64_t u_int64_t; 11 | 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /src/w_cabs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * cabs() wrapper for hypot(). 3 | * 4 | * Written by J.T. Conklin, 5 | * Placed into the Public Domain, 1994. 6 | */ 7 | 8 | #include "cdefs-compat.h" 9 | //__FBSDID("$FreeBSD: src/lib/msun/src/w_cabs.c,v 1.7 2008/03/30 20:03:06 das Exp $"); 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include "math_private.h" 16 | 17 | OLM_DLLEXPORT double 18 | cabs(double complex z) 19 | { 20 | return hypot(creal(z), cimag(z)); 21 | } 22 | 23 | #if LDBL_MANT_DIG == 53 24 | openlibm_weak_reference(cabs, cabsl); 25 | #endif 26 | -------------------------------------------------------------------------------- /src/w_cabsf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * cabsf() wrapper for hypotf(). 3 | * 4 | * Written by J.T. Conklin, 5 | * Placed into the Public Domain, 1994. 6 | */ 7 | 8 | #include 9 | #include 10 | 11 | #include "math_private.h" 12 | 13 | OLM_DLLEXPORT float 14 | cabsf(z) 15 | float complex z; 16 | { 17 | 18 | return hypotf(crealf(z), cimagf(z)); 19 | } 20 | -------------------------------------------------------------------------------- /src/w_cabsl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * cabs() wrapper for hypot(). 3 | * 4 | * Written by J.T. Conklin, 5 | * Placed into the Public Domain, 1994. 6 | * 7 | * Modified by Steven G. Kargl for the long double type. 8 | */ 9 | 10 | #include "cdefs-compat.h" 11 | //__FBSDID("$FreeBSD: src/lib/msun/src/w_cabsl.c,v 1.1 2008/03/30 20:02:03 das Exp $"); 12 | 13 | #include 14 | #include 15 | 16 | #include "math_private.h" 17 | 18 | OLM_DLLEXPORT long double 19 | cabsl(long double complex z) 20 | { 21 | return hypotl(creall(z), cimagl(z)); 22 | } 23 | -------------------------------------------------------------------------------- /test/.gitignore: -------------------------------------------------------------------------------- 1 | /test-float 2 | /test-float-system 3 | /test-float.dSYM 4 | /test-double 5 | /test-double-system 6 | /test-double.dSYM 7 | /bench-openlibm 8 | /bench-syslibm 9 | /*.exe 10 | -------------------------------------------------------------------------------- /test/Makefile: -------------------------------------------------------------------------------- 1 | OPENLIBM_HOME=$(abspath ..) 2 | include ../Make.inc 3 | 4 | # Set rpath of tests to builddir for loading shared library 5 | OPENLIBM_LIB = -L.. -lopenlibm 6 | ifneq ($(OS),WINNT) 7 | ifneq ($(OS),Darwin) 8 | OPENLIBM_LIB += -Wl,-rpath=$(OPENLIBM_HOME) 9 | endif 10 | else # WINNT 11 | CFLAGS_add += -DIMPORT_EXPORTS 12 | endif 13 | 14 | all: test-double test-float # test-double-system test-float-system 15 | 16 | bench: bench-syslibm bench-openlibm 17 | 18 | test-double: test-double.c libm-test.c libm-test-ulps.h 19 | $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_add) $(LDFLAGS) $(LDFLAGS_arch) $@.c -D__BSD_VISIBLE -I ../include -I../src $(OPENLIBM_LIB) -o $@ 20 | 21 | test-float: test-float.c libm-test.c libm-test-ulps.h 22 | $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_add) $(LDFLAGS) $(LDFLAGS_arch) $@.c -D__BSD_VISIBLE -I ../include -I../src $(OPENLIBM_LIB) -o $@ 23 | 24 | test-double-system: test-double.c libm-test.c libm-test-ulps.h 25 | $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_add) $(LDFLAGS) $(LDFLAGS_arch) $< -DSYS_MATH_H -lm -o $@ 26 | 27 | test-float-system: test-float.c libm-test.c libm-test-ulps.h 28 | $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_add) $(LDFLAGS) $(LDFLAGS_arch) $< -DSYS_MATH_H -lm -o $@ 29 | 30 | bench-openlibm: libm-bench.cpp 31 | $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_add) $(LDFLAGS) $(LDFLAGS_arch) $< $(OPENLIBM_LIB) -o $@ 32 | 33 | bench-syslibm: libm-bench.cpp 34 | $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_add) $(LDFLAGS) $(LDFLAGS_arch) $< -lm -o $@ 35 | 36 | clean: 37 | rm -fr test-double test-float test-double-system test-float-system bench-openlibm bench-syslibm *.dSYM 38 | -------------------------------------------------------------------------------- /test/test-211.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int 6 | main() 7 | { 8 | float x = 0xd.65874p-4f; 9 | float y = 4.0f; 10 | float z = powf (x, y); 11 | assert(z==0x1.f74424p-2); 12 | } 13 | -------------------------------------------------------------------------------- /test/test-double.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1997, 1999 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | Contributed by Andreas Jaeger , 1997. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #define FUNC(function) function 21 | #define FLOAT double 22 | #define TEST_MSG "testing double (without inline functions)\n" 23 | #define MATHCONST(x) x 24 | #define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cdouble 25 | #define PRINTF_EXPR "e" 26 | #define PRINTF_XEXPR "a" 27 | #define PRINTF_NEXPR "f" 28 | #define TEST_DOUBLE 1 29 | 30 | #ifndef __NO_MATH_INLINES 31 | # define __NO_MATH_INLINES 32 | #endif 33 | 34 | #include "libm-test.c" 35 | -------------------------------------------------------------------------------- /test/test-float.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1997, 1999 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | Contributed by Andreas Jaeger , 1997. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #define FUNC(function) function ## f 21 | #define FLOAT float 22 | #define TEST_MSG "testing float (without inline functions)\n" 23 | #define MATHCONST(x) x 24 | #define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cfloat 25 | #define PRINTF_EXPR "e" 26 | #define PRINTF_XEXPR "a" 27 | #define PRINTF_NEXPR "f" 28 | #define TEST_FLOAT 1 29 | 30 | #ifndef __NO_MATH_INLINES 31 | # define __NO_MATH_INLINES 32 | #endif 33 | 34 | #include "libm-test.c" 35 | -------------------------------------------------------------------------------- /wasm32/Make.files: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JuliaMath/openlibm/c9c6fd6eade60ba38427c675a7323b0d2bae6521/wasm32/Make.files -------------------------------------------------------------------------------- /wasm32/assert.h: -------------------------------------------------------------------------------- 1 | #define assert(x) ((void)0) 2 | -------------------------------------------------------------------------------- /wasm32/float.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define FLT_RADIX 2 4 | 5 | #define FLT_TRUE_MIN 1.40129846432481707092e-45F 6 | #define FLT_MIN 1.17549435082228750797e-38F 7 | #define FLT_MAX 3.40282346638528859812e+38F 8 | #define FLT_EPSILON 1.1920928955078125e-07F 9 | 10 | #define FLT_MANT_DIG 24 11 | #define FLT_MIN_EXP (-125) 12 | #define FLT_MAX_EXP 128 13 | #define FLT_HAS_SUBNORM 1 14 | 15 | #define FLT_DIG 6 16 | #define FLT_DECIMAL_DIG 9 17 | #define FLT_MIN_10_EXP (-37) 18 | #define FLT_MAX_10_EXP 38 19 | 20 | #define DBL_TRUE_MIN 4.94065645841246544177e-324 21 | #define DBL_MIN 2.22507385850720138309e-308 22 | #define DBL_MAX 1.79769313486231570815e+308 23 | #define DBL_EPSILON 2.22044604925031308085e-16 24 | 25 | #define DBL_MANT_DIG 53 26 | #define DBL_MIN_EXP (-1021) 27 | #define DBL_MAX_EXP 1024 28 | #define DBL_HAS_SUBNORM 1 29 | 30 | #define DBL_DIG 15 31 | #define DBL_DECIMAL_DIG 17 32 | #define DBL_MIN_10_EXP (-307) 33 | #define DBL_MAX_10_EXP 308 34 | -------------------------------------------------------------------------------- /wasm32/limits.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define INT_MIN INT32_MIN 4 | #define INT_MAX INT32_MAX 5 | #define LONG_MIN INT32_MIN 6 | #define LONG_MAX INT32_MAX 7 | #define LLONG_MIN INT64_MIN 8 | #define LLONG_MAX INT64_MAX 9 | 10 | -------------------------------------------------------------------------------- /wasm32/stdint.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef unsigned char uint8_t; 4 | typedef unsigned short uint16_t; 5 | typedef unsigned int uint32_t; 6 | typedef unsigned long long uint64_t; 7 | 8 | typedef char int8_t; 9 | typedef short int16_t; 10 | typedef int int32_t; 11 | typedef long long int64_t; 12 | 13 | typedef unsigned int uintptr_t; 14 | typedef int intptr_t; 15 | 16 | _Static_assert(sizeof (uint8_t) == 1, "invalid size"); 17 | _Static_assert(sizeof (uint16_t) == 2, "invalid size"); 18 | _Static_assert(sizeof (uint32_t) == 4, "invalid size"); 19 | _Static_assert(sizeof (uint64_t) == 8, "invalid size"); 20 | 21 | _Static_assert(sizeof (int8_t) == 1, "invalid size"); 22 | _Static_assert(sizeof (int16_t) == 2, "invalid size"); 23 | _Static_assert(sizeof (int32_t) == 4, "invalid size"); 24 | _Static_assert(sizeof (int64_t) == 8, "invalid size"); 25 | 26 | _Static_assert(sizeof (uintptr_t) == sizeof (intptr_t), "invalid size"); 27 | _Static_assert(sizeof (uintptr_t) == sizeof (void*), "invalid size"); 28 | _Static_assert(sizeof (uintptr_t) == 4, "invalid size"); 29 | 30 | #define UINT8_MAX 0xFF 31 | #define UINT16_MAX 0xFFFF 32 | #define UINT32_MAX 0xFFFFFFFFUL 33 | #define UINT64_MAX 0xFFFFFFFFFFFFFFFFULL 34 | 35 | #define INT8_MAX 0x7F 36 | #define INT16_MAX 0x7FFF 37 | #define INT32_MAX 0x7FFFFFFF 38 | #define INT64_MAX 0x7FFFFFFFFFFFFFFF 39 | 40 | #define INT8_MIN (-0x80) 41 | #define INT16_MIN (-0x8000) 42 | #define INT32_MIN (-0x80000000L) 43 | #define INT64_MIN (-0x8000000000000000LL) 44 | --------------------------------------------------------------------------------