Mercurial > nand-ecoscentric
changeset 3337:77f9d3253c3e
Add: Complex number header and library (single and double precision floating point),
port from Newlib.
Add: Single precision floating point library, port from Newlib.
[ Bugzilla 1001539 ]
line wrap: on
line diff
--- a/packages/language/c/libm/current/ChangeLog +++ b/packages/language/c/libm/current/ChangeLog @@ -1,3 +1,118 @@ +2013-08-25 Ilija Kocho <ilijak@siva.com.mk> + + * src/complex/cabs.c, src/complex/casinf.c, src/complex/ccosh.c, src/complex/cimagf.c, + * src/complex/cprojf.c, src/complex/ctan.c, src/complex/cabsf.c, src/complex/casinh.c, + * src/complex/ccoshf.c, src/complex/clog.c, src/complex/creal.c, src/complex/ctanf.c, + * src/complex/cacos.c, src/complex/casinhf.c, src/complex/cephes_subr.c, + * src/complex/clogf.c, src/complex/crealf.c, src/complex/ctanh.c, src/complex/cacosf.c, + * src/complex/catan.c, src/complex/cephes_subrf.c, src/complex/src/complex.tex, + * src/complex/csin.c, src/complex/ctanhf.c, src/complex/cacosh.c, src/complex/catanf.c, + * src/complex/cephes_subrf.h src/complex/conj.c, src/complex/csinf.c, + * src/complex/cacoshf.c, src/complex/catanh.c, src/complex/cephes_subr.h + * src/complex/conjf.c, src/complex/csinh.c, src/complex/carg.c, src/complex/catanhf.c, + * src/complex/cexp.c, src/complex/cpow.c, src/complex/csinhf.c, src/complex/cargf.c, + * src/complex/ccos.c, src/complex/cexpf.c, src/complex/cpowf.c, src/complex/csqrt.c, + * src/complex/casin.c, src/complex/ccosf.c, src/complex/cimag.c, src/complex/cproj.c, + * src/complex/csqrtf.c, + * include/src/complex.h: + + Add: Complex number header and library (single and double precision floating point), + port from Newlib. [ Bugzilla 1001539 ] + +2013-08-25 Visar Zejnullahu <visar.siva.mk> + Ilija Kocho <ilijak@siva.com.mk> + + * cdl/compat.cdl, cdl/libm.cdl, include/complex.h, include/math.h, + * src/float/ieee754-api/wf_acos.c, src/float/ieee754-api/wf_acosh.c, + * src/float/ieee754-api/wf_asin.c, src/float/ieee754-api/wf_atan2.c, + * src/float/ieee754-api/wf_atanh.c, src/float/ieee754-api/wf_cosh.c, + * src/float/ieee754-api/wf_exp.c, src/float/ieee754-api/wf_fmod.c, + * src/float/ieee754-api/wf_gamma.c, src/float/ieee754-api/wf_gamma_r.c, + * src/float/ieee754-api/wf_hypot.c, src/float/ieee754-api/wf_j0.c, + * src/float/ieee754-api/wf_j1.c, src/float/ieee754-api/wf_jn.c, + * src/float/ieee754-api/wf_lgamma.c, src/float/ieee754-api/wf_lgamma_r.c, + * src/float/ieee754-api/wf_log10.c, src/float/ieee754-api/wf_log.c, + * src/float/ieee754-api/wf_pow.c, src/float/ieee754-api/wf_remainder.c, + * src/float/ieee754-api/wf_scalb.c, src/float/ieee754-api/wf_sinh.c, + * src/float/ieee754-api/wf_sqrt.c, + * src/float/ieee754-core/ef_acos.c, src/float/ieee754-core/ef_acosh.c, + * src/float/ieee754-core/ef_asin.c, src/float/ieee754-core/ef_atan2.c, + * src/float/ieee754-core/ef_atanh.c, src/float/ieee754-core/ef_cosh.c, + * src/float/ieee754-core/ef_exp.c, src/float/ieee754-core/ef_fmod.c, + * src/float/ieee754-core/ef_gamma.c, src/float/ieee754-core/ef_gamma_r.c, + * src/float/ieee754-core/ef_hypot.c, src/float/ieee754-core/ef_j0.c, + * src/float/ieee754-core/ef_j1.c, src/float/ieee754-core/ef_jn.c, + * src/float/ieee754-core/ef_lgamma.c, src/float/ieee754-core/ef_lgamma_r.c, + * src/float/ieee754-core/ef_log10.c, src/float/ieee754-core/ef_log.c, + * src/float/ieee754-core/ef_pow.c, src/float/ieee754-core/ef_remainder.c, + * src/float/ieee754-core/ef_rem_pio2.c, src/float/ieee754-core/ef_scalb.c, + * src/float/ieee754-core/ef_sinh.c, src/float/ieee754-core/ef_sqrt.c, + * src/float/internal/kf_cos.c, src/float/internal/kf_rem_pio2.c, + * src/float/internal/kf_sin.c, src/float/internal/kf_tan.c, + * src/float/portable-api/sf_asinh.c, src/float/portable-api/sf_atan.c, + * src/float/portable-api/sf_cbrt.c, src/float/portable-api/sf_ceil.c, + * src/float/portable-api/sf_copysign.c, src/float/portable-api/sf_cos.c, + * src/float/portable-api/sf_erf.c, src/float/portable-api/sf_expm1.c, + * src/float/portable-api/sf_fabs.c, src/float/portable-api/sf_finite.c, + * src/float/portable-api/sf_floor.c, src/float/portable-api/sf_frexp.c, + * src/float/portable-api/sf_ilogb.c, src/float/portable-api/sf_isnan.c, + * src/float/portable-api/sf_ldexp.c, src/float/portable-api/sf_log1p.c, + * src/float/portable-api/sf_logb.c, src/float/portable-api/sf_modf.c, + * src/float/portable-api/sf_nextafter.c, src/float/portable-api/sf_rint.c, + * src/float/portable-api/sf_scalbn.c, src/float/portable-api/sf_significand.c, + * src/float/portable-api/sf_sin.c, src/float/portable-api/sf_tan.c, + * src/float/portable-api/sf_tanh.c, + * src/mathincl/fdlibm.h, + * tests/vector_support.h, + * tests/vectors/acosf.c, tests/vectors/atan2.h, + * tests/vectors/copysignf.h, tests/vectors/expf.h, + * tests/vectors/fmodf.c, tests/vectors/ilogbf.h, + * tests/vectors/log10f.c, tests/vectors/modff.h, tests/vectors/scalbf.h, + * tests/vectors/sqrtf.h, tests/vectors/acosf.h, tests/vectors/atanf.c, + * tests/vectors/cosf.c, tests/vectors/exp.h, tests/vectors/fmodf.h, + * tests/vectors/isnanf.c, tests/vectors/log10f.h, tests/vectors/modf.h, + * tests/vectors/scalbnf.c, tests/vectors/sqrt.h, tests/vectors/acos.h, + * tests/vectors/atanf.h, tests/vectors/cosf.h, tests/vectors/expm1f.c, + * tests/vectors/fmod.h, tests/vectors/isnanf.h, tests/vectors/log10.h, + * tests/vectors/nextafterf.c, tests/vectors/scalbnf.h, tests/vectors/tanf.c, + * tests/vectors/acoshf.c, tests/vectors/atan.h, tests/vectors/cos.h, + * tests/vectors/expm1f.h, tests/vectors/frexpf.c, tests/vectors/j0f.c, + * tests/vectors/log1pf.c, tests/vectors/nextafterf.h, + * tests/vectors/significandf.c, tests/vectors/tanf.h, + * tests/vectors/acoshf.h, tests/vectors/atanhf.c, tests/vectors/coshf.c, + * tests/vectors/fabsf.c, tests/vectors/frexpf.h, tests/vectors/j0f.h, + * tests/vectors/log1pf.h, tests/vectors/powf.c, tests/vectors/significandf.h, + * tests/vectors/tan.h, tests/vectors/asinf.c, tests/vectors/atanhf.h, + * tests/vectors/coshf.h, tests/vectors/fabsf.h, + * tests/vectors/frexpf_visar.h, tests/vectors/j1f.c, + * tests/vectors/logbf.c, tests/vectors/powf.h, + * tests/vectors/sinf.c, tests/vectors/tanhf.c, + * tests/vectors/asinf.h, tests/vectors/cbrtf.c, tests/vectors/cosh.h, + * tests/vectors/fabs.h, tests/vectors/frexp.h, tests/vectors/j1f.h, + * tests/vectors/logbf.h, tests/vectors/pow.h, tests/vectors/sinf.h, + * tests/vectors/tanhf.h, tests/vectors/asin.h, tests/vectors/cbrtf.h, + * tests/vectors/erfcf.c, tests/vectors/finitef.c, + * tests/vectors/gammaf.c, tests/vectors/jnf.c, tests/vectors/logf.c, + * tests/vectors/remainderf.c, tests/vectors/sin.h, + * tests/vectors/tanh.h, tests/vectors/asinhf.c, tests/vectors/ceilf.c, + * tests/vectors/erfcf.h, tests/vectors/finitef.h, + * tests/vectors/gammaf.h, tests/vectors/jnf.h, + * tests/vectors/logf.h, tests/vectors/remainderf.h, + * tests/vectors/sinhf.c, tests/vectors/vector_support_float.h, + * tests/vectors/asinhf.h, tests/vectors/ceilf.h, tests/vectors/erff.c, + * tests/vectors/floorf.c, tests/vectors/hypotf.c, tests/vectors/ldexpf.c, + * tests/vectors/log.h, tests/vectors/rintf.c, tests/vectors/sinhf.h, + * tests/vectors/vector_support.h, tests/vectors/atan2f.c, + * tests/vectors/ceil.h, tests/vectors/erff.h, tests/vectors/floorf.h, + * tests/vectors/hypotf.h, tests/vectors/ldexpf.h, + * tests/vectors/modf.c, tests/vectors/rintf.h, tests/vectors/sinh.h, + * tests/vectors/atan2f.h, tests/vectors/copysignf.c, tests/vectors/expf.c, + * tests/vectors/floor.h, tests/vectors/ilogbf.c, tests/vectors/ldexp.h, + * tests/vectors/modff.c, tests/vectors/scalbf.c, tests/vectors/sqrtf.c: + + Add: Single precision floating point library, port from Newlib. + [ Bugzilla 1001539 ] + 2010-11-11 Sergei Gavrikov <sergei.gavrikov@gmail.com> * cdl/libm.cdl (CYGPKG_LIBM_CFLAGS_ADD): Add a set of parentheses @@ -824,7 +939,7 @@ Fri Jun 5 07:07:03 1998 Jonathan Larmo // ####GPLCOPYRIGHTBEGIN#### // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2007, 2008, 2010 Free Software Foundation, Inc. +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2007, 2008, 2010, 2013 Free Software Foundation, Inc. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by
--- a/packages/language/c/libm/current/cdl/compat.cdl +++ b/packages/language/c/libm/current/cdl/compat.cdl @@ -8,7 +8,7 @@ ## ####ECOSGPLCOPYRIGHTBEGIN#### ## ------------------------------------------- ## This file is part of eCos, the Embedded Configurable Operating System. -## Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +## Copyright (C) 1998, 1999, 2000, 2001, 2002, 2013 Free Software Foundation, Inc. ## ## eCos is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free @@ -41,7 +41,7 @@ # # Author(s): jskov # Original data: jlarmour -# Contributors: +# Contributors: ilijak # Date: 1999-07-07 # #####DESCRIPTIONEND#### @@ -52,7 +52,7 @@ cdl_interface CYGINT_LIBM_COMPAT { requires 1 == CYGINT_LIBM_COMPAT } -cdl_option CYGSEM_LIBM_COMPAT_IEEE_ONLY { +cdl_component CYGSEM_LIBM_COMPAT_IEEE_ONLY { display "IEEE-only" default_value 0 implements CYGINT_LIBM_COMPAT @@ -66,6 +66,19 @@ cdl_option CYGSEM_LIBM_COMPAT_IEEE_ONLY modes. If not defined, the math library can be set at run-time to any of the supported compatibility modes." + + cdl_option CYGSEM_LIBM_IEEE_API_INLINE { + display "Inline IEEE754 API wrappers" + default_value 0 + + description " + IEEE754 API functions are just wrappers for + core functions. This introduces indirection which can can be + avoided by inlining. This will also prevent GCC from rendering + these functions as builtin. The HAL can override for a set of functions + by providing a list of builtin functions." + } + } cdl_component CYGNUM_LIBM_COMPATIBILITY { @@ -83,7 +96,7 @@ cdl_component CYGNUM_LIBM_COMPATIBILITY you choose which mode should be the default." cdl_option CYGNUM_LIBM_COMPAT_DEFAULT { - display "Numeric representation" + display "Numeric representation" flavor data calculated { \ CYGNUM_LIBM_COMPATIBILITY == "POSIX" ? "CYGNUM_LIBM_COMPAT_POSIX" :\ @@ -97,6 +110,16 @@ cdl_component CYGNUM_LIBM_COMPATIBILITY mode for numeric representation in terms of the values used to set that mode at run-time." } + + cdl_option CYGOPT_LIBM_COMPAT_POSIX_IEEE { + display "POSIX return NaN for out-of-domain argument." + active_if { CYGNUM_LIBM_COMPATIBILITY == "POSIX" } + default_value 0 + description "Later POSIX specification states that functions + may return either NaN (like IEEE), or implementation defined + value when argument is out of domain. For backward compatibility + default value is set to 0." + } } cdl_option CYGFUN_LIBM_SVID3_scalb {
--- a/packages/language/c/libm/current/cdl/libm.cdl +++ b/packages/language/c/libm/current/cdl/libm.cdl @@ -8,7 +8,7 @@ ## ####ECOSGPLCOPYRIGHTBEGIN#### ## ------------------------------------------- ## This file is part of eCos, the Embedded Configurable Operating System. -## Copyright (C) 1998, 1999, 2000, 2001, 2002, 2010 Free Software Foundation, Inc. +## Copyright (C) 1998, 1999, 2000, 2001, 2002, 2010, 2012, 2013 Free Software Foundation, Inc. ## ## eCos is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free @@ -41,7 +41,7 @@ # # Author(s): bartv # Original data: jlarmour -# Contributors: +# Contributors: visar, ilijak # Date: 1999-06-13 # #####DESCRIPTIONEND#### @@ -56,38 +56,85 @@ cdl_package CYGPKG_LIBM { containing many useful functions for mathematical calculations." - compile misc/matherr.c misc/standard.c misc/compatmode.cxx \ - misc/infconst.c \ - \ - double/ieee754-core/e_acos.c double/ieee754-core/e_asin.c \ - double/ieee754-core/e_atan2.c double/ieee754-core/e_cosh.c \ - double/ieee754-core/e_exp.c double/ieee754-core/e_fmod.c \ - double/ieee754-core/e_log.c double/ieee754-core/e_log10.c \ - double/ieee754-core/e_pow.c \ - double/ieee754-core/e_rem_pio2.c \ - double/ieee754-core/e_scalb.c double/ieee754-core/e_sinh.c \ - double/ieee754-core/e_sqrt.c \ - \ - double/ieee754-api/w_acos.c double/ieee754-api/w_asin.c \ - double/ieee754-api/w_atan2.c double/ieee754-api/w_cosh.c \ - double/ieee754-api/w_exp.c double/ieee754-api/w_fmod.c \ - double/ieee754-api/w_log.c double/ieee754-api/w_log10.c \ - double/ieee754-api/w_pow.c double/ieee754-api/w_scalb.c \ - double/ieee754-api/w_sinh.c double/ieee754-api/w_sqrt.c \ - \ - double/internal/k_cos.c double/internal/k_rem_pio2.c \ - double/internal/k_sin.c double/internal/k_tan.c \ - \ - double/portable-api/s_atan.c double/portable-api/s_ceil.c \ - double/portable-api/s_copysign.c \ - double/portable-api/s_cos.c double/portable-api/s_expm1.c \ - double/portable-api/s_fabs.c double/portable-api/s_finite.c \ - double/portable-api/s_floor.c double/portable-api/s_frexp.c \ - double/portable-api/s_isnan.c double/portable-api/s_ldexp.c \ - double/portable-api/s_rint.c double/portable-api/s_scalbn.c \ - double/portable-api/s_sin.c double/portable-api/s_tan.c \ - double/portable-api/s_modf.c double/portable-api/s_tanh.c - + compile misc/matherr.c misc/standard.c misc/standard_float.c \ + misc/compatmode.cxx misc/infconst.c \ + \ + double/ieee754-core/e_acos.c double/ieee754-core/e_asin.c \ + double/ieee754-core/e_atan2.c double/ieee754-core/e_cosh.c \ + double/ieee754-core/e_exp.c double/ieee754-core/e_fmod.c \ + double/ieee754-core/e_log.c double/ieee754-core/e_log10.c \ + double/ieee754-core/e_pow.c \ + double/ieee754-core/e_rem_pio2.c \ + double/ieee754-core/e_scalb.c double/ieee754-core/e_sinh.c \ + double/ieee754-core/e_sqrt.c double/ieee754-core/e_hypot.c \ + \ + double/ieee754-api/w_acos.c double/ieee754-api/w_asin.c \ + double/ieee754-api/w_atan2.c double/ieee754-api/w_cosh.c \ + double/ieee754-api/w_exp.c double/ieee754-api/w_fmod.c \ + double/ieee754-api/w_log.c double/ieee754-api/w_log10.c \ + double/ieee754-api/w_pow.c double/ieee754-api/w_scalb.c \ + double/ieee754-api/w_sinh.c double/ieee754-api/w_sqrt.c \ + double/ieee754-api/w_hypot.c \ + double/ieee754-core/e_gamma.c double/ieee754-api/w_gamma.c \ + double/ieee754-core/e_gamma_r.c double/ieee754-api/w_gamma_r.c \ + double/ieee754-core/e_lgamma.c double/ieee754-api/w_lgamma.c \ + double/ieee754-core/e_lgamma_r.c double/ieee754-api/w_lgamma_r.c \ + \ + double/internal/k_cos.c double/internal/k_rem_pio2.c \ + double/internal/k_sin.c double/internal/k_tan.c \ + \ + float/internal/kf_cos.c float/internal/kf_sin.c \ + float/internal/kf_rem_pio2.c float/internal/kf_tan.c \ + \ + double/portable-api/s_atan.c double/portable-api/s_ceil.c \ + double/portable-api/s_copysign.c \ + double/portable-api/s_cos.c double/portable-api/s_expm1.c \ + double/portable-api/s_fabs.c double/portable-api/s_finite.c \ + double/portable-api/s_floor.c double/portable-api/s_frexp.c \ + double/portable-api/s_isnan.c double/portable-api/s_ldexp.c \ + double/portable-api/s_rint.c double/portable-api/s_scalbn.c \ + double/portable-api/s_sin.c double/portable-api/s_tan.c \ + double/portable-api/s_modf.c double/portable-api/s_tanh.c \ + \ + float/ieee754-core/ef_rem_pio2.c \ + float/ieee754-core/ef_sqrt.c float/ieee754-api/wf_sqrt.c \ + float/ieee754-core/ef_pow.c float/ieee754-api/wf_pow.c \ + float/ieee754-core/ef_exp.c float/ieee754-api/wf_exp.c \ + float/ieee754-core/ef_asin.c float/ieee754-api/wf_asin.c \ + float/ieee754-core/ef_log.c float/ieee754-api/wf_log.c \ + float/ieee754-core/ef_log10.c float/ieee754-api/wf_log10.c \ + float/ieee754-core/ef_hypot.c float/ieee754-api/wf_hypot.c \ + float/ieee754-core/ef_fmod.c float/ieee754-api/wf_fmod.c \ + float/ieee754-core/ef_remainder.c float/ieee754-api/wf_remainder.c \ + float/ieee754-core/ef_scalb.c float/ieee754-api/wf_scalb.c \ + float/ieee754-core/ef_acos.c float/ieee754-api/wf_acos.c \ + float/ieee754-core/ef_atan2.c float/ieee754-api/wf_atan2.c \ + float/ieee754-core/ef_acosh.c float/ieee754-api/wf_acosh.c \ + float/ieee754-core/ef_atanh.c float/ieee754-api/wf_atanh.c \ + float/ieee754-core/ef_cosh.c float/ieee754-api/wf_cosh.c \ + float/ieee754-core/ef_j0.c float/ieee754-api/wf_j0.c \ + float/ieee754-core/ef_j1.c float/ieee754-api/wf_j1.c \ + float/ieee754-core/ef_jn.c float/ieee754-api/wf_jn.c \ + float/ieee754-core/ef_sinh.c float/ieee754-api/wf_sinh.c \ + float/portable-api/sf_asinh.c float/portable-api/sf_ilogb.c \ + float/portable-api/sf_copysign.c \ + float/portable-api/sf_sin.c \ + float/portable-api/sf_finite.c float/portable-api/sf_erf.c \ + float/portable-api/sf_isnan.c float/portable-api/sf_floor.c \ + float/portable-api/sf_modf.c \ + float/portable-api/sf_atan.c \ + float/portable-api/sf_ldexp.c \ + float/portable-api/sf_nextafter.c \ + float/portable-api/sf_tan.c float/portable-api/sf_cbrt.c \ + float/portable-api/sf_expm1.c \ + float/portable-api/sf_frexp.c \ + float/portable-api/sf_log1p.c float/portable-api/sf_rint.c \ + float/portable-api/sf_tanh.c float/portable-api/sf_ceil.c \ + float/portable-api/sf_fabs.c \ + float/portable-api/sf_logb.c \ + float/portable-api/sf_scalbn.c \ + float/portable-api/sf_cos.c \ + float/portable-api/sf_significand.c # COMPATIBILITY-MODE RELATED CONFIGURATION OPTIONS cdl_component CYGPKG_LIBM_COMPATIBILITY { @@ -216,6 +263,43 @@ cdl_package CYGPKG_LIBM { puts $::cdl_header "/****** proc output end ******/" } + cdl_component CYGPKG_COMPLEX { + display "Complex" + flavor bool + default_value 1 + + description " + Complex library provides support for some basic operations + on complex numbers as well as mathematical functions in + complex domain." + + compile complex/cabs.c complex/cabsf.c \ + complex/carg.c complex/cargf.c \ + \ + complex/creal.c complex/crealf.c \ + complex/cimag.c complex/cimagf.c \ + complex/conj.c complex/conjf.c \ + \ + complex/cacos.c complex/cacosf.c \ + complex/cacosh.c complex/cacoshf.c \ + complex/casin.c complex/casinf.c \ + complex/casinh.c complex/casinhf.c \ + complex/catan.c complex/catanf.c \ + complex/catanh.c complex/catanhf.c \ + complex/ccos.c complex/ccosf.c \ + complex/ccosh.c complex/ccoshf.c \ + complex/cephes_subr.c complex/cephes_subrf.c \ + complex/cexp.c complex/cexpf.c \ + complex/clog.c complex/clogf.c \ + complex/cpow.c complex/cpowf.c \ + complex/cproj.c complex/cprojf.c \ + complex/csin.c complex/csinf.c \ + complex/csinh.c complex/csinhf.c \ + complex/csqrt.c complex/csqrtf.c \ + complex/ctan.c complex/ctanf.c \ + complex/ctanh.c complex/ctanhf.c + } + cdl_component CYGPKG_LIBM_OPTIONS { display "Math library build options" flavor none @@ -252,9 +336,30 @@ cdl_package CYGPKG_LIBM { display "Math library tests" flavor data no_define - calculated { "tests/vectors/acos tests/vectors/asin tests/vectors/atan tests/vectors/atan2 tests/vectors/ceil tests/vectors/cos tests/vectors/cosh tests/vectors/exp tests/vectors/fabs tests/vectors/floor tests/vectors/fmod tests/vectors/frexp tests/vectors/ldexp tests/vectors/log tests/vectors/log10 tests/vectors/modf tests/vectors/pow tests/vectors/sin tests/vectors/sinh tests/vectors/sqrt tests/vectors/tan tests/vectors/tanh" } + calculated { "tests/vectors/acos tests/vectors/asin \ + tests/vectors/cos tests/vectors/cosh \ + tests/vectors/sin tests/vectors/sinh \ + tests/vectors/atan tests/vectors/atan2 \ + tests/vectors/tan tests/vectors/tanh \ + tests/vectors/sqrt tests/vectors/pow \ + tests/vectors/ceil tests/vectors/floor \ + tests/vectors/fabs tests/vectors/fmod \ + tests/vectors/frexp tests/vectors/ldexp \ + tests/vectors/exp tests/vectors/log tests/vectors/log10 \ + \ + tests/vectors/acosf tests/vectors/asinf \ + tests/vectors/cosf tests/vectors/coshf \ + tests/vectors/sinf tests/vectors/sinhf \ + tests/vectors/atanf tests/vectors/atan2f \ + tests/vectors/tanf tests/vectors/tanhf \ + tests/vectors/hypotf tests/vectors/sqrtf tests/vectors/powf \ + tests/vectors/floorf tests/vectors/ceilf \ + tests/vectors/fabsf tests/vectors/fmodf \ + tests/vectors/frexpf tests/vectors/ldexpf \ + tests/vectors/expf tests/vectors/logf tests/vectors/log10f " + } description " - This option specifies the set of tests for the math library." + this option specifies the set of tests for the math library." } } }
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/include/complex.h @@ -0,0 +1,202 @@ +#ifndef CYGONCE_COMPLEX_H +#define CYGONCE_COMPLEX_H + +//=========================================================================== +// +// complex.h +// +// Standard complex number functions conforming to ANSI and other standards +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2013 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ilijak +// Based on: see below +// Contributors: +// Date: 2013-06-05 +// Purpose: +// Description: Standard complex number mathematical functions. +// +// Usage: #include <complex.h> +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// This file was derived from a file with following copyright + +/* $NetBSD: complex.h,v 1.3 2010/09/15 16:11:30 christos Exp $ */ + +/* + * Written by Matthias Drochner. + * Public domain. + */ + +#ifndef _COMPLEX_H +#define _COMPLEX_H +#endif + +#define complex _Complex +#define _Complex_I (1.0fi) +#define I _Complex_I + +// 7.3.5 Trigonometric functions +// 7.3.5.1 The cacos functions +double complex cacos(double complex); +float complex cacosf(float complex); + +// 7.3.5.2 The casin functions +double complex casin(double complex); +float complex casinf(float complex); + +// 7.3.5.1 The catan functions +double complex catan(double complex); +float complex catanf(float complex); + +// 7.3.5.1 The ccos functions +double complex ccos(double complex); +float complex ccosf(float complex); + +// 7.3.5.1 The csin functions +double complex csin(double complex); +float complex csinf(float complex); + +// 7.3.5.1 The ctan functions +double complex ctan(double complex); +float complex ctanf(float complex); + +// 7.3.6 Hyperbolic functions +// 7.3.6.1 The cacosh functions +double complex cacosh(double complex); +float complex cacoshf(float complex); + +// 7.3.6.2 The casinh functions +double complex casinh(double complex); +float complex casinhf(float complex); + +// 7.3.6.3 The catanh functions +double complex catanh(double complex); +float complex catanhf(float complex); + +// 7.3.6.4 The ccosh functions +double complex ccosh(double complex); +float complex ccoshf(float complex); + +// 7.3.6.5 The csinh functions +double complex csinh(double complex); +float complex csinhf(float complex); + +// 7.3.6.6 The ctanh functions +double complex ctanh(double complex); +float complex ctanhf(float complex); + +// 7.3.7 Exponential and logarithmic functions +// 7.3.7.1 The cexp functions +double complex cexp(double complex); +float complex cexpf(float complex); + +// 7.3.7.2 The clog functions +double complex clog(double complex); +float complex clogf(float complex); + +// 7.3.9 Manipulation functions +// 7.3.9.2 The cimag functions +double cimag(double complex); +float cimagf(float complex); +//long double cimagl(long double complex); + +// 7.3.9.3 The conj functions +double complex conj(double complex); +float complex conjf(float complex); +//long double complex conjl(long double complex); + +// 7.3.9.4 The cproj functions +double complex cproj(double complex); +float complex cprojf(float complex); +//long double complex cprojl(long double complex); + +// 7.3.9.5 The creal functions +double creal(double complex); +float crealf(float complex); +//long double creall(long double complex); + +// 7.3.9.1 The carg functions +#ifdef CYGSEM_LIBM_IEEE_API_INLINE +CYGBLD_FORCE_INLINE double +carg(double complex z) +{ + return atan2( cimag(z) , creal(z) ); +} + +CYGBLD_FORCE_INLINE float +cargf(float complex z) +{ + return atan2f( cimagf(z) , crealf(z) ); +} +#else +double carg(double complex); +float cargf(float complex); +#endif + +// 7.3.8 Power and absolute-value functions +// 7.3.8.1 The cabs functions +#ifdef CYGSEM_LIBM_IEEE_API_INLINE +CYGBLD_FORCE_INLINE double +cabs(double complex z) +{ + return hypot( creal(z) , cimag(z) ); +} + +CYGBLD_FORCE_INLINE float +cabsf(float complex z) +{ + return hypotf( crealf(z) , cimagf(z) ); +} +#else +double cabs(double complex) ; +float cabsf(float complex) ; +#endif + +// 7.3.8.2 The cpow functions +double complex cpow(double complex, double complex); +float complex cpowf(float complex, float complex); + +// 7.3.8.3 The csqrt functions +double complex csqrt(double complex); +float complex csqrtf(float complex); + +#endif //CYGONCE_COMPLEX_H + +// End of complex.h
--- a/packages/language/c/libm/current/include/math.h +++ b/packages/language/c/libm/current/include/math.h @@ -10,7 +10,7 @@ // ####ECOSGPLCOPYRIGHTBEGIN#### // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. -// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2012, 2013 Free Software Foundation, Inc. // // eCos is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -42,9 +42,9 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): jlarmour -// Contributors: jlarmour +// Contributors: jlarmour, visar, ilijak // Date: 1998-02-13 -// Purpose: +// Purpose: // Description: Standard mathematical functions. These can be // configured to conform to ANSI section 7.5. There are also // a number of extensions conforming to IEEE-754 and behaviours @@ -57,33 +57,150 @@ // CONFIGURATION +#include <pkgconf/system.h> // System configuration header #include <pkgconf/libm.h> // Configuration header // Include the Math library? -#ifdef CYGPKG_LIBM +#ifdef CYGPKG_LIBM + +#ifdef CYGBLD_HAL_LIBM_H +# include CYGBLD_HAL_LIBM_H +#endif + +// Inline IEEE754 API macros +#define CYGBLD_LIBM_INLINE CYGBLD_FORCE_INLINE + +#ifdef CYGSEM_LIBM_IEEE_API_INLINE + +#define CYGDCL_LIBM_IEEE_API_INLINE_F(_fun) \ +externC double __ieee754_##_fun(double); \ +CYGBLD_LIBM_INLINE double _fun(double x) \ +{ \ + return __ieee754_##_fun(x); \ +} \ +externC float __ieee754_##_fun##f(float); \ +CYGBLD_LIBM_INLINE float _fun##f(float x) \ +{ \ + return __ieee754_##_fun##f(x); \ +} + +#define CYGDCL_LIBM_IEEE_API_INLINE_FF(_fun) \ +externC double __ieee754_##_fun(double, double); \ +CYGBLD_LIBM_INLINE double _fun(double x, double y) \ +{ \ + return __ieee754_##_fun(x, y); \ +} \ +externC float __ieee754_##_fun##f(float, float); \ +CYGBLD_LIBM_INLINE float _fun##f(float x, float y) \ +{ \ + return __ieee754_##_fun##f(x, y); \ +} + +#define CYGDCL_LIBM_IEEE_API_INLINE_IF(_fun) \ +externC double __ieee754_##_fun(int, double); \ +CYGBLD_LIBM_INLINE double _fun(int x, double y) \ +{ \ + return __ieee754_##_fun(x, y); \ +} \ +externC float __ieee754_##_fun##f(int, float); \ +CYGBLD_LIBM_INLINE float _fun##f(int x, float y) \ +{ \ + return __ieee754_##_fun##f(x, y); \ +} + +#define CYGDCL_LIBM_IEEE_API_INLINE_FIP(_fun) \ +externC double __ieee754_##_fun(double, int *); \ +CYGBLD_LIBM_INLINE double _fun(double x, int *y) \ +{ \ + return __ieee754_##_fun(x, y); \ +} \ +externC float __ieee754_##_fun##f(float, int*); \ +CYGBLD_LIBM_INLINE float _fun##f(float x, int *y) \ +{ \ + return __ieee754_##_fun##f(x, y); \ +} + +#else + +#define CYGDCL_LIBM_IEEE_API_INLINE_F(_fun) \ +externC inline double _fun(double); \ +externC float inline _fun##f(float); + +#define CYGDCL_LIBM_IEEE_API_INLINE_FF(_fun) \ +externC inline double _fun(double, double); \ +externC inline float _fun##f(float, float); + +#define CYGDCL_LIBM_IEEE_API_INLINE_IF(_fun) \ +externC inline double _fun(int, double); \ +externC inline float _fun##f(int, float); + +#define CYGDCL_LIBM_IEEE_API_INLINE_FIP(_fun) \ +externC inline double _fun(double, int *); \ +externC inline float _fun##f(float, int *); + +#endif // INCLUDES #include <cyg/infra/cyg_type.h> // Common type definitions and support #include <float.h> // Properties of FP representation on this // platform -#include <sys/ieeefp.h> // Cyg_libm_ieee_double_shape_type +#include <sys/ieeefp.h> // Cyg_libm_ieee_[double|float]_shape_type // CONSTANT DEFINITIONS +// Useful constants. + +#define MAXFLOAT 3.40282347e+38F + +#define M_E 2.7182818284590452354 +#define M_LOG2E 1.4426950408889634074 +#define M_LOG10E 0.43429448190325182765 +#define M_LN2 _M_LN2 +#define M_LN10 2.30258509299404568402 +#define M_PI 3.14159265358979323846 +#define M_TWOPI (M_PI * 2.0) +#define M_PI_2 1.57079632679489661923 +#define M_PI_4 0.78539816339744830962 +#define M_3PI_4 2.3561944901923448370E0 +#define M_SQRTPI 1.77245385090551602792981 +#define M_1_PI 0.31830988618379067154 +#define M_2_PI 0.63661977236758134308 +#define M_2_SQRTPI 1.12837916709551257390 +#define M_SQRT2 1.41421356237309504880 +#define M_SQRT1_2 0.70710678118654752440 +#define M_LN2LO 1.9082149292705877000E-10 +#define M_LN2HI 6.9314718036912381649E-1 +#define M_SQRT3 1.73205080756887719000 +#define M_IVLN10 0.43429448190325182765 /* 1 / log(10) */ +#define M_LOG2_E _M_LN2 +#define M_INVLN2 1.4426950408889633870E0 /* 1 / log(2) */ // HUGE_VAL is a positive double (not necessarily representable as a float) // representing infinity as specified in ANSI 7.5. cyg_libm_infinity is // defined further down +#if 1 #define HUGE_VAL (cyg_libm_infinity.value) +#define HUGE_VALF (cyg_libm_float_infinity.value) +#else + /* gcc >= 3.3 implicitly defines builtins for HUGE_VALx values. */ + +# ifndef HUGE_VAL +# define HUGE_VAL (__builtin_huge_val()) +# endif + +# ifndef HUGE_VALF +# define HUGE_VALF (__builtin_huge_valf()) +# endif + +#endif /* !gcc >= 3.3 */ #ifndef CYGSYM_LIBM_NO_XOPEN_SVID_NAMESPACE_POLLUTION // HUGE is defined in System V Interface Definition 3 (SVID3) as the largest // finite single precision number #define HUGE FLT_MAX // from float.h - // Values used in the type field of struct exception below #define DOMAIN 1 @@ -93,6 +210,9 @@ #define TLOSS 5 #define PLOSS 6 +#ifndef FP_ILOGBNAN +# define FP_ILOGBNAN INT_MAX +#endif // TYPE DEFINITIONS @@ -106,12 +226,20 @@ struct exception { double retval; // Value to be returned - can be altered by matherr() }; +struct exceptionf { + int type; // One of DOMAIN, SING, OVERFLOW, UNDERFLOW, TLOSS, PLOSS + char *name; // Name of the function generating the exception + float arg1; // First argument to the function + float arg2; // Second argument to the function + float retval; // Value to be returned - can be altered by matherr() +}; + #endif // ifndef CYGSYM_LIBM_NO_XOPEN_SVID_NAMESPACE_POLLUTION - // GLOBALS externC const Cyg_libm_ieee_double_shape_type cyg_libm_infinity; +externC const Cyg_libm_ieee_float_shape_type cyg_libm_float_infinity; //=========================================================================== // FUNCTION PROTOTYPES @@ -178,84 +306,108 @@ externC int signgam; // Trigonometric functions - ANSI 7.5.2 -externC double -acos( double ); // arc cosine i.e. inverse cos +// arc cosine i.e. inverse cos +CYGDCL_LIBM_IEEE_API_INLINE_F(acos) -externC double -asin( double ); // arc sine i.e. inverse sin +// arc sine i.e. inverse sin +CYGDCL_LIBM_IEEE_API_INLINE_F(asin) externC double atan( double ); // arc tan i.e. inverse tan -externC double -atan2( double, double ); // arc tan of (first arg/second arg) using signs - // of args to determine quadrant +externC float +atanf ( float ); + +// arc tan of (first arg/second arg) using signs +// of args to determine quadrant +CYGDCL_LIBM_IEEE_API_INLINE_FF(atan2) externC double cos( double ); // cosine +externC float +cosf( float ); + externC double sin( double ); // sine +externC float +sinf( float ); + externC double tan( double ); // tangent +externC float +tanf ( float ); + // Hyperbolic functions - ANSI 7.5.3 -externC double -cosh( double ); // hyperbolic cosine +// hyperbolic cosine +CYGDCL_LIBM_IEEE_API_INLINE_F(cosh) -externC double -sinh( double ); // hyperbolic sine +// hyperbolic sine +CYGDCL_LIBM_IEEE_API_INLINE_F(sinh) externC double tanh( double ); // hyperbolic tangent +externC float +tanhf ( float ); + // Exponential and Logarithmic Functions - ANSI 7.5.4 -externC double -exp( double ); // exponent +CYGDCL_LIBM_IEEE_API_INLINE_F(exp) externC double frexp( double, int * ); // break number into normalized fraction (returned) // and integral power of 2 (second arg) - -externC double -ldexp( double, int ); // multiples number by integral power of 2 +externC float +frexpf( float, int * ); externC double -log( double ); // natural logarithm +ldexp( double, int ); // multiples number by integral power of 2 + +externC float +ldexpf( float, int ); -externC double -log10( double ); // base ten logarithm +// natural logarithm +CYGDCL_LIBM_IEEE_API_INLINE_F(log) + +// base ten logarithm +CYGDCL_LIBM_IEEE_API_INLINE_F(log10) externC double modf( double, double * ); // break number into integral and fractional // parts, each of which has same sign as arg. - // It returns signed fractional part, and - // puts integral part in second arg +externC float // It returns signed fractional part, and +modff ( float, float *); // puts integral part in second arg // Power Functions - ANSI 7.5.5 -externC double -pow( double, double ); // (1st arg) to the power of (2nd arg) +// (1st arg) to the power of (2nd arg) +CYGDCL_LIBM_IEEE_API_INLINE_FF(pow) -externC double -sqrt( double ); // square root +// square root +CYGDCL_LIBM_IEEE_API_INLINE_F(sqrt) // Nearest integer, absolute value and remainder functions - ANSI 7.5.6 externC double ceil( double ); // smallest integer >= arg +externC float +ceilf ( float ); externC double fabs( double ); // absolute value +externC float +fabsf ( float ); externC double floor( double ); // largest integer <= arg +externC float +floorf ( float ); -externC double -fmod( double, double ); // remainder of (1st arg)/(2nd arg) +CYGDCL_LIBM_IEEE_API_INLINE_FF(fmod) //=========================================================================== // Other standard functions @@ -263,93 +415,121 @@ fmod( double, double ); // remainder #ifndef CYGSYM_LIBM_NO_XOPEN_SVID_NAMESPACE_POLLUTION externC int matherr( struct exception * ); // User-overridable error handling - see -#endif // <pkgconf/libm.h> for a discussion + // <pkgconf/libm.h> for a discussion +externC int +matherrf( struct exceptionf * ); +#endif // FIXME: from here needs to be documented and mentioned as non-ISO // Arc Hyperbolic trigonometric functions -externC double -acosh( double ); // Arc hyperbolic cos i.e. inverse cosh +// Arc hyperbolic cos i.e. inverse cosh +CYGDCL_LIBM_IEEE_API_INLINE_F(acosh) -externC double -asinh( double ); // Arc hyperbolic sin i.e. inverse sinh +// Arc hyperbolic sin i.e. inverse sinh +CYGDCL_LIBM_IEEE_API_INLINE_F(asinh) -externC double -atanh( double ); // Arc hyperbolic tan i.e. inverse tanh +// Arc hyperbolic tan i.e. inverse tanh +CYGDCL_LIBM_IEEE_API_INLINE_F(atanh) // Error functions externC double // Error function, such that erf( double ); // erf(x) = 2/sqrt(pi) * integral from // 0 to x of e**(-t**2) dt +externC float +erff ( float ); externC double // Complementary error function - simply erfc( double ); // 1.0 - erf(x) +externC float +erfcf ( float ); + // Gamma functions -externC double // Logarithm of the absolute value of the -lgamma( double ); // gamma function of the argument. The - // integer signgam is used to store the - // sign of the gamma function of the arg +// Logarithm of the absolute value of the +// gamma function of the argument. The +// integer signgam is used to store the +// sign of the gamma function of the arg +CYGDCL_LIBM_IEEE_API_INLINE_F(lgamma) -externC double -lgamma_r( double, int * ); // Re-entrant version of the above, where - // the user passes the location of signgam - // as the second argument +// Re-entrant version of the above, where +// the user passes the location of signgam +// as the second argument +CYGDCL_LIBM_IEEE_API_INLINE_FIP(lgamma_r) -externC double // Identical to lgamma()! -gamma( double ); // The reasons for this are historical, - // and may be changed in future standards - // - // To get the real gamma function, you should - // use: l=lgamma(x); g=signgam*exp(l); - // - // Do not just do signgam*exp(lgamma(x)) - // as lgamma() modifies signgam +// Identical to lgamma()! +// The reasons for this are historical, +// and may be changed in future standards +// +// To get the real gamma function, you should +// use: l=lgamma(x); g=signgam*exp(l); +// +// Do not just do signgam*exp(lgamma(x)) +// as lgamma() modifies signgam +CYGDCL_LIBM_IEEE_API_INLINE_F(gamma) externC double gamma_r( double, int * ); // Identical to lgamma_r(). See above. +externC float +gammaf_r( float, int * ); + // Bessel functions -externC double // Zero-th order Bessel function of the -j0( double ); // first kind at the ordinate of the argument +// Zero-th order Bessel function of the +// first kind at the ordinate of the argument +CYGDCL_LIBM_IEEE_API_INLINE_F(j0) -externC double // First-order Bessel function of the -j1( double ); // first kind at the ordinate of the argument +// First-order Bessel function of the +// first kind at the ordinate of the argument +CYGDCL_LIBM_IEEE_API_INLINE_F(j1) -externC double // Bessel function of the first kind of the -jn( int, double ); // order of the first argument at the - // ordinate of the second argument +// Bessel function of the first kind of the +// order of the first argument at the +// ordinate of the second argument +CYGDCL_LIBM_IEEE_API_INLINE_IF(jn) externC double // Zero-th order Bessel function of the y0( double ); // second kind at the ordinate of the - // argument + +externC float +y0f( float ); externC double // First-order Bessel function of the y1( double ); // second kind at the ordinate of the // argument +externC float +y1f( float ); externC double // Bessel function of the second kind of the yn( int, double ); // order of the first argument at the // ordinate of the second argument +externC float +ynf( int, float ); // scalb*() externC double // scalbn(x,n) returns x*(2**n) scalbn( double, int ); +externC float +scalbnf ( float, int); + #ifdef CYGFUN_LIBM_SVID3_scalb -externC double -scalb( double, double ); // as above except n is a floating point arg +// as above except n is a floating point arg +CYGDCL_LIBM_IEEE_API_INLINE_FF(scalb) #else externC double scalb( double, int ); // as scalbn() +externC float +scalbf( float, int ); + #endif // ifdef CYGFUN_LIBM_SVID3_scalb // And the rest @@ -357,58 +537,90 @@ scalb( double, int ); // as externC double cbrt( double ); // Cube Root -externC double // hypotenuse function, defined such that: -hypot( double, double ); // hypot(x,y)==sqrt(x**2 + y**2) +externC float +cbrtf( float ); + +// hypotenuse function, defined such that: +// hypotf(x,y)==sqrt(x**2 + y**2) + +CYGDCL_LIBM_IEEE_API_INLINE_FF(hypot) externC int // whether the argument is NaN isnan( double ); externC int +isnanf ( float ); + +externC int // wheteher the argument is infinite +isinf(double); + +externC int +isinff(float); + +externC int finite( double ); // whether the argument is finite +externC int +finitef ( float ); + externC double // logb returns the binary exponent of its logb( double ); // argument as an integral value // This is not recommended - use ilogb - // instead +externC float // instead +logbf ( float ); externC int // As for logb, but has the more correct ilogb( double ); // return value type of int +externC int +ilogbf ( float ); externC double // nextafter(x,y) returns the next nextafter( double, double ); // representable floating point number // adjacent to x in the direction of y - // i.e. the next greater FP if y>x, the next - // less FP if y<x, or just x if y==x +externC float // i.e. the next greater FP if y>x, the next +nextafterf ( float, float ); // less FP if y<x, or just x if y==x -externC double // remainder(x,y) returns the remainder -remainder( double, double ); // when x is divided by y +// when x is divided by y +CYGDCL_LIBM_IEEE_API_INLINE_FF(remainder) externC double // IEEE Test Vector significand( double ); // significand(x) computes: // scalb(x, (double) -ilogb(x)) - +externC float +significandf( float ); + //=========================================================================== // Non-standard functions externC double // copysign(x,y) returns a number with copysign ( double, double ); // the absolute value of x and the sign of y +externC float +copysignf ( float, float ); + externC double // rounds to an integer according to the rint( double ); // current rounding mode +externC float +rintf ( float ); + // BSD functions externC double // expm1(x) returns the equivalent of expm1( double ); // (exp(x) - 1) but more accurately when // x tends to zero +externC float +expm1f ( float ); externC double // log1p(x) returns the equivalent of log1p( double ); // log(1+x) but more accurately when // x tends to zero +externC float +log1pf ( float ); -#endif // ifdef CYGPKG_LIBM +#endif // ifdef CYGPKG_LIBM #endif // CYGONCE_LIBM_MATH_H multiple inclusion protection
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/cabs.c @@ -0,0 +1,53 @@ +/* $NetBSD: cabs.c,v 1.1 2007/08/20 16:01:30 drochner Exp $ */ + +/* + * Written by Matthias Drochner <drochner@NetBSD.org>. + * Public domain. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +/* +FUNCTION + <<cabs>>, <<cabsf>>---complex absolute-value + +INDEX + cabs +INDEX + cabsf + +ANSI_SYNOPSIS + #include <complex.h> + double cabs(double complex <[z]>); + float cabsf(float complex <[z]>); + + +DESCRIPTION + These functions compute compute the complex absolute value + (also called norm, modulus, or magnitude) of <[z]>. + + <<cabsf>> is identical to <<cabs>>, except that it performs + its calculations on <<floats complex>>. + +RETURNS + The cabs functions return the complex absolute value. + +PORTABILITY + <<cabs>> and <<cabsf>> are ISO C99 + +QUICKREF + <<cabs>> and <<cabsf>> are ISO C99 + +*/ + + +#include <complex.h> +#include <math.h> + +double +cabs(double complex z) +{ + + return hypot( creal(z), cimag(z) ); +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/cabsf.c @@ -0,0 +1,19 @@ +/* $NetBSD: cabsf.c,v 1.1 2007/08/20 16:01:30 drochner Exp $ */ + +/* + * Written by Matthias Drochner <drochner@NetBSD.org>. + * Public domain. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +#include <complex.h> +#include <math.h> + +float +cabsf(float complex z) +{ + + return hypotf( crealf(z), cimagf(z) ); +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/cacos.c @@ -0,0 +1,99 @@ +/* $NetBSD: cacos.c,v 1.1 2007/08/20 16:01:30 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +/* +FUNCTION + <<cacos>>, <<cacosf>>---complex arc cosine + +INDEX + cacos +INDEX + cacosf + +ANSI_SYNOPSIS + #include <complex.h> + double complex cacos(double complex <[z]>); + float complex cacosf(float complex <[z]>); + + +DESCRIPTION + These functions compute the complex arc cosine of <[z]>, + with branch cuts outside the interval [-1, +1] along the real axis. + + <<cacosf>> is identical to <<cacos>>, except that it performs + its calculations on <<floats complex>>. + +RETURNS + @ifnottex + These functions return the complex arc cosine value, in the range + of a strip mathematically unbounded along the imaginary axis + and in the interval [0, pi] along the real axis. + @end ifnottex + @tex + These functions return the complex arc cosine value, in the range + of a strip mathematically unbounded along the imaginary axis + and in the interval [<<0>>, $\pi$] along the real axis. + @end tex + +PORTABILITY + <<cacos>> and <<cacosf>> are ISO C99 + +QUICKREF + <<cacos>> and <<cacosf>> are ISO C99 + +*/ + +#include <complex.h> +#include <math.h> + +double complex +cacos(double complex z) +{ + double complex w; + + /* FIXME: The original NetBSD code results in an ICE when trying to + build this function on ARM/Thumb using gcc 4.5.1. For now we use + a hopefully temporary workaround. */ +#if 0 + w = casin(z); + w = (M_PI_2 - creal(w)) - cimag(w) * I; +#else + double complex tmp0, tmp1; + + tmp0 = casin(z); + tmp1 = M_PI_2 - creal(tmp0); + w = tmp1 - (cimag(tmp0) * I); +#endif + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/cacosf.c @@ -0,0 +1,46 @@ +/* $NetBSD: cacosf.c,v 1.1 2007/08/20 16:01:30 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +#include <complex.h> +#include <math.h> + +float complex +cacosf(float complex z) +{ + float complex w; + + w = casinf(z); + w = ((float)M_PI_2 - crealf(w)) - cimagf(w) * I; + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/cacosh.c @@ -0,0 +1,93 @@ +/* $NetBSD: cacosh.c,v 1.2 2009/08/03 19:41:32 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +/* +FUNCTION + <<cacosh>>, <<cacoshf>>---complex arc hyperbolic cosine + +INDEX + cacosh +INDEX + cacoshf + +ANSI_SYNOPSIS + #include <complex.h> + double complex cacosh(double complex <[z]>); + float complex cacoshf(float complex <[z]>); + + +DESCRIPTION + These functions compute the complex arc hyperbolic cosine of <[z]>, + with a branch cut at values less than 1 along the real axis. + + <<cacoshf>> is identical to <<cacosh>>, except that it performs + its calculations on <<floats complex>>. + +RETURNS + @ifnottex + These functions return the complex arc hyperbolic cosine value, + in the range of a half-strip of non-negative values along the + real axis and in the interval [-i * pi, +i * pi] along the + imaginary axis. + @end ifnottex + @tex + These functions return the complex arc hyperbolic cosine value, + in the range of a half-strip of non-negative values along the + real axis and in the interval [$-i\pi$, $+i\pi$] along the + imaginary axis. + @end tex + +PORTABILITY + <<cacosh>> and <<cacoshf>> are ISO C99 + +QUICKREF + <<cacosh>> and <<cacoshf>> are ISO C99 + +*/ + + +#include <complex.h> + +double complex +cacosh(double complex z) +{ + double complex w; + +#if 0 /* does not give the principal value */ + w = I * cacos(z); +#else + w = clog(z + csqrt(z + 1) * csqrt(z - 1)); +#endif + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/cacoshf.c @@ -0,0 +1,48 @@ +/* $NetBSD: cacoshf.c,v 1.2 2009/08/03 19:41:32 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +#include <complex.h> + +float complex +cacoshf(float complex z) +{ + float complex w; + +#if 0 /* does not give the principal value */ + w = I * cacosf(z); +#else + w = clogf(z + csqrtf(z + 1) * csqrtf(z - 1)); +#endif + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/carg.c @@ -0,0 +1,59 @@ +/* $NetBSD: carg.c,v 1.1 2007/08/20 16:01:31 drochner Exp $ */ + +/* + * Written by Matthias Drochner <drochner@NetBSD.org>. + * Public domain. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +/* +FUNCTION + <<carg>>, <<cargf>>---argument (phase angle) + +INDEX + carg +INDEX + cargf + +ANSI_SYNOPSIS + #include <complex.h> + double carg(double complex <[z]>); + float cargf(float complex <[z]>); + + +DESCRIPTION + These functions compute the argument (also called phase angle) + of <[z]>, with a branch cut along the negative real axis. + + <<cargf>> is identical to <<carg>>, except that it performs + its calculations on <<floats complex>>. + +RETURNS + @ifnottex + The carg functions return the value of the argument in the + interval [-pi, +pi] + @end ifnottex + @tex + The carg functions return the value of the argument in the + interval [$-\pi$, $+\pi$] + @end tex + +PORTABILITY + <<carg>> and <<cargf>> are ISO C99 + +QUICKREF + <<carg>> and <<cargf>> are ISO C99 + +*/ + +#include <complex.h> +#include <math.h> + +double +carg(double complex z) +{ + + return atan2( cimag(z) , creal(z) ); +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/cargf.c @@ -0,0 +1,19 @@ +/* $NetBSD: cargf.c,v 1.1 2007/08/20 16:01:31 drochner Exp $ */ + +/* + * Written by Matthias Drochner <drochner@NetBSD.org>. + * Public domain. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +#include <complex.h> +#include <math.h> + +float +cargf(float complex z) +{ + + return atan2f( cimagf(z), crealf(z) ); +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/casin.c @@ -0,0 +1,165 @@ +/* $NetBSD: casin.c,v 1.1 2007/08/20 16:01:31 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +/* +FUNCTION + <<casin>>, <<casinf>>---complex arc sine + +INDEX + casin +INDEX + casinf + +ANSI_SYNOPSIS + #include <complex.h> + double complex casin(double complex <[z]>); + float complex casinf(float complex <[z]>); + + +DESCRIPTION + These functions compute the complex arc sine of <[z]>, + with branch cuts outside the interval [-1, +1] along the real axis. + + <<casinf>> is identical to <<casin>>, except that it performs + its calculations on <<floats complex>>. + +RETURNS + @ifnottex + These functions return the complex arc sine value, in the range + of a strip mathematically unbounded along the imaginary axis + and in the interval [-pi/2, +pi/2] along the real axis. + @end ifnottex + @tex + These functions return the complex arc sine value, in the range + of a strip mathematically unbounded along the imaginary axis + and in the interval [$-\pi/2$, $+\pi/2$] along the real axis. + @end tex + +PORTABILITY + <<casin>> and <<casinf>> are ISO C99 + +QUICKREF + <<casin>> and <<casinf>> are ISO C99 + +*/ + + +#include <complex.h> +#include <math.h> + +#ifdef __weak_alias +__weak_alias(casin, _casin) +#endif + +double complex +casin(double complex z) +{ + double complex w; + double complex ca, ct, zz, z2; + double x, y; + + x = creal(z); + y = cimag(z); + +#if 0 /* MD: test is incorrect, casin(>1) is defined */ + if (y == 0.0) { + if (fabs(x) > 1.0) { + w = M_PI_2 + 0.0 * I; +#if 0 + mtherr ("casin", DOMAIN); +#endif + } else { + w = asin(x) + 0.0 * I; + } + return w; + } +#endif + +/* Power series expansion */ +/* +b = cabs(z); +if( b < 0.125 ) +{ +z2.r = (x - y) * (x + y); +z2.i = 2.0 * x * y; + +cn = 1.0; +n = 1.0; +ca.r = x; +ca.i = y; +sum.r = x; +sum.i = y; +do + { + ct.r = z2.r * ca.r - z2.i * ca.i; + ct.i = z2.r * ca.i + z2.i * ca.r; + ca.r = ct.r; + ca.i = ct.i; + + cn *= n; + n += 1.0; + cn /= n; + n += 1.0; + b = cn/n; + + ct.r *= b; + ct.i *= b; + sum.r += ct.r; + sum.i += ct.i; + b = fabs(ct.r) + fabs(ct.i); + } +while( b > MACHEP ); +w->r = sum.r; +w->i = sum.i; +return; +} +*/ + + + ca = x + y * I; + ct = ca * I; + /* sqrt( 1 - z*z) */ + /* cmul( &ca, &ca, &zz ) */ + /*x * x - y * y */ + zz = (x - y) * (x + y) + (2.0 * x * y) * I; + + zz = 1.0 - creal(zz) - cimag(zz) * I; + z2 = csqrt(zz); + + zz = ct + z2; + zz = clog(zz); + /* multiply by 1/i = -i */ + w = zz * (-1.0 * I); + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/casinf.c @@ -0,0 +1,122 @@ +/* $NetBSD: casinf.c,v 1.1 2007/08/20 16:01:31 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +#include <complex.h> +#include <math.h> + +#ifdef __weak_alias +__weak_alias(casinf, _casinf) +#endif + +float complex +casinf(float complex z) +{ + float complex w; + float complex ca, ct, zz, z2; + float x, y; + + x = crealf(z); + y = cimagf(z); + +#if 0 /* MD: test is incorrect, casin(>1) is defined */ + if (y == 0.0f) { + if (fabsf(x) > 1.0) { + w = M_PI_2 + 0.0f * I; +#if 0 + mtherr ("casin", DOMAIN); +#endif + } else { + w = asinf(x) + 0.0f * I; + } + return w; + } +#endif + +/* Power series expansion */ +/* +b = cabsf(z); +if( b < 0.125 ) +{ +z2.r = (x - y) * (x + y); +z2.i = 2.0 * x * y; + +cn = 1.0; +n = 1.0; +ca.r = x; +ca.i = y; +sum.r = x; +sum.i = y; +do + { + ct.r = z2.r * ca.r - z2.i * ca.i; + ct.i = z2.r * ca.i + z2.i * ca.r; + ca.r = ct.r; + ca.i = ct.i; + + cn *= n; + n += 1.0; + cn /= n; + n += 1.0; + b = cn/n; + + ct.r *= b; + ct.i *= b; + sum.r += ct.r; + sum.i += ct.i; + b = fabsf(ct.r) + fabsf(ct.i); + } +while( b > MACHEP ); +w->r = sum.r; +w->i = sum.i; +return; +} +*/ + + + ca = x + y * I; + ct = ca * I; + /* sqrt( 1 - z*z) */ + /* cmul( &ca, &ca, &zz ) */ + /*x * x - y * y */ + zz = (x - y) * (x + y) + (2.0f * x * y) * I; + + zz = 1.0f - crealf(zz) - cimagf(zz) * I; + z2 = csqrtf(zz); + + zz = ct + z2; + zz = clogf(zz); + /* multiply by 1/i = -i */ + w = zz * (-1.0f * I); + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/casinh.c @@ -0,0 +1,97 @@ +/* $NetBSD: casinh.c,v 1.1 2007/08/20 16:01:31 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +/* +FUNCTION + <<casinh>>, <<casinhf>>---complex arc hyperbolic sine + +INDEX + casinh +INDEX + casinhf + +ANSI_SYNOPSIS + #include <complex.h> + double complex casinh(double complex <[z]>); + float complex casinhf(float complex <[z]>); + + +DESCRIPTION + @ifnottex + These functions compute the complex arc hyperbolic sine of <[z]>, + with branch cuts outside the interval [-i, +i] along the + imaginary axis. + @end ifnottex + @tex + These functions compute the complex arc hyperbolic sine of <[z]>, + with branch cuts outside the interval [$-i$, $+i$] along the + imaginary axis. + @end tex + + <<casinhf>> is identical to <<casinh>>, except that it performs + its calculations on <<floats complex>>. + +RETURNS + @ifnottex + These functions return the complex arc hyperbolic sine value, + in the range of a strip mathematically unbounded along the + real axis and in the interval [-i*p/2, +i*p/2] along the + imaginary axis. + @end ifnottex + @tex + These functions return the complex arc hyperbolic sine value, + in the range of a strip mathematically unbounded along the + real axis and in the interval [$-i\pi/2$, $+i\pi/2$] along the + imaginary axis. + @end tex + +PORTABILITY + <<casinh>> and <<casinhf>> are ISO C99 + +QUICKREF + <<casinh>> and <<casinhf>> are ISO C99 + +*/ + + +#include <complex.h> + +double complex +casinh(double complex z) +{ + double complex w; + + w = -1.0 * I * casin(z * I); + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/casinhf.c @@ -0,0 +1,44 @@ +/* $NetBSD: casinhf.c,v 1.1 2007/08/20 16:01:32 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +#include <complex.h> + +float complex +casinhf(float complex z) +{ + float complex w; + + w = -1.0f * I * casinf(z * I); + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/catan.c @@ -0,0 +1,130 @@ +/* $NetBSD: catan.c,v 1.1 2007/08/20 16:01:32 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +/* +FUNCTION + <<catan>>, <<catanf>>---complex arc tangent + +INDEX + catan +INDEX + catanf + +ANSI_SYNOPSIS + #include <complex.h> + double complex catan(double complex <[z]>); + float complex catanf(float complex <[z]>); + + +DESCRIPTION + @ifnottex + These functions compute the complex arc tangent of <[z]>, + with branch cuts outside the interval [-i, +i] along the + imaginary axis. + @end ifnottex + @tex + These functions compute the complex arc tangent of <[z]>, + with branch cuts outside the interval [$-i$, $+i$] along the + imaginary axis. + @end tex + + <<catanf>> is identical to <<catan>>, except that it performs + its calculations on <<floats complex>>. + +RETURNS + @ifnottex + These functions return the complex arc tangent value, in the range + of a strip mathematically unbounded along the imaginary axis + and in the interval [-pi/2, +pi/2] along the real axis. + @end ifnottex + @tex + These functions return the complex arc tangent, in the range + of a strip mathematically unbounded along the imaginary axis + and in the interval [$-\pi/2$, $+\pi/2$] along the real axis. + @end tex + +PORTABILITY + <<catan>> and <<catanf>> are ISO C99 + +QUICKREF + <<catan>> and <<catanf>> are ISO C99 + +*/ + + +#include <complex.h> +#include <math.h> +#include "cephes_subr.h" + +#ifdef __weak_alias +__weak_alias(catan, _catan) +#endif + +double complex +catan(double complex z) +{ + double complex w; + double a, t, x, x2, y; + + x = creal(z); + y = cimag(z); + + if ((x == 0.0) && (y > 1.0)) + goto ovrf; + + x2 = x * x; + a = 1.0 - x2 - (y * y); + if (a == 0.0) + goto ovrf; + + t = 0.5 * atan2(2.0 * x, a); + w = _redupi(t); + + t = y - 1.0; + a = x2 + (t * t); + if (a == 0.0) + goto ovrf; + + t = y + 1.0; + a = (x2 + (t * t))/a; + w = w + (0.25 * log(a)) * I; + return w; + +ovrf: +#if 0 + mtherr ("catan", OVERFLOW); +#endif + w = HUGE_VAL + HUGE_VAL * I; + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/catanf.c @@ -0,0 +1,79 @@ +/* $NetBSD: catanf.c,v 1.1 2007/08/20 16:01:32 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +#include <complex.h> +#include <math.h> +#include "cephes_subrf.h" + +#ifdef __weak_alias +__weak_alias(catanf, _catanf) +#endif + +float complex +catanf(float complex z) +{ + float complex w; + float a, t, x, x2, y; + + x = crealf(z); + y = cimagf(z); + + if ((x == 0.0f) && (y > 1.0f)) + goto ovrf; + + x2 = x * x; + a = 1.0f - x2 - (y * y); + if (a == 0.0f) + goto ovrf; + + t = 0.5f * atan2f(2.0f * x, a); + w = _redupif(t); + + t = y - 1.0f; + a = x2 + (t * t); + if (a == 0.0f) + goto ovrf; + + t = y + 1.0f; + a = (x2 + (t * t))/a; + w = w + (0.25f * logf(a)) * I; + return w; + +ovrf: +#if 0 + mtherr ("catan", OVERFLOW); +#endif + w = HUGE_VALF + HUGE_VALF * I; + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/catanh.c @@ -0,0 +1,90 @@ +/* $NetBSD: catanh.c,v 1.1 2007/08/20 16:01:32 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +/* +FUNCTION + <<catanh>>, <<catanhf>>---complex arc hyperbolic tangent + +INDEX + catanh +INDEX + catanhf + +ANSI_SYNOPSIS + #include <complex.h> + double complex catanh(double complex <[z]>); + float complex catanhf(float complex <[z]>); + + +DESCRIPTION + These functions compute the complex arc hyperbolic tan of <[z]>, + with branch cuts outside the interval [-1, +1] along the + real axis. + + <<catanhf>> is identical to <<catanh>>, except that it performs + its calculations on <<floats complex>>. + +RETURNS + @ifnottex + These functions return the complex arc hyperbolic tangent value, + in the range of a strip mathematically unbounded along the + real axis and in the interval [-i*p/2, +i*p/2] along the + imaginary axis. + @end ifnottex + @tex + These functions return the complex arc hyperbolic tangent value, + in the range of a strip mathematically unbounded along the + real axis and in the interval [$-i\pi/2$, $+i\pi/2$] along the + imaginary axis. + @end tex + +PORTABILITY + <<catanh>> and <<catanhf>> are ISO C99 + +QUICKREF + <<catanh>> and <<catanhf>> are ISO C99 + +*/ + + +#include <complex.h> + +double complex +catanh(double complex z) +{ + double complex w; + + w = -1.0 * I * catan(z * I); + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/catanhf.c @@ -0,0 +1,44 @@ +/* $NetBSD: catanhf.c,v 1.1 2007/08/20 16:01:32 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +#include <complex.h> + +float complex +catanhf(float complex z) +{ + float complex w; + + w = -1.0f * I * catanf(z * I); + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/ccos.c @@ -0,0 +1,81 @@ +/* $NetBSD: ccos.c,v 1.1 2007/08/20 16:01:32 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +/* +FUNCTION + <<ccos>>, <<ccosf>>---complex cosine + +INDEX + ccos +INDEX + ccosf + +ANSI_SYNOPSIS + #include <complex.h> + double complex ccos(double complex <[z]>); + float complex ccosf(float complex <[z]>); + + +DESCRIPTION + These functions compute the complex cosine of <[z]>. + + <<ccosf>> is identical to <<ccos>>, except that it performs + its calculations on <<floats complex>>. + +RETURNS + These functions return the complex cosine value. + +PORTABILITY + <<ccos>> and <<ccosf>> are ISO C99 + +QUICKREF + <<ccos>> and <<ccosf>> are ISO C99 + +*/ + + +#include <complex.h> +#include <math.h> +#include "cephes_subr.h" + +double complex +ccos(double complex z) +{ + double complex w; + double ch, sh; + + _cchsh(cimag(z), &ch, &sh); + w = cos(creal(z)) * ch - (sin(creal(z)) * sh) * I; + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/ccosf.c @@ -0,0 +1,48 @@ +/* $NetBSD: ccosf.c,v 1.1 2007/08/20 16:01:33 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +#include <complex.h> +#include <math.h> +#include "cephes_subrf.h" + +float complex +ccosf(float complex z) +{ + float complex w; + float ch, sh; + + _cchshf(cimagf(z), &ch, &sh); + w = cosf(crealf(z)) * ch - (sinf(crealf(z)) * sh) * I; + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/ccosh.c @@ -0,0 +1,81 @@ +/* $NetBSD: ccosh.c,v 1.1 2007/08/20 16:01:33 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +/* +FUNCTION + <<ccosh>>, <<ccoshf>>---complex hyperbolic cosine + +INDEX + ccosh +INDEX + ccoshf + +ANSI_SYNOPSIS + #include <complex.h> + double complex ccosh(double complex <[z]>); + float complex ccoshf(float complex <[z]>); + + +DESCRIPTION + These functions compute the complex hyperbolic cosine of <[z]>. + + <<ccoshf>> is identical to <<ccosh>>, except that it performs + its calculations on <<floats complex>>. + +RETURNS + These functions return the complex hyperbolic cosine value. + +PORTABILITY + <<ccosh>> and <<ccoshf>> are ISO C99 + +QUICKREF + <<ccosh>> and <<ccoshf>> are ISO C99 + +*/ + + +#include <complex.h> +#include <math.h> + +double complex +ccosh(double complex z) +{ + double complex w; + double x, y; + + x = creal(z); + y = cimag(z); + w = cosh(x) * cos(y) + (sinh(x) * sin(y)) * I; + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/ccoshf.c @@ -0,0 +1,48 @@ +/* $NetBSD: ccoshf.c,v 1.1 2007/08/20 16:01:33 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +#include <complex.h> +#include <math.h> + +float complex +ccoshf(float complex z) +{ + float complex w; + float x, y; + + x = crealf(z); + y = cimagf(z); + w = coshf(x) * cosf(y) + (sinhf(x) * sinf(y)) * I; + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/cephes_subr.c @@ -0,0 +1,126 @@ +/* $NetBSD: cephes_subr.c,v 1.1 2007/08/20 16:01:33 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +#include <complex.h> +#include <math.h> +#include "cephes_subr.h" + +/* calculate cosh and sinh */ + +void +_cchsh(double x, double *c, double *s) +{ + double e, ei; + + if (fabs(x) <= 0.5) { + *c = cosh(x); + *s = sinh(x); + } else { + e = exp(x); + ei = 0.5 / e; + e = 0.5 * e; + *s = e - ei; + *c = e + ei; + } +} + +/* Program to subtract nearest integer multiple of PI */ + +/* extended precision value of PI: */ +static const double DP1 = 3.14159265160560607910E0; +static const double DP2 = 1.98418714791870343106E-9; +static const double DP3 = 1.14423774522196636802E-17; +#define MACHEP 1.1e-16 + +double +_redupi(double x) +{ + double t; + long i; + + t = x / M_PI; + if (t >= 0.0) + t += 0.5; + else + t -= 0.5; + + i = t; /* the multiple */ + t = i; + t = ((x - t * DP1) - t * DP2) - t * DP3; + return t; +} + +/* Taylor series expansion for cosh(2y) - cos(2x) */ + +double +_ctans(double complex z) +{ + double f, x, x2, y, y2, rn, t; + double d; + + x = fabs(2.0 * creal(z)); + y = fabs(2.0 * cimag(z)); + + x = _redupi(x); + + x = x * x; + y = y * y; + x2 = 1.0; + y2 = 1.0; + f = 1.0; + rn = 0.0; + d = 0.0; + do { + rn += 1.0; + f *= rn; + rn += 1.0; + f *= rn; + x2 *= x; + y2 *= y; + t = y2 + x2; + t /= f; + d += t; + + rn += 1.0; + f *= rn; + rn += 1.0; + f *= rn; + x2 *= x; + y2 *= y; + t = y2 - x2; + t /= f; + d += t; + } while (fabs(t/d) > MACHEP); + return d; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/cephes_subr.h @@ -0,0 +1,5 @@ +/* $NetBSD: cephes_subr.h,v 1.1 2007/08/20 16:01:33 drochner Exp $ */ + +void _cchsh(double, double *, double *); +double _redupi(double); +double _ctans(double complex);
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/cephes_subrf.c @@ -0,0 +1,125 @@ +/* $NetBSD: cephes_subrf.c,v 1.1 2007/08/20 16:01:34 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +#include <complex.h> +#include <math.h> +#include "cephes_subrf.h" + +/* calculate cosh and sinh */ + +void +_cchshf(float x, float *c, float *s) +{ + float e, ei; + + if (fabsf(x) <= 0.5f) { + *c = coshf(x); + *s = sinhf(x); + } else { + e = expf(x); + ei = 0.5f / e; + e = 0.5f * e; + *s = e - ei; + *c = e + ei; + } +} + +/* Program to subtract nearest integer multiple of PI */ + +/* extended precision value of PI: */ +static const double DP1 = 3.140625; +static const double DP2 = 9.67502593994140625E-4; +static const double DP3 = 1.509957990978376432E-7; +#define MACHEPF 3.0e-8 + +float +_redupif(float x) +{ + float t; + long i; + + t = x / (float)M_PI; + if (t >= 0.0f) + t += 0.5f; + else + t -= 0.5f; + + i = t; /* the multiple */ + t = i; + t = ((x - t * DP1) - t * DP2) - t * DP3; + return t; +} + +/* Taylor series expansion for cosh(2y) - cos(2x) */ + +float +_ctansf(float complex z) +{ + float f, x, x2, y, y2, rn, t, d; + + x = fabsf(2.0f * crealf(z)); + y = fabsf(2.0f * cimagf(z)); + + x = _redupif(x); + + x = x * x; + y = y * y; + x2 = 1.0f; + y2 = 1.0f; + f = 1.0f; + rn = 0.0f; + d = 0.0f; + do { + rn += 1.0f; + f *= rn; + rn += 1.0f; + f *= rn; + x2 *= x; + y2 *= y; + t = y2 + x2; + t /= f; + d += t; + + rn += 1.0f; + f *= rn; + rn += 1.0f; + f *= rn; + x2 *= x; + y2 *= y; + t = y2 - x2; + t /= f; + d += t; + } while (fabsf(t/d) > MACHEPF); + return d; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/cephes_subrf.h @@ -0,0 +1,5 @@ +/* $NetBSD: cephes_subrf.h,v 1.1 2007/08/20 16:01:34 drochner Exp $ */ + +void _cchshf(float, float *, float *); +float _redupif(float); +float _ctansf(float complex);
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/cexp.c @@ -0,0 +1,82 @@ +/* $NetBSD: cexp.c,v 1.1 2007/08/20 16:01:34 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +/* +FUNCTION + <<cexp>>, <<cexpf>>---complex base-e exponential + +INDEX + cexp +INDEX + cexpf + +ANSI_SYNOPSIS + #include <complex.h> + double complex cexp(double complex <[z]>); + float complex cexpf(float complex <[z]>); + + +DESCRIPTION + These functions compute the complex base-<[e]> exponential of <[z]>. + + <<cexpf>> is identical to <<cexp>>, except that it performs + its calculations on <<floats complex>>. + +RETURNS + The cexp functions return the complex base-<[e]> exponential value. + +PORTABILITY + <<cexp>> and <<cexpf>> are ISO C99 + +QUICKREF + <<cexp>> and <<cexpf>> are ISO C99 + +*/ + + +#include <complex.h> +#include <math.h> + +double complex +cexp(double complex z) +{ + double complex w; + double r, x, y; + + x = creal(z); + y = cimag(z); + r = exp(x); + w = r * cos(y) + r * sin(y) * I; + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/cexpf.c @@ -0,0 +1,49 @@ +/* $NetBSD: cexpf.c,v 1.1 2007/08/20 16:01:34 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +#include <complex.h> +#include <math.h> + +float complex +cexpf(float complex z) +{ + float complex w; + float r, x, y; + + x = crealf(z); + y = cimagf(z); + r = expf(x); + w = r * cosf(y) + r * sinf(y) * I; + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/cimag.c @@ -0,0 +1,61 @@ +//=========================================================================== +// +// cimag.c +// +// Complex numbr real part - double precision. +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2013 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ilijak +// Contributors: +// Date: 2013-06-06 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +#include <complex.h> + +double +cimag(double complex z) +{ + return __builtin_cimag(z); +} + +// End of cimag.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/cimagf.c @@ -0,0 +1,61 @@ +//=========================================================================== +// +// cimagf.c +// +// Complex numbr real part - single precision. +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2013 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ilijak +// Contributors: +// Date: 2013-06-06 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +#include <complex.h> + +float +cimagf(float complex z) +{ + return __builtin_cimagf(z); +} + +// End of cimagf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/clog.c @@ -0,0 +1,91 @@ +/* $NetBSD: clog.c,v 1.1 2007/08/20 16:01:35 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +/* +FUNCTION + <<clog>>, <<clogf>>---complex base-e logarithm + +INDEX + clog +INDEX + clogf + +ANSI_SYNOPSIS + #include <complex.h> + double complex clog(double complex <[z]>); + float complex clogf(float complex <[z]>); + + +DESCRIPTION + These functions compute the complex natural (base-<[e]>) logarithm + of <[z]>, with a branch cut along the negative real axis. + + <<clogf>> is identical to <<clog>>, except that it performs + its calculations on <<floats complex>>. + +RETURNS + @ifnottex + The clog functions return the complex natural logarithm value, in + the range of a strip mathematically unbounded along the real axis + and in the interval [-i*pi , +i*pi] along the imaginary axis. + @end ifnottex + @tex + The clog functions return the complex natural logarithm value, in + the range of a strip mathematically unbounded along the real axis + and in the interval [$-i\pi$, $+i\pi$] along the imaginary axis. + @end tex + +PORTABILITY + <<clog>> and <<clogf>> are ISO C99 + +QUICKREF + <<clog>> and <<clogf>> are ISO C99 + +*/ + +#include <complex.h> +#include <math.h> + +double complex +clog(double complex z) +{ + double complex w; + double p, rr; + + rr = cabs(z); + p = log(rr); + rr = atan2(cimag(z), creal(z)); + w = p + rr * I; + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/clogf.c @@ -0,0 +1,49 @@ +/* $NetBSD: clogf.c,v 1.1 2007/08/20 16:01:35 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +#include <complex.h> +#include <math.h> + +float complex +clogf(float complex z) +{ + float complex w; + float p, rr; + + rr = cabsf(z); + p = logf(rr); + rr = atan2f(cimagf(z), crealf(z)); + w = p + rr * I; + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/complex.tex @@ -0,0 +1,55 @@ +@node Complex +@chapter Mathematical Complex Functions (@file{complex.h}) + +This chapter groups the complex mathematical functions. The +corresponding definitions and declarations are in @file{complex.h}. +Functions and documentations are taken from NetBSD. + +@menu +* cabs:: Complex absolute value +* cacos:: Complex arc cosine +* cacosh:: Complex arc hyperbolic cosine +* carg:: Argument (also called phase angle) +* casin:: Complex arc sine +* casinh:: Complex arc hyperbolic sine +* catan:: Complex arc tangent +* catanh:: Complex arc hyperbolic tangent +* ccos:: Complex cosine +* ccosh:: Complex hyperbolic cosine +* cexp:: Complex exponent +* cimag:: Imaginary part +* clog:: Complex natural (base e) logarithm +* conj:: Complex conjugate +* cpow:: Complex power function +* cproj:: Compute a projection on the Riemann sphere +* creal:: Real part +* csin:: Complex sine +* csinh:: Complex hyperbolic sine +* csqrt:: Complex square root +* ctan:: Complex tangent +* ctanh:: Complex hyperbolic tangent +@end menu + + +@page @include complex/cabs.def +@page @include complex/cacos.def +@page @include complex/cacosh.def +@page @include complex/carg.def +@page @include complex/casin.def +@page @include complex/casinh.def +@page @include complex/catan.def +@page @include complex/catanh.def +@page @include complex/ccos.def +@page @include complex/ccosh.def +@page @include complex/cexp.def +@page @include complex/cimag.def +@page @include complex/clog.def +@page @include complex/conj.def +@page @include complex/cpow.def +@page @include complex/cproj.def +@page @include complex/creal.def +@page @include complex/csin.def +@page @include complex/csinh.def +@page @include complex/csqrt.def +@page @include complex/ctan.def +@page @include complex/ctanh.def
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/conj.c @@ -0,0 +1,61 @@ +//=========================================================================== +// +// conj.c +// +// Complex cojugate - double precision. +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2013 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ilijak +// Contributors: +// Date: 2013-06-06 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +#include <complex.h> + +double complex +conj(double complex z) +{ + return __builtin_conj(z); +} + +// End of conj.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/conjf.c @@ -0,0 +1,61 @@ +//=========================================================================== +// +// conjf.c +// +// Complex cojugate - single precision. +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2013 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: ilijak +// Date: 2013-06-06 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +#include <complex.h> + +float complex +conjf(float complex z) +{ + return __builtin_conjf(z); +} + +// End of conjf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/cpow.c @@ -0,0 +1,101 @@ +/* $NetBSD: cpow.c,v 1.1 2007/08/20 16:01:35 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +/* +FUNCTION + <<cpow>>, <<cpowf>>---complex power + +INDEX + cpow +INDEX + cpowf + +ANSI_SYNOPSIS + #include <complex.h> + double complex cpow(double complex <[x]>, double complex <[y]>); + float complex cpowf(float complex <[x]>, float complex <[y]>); + + +DESCRIPTION + @ifnottex + The cpow functions compute the complex power function x^y + power, with a branch cut for the first parameter along the + negative real axis. + @end ifnottex + @tex + The cpow functions compute the complex power function $x^y$ + power, with a branch cut for the first parameter along the + negative real axis. + @end tex + + <<cpowf>> is identical to <<cpow>>, except that it performs + its calculations on <<floats complex>>. + +RETURNS + The cpow functions return the complex power function value. + +PORTABILITY + <<cpow>> and <<cpowf>> are ISO C99 + +QUICKREF + <<cpow>> and <<cpowf>> are ISO C99 + +*/ + + +#include <complex.h> +#include <math.h> + +double complex +cpow(double complex a, double complex z) +{ + double complex w; + double x, y, r, theta, absa, arga; + + x = creal(z); + y = cimag(z); + absa = cabs(a); + if (absa == 0.0) { + return (0.0 + 0.0 * I); + } + arga = carg(a); + r = pow(absa, x); + theta = x * arga; + if (y != 0.0) { + r = r * exp(-y * arga); + theta = theta + y * log(absa); + } + w = r * cos(theta) + (r * sin(theta)) * I; + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/cpowf.c @@ -0,0 +1,59 @@ +/* $NetBSD: cpowf.c,v 1.1 2007/08/20 16:01:36 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +#include <complex.h> +#include <math.h> + +float complex +cpowf(float complex a, float complex z) +{ + float complex w; + float x, y, r, theta, absa, arga; + + x = crealf(z); + y = cimagf(z); + absa = cabsf(a); + if (absa == 0.0f) { + return (0.0f + 0.0f * I); + } + arga = cargf(a); + r = powf(absa, x); + theta = x * arga; + if (y != 0.0f) { + r = r * expf(-y * arga); + theta = theta + y * logf(absa); + } + w = r * cosf(theta) + (r * sinf(theta)) * I; + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/cproj.c @@ -0,0 +1,106 @@ +/* $NetBSD: cproj.c,v 1.3 2010/09/20 17:51:38 christos Exp $ */ + +/*- + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +/* +FUNCTION + <<cproj>>, <<cprojf>>--- Riemann sphere projection + +INDEX + cproj +INDEX + cprojf + +ANSI_SYNOPSIS + #include <complex.h> + double complex cproj(double complex <[z]>); + float complex cprojf(float complex <[z]>); + + +DESCRIPTION + These functions compute a projection of <[z]> onto the Riemann + sphere: <[z]> projects to <[z]> except that all complex infinities + (even those with one infinite part and one NaN part) project + to positive infinity on the real axis. If <[z]> has an infinite part, + then <<cproj>>(<[z]>) is equivalent to + + INFINITY + I * copysign(0.0, cimag(z)) + + <<cprojf>> is identical to <<cproj>>, except that it performs + its calculations on <<floats complex>>. + +RETURNS + The cproj functions return the value of the projection onto + the Riemann sphere. + +PORTABILITY + <<cproj>> and <<cprojf>> are ISO C99 + +QUICKREF + <<cproj>> and <<cprojf>> are ISO C99 + +*/ + +//#include <sys/cdefs.h> +/*__RCSID("$NetBSD: cproj.c,v 1.3 2010/09/20 17:51:38 christos Exp $"); */ + +#include <complex.h> +#include <math.h> + +#include "../mathincl/fdlibm.h" + +/* + * cproj(double complex z) + * + * These functions return the value of the projection (not stereographic!) + * onto the Riemann sphere. + * + * z projects to z, except that all complex infinities (even those with one + * infinite part and one NaN part) project to positive infinity on the real axis. + * If z has an infinite part, then cproj(z) shall be equivalent to: + * + * INFINITY + I * copysign(0.0, cimag(z)) + */ +double complex +cproj(double complex z) +{ + double_complex w = { .z = z }; + + if (isinf(creal(z)) || isinf(cimag(z))) { +#ifdef __INFINITY + REAL_PART(w) = __INFINITY; +#else + REAL_PART(w) = HUGE_VAL; +#endif + IMAG_PART(w) = copysign(0.0, cimag(z)); + } + + return (w.z); +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/cprojf.c @@ -0,0 +1,67 @@ +/* $NetBSD: cprojf.c,v 1.3 2010/09/20 17:51:38 christos Exp $ */ + +/*- + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +/*__RCSID("$NetBSD: cprojf.c,v 1.3 2010/09/20 17:51:38 christos Exp $"); */ + +#include <complex.h> +#include <math.h> + +#include "../mathincl/fdlibm.h" + +/* + * cprojf(float complex z) + * + * These functions return the value of the projection (not stereographic!) + * onto the Riemann sphere. + * + * z projects to z, except that all complex infinities (even those with one + * infinite part and one NaN part) project to positive infinity on the real axis. + * If z has an infinite part, then cproj(z) shall be equivalent to: + * + * INFINITY + I * copysign(0.0, cimag(z)) + */ + +float complex +cprojf(float complex z) +{ + float_complex w = { .z = z }; + + if (isinff(crealf(z)) || isinff(cimagf(z))) { +#ifdef __INFINITY + REAL_PART(w) = __INFINITY; +#else + REAL_PART(w) = HUGE_VALF; +#endif + IMAG_PART(w) = copysignf(0.0, cimagf(z)); + } + + return (w.z); +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/creal.c @@ -0,0 +1,61 @@ +//=========================================================================== +// +// creal.c +// +// Complex numbr real part - double precision. +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2013 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ilijak +// Contributors: +// Date: 2013-06-06 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +#include <complex.h> + +double +creal(double complex z) +{ + return __builtin_creal(z); +} + +// End of creal.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/crealf.c @@ -0,0 +1,61 @@ +//=========================================================================== +// +// crealf.c +// +// Complex numbr real part - single precision. +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2013 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ilijak +// Contributors: +// Date: 2013-06-06 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +#include <complex.h> + +float +crealf(float complex z) +{ + return __builtin_crealf(z); +} + +// End of crealf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/csin.c @@ -0,0 +1,81 @@ +/* $NetBSD: csin.c,v 1.1 2007/08/20 16:01:36 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +/* +FUNCTION + <<csin>>, <<csinf>>---complex sine + +INDEX + csin +INDEX + csinf + +ANSI_SYNOPSIS + #include <complex.h> + double complex csin(double complex <[z]>); + float complex csinf(float complex <[z]>); + + +DESCRIPTION + These functions compute the complex sine of <[z]>. + + <<csinf>> is identical to <<csin>>, except that it performs + its calculations on <<floats complex>>. + +RETURNS + These functions return the complex sine value. + +PORTABILITY + <<csin>> and <<csinf>> are ISO C99 + +QUICKREF + <<csin>> and <<csinf>> are ISO C99 + +*/ + + +#include <complex.h> +#include <math.h> +#include "cephes_subr.h" + +double complex +csin(double complex z) +{ + double complex w; + double ch, sh; + + _cchsh(cimag(z), &ch, &sh); + w = sin(creal(z)) * ch + (cos(creal(z)) * sh) * I; + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/csinf.c @@ -0,0 +1,48 @@ +/* $NetBSD: csinf.c,v 1.1 2007/08/20 16:01:36 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +#include <complex.h> +#include <math.h> +#include "cephes_subrf.h" + +float complex +csinf(float complex z) +{ + float complex w; + float ch, sh; + + _cchshf(cimagf(z), &ch, &sh); + w = sinf(crealf(z)) * ch + (cosf(crealf(z)) * sh) * I; + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/csinh.c @@ -0,0 +1,80 @@ +/* $NetBSD: csinh.c,v 1.1 2007/08/20 16:01:36 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +/* +FUNCTION + <<csinh>>, <<csinhf>>---complex hyperbolic sine + +INDEX + csinh +INDEX + csinhf + +ANSI_SYNOPSIS + #include <complex.h> + double complex csinh(double complex <[z]>); + float complex csinhf(float complex <[z]>); + + +DESCRIPTION + These functions compute the complex hyperbolic sine of <[z]>. + + <<ccoshf>> is identical to <<ccosh>>, except that it performs + its calculations on <<floats complex>>. + +RETURNS + These functions return the complex hyperbolic sine value. + +PORTABILITY + <<csinh>> and <<csinhf>> are ISO C99 + +QUICKREF + <<csinh>> and <<csinhf>> are ISO C99 + +*/ + +#include <complex.h> +#include <math.h> + +double complex +csinh(double complex z) +{ + double complex w; + double x, y; + + x = creal(z); + y = cimag(z); + w = sinh(x) * cos(y) + (cosh(x) * sin(y)) * I; + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/csinhf.c @@ -0,0 +1,48 @@ +/* $NetBSD: csinhf.c,v 1.1 2007/08/20 16:01:37 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +#include <complex.h> +#include <math.h> + +float complex +csinhf(float complex z) +{ + float complex w; + float x, y; + + x = crealf(z); + y = cimagf(z); + w = sinhf(x) * cosf(y) + (coshf(x) * sinf(y)) * I; + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/csqrt.c @@ -0,0 +1,137 @@ +/* $NetBSD: csqrt.c,v 1.1 2007/08/20 16:01:37 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +/* +FUNCTION + <<csqrt>>, <<csqrtf>>---complex square root + +INDEX + csqrt +INDEX + csqrtf + +ANSI_SYNOPSIS + #include <complex.h> + double complex csqrt(double complex <[z]>); + float complex csqrtf(float complex <[z]>); + + +DESCRIPTION + These functions compute the complex square root of <[z]>, with + a branch cut along the negative real axis. + + <<csqrtf>> is identical to <<csqrt>>, except that it performs + its calculations on <<floats complex>>. + +RETURNS + The csqrt functions return the complex square root value, in + the range of the right halfplane (including the imaginary axis). + +PORTABILITY + <<csqrt>> and <<csqrtf>> are ISO C99 + +QUICKREF + <<csqrt>> and <<csqrtf>> are ISO C99 + +*/ + + +#include <complex.h> +#include <math.h> + +double complex +csqrt(double complex z) +{ + double complex w; + double x, y, r, t, scale; + + x = creal (z); + y = cimag (z); + + if (y == 0.0) { + if (x == 0.0) { + w = 0.0 + y * I; + } else { + r = fabs(x); + r = sqrt(r); + if (x < 0.0) { + w = 0.0 + r * I; + } else { + w = r + y * I; + } + } + return w; + } + if (x == 0.0) { + r = fabs(y); + r = sqrt(0.5 * r); + if (y > 0) + w = r + r * I; + else + w = r - r * I; + return w; + } + /* Rescale to avoid internal overflow or underflow. */ + if ((fabs(x) > 4.0) || (fabs(y) > 4.0)) { + x *= 0.25; + y *= 0.25; + scale = 2.0; + } else { +#if 1 + x *= 1.8014398509481984e16; /* 2^54 */ + y *= 1.8014398509481984e16; + scale = 7.450580596923828125e-9; /* 2^-27 */ +#else + x *= 4.0; + y *= 4.0; + scale = 0.5; +#endif + } + w = x + y * I; + r = cabs(w); + if (x > 0) { + t = sqrt(0.5 * r + 0.5 * x); + r = scale * fabs((0.5 * y) / t ); + t *= scale; + } else { + r = sqrt(0.5 * r - 0.5 * x); + t = scale * fabs((0.5 * y) / r); + r *= scale; + } + if (y < 0) + w = t - r * I; + else + w = t + r * I; + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/csqrtf.c @@ -0,0 +1,102 @@ +/* $NetBSD: csqrtf.c,v 1.1 2007/08/20 16:01:37 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +#include <complex.h> +#include <math.h> + +float complex +csqrtf(float complex z) +{ + float complex w; + float x, y, r, t, scale; + + x = crealf (z); + y = cimagf (z); + + if (y == 0.0f) { + if (x < 0.0f) { + w = 0.0f + sqrtf(-x) * I; + return w; + } else if (x == 0.0f) { + return (0.0f + y * I); + } else { + w = sqrtf(x) + y * I; + return w; + } + } + + if (x == 0.0f) { + r = fabsf(y); + r = sqrtf(0.5f * r); + if (y > 0) + w = r + r * I; + else + w = r - r * I; + return w; + } + + /* Rescale to avoid internal overflow or underflow. */ + if ((fabsf(x) > 4.0f) || (fabsf(y) > 4.0f)) { + x *= 0.25f; + y *= 0.25f; + scale = 2.0f; + } else { +#if 1 + x *= 6.7108864e7f; /* 2^26 */ + y *= 6.7108864e7f; + scale = 1.220703125e-4f; /* 2^-13 */ +#else + x *= 4.0f; + y *= 4.0f; + scale = 0.5f; +#endif + } + w = x + y * I; + r = cabsf(w); + if( x > 0 ) { + t = sqrtf(0.5f * r + 0.5f * x); + r = scale * fabsf((0.5f * y) / t); + t *= scale; + } else { + r = sqrtf(0.5f * r - 0.5f * x); + t = scale * fabsf((0.5f * y) / r); + r *= scale; + } + + if (y < 0) + w = t - r * I; + else + w = t + r * I; + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/ctan.c @@ -0,0 +1,91 @@ +/* $NetBSD: ctan.c,v 1.1 2007/08/20 16:01:37 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +/* +FUNCTION + <<ctan>>, <<ctanf>>---complex tangent + +INDEX + ctan +INDEX + ctanf + +ANSI_SYNOPSIS + #include <complex.h> + double complex ctan(double complex <[z]>); + float complex ctanf(float complex <[z]>); + + +DESCRIPTION + These functions compute the complex tangent of <[z]>. + + <<ctanf>> is identical to <<ctan>>, except that it performs + its calculations on <<floats complex>>. + +RETURNS + These functions return the complex tangent value. + +PORTABILITY + <<ctan>> and <<ctanf>> are ISO C99 + +QUICKREF + <<ctan>> and <<ctanf>> are ISO C99 + +*/ + + +#include <complex.h> +#include <math.h> +#include "cephes_subr.h" + +double complex +ctan(double complex z) +{ + double complex w; + double d; + + d = cos(2.0 * creal(z)) + cosh(2.0 * cimag(z)); + + if (fabs(d) < 0.25) + d = _ctans(z); + + if (d == 0.0) { + /* mtherr ("ctan", OVERFLOW); */ + w = HUGE_VAL + HUGE_VAL * I; + return w; + } + + w = sin(2.0 * creal(z)) / d + (sinh(2.0 * cimag(z)) / d) * I; + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/ctanf.c @@ -0,0 +1,58 @@ +/* $NetBSD: ctanf.c,v 1.1 2007/08/20 16:01:38 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +#include <complex.h> +#include <math.h> +#include "cephes_subrf.h" + +float complex +ctanf(float complex z) +{ + float complex w; + float d; + + d = cosf(2.0f * crealf(z)) + coshf(2.0f * cimagf(z)); + + if (fabsf(d) < 0.25f) + d = _ctansf(z); + + if (d == 0.0f) { + /* mtherr ("ctan", OVERFLOW); */ + w = HUGE_VALF + HUGE_VALF * I; + return w; + } + + w = sinf(2.0f * crealf(z)) / d + (sinhf(2.0f * cimagf(z)) / d) * I; + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/ctanh.c @@ -0,0 +1,83 @@ +/* $NetBSD: ctanh.c,v 1.1 2007/08/20 16:01:38 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +/* +FUNCTION + <<ctanh>>, <<ctanf>>---complex hyperbolic tangent + +INDEX + ctanh +INDEX + ctanhf + +ANSI_SYNOPSIS + #include <complex.h> + double complex ctanh(double complex <[z]>); + float complex ctanhf(float complex <[z]>); + + +DESCRIPTION + These functions compute the complex hyperbolic tangent of <[z]>. + + <<ctanhf>> is identical to <<ctanh>>, except that it performs + its calculations on <<floats complex>>. + +RETURNS + These functions return the complex hyperbolic tangent value. + +PORTABILITY + <<ctanh>> and <<ctanhf>> are ISO C99 + +QUICKREF + <<ctanh>> and <<ctanhf>> are ISO C99 + +*/ + + +#include <complex.h> +#include <math.h> + +double complex +ctanh(double complex z) +{ + double complex w; + double x, y, d; + + x = creal(z); + y = cimag(z); + d = cosh(2.0 * x) + cos(2.0 * y); + w = sinh(2.0 * x) / d + (sin(2.0 * y) / d) * I; + + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/complex/ctanhf.c @@ -0,0 +1,50 @@ +/* $NetBSD: ctanhf.c,v 1.1 2007/08/20 16:01:38 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * imported and modified include for newlib 2010/10/03 + * Marco Atzeri <marco_atzeri@yahoo.it> + */ + +#include <complex.h> +#include <math.h> + +float complex +ctanhf(float complex z) +{ + float complex w; + float x, y, d; + + x = crealf(z); + y = cimagf(z); + d = coshf(2.0f * x) + cosf(2.0f * y); + w = sinhf(2.0f * x) / d + (sinf(2.0f * y) / d) * I; + + return w; +}
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-api/wf_acos.c @@ -0,0 +1,103 @@ +//=========================================================================== +// +// wf_acos.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * wrap_acosf(x) + */ + +#include "mathincl/fdlibm.h" + +#ifdef _HAVE_STDC + float acosf(float x) /* wrapper acosf */ +#else + float acosf(x) /* wrapper acosf */ + float x; +#endif +{ +#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY + return __ieee754_acosf(x); +#else + float z; + + z = __ieee754_acosf(x); + if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE || isnanf(x)) return z; + if(fabsf(x)>(float)1.0) { + return __kernel_standard_float(x,x,1); /* acos(|x|>1) */ + } else + return z; +#endif +} + +#endif // ifdef CYGPKG_LIBM + +// EOF wf_acos.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-api/wf_acosh.c @@ -0,0 +1,103 @@ +//=========================================================================== +// +// wf_acosh.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + * + */ + +/* + * wrapper acoshf(x) + */ + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ + float acoshf(float x) /* wrapper acoshf */ +#else + float acoshf(x) /* wrapper acoshf */ + float x; +#endif +{ +#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY + return __ieee754_acoshf(x); +#else + float z; + z = __ieee754_acoshf(x); + if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE || isnanf(x)) return z; + if(x<1.0) { + return __kernel_standard(x,x,29); /* acosh(x<1) */ + } else + return z; +#endif +} + +#endif // ifdef CYGPKG_LIBM + +// EOF wf_acosh.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-api/wf_asin.c @@ -0,0 +1,104 @@ +//=========================================================================== +// +// wf_asin.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + * + */ + +/* + * wrapper asinf(x) + */ + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ + float asinf(float x) /* wrapper asinf */ +#else + float asinf(x) /* wrapper asinf */ + float x; +#endif +{ +#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY + return __ieee754_asinf(x); +#else + float z; + + z = __ieee754_asinf(x); + if( cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE || isnanf(x)) return z; + if(fabsf(x)>(float)1.0) { + return __kernel_standard_float(x,x,2); /* asin(|x|>1) */ + } else + return z; +#endif +} + +#endif // ifdef CYGPKG_LIBM + +// EOF wf_asin.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-api/wf_atan2.c @@ -0,0 +1,93 @@ +//=========================================================================== +// +// wf_atan2.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + * + */ + +/* + * wrapper atan2f(y,x) + */ + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ + float atan2f(float y, float x) /* wrapper atan2f */ +#else + float atan2f(y,x) /* wrapper atan2 */ + float y,x; +#endif +{ + return __ieee754_atan2f(y,x); +} + +#endif // ifdef CYGPKG_LIBM + +// EOF wf_atan2.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-api/wf_atanh.c @@ -0,0 +1,105 @@ +//=========================================================================== +// +// wf_atanh.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ +/* + * wrapper atanhf(x) + */ + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ + float atanhf(float x) /* wrapper atanhf */ +#else + float atanhf(x) /* wrapper atanhf */ + float x; +#endif +{ +#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY + return __ieee754_atanhf(x); +#else + float z,y; + z = __ieee754_atanhf(x); + if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE || isnanf(x)) return z; + y = fabs(x); + if(y>=1.0) { + if(y>1.0) + return __kernel_standard(x,x,30); /* atanh(|x|>1) */ + else + return __kernel_standard(x,x,31); /* atanh(|x|==1) */ + } else + return z; +#endif +} + +#endif // ifdef CYGPKG_LIBM + +// EOF wf_atanh.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-api/wf_cosh.c @@ -0,0 +1,102 @@ +//=========================================================================== +// +// wf_cosh.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * wrapper coshf(x) + */ + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ + float coshf(float x) /* wrapper coshf */ +#else + float coshf(x) /* wrapper coshf */ + float x; +#endif +{ +#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY + return __ieee754_coshf(x); +#else + float z; + z = __ieee754_coshf(x); + if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE || isnanf(x)) return z; + if(fabsf(x)>(float)8.9415985107e+01) { + return __kernel_standard(x,x,5); /* cosh overflow */ + } else + return z; +#endif +} + +#endif // ifdef CYGPKG_LIBM + +// EOF wf_cosh.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-api/wf_exp.c @@ -0,0 +1,114 @@ +//=========================================================================== +// +// wf_exp.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * wrapper expf(x) + */ + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +o_threshold= 8.8721679688e+01, /* 0x42b17180 */ +u_threshold= -1.0397208405e+02; /* 0xc2cff1b5 */ + +#ifdef __STDC__ + float expf(float x) /* wrapper expf */ +#else + float expf(x) /* wrapper expf */ + float x; +#endif +{ +#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY + return __ieee754_expf(x); +#else + float z; + //struct exception exc; + z = __ieee754_expf(x); + if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE) return z; + if(finitef(x)) { + if(x>o_threshold) + return __kernel_standard(x,x,6); /* exp overflow */ + else if(x<u_threshold) + return __kernel_standard(x,x,7); /* exp underflow */ + } + return z; +#endif +} + +#endif // ifdef CYGPKG_LIBM + +// EOF wf_exp.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-api/wf_fmod.c @@ -0,0 +1,102 @@ +//=========================================================================== +// +// w_fmod.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * wrapper fmodf(x,y) + */ + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ + float fmodf(float x, float y) /* wrapper fmodf */ +#else + float fmodf(x,y) /* wrapper fmodf */ + float x,y; +#endif +{ +#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY + return __ieee754_fmodf(x,y); +#else + float z; + z = __ieee754_fmodf(x,y); + if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE ||isnanf(y)||isnanf(x)) return z; + if(y==0.0) { + return __kernel_standard(x,y,27); /* fmod(x,0) */ + } else + return z; +#endif +} + +#endif // ifdef CYGPKG_LIBM + +// EOF wf_fmod.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-api/wf_gamma.c @@ -0,0 +1,103 @@ +//=========================================================================== +// +// wf_gamma.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + * + */ + +#include <math.h> +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ + float gammaf(float x) +#else + float gammaf(x) + float x; +#endif +{ +#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY + return __ieee754_gammaf_r(x,&signgam); +#else + float y; + y = __ieee754_gammaf_r(x,&signgam); + if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE) return y; + if(!finitef(y)&&finitef(x)) { + if(floorf(x)==x&&x<=0.0) + return __kernel_standard(x,x,41); /* gamma pole */ + else + return __kernel_standard(x,x,40); /* gamma overflow */ + } else + return y; +#endif +} + +#endif // ifdef CYGPKG_LIBM + +// EOF wf_gamma.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-api/wf_gamma_r.c @@ -0,0 +1,106 @@ +//=========================================================================== +// +// wf_gamma_r.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * wrapper float gammaf_r(float x, int *signgamp) + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ + float gammaf_r(float x, int *signgamp) /* wrapper lgammaf_r */ +#else + float gammaf_r(x,signgamp) /* wrapper lgammaf_r */ + float x; int *signgamp; +#endif +{ +#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY + return __ieee754_gammaf_r(x,signgamp); +#else + float y; + y = __ieee754_gammaf_r(x,signgamp); + if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE) return y; + if(!finitef(y)&&finitef(x)) { + if(floorf(x)==x&&x<=0.0) + return __kernel_standard(x,x,41); /* gamma pole */ + else + return __kernel_standard(x,x,40); /* gamma overflow */ + } else + return y; +#endif +} + +#endif // ifdef CYGPKG_LIBM + +// EOF wf_gamma_r.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-api/wf_hypot.c @@ -0,0 +1,102 @@ +//=========================================================================== +// +// wf_hypot.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * wrapper hypotf(x,y) + */ + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ + float hypotf(float x, float y) /* wrapper hypotf */ +#else + float hypotf(x,y) /* wrapper hypotf */ + float x,y; +#endif +{ +#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY + return __ieee754_hypotf(x,y); +#else + float z; + z = __ieee754_hypotf(x,y); + if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE) return z; + if((!finitef(z))&&finitef(x)&&finitef(y)) + return __kernel_standard(x,y,4); /* hypot overflow */ + else + return z; +#endif +} + +#endif // ifdef CYGPKG_LIBM + +// EOF wf_hypot.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-api/wf_j0.c @@ -0,0 +1,129 @@ +//=========================================================================== +// +// w_j0.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * wrapper j0f(float x), y0f(float x) + */ + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ + float j0f(float x) /* wrapper j0f */ +#else + float j0f(x) /* wrapper j0f */ + float x; +#endif +{ +#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY + return __ieee754_j0f(x); +#else + float z = __ieee754_j0f(x); + if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE || isnanf(x)) return z; + if(fabsf(x)>(float)X_TLOSS) { + return __kernel_standard(x,x,34); /* j0(|x|>X_TLOSS) */ + } else + return z; +#endif +} + +#ifdef __STDC__ + float y0f(float x) /* wrapper y0f */ +#else + float y0f(x) /* wrapper y0f */ + float x; +#endif +{ +#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY + return __ieee754_y0f(x); +#else + float z; + z = __ieee754_y0f(x); + if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE || isnanf(x) ) return z; + if(x <= 0.0){ + if(x==0.0) + /* d= -one/(x-x); */ + return __kernel_standard(x,x,8); + else + /* d = zero/(x-x); */ + return __kernel_standard(x,x,9); + } + if(x>X_TLOSS) { + return __kernel_standard(x,x,35); /* y0(x>X_TLOSS) */ + } else + return z; +#endif +} + +#endif // ifdef CYGPKG_LIBM + +// EOF wf_j0.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-api/wf_j1.c @@ -0,0 +1,130 @@ +//=========================================================================== +// +// wf_j1.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * wrapper of j1f,y1f + */ + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ + float j1f(float x) /* wrapper j1f */ +#else + float j1f(x) /* wrapper j1f */ + float x; +#endif +{ +#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY + return __ieee754_j1f(x); +#else + float z; + z = __ieee754_j1f(x); + if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE || isnanf(x) ) return z; + if(fabs(x)>X_TLOSS) { + return __kernel_standard(x,x,36); /* j1(|x|>X_TLOSS) */ + } else + return z; +#endif +} + +#ifdef __STDC__ + float y1f(float x) /* wrapper y1f */ +#else + float y1f(x) /* wrapper y1f */ + float x; +#endif +{ +#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY + return __ieee754_y1f(x); +#else + float z; + z = __ieee754_y1f(x); + if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE || isnanf(x) ) return z; + if(x <= 0.0){ + if(x==0.0) + /* d= -one/(x-x); */ + return __kernel_standard(x,x,10); + else + /* d = zero/(x-x); */ + return __kernel_standard(x,x,11); + } + if(x>X_TLOSS) { + return __kernel_standard(x,x,37); /* y1(x>X_TLOSS) */ + } else + return z; +#endif +} + +#endif // ifdef CYGPKG_LIBM + +// EOF wf_j1.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-api/wf_jn.c @@ -0,0 +1,117 @@ +//=========================================================================== +// +// wf_jn.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#include "mathincl/fdlibm.h" + + float jnf(int n, float x) /* wrapper jnf */ +{ +#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY + return __ieee754_jnf(n,x); +#else + float z; + z = __ieee754_jnf(n,x); + if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE || isnanf(x) ) return z; + if(fabsf(x)>(float)X_TLOSS) { + return __kernel_standard((double)n,x,38); /* jn(|x|>X_TLOSS,n) */ + } else + return z; +#endif +} + + + float ynf(int n, float x) /* wrapper ynf */ +{ +#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY + return __ieee754_ynf(n,x); +#else + float z; + z = __ieee754_ynf(n,x); + if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE || isnanf(x) ) return z; + if(x <= 0.0){ + if(x==0.0) + /* d= -one/(x-x); */ + return __kernel_standard((double)n,x,12); + else + /* d = zero/(x-x); */ + return __kernel_standard((double)n,x,13); + } + if(x>X_TLOSS) { + return __kernel_standard((double)n,x,39); /* yn(x>X_TLOSS,n) */ + } else + return z; +#endif +} + +#endif // ifdef CYGPKG_LIBM + +// EOF wf_jn.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-api/wf_lgamma.c @@ -0,0 +1,103 @@ +//=========================================================================== +// +// wf_lgamma.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + * + */ + +#include <math.h> +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ + float lgammaf(float x) +#else + float lgammaf(x) + float x; +#endif +{ +#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY + return __ieee754_lgammaf_r(x,&signgam); +#else + float y; + y = __ieee754_lgammaf_r(x,&signgam); + if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE) return y; + if(!finitef(y)&&finitef(x)) { + if(floorf(x)==x&&x<=0.0) + return __kernel_standard(x,x,15); /* lgamma pole */ + else + return __kernel_standard(x,x,14); /* lgamma overflow */ + } else + return y; +#endif +} + +#endif // ifdef CYGPKG_LIBM + +// EOF wf_lgamma.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-api/wf_lgamma_r.c @@ -0,0 +1,105 @@ +//=========================================================================== +// +// w_lgamma_r.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * wrapper float lgammaf_r(float x, int *signgamp) + */ + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ + float lgammaf_r(float x, int *signgamp) /* wrapper lgammaf_r */ +#else + float lgammaf_r(x,signgamp) /* wrapper lgammaf_r */ + float x; int *signgamp; +#endif +{ +#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY + return __ieee754_lgammaf_r(x,signgamp); +#else + float y; + y = __ieee754_lgammaf_r(x,signgamp); + if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE) return y; + if(!finitef(y)&&finitef(x)) { + if(floorf(x)==x&&x<=0.0) + return __kernel_standard(x,x,15); /* lgamma pole */ + else + return __kernel_standard(x,x,14); /* lgamma overflow */ + } else + return y; +#endif +} + +#endif // ifdef CYGPKG_LIBM + +// EOF wf_lgamma_r.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-api/wf_log.c @@ -0,0 +1,102 @@ +//=========================================================================== +// +// wf_log.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * wrapper logf(x) + */ + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ + float logf(float x) /* wrapper logf */ +#else + float logf(x) /* wrapper logf */ + float x; +#endif +{ +#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY + return __ieee754_logf(x); +#else + float z; + z = __ieee754_logf(x); + if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE || isnan(x) || x > 0.0) return z; + if(x==0.0) + return __kernel_standard_float(x,x,16); /* log(0) */ + else + return __kernel_standard_float(x,x,17); /* log(x<0) */ +#endif +} + +#endif // ifdef CYGPKG_LIBM + +// EOF wf_log.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-api/wf_log10.c @@ -0,0 +1,111 @@ +//=========================================================================== +// +// w_log10.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * wrapper log10f(X) + */ + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ + float log10f(float x) /* wrapper log10f */ +#else + float log10f(x) /* wrapper log10f */ + float x; +#endif +{ +#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY + return __ieee754_log10f(x); +#else + float z; + cyg_uint32 compat_mode = cyg_libm_get_compat_mode(); + + z = __ieee754_log10f(x); + if( +#ifdef CYGOPT_LIBM_COMPAT_POSIX_IEEE + compat_mode == CYGNUM_LIBM_COMPAT_POSIX || +#endif + compat_mode == CYGNUM_LIBM_COMPAT_IEEE || isnanf(x)) return z; + if(x<=0.0) { + if(x==0.0) + return __kernel_standard(x,x,18); /* log10(0) */ + else + return __kernel_standard(x,x,19); /* log10(x<0) */ + } else + return z; +#endif +} + +#endif // ifdef CYGPKG_LIBM + +// EOF wf_log10.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-api/wf_pow.c @@ -0,0 +1,119 @@ +//======================================================================== +// +// wf_pow.c +// +// Part of the standard mathematical function library +// +//======================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * wrapper powf(x,y) return x**y + */ + +#include "mathincl/fdlibm.h" + + float powf(float x, float y) /* wrapper powf */ +{ +#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY + return __ieee754_powf(x,y); +#else + float z; + z=__ieee754_powf(x,y); + if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE|| + isnan(y)) + return z; + if(isnan(x)) { + if(y==0.0) + return __kernel_standard(x,y,42); /* pow(NaN,0.0) */ + else + return z; + } + if(x==0.0){ + if(y==0.0) + return __kernel_standard(x,y,20); /* pow(0.0,0.0) */ + if(finitef(y)&&y<0.0) + return __kernel_standard(x,y,23); /* pow(0.0,negative) */ + return z; + } + if(!finitef(z)) { + if(finitef(x)&&finitef(y)) { + if(isnan(z)) + return __kernel_standard(x,y,24);/* pow neg**non-int */ + else + return __kernel_standard(x,y,21); /* pow overflow */ + } + } + if(z==0.0&&finitef(x)&&finitef(y)) + return __kernel_standard(x,y,22); /* pow underflow */ + return z; +#endif +} + +#endif // ifdef CYGPKG_LIBM + +// EOF wf_pow.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-api/wf_remainder.c @@ -0,0 +1,103 @@ +//=========================================================================== +// +// wf_remainder.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * wrapper remainderf(x,p) + */ + +#include "mathincl/fdlibm.h" +//#include <errno.h> + +#ifdef __STDC__ + float remainderf(float x, float y) /* wrapper remainder */ +#else + float remainderf(x,y) /* wrapper remainder */ + float x,y; +#endif +{ +#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY + return __ieee754_remainderf(x,y); +#else + double z; + z = __ieee754_remainderf(x,y); + if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE || isnanf(y)) return z; + if(y==0.0) + return __kernel_standard(x,y,28); /* remainder(x,0) */ + else + return z; +#endif +} + +#endif // ifdef CYGPKG_LIBM + +// EOF wf_remainder.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-api/wf_scalb.c @@ -0,0 +1,124 @@ +//=========================================================================== +// +// wf_scalb.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * wrapper scalbf(float x, float fn) is provide for + * passing various standard test suite. One + * should use scalbn() instead. + */ + +// CONFIGURATION + + +#include "mathincl/fdlibm.h" +#ifndef CYGSEM_LIBM_COMPAT_IEEE_ONLY +# include <errno.h> +#endif + +#ifdef __STDC__ +#ifdef CYGFUN_LIBM_SVID3_scalb + float scalbf(float x, float fn) /* wrapper scalbf */ +#else + float scalbf(float x, int fn) /* wrapper scalbf */ +#endif +#else + float scalbf(x,fn) /* wrapper scalbf */ +#ifdef CYGFUN_LIBM_SVID3_scalb + float x,fn; +#else + float x; int fn; +#endif +#endif +{ +#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY + return __ieee754_scalbf(x,fn); +#else + double z; + z = __ieee754_scalbf(x,fn); + if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE) return z; + if(!(finitef(z)||isnanf(z))&&finitef(x)) { + return __kernel_standard(x,(double)fn,32); /* scalb overflow */ + } + if(z==0.0&&z!=x) { + return __kernel_standard(x,(double)fn,33); /* scalb underflow */ + } +#ifdef CYGFUN_LIBM_SVID3_scalb + if(!finitef(fn)) errno = ERANGE; +#endif + return z; +#endif +} + +#endif // ifdef CYGPKG_LIBM + +// EOF wf_scalb.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-api/wf_sinh.c @@ -0,0 +1,104 @@ +//=========================================================================== +// +// wf_sinh.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * wrapper sinhf(x) + */ + +// CONFIGURATION + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ + float sinhf(float x) /* wrapper sinhf */ +#else + float sinhf(x) /* wrapper sinhf */ + float x; +#endif +{ +#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY + return __ieee754_sinhf(x); +#else + float z; + z = __ieee754_sinhf(x); + if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE) return z; + if(!finitef(z)&&finitef(x)) { + return __kernel_standard(x,x,25); /* sinh overflow */ + } else + return z; +#endif +} + +#endif // ifdef CYGPKG_LIBM + +// EOF wf_sinh.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-api/wf_sqrt.c @@ -0,0 +1,98 @@ +//=========================================================================== +// +// wf_sqrt.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * wrapper sqrtf(x) + */ + +#include "mathincl/fdlibm.h" + +float sqrtf(float x) /* wrapper sqrtf */ + +{ +#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY + return __ieee754_sqrtf(x); +#else + float z; + z = __ieee754_sqrtf(x); + if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE || isnan(x)) return z; + if(x<0.0) { + return __kernel_standard(x,x,26); /* sqrt(negative) */ + } else + return z; +#endif +} + +#endif // ifdef CYGPKG_LIBM + +// EOF wf_sqrtf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-core/ef_acos.c @@ -0,0 +1,151 @@ +//=========================================================================== +// +// ef_acos.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* ef_acos.c -- float version of e_acos.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +one = 1.0000000000e+00, /* 0x3F800000 */ +pi = 3.1415925026e+00, /* 0x40490fda */ +pio2_hi = 1.5707962513e+00, /* 0x3fc90fda */ +pio2_lo = 7.5497894159e-08, /* 0x33a22168 */ +pS0 = 1.6666667163e-01, /* 0x3e2aaaab */ +pS1 = -3.2556581497e-01, /* 0xbea6b090 */ +pS2 = 2.0121252537e-01, /* 0x3e4e0aa8 */ +pS3 = -4.0055535734e-02, /* 0xbd241146 */ +pS4 = 7.9153501429e-04, /* 0x3a4f7f04 */ +pS5 = 3.4793309169e-05, /* 0x3811ef08 */ +qS1 = -2.4033949375e+00, /* 0xc019d139 */ +qS2 = 2.0209457874e+00, /* 0x4001572d */ +qS3 = -6.8828397989e-01, /* 0xbf303361 */ +qS4 = 7.7038154006e-02; /* 0x3d9dc62e */ + +#ifdef __STDC__ + float __ieee754_acosf(float x) +#else + float __ieee754_acosf(x) + float x; +#endif +{ + float z,p,q,r,w,s,c,df; + __int32_t hx,ix; + hx = CYG_LIBM_WORD(x); + ix = hx&0x7fffffff; + if(ix==0x3f800000) { /* |x|==1 */ + if(hx>0) return 0.0; /* acos(1) = 0 */ + else return pi+(float)2.0*pio2_lo; /* acos(-1)= pi */ + } else if(ix>0x3f800000) { /* |x| >= 1 */ + return (x-x)/(x-x); /* acos(|x|>1) is NaN */ + } + if(ix<0x3f000000) { /* |x| < 0.5 */ + if(ix<=0x23000000) return pio2_hi+pio2_lo;/*if|x|<2**-57*/ + z = x*x; + p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5))))); + q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4))); + r = p/q; + return pio2_hi - (x - (pio2_lo-x*r)); + } else if (hx<0) { /* x < -0.5 */ + z = (one+x)*(float)0.5; + p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5))))); + q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4))); + s = __ieee754_sqrtf(z); + r = p/q; + w = r*s-pio2_lo; + return pi - (float)2.0*(s+w); + } else { /* x > 0.5 */ + __int32_t idf; + z = (one-x)*(float)0.5; + s = __ieee754_sqrtf(z); + df = s; + idf = CYG_LIBM_WORD(df); + SET_FLOAT_WORD(df,idf&0xfffff000); + c = (z-df*df)/(s+df); + p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5))))); + q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4))); + r = p/q; + w = r*s+c; + return (float)2.0*(df+w); + } +} + +#endif // ifdef CYGPKG_LIBM + +// EOF ef_acos.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-core/ef_acosh.c @@ -0,0 +1,120 @@ +//=========================================================================== +// +// ef_acosh.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* ef_acosh.c -- float version of e_acosh.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + * + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +one = 1.0, +ln2 = 6.9314718246e-01; /* 0x3f317218 */ + +#ifdef __STDC__ + float __ieee754_acoshf(float x) +#else + float __ieee754_acoshf(x) + float x; +#endif +{ + float t; + __int32_t hx; + hx = CYG_LIBM_WORD(x); + if(hx<0x3f800000) { /* x < 1 */ + return (x-x)/(x-x); + } else if(hx >=0x4d800000) { /* x > 2**28 */ + if(!FLT_UWORD_IS_FINITE(hx)) { /* x is inf of NaN */ + return x+x; + } else + return __ieee754_logf(x)+ln2; /* acosh(huge)=log(2x) */ + } else if (hx==0x3f800000) { + return 0.0; /* acosh(1) = 0 */ + } else if (hx > 0x40000000) { /* 2**28 > x > 2 */ + t=x*x; + return __ieee754_logf((float)2.0*x-one/(x+__ieee754_sqrtf(t-one))); + } else { /* 1<x<2 */ + t = x-one; + return log1pf(t+__ieee754_sqrtf((float)2.0*t+t*t)); + } +} + +#endif // ifdef CYGPKG_LIBM + +// EOF e_acosh.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-core/ef_asin.c @@ -0,0 +1,151 @@ +//=========================================================================== +// +// ef_asin.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +one = 1.0000000000e+00, /* 0x3F800000 */ +huge = 1.000e+30, +pio2_hi = 1.57079637050628662109375f, +pio2_lo = -4.37113900018624283e-8f, +pio4_hi = 0.785398185253143310546875f, + /* coefficient for R(x^2) */ +pS0 = 1.6666667163e-01, /* 0x3e2aaaab */ +pS1 = -3.2556581497e-01, /* 0xbea6b090 */ +pS2 = 2.0121252537e-01, /* 0x3e4e0aa8 */ +pS3 = -4.0055535734e-02, /* 0xbd241146 */ +pS4 = 7.9153501429e-04, /* 0x3a4f7f04 */ +pS5 = 3.4793309169e-05, /* 0x3811ef08 */ +qS1 = -2.4033949375e+00, /* 0xc019d139 */ +qS2 = 2.0209457874e+00, /* 0x4001572d */ +qS3 = -6.8828397989e-01, /* 0xbf303361 */ +qS4 = 7.7038154006e-02; /* 0x3d9dc62e */ + +#ifdef __STDC__ + float __ieee754_asinf(float x) +#else + float __ieee754_asinf(x) + float x; +#endif +{ + float t,w,p,q,c,r,s; + __int32_t hx,ix; + hx = CYG_LIBM_WORD(x); + ix = hx&0x7fffffff; + if(ix==0x3f800000) { + /* asin(1)=+-pi/2 with inexact */ + return x*pio2_hi+x*pio2_lo; + } else if(ix> 0x3f800000) { /* |x|>= 1 */ + return (x-x)/(x-x); /* asin(|x|>1) is NaN */ + } else if (ix<0x3f000000) { /* |x|<0.5 */ + if(ix<0x32000000) { /* if |x| < 2**-27 */ + if(huge+x>one) return x;/* return x with inexact if x!=0*/ + } else { + t = x*x; + p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5))))); + q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4))); + w = p/q; + return x+x*w; + } + } + /* 1> |x|>= 0.5 */ + w = one-fabsf(x); + t = w*(float)0.5; + p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5))))); + q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4))); + s = __ieee754_sqrtf(t); + if(ix>=0x3F79999A) { /* if |x| > 0.975 */ + w = p/q; + t = pio2_hi-((float)2.0*(s+s*w)-pio2_lo); + } else { + __int32_t iw; + w = s; + iw = CYG_LIBM_WORD(w); + SET_FLOAT_WORD(w,iw&0xfffff000); + c = (t-w*w)/(s+w); + r = p/q; + p = (float)2.0*s*r-(pio2_lo-(float)2.0*c); + q = pio4_hi-(float)2.0*w; + t = pio4_hi-(p-q); + } + if(hx>0) return t; else return -t; +} + +#endif // ifdef CYGPKG_LIBM + +// EOF ef_asin.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-core/ef_atan2.c @@ -0,0 +1,167 @@ +//=========================================================================== +// +// e_atan2.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* ef_atan2.c -- float version of e_atan2.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + * + */ + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +tiny = 1.0e-30, +zero = 0.0, +pi_o_4 = 7.8539818525e-01, /* 0x3f490fdb */ +pi_o_2 = 1.5707963705e+00, /* 0x3fc90fdb */ +pi = 3.1415927410e+00, /* 0x40490fdb */ +pi_lo = -8.7422776573e-08; /* 0xb3bbbd2e */ + +#ifdef __STDC__ + float __ieee754_atan2f(float y, float x) +#else + float __ieee754_atan2f(y,x) + float y,x; +#endif +{ + float z; + __int32_t k,m,hx,hy,ix,iy; + + hx = CYG_LIBM_WORD(x); + ix = hx&0x7fffffff; + hy = CYG_LIBM_WORD(y); + iy = hy&0x7fffffff; + if(FLT_UWORD_IS_NAN(ix)|| + FLT_UWORD_IS_NAN(iy)) /* x or y is NaN */ + return x+y; + if(hx==0x3f800000) return atanf(y); /* x=1.0 */ + m = ((hy>>31)&1)|((hx>>30)&2); /* 2*sign(x)+sign(y) */ + + /* when y = 0 */ + if(FLT_UWORD_IS_ZERO(iy)) { + switch(m) { + case 0: + case 1: return y; /* atan(+-0,+anything)=+-0 */ + case 2: return pi+tiny;/* atan(+0,-anything) = pi */ + case 3: return -pi-tiny;/* atan(-0,-anything) =-pi */ + } + } + /* when x = 0 */ + if(FLT_UWORD_IS_ZERO(ix)) return (hy<0)? -pi_o_2-tiny: pi_o_2+tiny; + + /* when x is INF */ + if(FLT_UWORD_IS_INFINITE(ix)) { + if(FLT_UWORD_IS_INFINITE(iy)) { + switch(m) { + case 0: return pi_o_4+tiny;/* atan(+INF,+INF) */ + case 1: return -pi_o_4-tiny;/* atan(-INF,+INF) */ + case 2: return (float)3.0*pi_o_4+tiny;/*atan(+INF,-INF)*/ + case 3: return (float)-3.0*pi_o_4-tiny;/*atan(-INF,-INF)*/ + } + } else { + switch(m) { + case 0: return zero ; /* atan(+...,+INF) */ + case 1: return -zero ; /* atan(-...,+INF) */ + case 2: return pi+tiny ; /* atan(+...,-INF) */ + case 3: return -pi-tiny ; /* atan(-...,-INF) */ + } + } + } + /* when y is INF */ + if(FLT_UWORD_IS_INFINITE(iy)) return (hy<0)? -pi_o_2-tiny: pi_o_2+tiny; + + /* compute y/x */ + k = (iy-ix)>>23; + if(k > 60) z=pi_o_2+(float)0.5*pi_lo; /* |y/x| > 2**60 */ + else if(hx<0&&k<-60) z=0.0; /* |y|/x < -2**60 */ + else z=atanf(fabsf(y/x)); /* safe to do y/x */ + switch (m) { + case 0: return z ; /* atan(+,+) */ + case 1: { + __uint32_t zh; + zh = CYG_LIBM_WORD(z); + SET_FLOAT_WORD(z,zh ^ 0x80000000); + } + return z ; /* atan(-,+) */ + case 2: return pi-(z-pi_lo);/* atan(+,-) */ + default: /* case 3 */ + return (z-pi_lo)-pi;/* atan(-,-) */ + } +} + +#endif // ifdef CYGPKG_LIBM + +// EOF ef_atan2.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-core/ef_atanh.c @@ -0,0 +1,121 @@ +//=========================================================================== +// +// ef_atanh.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* ef_atanh.c -- float version of e_atanh.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + * + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static const float one = 1.0, huge = 1e30; +#else +static float one = 1.0, huge = 1e30; +#endif + +#ifdef __STDC__ +static const float zero = 0.0; +#else +static float zero = 0.0; +#endif + +#ifdef __STDC__ + float __ieee754_atanhf(float x) +#else + float __ieee754_atanhf(x) + float x; +#endif +{ + float t; + __int32_t hx,ix; + hx = CYG_LIBM_WORD(x); + ix = hx&0x7fffffff; + if (ix>0x3f800000) /* |x|>1 */ + return (x-x)/(x-x); + if(ix==0x3f800000) + return x/zero; + if(ix<0x31800000&&(huge+x)>zero) return x; /* x<2**-28 */ + SET_FLOAT_WORD(x,ix); + if(ix<0x3f000000) { /* x < 0.5 */ + t = x+x; + t = (float)0.5*log1pf(t+t*x/(one-x)); + } else + t = (float)0.5*log1pf((x+x)/(one-x)); + if(hx>=0) return t; else return -t; +} + +#endif // ifdef CYGPKG_LIBM + +// EOF ef_atanh.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-core/ef_cosh.c @@ -0,0 +1,134 @@ +//=========================================================================== +// +// ef_cosh.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* ef_cosh.c -- float version of e_cosh.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static const float one = 1.0, half=0.5, huge = 1.0e30; +#else +static float one = 1.0, half=0.5, huge = 1.0e30; +#endif + +#ifdef __STDC__ + float __ieee754_coshf(float x) +#else + float __ieee754_coshf(x) + float x; +#endif +{ + float t,w; + __int32_t ix; + + ix = CYG_LIBM_WORD(x); + ix &= 0x7fffffff; + + /* x is INF or NaN */ + if(!FLT_UWORD_IS_FINITE(ix)) return x*x; + + /* |x| in [0,0.5*ln2], return 1+expm1(|x|)^2/(2*exp(|x|)) */ + if(ix<0x3eb17218) { + t = expm1f(fabsf(x)); + w = one+t; + if (ix<0x24000000) return w; /* cosh(tiny) = 1 */ + return one+(t*t)/(w+w); + } + + /* |x| in [0.5*ln2,22], return (exp(|x|)+1/exp(|x|)/2; */ + if (ix < 0x41b00000) { + t = __ieee754_expf(fabsf(x)); + return half*t+half/t; + } + + /* |x| in [22, log(maxdouble)] return half*exp(|x|) */ + if (ix <= FLT_UWORD_LOG_MAX) + return half*__ieee754_expf(fabsf(x)); + + /* |x| in [log(maxdouble), overflowthresold] */ + if (ix <= FLT_UWORD_LOG_2MAX) { + w = __ieee754_expf(half*fabsf(x)); + t = half*w; + return t*w; + } + + /* |x| > overflowthresold, cosh(x) overflow */ + return huge*huge; +} + +#endif // ifdef CYGPKG_LIBM + +// EOF ef_cosh.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-core/ef_exp.c @@ -0,0 +1,165 @@ +//=========================================================================== +// +// ef_exp.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* ef_exp.c -- float version of e_exp.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +one = 1.0, +halF[2] = {0.5,-0.5,}, +huge = 1.0e+30, +twom100 = 7.8886090522e-31, /* 2**-100=0x0d800000 */ +ln2HI[2] ={ 6.9313812256e-01, /* 0x3f317180 */ + -6.9313812256e-01,}, /* 0xbf317180 */ +ln2LO[2] ={ 9.0580006145e-06, /* 0x3717f7d1 */ + -9.0580006145e-06,}, /* 0xb717f7d1 */ +invln2 = 1.4426950216e+00, /* 0x3fb8aa3b */ +P1 = 1.6666667163e-01, /* 0x3e2aaaab */ +P2 = -2.7777778450e-03, /* 0xbb360b61 */ +P3 = 6.6137559770e-05, /* 0x388ab355 */ +P4 = -1.6533901999e-06, /* 0xb5ddea0e */ +P5 = 4.1381369442e-08; /* 0x3331bb4c */ + +#ifdef __STDC__ + float __ieee754_expf(float x) /* default IEEE double exp */ +#else + float __ieee754_expf(x) /* default IEEE double exp */ + float x; +#endif +{ + float y,hi,lo,c,t; + __int32_t k,xsb,sx; + __uint32_t hx; + + sx = CYG_LIBM_WORD(x); + xsb = (sx>>31)&1; /* sign bit of x */ + hx = sx & 0x7fffffff; /* high word of |x| */ + + /* filter out non-finite argument */ + if(FLT_UWORD_IS_NAN(hx)) + return x+x; /* NaN */ + if(FLT_UWORD_IS_INFINITE(hx)) + return (xsb==0)? x:0.0; /* exp(+-inf)={inf,0} */ + if(sx > FLT_UWORD_LOG_MAX) + return huge*huge; /* overflow */ + if(sx < 0 && hx > FLT_UWORD_LOG_MIN) + return twom100*twom100; /* underflow */ + + /* argument reduction */ + if(hx > 0x3eb17218) { /* if |x| > 0.5 ln2 */ + if(hx < 0x3F851592) { /* and |x| < 1.5 ln2 */ + hi = x-ln2HI[xsb]; lo=ln2LO[xsb]; k = 1-xsb-xsb; + } else { + k = invln2*x+halF[xsb]; + t = k; + hi = x - t*ln2HI[0]; /* t*ln2HI is exact here */ + lo = t*ln2LO[0]; + } + x = hi - lo; + } + else if(hx < 0x31800000) { /* when |x|<2**-28 */ + if(huge+x>one) + return one+x;/* trigger inexact */ + else // VAE + k = 0; + } + else k = 0; + + /* x is now in primary range */ + t = x*x; + c = x - t*(P1+t*(P2+t*(P3+t*(P4+t*P5)))); + if(k==0) return one-((x*c)/(c-(float)2.0)-x); + else y = one-((lo-(x*c)/((float)2.0-c))-hi); + if(k >= -125) { + __uint32_t hy; + hy = CYG_LIBM_WORD(y); + SET_FLOAT_WORD(y,hy+(k<<23)); /* add k to y's exponent */ + return y; + } else { + __uint32_t hy; + hy = CYG_LIBM_WORD(y); + SET_FLOAT_WORD(y,hy+((k+100)<<23)); /* add k to y's exponent */ + return y*twom100; + } +} +#endif // ifdef CYGPKG_LIBM + +// EOF ef_exp.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-core/ef_fmod.c @@ -0,0 +1,180 @@ +//=========================================================================== +// +// ef_fmod.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* ef_fmod.c -- float version of e_fmod.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * __ieee754_fmodf(x,y) + * Return x mod y in exact arithmetic + * Method: shift and subtract + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static const float one = 1.0, Zero[] = {0.0, -0.0,}; +#else +static float one = 1.0, Zero[] = {0.0, -0.0,}; +#endif + +#ifdef __STDC__ + float __ieee754_fmodf(float x, float y) +#else + float __ieee754_fmodf(x,y) + float x,y ; +#endif +{ + __int32_t n,hx,hy,hz,ix,iy,sx,i; + + hx = CYG_LIBM_WORD(x); + hy = CYG_LIBM_WORD(y); + sx = hx&0x80000000; /* sign of x */ + hx ^=sx; /* |x| */ + hy &= 0x7fffffff; /* |y| */ + + /* purge off exception values */ + if(FLT_UWORD_IS_ZERO(hy)|| + !FLT_UWORD_IS_FINITE(hx)|| + FLT_UWORD_IS_NAN(hy)) + return (x*y)/(x*y); + if(hx<hy) return x; /* |x|<|y| return x */ + if(hx==hy) + return Zero[(__uint32_t)sx>>31]; /* |x|=|y| return x*0*/ + + /* Note: y cannot be zero if we reach here. */ + + /* determine ix = ilogb(x) */ + if(FLT_UWORD_IS_SUBNORMAL(hx)) { /* subnormal x */ + for (ix = -126,i=(hx<<8); i>0; i<<=1) ix -=1; + } else ix = (hx>>23)-127; + + /* determine iy = ilogb(y) */ + if(FLT_UWORD_IS_SUBNORMAL(hy)) { /* subnormal y */ + for (iy = -126,i=(hy<<8); i>=0; i<<=1) iy -=1; + } else iy = (hy>>23)-127; + + /* set up {hx,lx}, {hy,ly} and align y to x */ + if(ix >= -126) + hx = 0x00800000|(0x007fffff&hx); + else { /* subnormal x, shift x to normal */ + n = -126-ix; + hx = hx<<n; + } + if(iy >= -126) + hy = 0x00800000|(0x007fffff&hy); + else { /* subnormal y, shift y to normal */ + n = -126-iy; + hy = hy<<n; + } + + /* fix point fmod */ + n = ix - iy; + while(n--) { + hz=hx-hy; + if(hz<0){hx = hx+hx;} + else { + if(hz==0) /* return sign(x)*0 */ + return Zero[(__uint32_t)sx>>31]; + hx = hz+hz; + } + } + hz=hx-hy; + if(hz>=0) {hx=hz;} + + /* convert back to floating value and restore the sign */ + if(hx==0) /* return sign(x)*0 */ + return Zero[(__uint32_t)sx>>31]; + while(hx<0x00800000) { /* normalize x */ + hx = hx+hx; + iy -= 1; + } + if(iy>= -126) { /* normalize output */ + hx = ((hx-0x00800000)|((iy+127)<<23)); + SET_FLOAT_WORD(x,hx|sx); + } else { /* subnormal output */ + /* If denormals are not supported, this code will generate a + zero representation. */ + n = -126 - iy; + hx >>= n; + SET_FLOAT_WORD(x,hx|sx); + x *= one; /* create necessary signal */ + } + return x; /* exact output */ +} + +#endif // ifdef CYGPKG_LIBM + +// EOF ef_fmod.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-core/ef_gamma.c @@ -0,0 +1,93 @@ +//=========================================================================== +// +// ef_gamma.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* @(#)ef_gamma.c 1.3 95/01/18 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + * + */ + +/* __ieee754_gamma(x) + * Return the logarithm of the Gamma function of x. + * + * Method: call __ieee754_gamma_r + */ + +#include <math.h> +#include "mathincl/fdlibm.h" + +float +__ieee754_gammaf(float x) +{ + return __ieee754_gammaf_r(x,&signgam); +} + +#endif // ifdef CYGPKG_LIBM + +// EOF ef_gamma.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-core/ef_gamma_r.c @@ -0,0 +1,106 @@ +//=========================================================================== +// +// ef_gamma_r.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + +/* erf_gamma.c -- float version of er_gamma.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + * + */ + +/* __ieee754_gammaf_r(x, signgamp) + * Reentrant version of the logarithm of the Gamma function + * with user provide pointer for the sign of Gamma(x). + * + * Method: See __ieee754_lgammaf_r + */ + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ + float __ieee754_gammaf_r(float x, int *signgamp) +#else + float __ieee754_gammaf_r(x,signgamp) + float x; int *signgamp; +#endif +{ + return __ieee754_lgammaf_r(x,signgamp); +} + +#endif // ifdef CYGPKG_LIBM + +// EOF ef_gamma_r.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-core/ef_hypot.c @@ -0,0 +1,149 @@ +//=========================================================================== +// +// ef_hypot.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* ef_hypot.c -- float version of e_hypot.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ + float __ieee754_hypotf(float x, float y) +#else + float __ieee754_hypotf(x,y) + float x, y; +#endif +{ + float a=x,b=y,t1,t2,y1,y2,w; + __int32_t j,k,ha,hb; + + ha = CYG_LIBM_WORD(x); + ha &= 0x7fffffffL; + hb = CYG_LIBM_WORD(y); + hb &= 0x7fffffffL; + if(hb > ha) {a=y;b=x;j=ha; ha=hb;hb=j;} else {a=x;b=y;} + SET_FLOAT_WORD(a,ha); /* a <- |a| */ + SET_FLOAT_WORD(b,hb); /* b <- |b| */ + if((ha-hb)>0xf000000L) {return a+b;} /* x/y > 2**30 */ + k=0; + if(ha > 0x58800000L) { /* a>2**50 */ + if(!FLT_UWORD_IS_FINITE(ha)) { /* Inf or NaN */ + w = a+b; /* for sNaN */ + if(FLT_UWORD_IS_INFINITE(ha)) w = a; + if(FLT_UWORD_IS_INFINITE(hb)) w = b; + return w; + } + /* scale a and b by 2**-68 */ + ha -= 0x22000000L; hb -= 0x22000000L; k += 68; + SET_FLOAT_WORD(a,ha); + SET_FLOAT_WORD(b,hb); + } + if(hb < 0x26800000L) { /* b < 2**-50 */ + if(FLT_UWORD_IS_ZERO(hb)) { + return a; + } else if(FLT_UWORD_IS_SUBNORMAL(hb)) { + SET_FLOAT_WORD(t1,0x7e800000L); /* t1=2^126 */ + b *= t1; + a *= t1; + k -= 126; + } else { /* scale a and b by 2^68 */ + ha += 0x22000000; /* a *= 2^68 */ + hb += 0x22000000; /* b *= 2^68 */ + k -= 68; + SET_FLOAT_WORD(a,ha); + SET_FLOAT_WORD(b,hb); + } + } + /* medium size a and b */ + w = a-b; + if (w>b) { + SET_FLOAT_WORD(t1,ha&0xfffff000L); + t2 = a-t1; + w = __ieee754_sqrtf(t1*t1-(b*(-b)-t2*(a+t1))); + } else { + a = a+a; + SET_FLOAT_WORD(y1,hb&0xfffff000L); + y2 = b - y1; + SET_FLOAT_WORD(t1,ha+0x00800000L); + t2 = a - t1; + w = __ieee754_sqrtf(t1*y1-(w*(-w)-(t1*y2+t2*b))); + } + if(k!=0) { + SET_FLOAT_WORD(t1,0x3f800000L+(k<<23)); + return t1*w; + } else return w; +} +#endif // ifdef CYGPKG_LIBM + +// EOF ef_hypot.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-core/ef_j0.c @@ -0,0 +1,506 @@ +//=========================================================================== +// +// ef_j0.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* ef_j0.c -- float version of e_j0.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static float pzerof(float), qzerof(float); +#else +static float pzerof(), qzerof(); +#endif + +#ifdef __STDC__ +static const float +#else +static float +#endif +huge = 1e30, +one = 1.0, +invsqrtpi= 5.6418961287e-01, /* 0x3f106ebb */ +tpi = 6.3661974669e-01, /* 0x3f22f983 */ + /* R0/S0 on [0, 2.00] */ +R02 = 1.5625000000e-02, /* 0x3c800000 */ +R03 = -1.8997929874e-04, /* 0xb947352e */ +R04 = 1.8295404516e-06, /* 0x35f58e88 */ +R05 = -4.6183270541e-09, /* 0xb19eaf3c */ +S01 = 1.5619102865e-02, /* 0x3c7fe744 */ +S02 = 1.1692678527e-04, /* 0x38f53697 */ +S03 = 5.1354652442e-07, /* 0x3509daa6 */ +S04 = 1.1661400734e-09; /* 0x30a045e8 */ + +#ifdef __STDC__ +static const float zero = 0.0; +#else +static float zero = 0.0; +#endif + +#ifdef __STDC__ + float __ieee754_j0f(float x) +#else + float __ieee754_j0f(x) + float x; +#endif +{ + float z, s,c,ss,cc,r,u,v; + __int32_t hx,ix; + + hx = CYG_LIBM_WORD(x); + ix = hx&0x7fffffff; + if(!FLT_UWORD_IS_FINITE(ix)) return one/(x*x); + x = fabsf(x); + if(ix >= 0x40000000) { /* |x| >= 2.0 */ + s = sinf(x); + c = cosf(x); + ss = s-c; + cc = s+c; + if(ix<=FLT_UWORD_HALF_MAX) { /* make sure x+x not overflow */ + z = -cosf(x+x); + if ((s*c)<zero) cc = z/ss; + else ss = z/cc; + } + /* + * j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x) + * y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x) + */ + if(ix>0x80000000) z = (invsqrtpi*cc)/__ieee754_sqrtf(x); + else { + u = pzerof(x); v = qzerof(x); + z = invsqrtpi*(u*cc-v*ss)/__ieee754_sqrtf(x); + } + return z; + } + if(ix<0x39000000) { /* |x| < 2**-13 */ + if(huge+x>one) { /* raise inexact if x != 0 */ + if(ix<0x32000000) return one; /* |x|<2**-27 */ + else return one - (float)0.25*x*x; + } + } + z = x*x; + r = z*(R02+z*(R03+z*(R04+z*R05))); + s = one+z*(S01+z*(S02+z*(S03+z*S04))); + if(ix < 0x3F800000) { /* |x| < 1.00 */ + return one + z*((float)-0.25+(r/s)); + } else { + u = (float)0.5*x; + return((one+u)*(one-u)+z*(r/s)); + } +} + +#ifdef __STDC__ +static const float +#else +static float +#endif +u00 = -7.3804296553e-02, /* 0xbd9726b5 */ +u01 = 1.7666645348e-01, /* 0x3e34e80d */ +u02 = -1.3818567619e-02, /* 0xbc626746 */ +u03 = 3.4745343146e-04, /* 0x39b62a69 */ +u04 = -3.8140706238e-06, /* 0xb67ff53c */ +u05 = 1.9559013964e-08, /* 0x32a802ba */ +u06 = -3.9820518410e-11, /* 0xae2f21eb */ +v01 = 1.2730483897e-02, /* 0x3c509385 */ +v02 = 7.6006865129e-05, /* 0x389f65e0 */ +v03 = 2.5915085189e-07, /* 0x348b216c */ +v04 = 4.4111031494e-10; /* 0x2ff280c2 */ + +#ifdef __STDC__ + float __ieee754_y0f(float x) +#else + float __ieee754_y0f(x) + float x; +#endif +{ + float z, s,c,ss,cc,u,v; + __int32_t hx,ix; + + hx = CYG_LIBM_WORD(x); + ix = 0x7fffffff&hx; + /* Y0(NaN) is NaN, y0(-inf) is Nan, y0(inf) is 0 */ + if(!FLT_UWORD_IS_FINITE(ix)) return one/(x+x*x); + if(FLT_UWORD_IS_ZERO(ix)) return -one/zero; + if(hx<0) return zero/zero; + if(ix >= 0x40000000) { /* |x| >= 2.0 */ + /* y0(x) = sqrt(2/(pi*x))*(p0(x)*sin(x0)+q0(x)*cos(x0)) + * where x0 = x-pi/4 + * Better formula: + * cos(x0) = cos(x)cos(pi/4)+sin(x)sin(pi/4) + * = 1/sqrt(2) * (sin(x) + cos(x)) + * sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4) + * = 1/sqrt(2) * (sin(x) - cos(x)) + * To avoid cancellation, use + * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) + * to compute the worse one. + */ + s = sinf(x); + c = cosf(x); + ss = s-c; + cc = s+c; + /* + * j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x) + * y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x) + */ + if(ix<=FLT_UWORD_HALF_MAX) { /* make sure x+x not overflow */ + z = -cosf(x+x); + if ((s*c)<zero) cc = z/ss; + else ss = z/cc; + } + if(ix>0x80000000) z = (invsqrtpi*ss)/__ieee754_sqrtf(x); + else { + u = pzerof(x); v = qzerof(x); + z = invsqrtpi*(u*ss+v*cc)/__ieee754_sqrtf(x); + } + return z; + } + if(ix<=0x32000000) { /* x < 2**-27 */ + return(u00 + tpi*__ieee754_logf(x)); + } + z = x*x; + u = u00+z*(u01+z*(u02+z*(u03+z*(u04+z*(u05+z*u06))))); + v = one+z*(v01+z*(v02+z*(v03+z*v04))); + return(u/v + tpi*(__ieee754_j0f(x)*__ieee754_logf(x))); +} + +/* The asymptotic expansions of pzero is + * 1 - 9/128 s^2 + 11025/98304 s^4 - ..., where s = 1/x. + * For x >= 2, We approximate pzero by + * pzero(x) = 1 + (R/S) + * where R = pR0 + pR1*s^2 + pR2*s^4 + ... + pR5*s^10 + * S = 1 + pS0*s^2 + ... + pS4*s^10 + * and + * | pzero(x)-1-R/S | <= 2 ** ( -60.26) + */ +#ifdef __STDC__ +static const float pR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ +#else +static float pR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ +#endif + 0.0000000000e+00, /* 0x00000000 */ + -7.0312500000e-02, /* 0xbd900000 */ + -8.0816707611e+00, /* 0xc1014e86 */ + -2.5706311035e+02, /* 0xc3808814 */ + -2.4852163086e+03, /* 0xc51b5376 */ + -5.2530439453e+03, /* 0xc5a4285a */ +}; +#ifdef __STDC__ +static const float pS8[5] = { +#else +static float pS8[5] = { +#endif + 1.1653436279e+02, /* 0x42e91198 */ + 3.8337448730e+03, /* 0x456f9beb */ + 4.0597855469e+04, /* 0x471e95db */ + 1.1675296875e+05, /* 0x47e4087c */ + 4.7627726562e+04, /* 0x473a0bba */ +}; +#ifdef __STDC__ +static const float pR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ +#else +static float pR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ +#endif + -1.1412546255e-11, /* 0xad48c58a */ + -7.0312492549e-02, /* 0xbd8fffff */ + -4.1596107483e+00, /* 0xc0851b88 */ + -6.7674766541e+01, /* 0xc287597b */ + -3.3123129272e+02, /* 0xc3a59d9b */ + -3.4643338013e+02, /* 0xc3ad3779 */ +}; +#ifdef __STDC__ +static const float pS5[5] = { +#else +static float pS5[5] = { +#endif + 6.0753936768e+01, /* 0x42730408 */ + 1.0512523193e+03, /* 0x44836813 */ + 5.9789707031e+03, /* 0x45bad7c4 */ + 9.6254453125e+03, /* 0x461665c8 */ + 2.4060581055e+03, /* 0x451660ee */ +}; + +#ifdef __STDC__ +static const float pR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ +#else +static float pR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ +#endif + -2.5470459075e-09, /* 0xb12f081b */ + -7.0311963558e-02, /* 0xbd8fffb8 */ + -2.4090321064e+00, /* 0xc01a2d95 */ + -2.1965976715e+01, /* 0xc1afba52 */ + -5.8079170227e+01, /* 0xc2685112 */ + -3.1447946548e+01, /* 0xc1fb9565 */ +}; +#ifdef __STDC__ +static const float pS3[5] = { +#else +static float pS3[5] = { +#endif + 3.5856033325e+01, /* 0x420f6c94 */ + 3.6151397705e+02, /* 0x43b4c1ca */ + 1.1936077881e+03, /* 0x44953373 */ + 1.1279968262e+03, /* 0x448cffe6 */ + 1.7358093262e+02, /* 0x432d94b8 */ +}; + +#ifdef __STDC__ +static const float pR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ +#else +static float pR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ +#endif + -8.8753431271e-08, /* 0xb3be98b7 */ + -7.0303097367e-02, /* 0xbd8ffb12 */ + -1.4507384300e+00, /* 0xbfb9b1cc */ + -7.6356959343e+00, /* 0xc0f4579f */ + -1.1193166733e+01, /* 0xc1331736 */ + -3.2336456776e+00, /* 0xc04ef40d */ +}; +#ifdef __STDC__ +static const float pS2[5] = { +#else +static float pS2[5] = { +#endif + 2.2220300674e+01, /* 0x41b1c32d */ + 1.3620678711e+02, /* 0x430834f0 */ + 2.7047027588e+02, /* 0x43873c32 */ + 1.5387539673e+02, /* 0x4319e01a */ + 1.4657617569e+01, /* 0x416a859a */ +}; + +#ifdef __STDC__ + static float pzerof(float x) +#else + static float pzerof(x) + float x; +#endif +{ +#ifdef __STDC__ + const float *p,*q; +#else + float *p,*q; +#endif + float z,r,s; + __int32_t ix; + ix = CYG_LIBM_WORD(x); + ix &= 0x7fffffff; + if(ix>=0x41000000) {p = pR8; q= pS8;} + else if(ix>=0x40f71c58){p = pR5; q= pS5;} + else if(ix>=0x4036db68){p = pR3; q= pS3;} + else {p = pR2; q= pS2;} + z = one/(x*x); + r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); + s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4])))); + return one+ r/s; +} + + +/* For x >= 8, the asymptotic expansions of qzero is + * -1/8 s + 75/1024 s^3 - ..., where s = 1/x. + * We approximate qzero by + * qzero(x) = s*(-1.25 + (R/S)) + * where R = qR0 + qR1*s^2 + qR2*s^4 + ... + qR5*s^10 + * S = 1 + qS0*s^2 + ... + qS5*s^12 + * and + * | qzero(x)/s +1.25-R/S | <= 2 ** ( -61.22) + */ +#ifdef __STDC__ +static const float qR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ +#else +static float qR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ +#endif + 0.0000000000e+00, /* 0x00000000 */ + 7.3242187500e-02, /* 0x3d960000 */ + 1.1768206596e+01, /* 0x413c4a93 */ + 5.5767340088e+02, /* 0x440b6b19 */ + 8.8591972656e+03, /* 0x460a6cca */ + 3.7014625000e+04, /* 0x471096a0 */ +}; +#ifdef __STDC__ +static const float qS8[6] = { +#else +static float qS8[6] = { +#endif + 1.6377603149e+02, /* 0x4323c6aa */ + 8.0983447266e+03, /* 0x45fd12c2 */ + 1.4253829688e+05, /* 0x480b3293 */ + 8.0330925000e+05, /* 0x49441ed4 */ + 8.4050156250e+05, /* 0x494d3359 */ + -3.4389928125e+05, /* 0xc8a7eb69 */ +}; + +#ifdef __STDC__ +static const float qR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ +#else +static float qR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ +#endif + 1.8408595828e-11, /* 0x2da1ec79 */ + 7.3242180049e-02, /* 0x3d95ffff */ + 5.8356351852e+00, /* 0x40babd86 */ + 1.3511157227e+02, /* 0x43071c90 */ + 1.0272437744e+03, /* 0x448067cd */ + 1.9899779053e+03, /* 0x44f8bf4b */ +}; +#ifdef __STDC__ +static const float qS5[6] = { +#else +static float qS5[6] = { +#endif + 8.2776611328e+01, /* 0x42a58da0 */ + 2.0778142090e+03, /* 0x4501dd07 */ + 1.8847289062e+04, /* 0x46933e94 */ + 5.6751113281e+04, /* 0x475daf1d */ + 3.5976753906e+04, /* 0x470c88c1 */ + -5.3543427734e+03, /* 0xc5a752be */ +}; + +#ifdef __STDC__ +static const float qR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ +#else +static float qR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ +#endif + 4.3774099900e-09, /* 0x3196681b */ + 7.3241114616e-02, /* 0x3d95ff70 */ + 3.3442313671e+00, /* 0x405607e3 */ + 4.2621845245e+01, /* 0x422a7cc5 */ + 1.7080809021e+02, /* 0x432acedf */ + 1.6673394775e+02, /* 0x4326bbe4 */ +}; +#ifdef __STDC__ +static const float qS3[6] = { +#else +static float qS3[6] = { +#endif + 4.8758872986e+01, /* 0x42430916 */ + 7.0968920898e+02, /* 0x44316c1c */ + 3.7041481934e+03, /* 0x4567825f */ + 6.4604252930e+03, /* 0x45c9e367 */ + 2.5163337402e+03, /* 0x451d4557 */ + -1.4924745178e+02, /* 0xc3153f59 */ +}; + +#ifdef __STDC__ +static const float qR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ +#else +static float qR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ +#endif + 1.5044444979e-07, /* 0x342189db */ + 7.3223426938e-02, /* 0x3d95f62a */ + 1.9981917143e+00, /* 0x3fffc4bf */ + 1.4495602608e+01, /* 0x4167edfd */ + 3.1666231155e+01, /* 0x41fd5471 */ + 1.6252708435e+01, /* 0x4182058c */ +}; +#ifdef __STDC__ +static const float qS2[6] = { +#else +static float qS2[6] = { +#endif + 3.0365585327e+01, /* 0x41f2ecb8 */ + 2.6934811401e+02, /* 0x4386ac8f */ + 8.4478375244e+02, /* 0x44533229 */ + 8.8293585205e+02, /* 0x445cbbe5 */ + 2.1266638184e+02, /* 0x4354aa98 */ + -5.3109550476e+00, /* 0xc0a9f358 */ +}; + +#ifdef __STDC__ + static float qzerof(float x) +#else + static float qzerof(x) + float x; +#endif +{ +#ifdef __STDC__ + const float *p,*q; +#else + float *p,*q; +#endif + float s,r,z; + __int32_t ix; + ix = CYG_LIBM_WORD(x); + ix &= 0x7fffffff; + if(ix>=0x41000000) {p = qR8; q= qS8;} + else if(ix>=0x40f71c58){p = qR5; q= qS5;} + else if(ix>=0x4036db68){p = qR3; q= qS3;} + else {p = qR2; q= qS2;} + z = one/(x*x); + r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); + s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5]))))); + return (-(float).125 + r/s)/x; +} + +#endif // ifdef CYGPKG_LIBM + +// EOF ef_j0.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-core/ef_j1.c @@ -0,0 +1,506 @@ +//=========================================================================== +// +// ef_j1.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* ef_j1.c -- float version of e_j1.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static float ponef(float), qonef(float); +#else +static float ponef(), qonef(); +#endif + +#ifdef __STDC__ +static const float +#else +static float +#endif +huge = 1e30, +one = 1.0, +invsqrtpi= 5.6418961287e-01, /* 0x3f106ebb */ +tpi = 6.3661974669e-01, /* 0x3f22f983 */ + /* R0/S0 on [0,2] */ +r00 = -6.2500000000e-02, /* 0xbd800000 */ +r01 = 1.4070566976e-03, /* 0x3ab86cfd */ +r02 = -1.5995563444e-05, /* 0xb7862e36 */ +r03 = 4.9672799207e-08, /* 0x335557d2 */ +s01 = 1.9153760746e-02, /* 0x3c9ce859 */ +s02 = 1.8594678841e-04, /* 0x3942fab6 */ +s03 = 1.1771846857e-06, /* 0x359dffc2 */ +s04 = 5.0463624390e-09, /* 0x31ad6446 */ +s05 = 1.2354227016e-11; /* 0x2d59567e */ + +#ifdef __STDC__ +static const float zero = 0.0; +#else +static float zero = 0.0; +#endif + +#ifdef __STDC__ + float __ieee754_j1f(float x) +#else + float __ieee754_j1f(x) + float x; +#endif +{ + float z, s,c,ss,cc,r,u,v,y; + __int32_t hx,ix; + + hx = CYG_LIBM_WORD(x); + ix = hx&0x7fffffff; + if(!FLT_UWORD_IS_FINITE(ix)) return one/x; + y = fabsf(x); + if(ix >= 0x40000000) { /* |x| >= 2.0 */ + s = sinf(y); + c = cosf(y); + ss = -s-c; + cc = s-c; + if(ix<=FLT_UWORD_HALF_MAX) { /* make sure y+y not overflow */ + z = cosf(y+y); + if ((s*c)>zero) cc = z/ss; + else ss = z/cc; + } + /* + * j1(x) = 1/sqrt(pi) * (P(1,x)*cc - Q(1,x)*ss) / sqrt(x) + * y1(x) = 1/sqrt(pi) * (P(1,x)*ss + Q(1,x)*cc) / sqrt(x) + */ + if(ix>0x80000000) z = (invsqrtpi*cc)/__ieee754_sqrtf(y); + else { + u = ponef(y); v = qonef(y); + z = invsqrtpi*(u*cc-v*ss)/__ieee754_sqrtf(y); + } + if(hx<0) return -z; + else return z; + } + if(ix<0x32000000) { /* |x|<2**-27 */ + if(huge+x>one) return (float)0.5*x;/* inexact if x!=0 necessary */ + } + z = x*x; + r = z*(r00+z*(r01+z*(r02+z*r03))); + s = one+z*(s01+z*(s02+z*(s03+z*(s04+z*s05)))); + r *= x; + return(x*(float)0.5+r/s); +} + +#ifdef __STDC__ +static const float U0[5] = { +#else +static float U0[5] = { +#endif + -1.9605709612e-01, /* 0xbe48c331 */ + 5.0443872809e-02, /* 0x3d4e9e3c */ + -1.9125689287e-03, /* 0xbafaaf2a */ + 2.3525259166e-05, /* 0x37c5581c */ + -9.1909917899e-08, /* 0xb3c56003 */ +}; +#ifdef __STDC__ +static const float V0[5] = { +#else +static float V0[5] = { +#endif + 1.9916731864e-02, /* 0x3ca3286a */ + 2.0255257550e-04, /* 0x3954644b */ + 1.3560879779e-06, /* 0x35b602d4 */ + 6.2274145840e-09, /* 0x31d5f8eb */ + 1.6655924903e-11, /* 0x2d9281cf */ +}; + +#ifdef __STDC__ + float __ieee754_y1f(float x) +#else + float __ieee754_y1f(x) + float x; +#endif +{ + float z, s,c,ss,cc,u,v; + __int32_t hx,ix; + + hx = CYG_LIBM_WORD(x); + ix = 0x7fffffff&hx; + /* if Y1(NaN) is NaN, Y1(-inf) is NaN, Y1(inf) is 0 */ + if(!FLT_UWORD_IS_FINITE(ix)) return one/(x+x*x); + if(FLT_UWORD_IS_ZERO(ix)) return -one/zero; + if(hx<0) return zero/zero; + if(ix >= 0x40000000) { /* |x| >= 2.0 */ + s = sinf(x); + c = cosf(x); + ss = -s-c; + cc = s-c; + if(ix<=FLT_UWORD_HALF_MAX) { /* make sure x+x not overflow */ + z = cosf(x+x); + if ((s*c)>zero) cc = z/ss; + else ss = z/cc; + } + /* y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x0)+q1(x)*cos(x0)) + * where x0 = x-3pi/4 + * Better formula: + * cos(x0) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4) + * = 1/sqrt(2) * (sin(x) - cos(x)) + * sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4) + * = -1/sqrt(2) * (cos(x) + sin(x)) + * To avoid cancellation, use + * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) + * to compute the worse one. + */ + if(ix>0x48000000) z = (invsqrtpi*ss)/__ieee754_sqrtf(x); + else { + u = ponef(x); v = qonef(x); + z = invsqrtpi*(u*ss+v*cc)/__ieee754_sqrtf(x); + } + return z; + } + if(ix<=0x24800000) { /* x < 2**-54 */ + return(-tpi/x); + } + z = x*x; + u = U0[0]+z*(U0[1]+z*(U0[2]+z*(U0[3]+z*U0[4]))); + v = one+z*(V0[0]+z*(V0[1]+z*(V0[2]+z*(V0[3]+z*V0[4])))); + return(x*(u/v) + tpi*(__ieee754_j1f(x)*__ieee754_logf(x)-one/x)); +} + +/* For x >= 8, the asymptotic expansions of pone is + * 1 + 15/128 s^2 - 4725/2^15 s^4 - ..., where s = 1/x. + * We approximate pone by + * pone(x) = 1 + (R/S) + * where R = pr0 + pr1*s^2 + pr2*s^4 + ... + pr5*s^10 + * S = 1 + ps0*s^2 + ... + ps4*s^10 + * and + * | pone(x)-1-R/S | <= 2 ** ( -60.06) + */ + +#ifdef __STDC__ +static const float pr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ +#else +static float pr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ +#endif + 0.0000000000e+00, /* 0x00000000 */ + 1.1718750000e-01, /* 0x3df00000 */ + 1.3239480972e+01, /* 0x4153d4ea */ + 4.1205184937e+02, /* 0x43ce06a3 */ + 3.8747453613e+03, /* 0x45722bed */ + 7.9144794922e+03, /* 0x45f753d6 */ +}; +#ifdef __STDC__ +static const float ps8[5] = { +#else +static float ps8[5] = { +#endif + 1.1420736694e+02, /* 0x42e46a2c */ + 3.6509309082e+03, /* 0x45642ee5 */ + 3.6956207031e+04, /* 0x47105c35 */ + 9.7602796875e+04, /* 0x47bea166 */ + 3.0804271484e+04, /* 0x46f0a88b */ +}; + +#ifdef __STDC__ +static const float pr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ +#else +static float pr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ +#endif + 1.3199052094e-11, /* 0x2d68333f */ + 1.1718749255e-01, /* 0x3defffff */ + 6.8027510643e+00, /* 0x40d9b023 */ + 1.0830818176e+02, /* 0x42d89dca */ + 5.1763616943e+02, /* 0x440168b7 */ + 5.2871520996e+02, /* 0x44042dc6 */ +}; +#ifdef __STDC__ +static const float ps5[5] = { +#else +static float ps5[5] = { +#endif + 5.9280597687e+01, /* 0x426d1f55 */ + 9.9140142822e+02, /* 0x4477d9b1 */ + 5.3532670898e+03, /* 0x45a74a23 */ + 7.8446904297e+03, /* 0x45f52586 */ + 1.5040468750e+03, /* 0x44bc0180 */ +}; + +#ifdef __STDC__ +static const float pr3[6] = { +#else +static float pr3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ +#endif + 3.0250391081e-09, /* 0x314fe10d */ + 1.1718686670e-01, /* 0x3defffab */ + 3.9329774380e+00, /* 0x407bb5e7 */ + 3.5119403839e+01, /* 0x420c7a45 */ + 9.1055007935e+01, /* 0x42b61c2a */ + 4.8559066772e+01, /* 0x42423c7c */ +}; +#ifdef __STDC__ +static const float ps3[5] = { +#else +static float ps3[5] = { +#endif + 3.4791309357e+01, /* 0x420b2a4d */ + 3.3676245117e+02, /* 0x43a86198 */ + 1.0468714600e+03, /* 0x4482dbe3 */ + 8.9081134033e+02, /* 0x445eb3ed */ + 1.0378793335e+02, /* 0x42cf936c */ +}; + +#ifdef __STDC__ +static const float pr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ +#else +static float pr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ +#endif + 1.0771083225e-07, /* 0x33e74ea8 */ + 1.1717621982e-01, /* 0x3deffa16 */ + 2.3685150146e+00, /* 0x401795c0 */ + 1.2242610931e+01, /* 0x4143e1bc */ + 1.7693971634e+01, /* 0x418d8d41 */ + 5.0735230446e+00, /* 0x40a25a4d */ +}; +#ifdef __STDC__ +static const float ps2[5] = { +#else +static float ps2[5] = { +#endif + 2.1436485291e+01, /* 0x41ab7dec */ + 1.2529022980e+02, /* 0x42fa9499 */ + 2.3227647400e+02, /* 0x436846c7 */ + 1.1767937469e+02, /* 0x42eb5bd7 */ + 8.3646392822e+00, /* 0x4105d590 */ +}; + +#ifdef __STDC__ + static float ponef(float x) +#else + static float ponef(x) + float x; +#endif +{ +#ifdef __STDC__ + const float *p,*q; +#else + float *p,*q; +#endif + float z,r,s; + __int32_t ix; + ix = CYG_LIBM_WORD(x); + ix &= 0x7fffffff; + if(ix>=0x41000000) {p = pr8; q= ps8;} + else if(ix>=0x40f71c58){p = pr5; q= ps5;} + else if(ix>=0x4036db68){p = pr3; q= ps3;} + else {p = pr2; q= ps2;} + z = one/(x*x); + r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); + s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4])))); + return one+ r/s; +} + + +/* For x >= 8, the asymptotic expansions of qone is + * 3/8 s - 105/1024 s^3 - ..., where s = 1/x. + * We approximate qone by + * qone(x) = s*(0.375 + (R/S)) + * where R = qr1*s^2 + qr2*s^4 + ... + qr5*s^10 + * S = 1 + qs1*s^2 + ... + qs6*s^12 + * and + * | qone(x)/s -0.375-R/S | <= 2 ** ( -61.13) + */ + +#ifdef __STDC__ +static const float qr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ +#else +static float qr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ +#endif + 0.0000000000e+00, /* 0x00000000 */ + -1.0253906250e-01, /* 0xbdd20000 */ + -1.6271753311e+01, /* 0xc1822c8d */ + -7.5960174561e+02, /* 0xc43de683 */ + -1.1849806641e+04, /* 0xc639273a */ + -4.8438511719e+04, /* 0xc73d3683 */ +}; +#ifdef __STDC__ +static const float qs8[6] = { +#else +static float qs8[6] = { +#endif + 1.6139537048e+02, /* 0x43216537 */ + 7.8253862305e+03, /* 0x45f48b17 */ + 1.3387534375e+05, /* 0x4802bcd6 */ + 7.1965775000e+05, /* 0x492fb29c */ + 6.6660125000e+05, /* 0x4922be94 */ + -2.9449025000e+05, /* 0xc88fcb48 */ +}; + +#ifdef __STDC__ +static const float qr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ +#else +static float qr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ +#endif + -2.0897993405e-11, /* 0xadb7d219 */ + -1.0253904760e-01, /* 0xbdd1fffe */ + -8.0564479828e+00, /* 0xc100e736 */ + -1.8366960144e+02, /* 0xc337ab6b */ + -1.3731937256e+03, /* 0xc4aba633 */ + -2.6124443359e+03, /* 0xc523471c */ +}; +#ifdef __STDC__ +static const float qs5[6] = { +#else +static float qs5[6] = { +#endif + 8.1276550293e+01, /* 0x42a28d98 */ + 1.9917987061e+03, /* 0x44f8f98f */ + 1.7468484375e+04, /* 0x468878f8 */ + 4.9851425781e+04, /* 0x4742bb6d */ + 2.7948074219e+04, /* 0x46da5826 */ + -4.7191835938e+03, /* 0xc5937978 */ +}; + +#ifdef __STDC__ +static const float qr3[6] = { +#else +static float qr3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ +#endif + -5.0783124372e-09, /* 0xb1ae7d4f */ + -1.0253783315e-01, /* 0xbdd1ff5b */ + -4.6101160049e+00, /* 0xc0938612 */ + -5.7847221375e+01, /* 0xc267638e */ + -2.2824453735e+02, /* 0xc3643e9a */ + -2.1921012878e+02, /* 0xc35b35cb */ +}; +#ifdef __STDC__ +static const float qs3[6] = { +#else +static float qs3[6] = { +#endif + 4.7665153503e+01, /* 0x423ea91e */ + 6.7386511230e+02, /* 0x4428775e */ + 3.3801528320e+03, /* 0x45534272 */ + 5.5477290039e+03, /* 0x45ad5dd5 */ + 1.9031191406e+03, /* 0x44ede3d0 */ + -1.3520118713e+02, /* 0xc3073381 */ +}; + +#ifdef __STDC__ +static const float qr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ +#else +static float qr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ +#endif + -1.7838172539e-07, /* 0xb43f8932 */ + -1.0251704603e-01, /* 0xbdd1f475 */ + -2.7522056103e+00, /* 0xc0302423 */ + -1.9663616180e+01, /* 0xc19d4f16 */ + -4.2325313568e+01, /* 0xc2294d1f */ + -2.1371921539e+01, /* 0xc1aaf9b2 */ +}; +#ifdef __STDC__ +static const float qs2[6] = { +#else +static float qs2[6] = { +#endif + 2.9533363342e+01, /* 0x41ec4454 */ + 2.5298155212e+02, /* 0x437cfb47 */ + 7.5750280762e+02, /* 0x443d602e */ + 7.3939318848e+02, /* 0x4438d92a */ + 1.5594900513e+02, /* 0x431bf2f2 */ + -4.9594988823e+00, /* 0xc09eb437 */ +}; + +#ifdef __STDC__ + static float qonef(float x) +#else + static float qonef(x) + float x; +#endif +{ +#ifdef __STDC__ + const float *p,*q; +#else + float *p,*q; +#endif + float s,r,z; + __int32_t ix; + ix = CYG_LIBM_WORD(x); + ix &= 0x7fffffff; + if(ix>=0x40200000) {p = qr8; q= qs8;} + else if(ix>=0x40f71c58){p = qr5; q= qs5;} + else if(ix>=0x4036db68){p = qr3; q= qs3;} + else {p = qr2; q= qs2;} + z = one/(x*x); + r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); + s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5]))))); + return ((float).375 + r/s)/x; +} + +#endif // ifdef CYGPKG_LIBM + +// EOF ef_j1.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-core/ef_jn.c @@ -0,0 +1,274 @@ +//=========================================================================== +// +// ef_jn.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* ef_jn.c -- float version of e_jn.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +invsqrtpi= 5.6418961287e-01, /* 0x3f106ebb */ +two = 2.0000000000e+00, /* 0x40000000 */ +one = 1.0000000000e+00; /* 0x3F800000 */ + +#ifdef __STDC__ +static const float zero = 0.0000000000e+00; +#else +static float zero = 0.0000000000e+00; +#endif + +#ifdef __STDC__ + float __ieee754_jnf(int n, float x) +#else + float __ieee754_jnf(n,x) + int n; float x; +#endif +{ + __int32_t i,hx,ix, sgn; + float a, b, temp, di; + float z, w; + + /* J(-n,x) = (-1)^n * J(n, x), J(n, -x) = (-1)^n * J(n, x) + * Thus, J(-n,x) = J(n,-x) + */ + hx = CYG_LIBM_WORD(x); + ix = 0x7fffffff&hx; + /* if J(n,NaN) is NaN */ + if(FLT_UWORD_IS_NAN(ix)) return x+x; + if(n<0){ + n = -n; + x = -x; + hx ^= 0x80000000; + } + if(n==0) return(__ieee754_j0f(x)); + if(n==1) return(__ieee754_j1f(x)); + sgn = (n&1)&(hx>>31); /* even n -- 0, odd n -- sign(x) */ + x = fabsf(x); + if(FLT_UWORD_IS_ZERO(ix)||FLT_UWORD_IS_INFINITE(ix)) + b = zero; + else if((float)n<=x) { + /* Safe to use J(n+1,x)=2n/x *J(n,x)-J(n-1,x) */ + a = __ieee754_j0f(x); + b = __ieee754_j1f(x); + for(i=1;i<n;i++){ + temp = b; + b = b*((float)(i+i)/x) - a; /* avoid underflow */ + a = temp; + } + } else { + if(ix<0x30800000) { /* x < 2**-29 */ + /* x is tiny, return the first Taylor expansion of J(n,x) + * J(n,x) = 1/n!*(x/2)^n - ... + */ + if(n>33) /* underflow */ + b = zero; + else { + temp = x*(float)0.5; b = temp; + for (a=one,i=2;i<=n;i++) { + a *= (float)i; /* a = n! */ + b *= temp; /* b = (x/2)^n */ + } + b = b/a; + } + } else { + /* use backward recurrence */ + /* x x^2 x^2 + * J(n,x)/J(n-1,x) = ---- ------ ------ ..... + * 2n - 2(n+1) - 2(n+2) + * + * 1 1 1 + * (for large x) = ---- ------ ------ ..... + * 2n 2(n+1) 2(n+2) + * -- - ------ - ------ - + * x x x + * + * Let w = 2n/x and h=2/x, then the above quotient + * is equal to the continued fraction: + * 1 + * = ----------------------- + * 1 + * w - ----------------- + * 1 + * w+h - --------- + * w+2h - ... + * + * To determine how many terms needed, let + * Q(0) = w, Q(1) = w(w+h) - 1, + * Q(k) = (w+k*h)*Q(k-1) - Q(k-2), + * When Q(k) > 1e4 good for single + * When Q(k) > 1e9 good for double + * When Q(k) > 1e17 good for quadruple + */ + /* determine k */ + float t,v; + float q0,q1,h,tmp; __int32_t k,m; + w = (n+n)/(float)x; h = (float)2.0/(float)x; + q0 = w; z = w+h; q1 = w*z - (float)1.0; k=1; + while(q1<(float)1.0e9) { + k += 1; z += h; + tmp = z*q1 - q0; + q0 = q1; + q1 = tmp; + } + m = n+n; + for(t=zero, i = 2*(n+k); i>=m; i -= 2) t = one/(i/x-t); + a = t; + b = one; + /* estimate log((2/x)^n*n!) = n*log(2/x)+n*ln(n) + * Hence, if n*(log(2n/x)) > ... + * single 8.8722839355e+01 + * double 7.09782712893383973096e+02 + * long double 1.1356523406294143949491931077970765006170e+04 + * then recurrent value may overflow and the result is + * likely underflow to zero + */ + tmp = n; + v = two/x; + tmp = tmp*__ieee754_logf(fabsf(v*tmp)); + if(tmp<(float)8.8721679688e+01) { + for(i=n-1,di=(float)(i+i);i>0;i--){ + temp = b; + b *= di; + b = b/x - a; + a = temp; + di -= two; + } + } else { + for(i=n-1,di=(float)(i+i);i>0;i--){ + temp = b; + b *= di; + b = b/x - a; + a = temp; + di -= two; + /* scale b to avoid spurious overflow */ + if(b>(float)1e10) { + a /= b; + t /= b; + b = one; + } + } + } + b = (t*__ieee754_j0f(x)/b); + } + } + if(sgn==1) return -b; else return b; +} + +#ifdef __STDC__ + float __ieee754_ynf(int n, float x) +#else + float __ieee754_ynf(n,x) + int n; float x; +#endif +{ + __int32_t i,hx,ix,ib; + __int32_t sign; + float a, b, temp; + + hx = CYG_LIBM_WORD(x); + ix = 0x7fffffff&hx; + /* if Y(n,NaN) is NaN */ + if(FLT_UWORD_IS_NAN(ix)) return x+x; + if(FLT_UWORD_IS_ZERO(ix)) return -one/zero; + if(hx<0) return zero/zero; + sign = 1; + if(n<0){ + n = -n; + sign = 1 - ((n&1)<<1); + } + if(n==0) return(__ieee754_y0f(x)); + if(n==1) return(sign*__ieee754_y1f(x)); + if(FLT_UWORD_IS_INFINITE(ix)) return zero; + + a = __ieee754_y0f(x); + b = __ieee754_y1f(x); + /* quit if b is -inf */ + ib = CYG_LIBM_WORD(b); + for(i=1;i<n&&ib!=0xff800000;i++){ + temp = b; + b = ((float)(i+i)/x)*b - a; + ib = CYG_LIBM_WORD(b); + a = temp; + } + if(sign>0) return b; else return -b; +} + +#endif // ifdef CYGPKG_LIBM + +// EOF ef_jn.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-core/ef_lgamma.c @@ -0,0 +1,93 @@ +//=========================================================================== +// +// ef_lgamma.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* @(#)e_lgamma.c 1.3 95/01/18 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + * + */ + +/* __ieee754_lgamma(x) + * Return the logarithm of the Gamma function of x. + * + * Method: call __ieee754_lgamma_r + */ + +#include <math.h> +#include "mathincl/fdlibm.h" + +float +__ieee754_lgammaf(float x) +{ + return __ieee754_lgammaf_r(x,&signgam); +} + +#endif // ifdef CYGPKG_LIBM + +// EOF ef_lgamma.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-core/ef_lgamma_r.c @@ -0,0 +1,316 @@ +//=========================================================================== +// +// ef_lgamma_r.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + +/* erf_lgamma.c -- float version of er_lgamma.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + * + */ + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +two23= 8.3886080000e+06, /* 0x4b000000 */ +half= 5.0000000000e-01, /* 0x3f000000 */ +one = 1.0000000000e+00, /* 0x3f800000 */ +pi = 3.1415927410e+00, /* 0x40490fdb */ +a0 = 7.7215664089e-02, /* 0x3d9e233f */ +a1 = 3.2246702909e-01, /* 0x3ea51a66 */ +a2 = 6.7352302372e-02, /* 0x3d89f001 */ +a3 = 2.0580807701e-02, /* 0x3ca89915 */ +a4 = 7.3855509982e-03, /* 0x3bf2027e */ +a5 = 2.8905137442e-03, /* 0x3b3d6ec6 */ +a6 = 1.1927076848e-03, /* 0x3a9c54a1 */ +a7 = 5.1006977446e-04, /* 0x3a05b634 */ +a8 = 2.2086278477e-04, /* 0x39679767 */ +a9 = 1.0801156895e-04, /* 0x38e28445 */ +a10 = 2.5214456400e-05, /* 0x37d383a2 */ +a11 = 4.4864096708e-05, /* 0x383c2c75 */ +tc = 1.4616321325e+00, /* 0x3fbb16c3 */ +tf = -1.2148628384e-01, /* 0xbdf8cdcd */ +/* tt = -(tail of tf) */ +tt = 6.6971006518e-09, /* 0x31e61c52 */ +t0 = 4.8383611441e-01, /* 0x3ef7b95e */ +t1 = -1.4758771658e-01, /* 0xbe17213c */ +t2 = 6.4624942839e-02, /* 0x3d845a15 */ +t3 = -3.2788541168e-02, /* 0xbd064d47 */ +t4 = 1.7970675603e-02, /* 0x3c93373d */ +t5 = -1.0314224288e-02, /* 0xbc28fcfe */ +t6 = 6.1005386524e-03, /* 0x3bc7e707 */ +t7 = -3.6845202558e-03, /* 0xbb7177fe */ +t8 = 2.2596477065e-03, /* 0x3b141699 */ +t9 = -1.4034647029e-03, /* 0xbab7f476 */ +t10 = 8.8108185446e-04, /* 0x3a66f867 */ +t11 = -5.3859531181e-04, /* 0xba0d3085 */ +t12 = 3.1563205994e-04, /* 0x39a57b6b */ +t13 = -3.1275415677e-04, /* 0xb9a3f927 */ +t14 = 3.3552918467e-04, /* 0x39afe9f7 */ +u0 = -7.7215664089e-02, /* 0xbd9e233f */ +u1 = 6.3282704353e-01, /* 0x3f2200f4 */ +u2 = 1.4549225569e+00, /* 0x3fba3ae7 */ +u3 = 9.7771751881e-01, /* 0x3f7a4bb2 */ +u4 = 2.2896373272e-01, /* 0x3e6a7578 */ +u5 = 1.3381091878e-02, /* 0x3c5b3c5e */ +v1 = 2.4559779167e+00, /* 0x401d2ebe */ +v2 = 2.1284897327e+00, /* 0x4008392d */ +v3 = 7.6928514242e-01, /* 0x3f44efdf */ +v4 = 1.0422264785e-01, /* 0x3dd572af */ +v5 = 3.2170924824e-03, /* 0x3b52d5db */ +s0 = -7.7215664089e-02, /* 0xbd9e233f */ +s1 = 2.1498242021e-01, /* 0x3e5c245a */ +s2 = 3.2577878237e-01, /* 0x3ea6cc7a */ +s3 = 1.4635047317e-01, /* 0x3e15dce6 */ +s4 = 2.6642270386e-02, /* 0x3cda40e4 */ +s5 = 1.8402845599e-03, /* 0x3af135b4 */ +s6 = 3.1947532989e-05, /* 0x3805ff67 */ +r1 = 1.3920053244e+00, /* 0x3fb22d3b */ +r2 = 7.2193557024e-01, /* 0x3f38d0c5 */ +r3 = 1.7193385959e-01, /* 0x3e300f6e */ +r4 = 1.8645919859e-02, /* 0x3c98bf54 */ +r5 = 7.7794247773e-04, /* 0x3a4beed6 */ +r6 = 7.3266842264e-06, /* 0x36f5d7bd */ +w0 = 4.1893854737e-01, /* 0x3ed67f1d */ +w1 = 8.3333335817e-02, /* 0x3daaaaab */ +w2 = -2.7777778450e-03, /* 0xbb360b61 */ +w3 = 7.9365057172e-04, /* 0x3a500cfd */ +w4 = -5.9518753551e-04, /* 0xba1c065c */ +w5 = 8.3633989561e-04, /* 0x3a5b3dd2 */ +w6 = -1.6309292987e-03; /* 0xbad5c4e8 */ + +#ifdef __STDC__ +static const float zero= 0.0000000000e+00; +#else +static float zero= 0.0000000000e+00; +#endif + +#ifdef __STDC__ + static float sin_pif(float x) +#else + static float sin_pif(x) + float x; +#endif +{ + float y,z; + __int32_t n,ix; + + ix = CYG_LIBM_WORD(x); + ix &= 0x7fffffff; + + if(ix<0x3e800000) return __kernel_sinf(pi*x,zero,0); + y = -x; /* x is assume negative */ + + /* + * argument reduction, make sure inexact flag not raised if input + * is an integer + */ + z = floorf(y); + if(z!=y) { /* inexact anyway */ + y *= (float)0.5; + y = (float)2.0*(y - floorf(y)); /* y = |x| mod 2.0 */ + n = (__int32_t) (y*(float)4.0); + } else { + if(ix>=0x4b800000) { + y = zero; n = 0; /* y must be even */ + } else { + if(ix<0x4b000000) z = y+two23; /* exact */ + n = CYG_LIBM_WORD(z); + n &= 1; + y = n; + n<<= 2; + } + } + switch (n) { + case 0: y = __kernel_sinf(pi*y,zero,0); break; + case 1: + case 2: y = __kernel_cosf(pi*((float)0.5-y),zero); break; + case 3: + case 4: y = __kernel_sinf(pi*(one-y),zero,0); break; + case 5: + case 6: y = -__kernel_cosf(pi*(y-(float)1.5),zero); break; + default: y = __kernel_sinf(pi*(y-(float)2.0),zero,0); break; + } + return -y; +} + + +#ifdef __STDC__ + float __ieee754_lgammaf_r(float x, int *signgamp) +#else + float __ieee754_lgammaf_r(x,signgamp) + float x; int *signgamp; +#endif +{ + float t,y,z,nadj,p,p1,p2,p3,q,r,w; + __int32_t i,hx,ix; + + hx = CYG_LIBM_WORD(x); + + /* purge off +-inf, NaN, +-0, and negative arguments */ + *signgamp = 1; + ix = hx&0x7fffffff; + if(ix>=0x7f800000) return x*x; + if(ix==0) return one/zero; + if(ix<0x1c800000) { /* |x|<2**-70, return -log(|x|) */ + if(hx<0) { + *signgamp = -1; + return -__ieee754_logf(-x); + } else return -__ieee754_logf(x); + } + if(hx<0) { + if(ix>=0x4b000000) /* |x|>=2**23, must be -integer */ + return one/zero; + t = sin_pif(x); + if(t==zero) return one/zero; /* -integer */ + nadj = __ieee754_logf(pi/fabsf(t*x)); + if(t<zero) *signgamp = -1; + x = -x; + } + + /* purge off 1 and 2 */ + if (ix==0x3f800000||ix==0x40000000) r = 0; + /* for x < 2.0 */ + else if(ix<0x40000000) { + if(ix<=0x3f666666) { /* lgamma(x) = lgamma(x+1)-log(x) */ + r = -__ieee754_logf(x); + if(ix>=0x3f3b4a20) {y = one-x; i= 0;} + else if(ix>=0x3e6d3308) {y= x-(tc-one); i=1;} + else {y = x; i=2;} + } else { + r = zero; + if(ix>=0x3fdda618) {y=(float)2.0-x;i=0;} /* [1.7316,2] */ + else if(ix>=0x3F9da620) {y=x-tc;i=1;} /* [1.23,1.73] */ + else {y=x-one;i=2;} + } + switch(i) { + case 0: + z = y*y; + p1 = a0+z*(a2+z*(a4+z*(a6+z*(a8+z*a10)))); + p2 = z*(a1+z*(a3+z*(a5+z*(a7+z*(a9+z*a11))))); + p = y*p1+p2; + r += (p-(float)0.5*y); break; + case 1: + z = y*y; + w = z*y; + p1 = t0+w*(t3+w*(t6+w*(t9 +w*t12))); /* parallel comp */ + p2 = t1+w*(t4+w*(t7+w*(t10+w*t13))); + p3 = t2+w*(t5+w*(t8+w*(t11+w*t14))); + p = z*p1-(tt-w*(p2+y*p3)); + r += (tf + p); break; + case 2: + p1 = y*(u0+y*(u1+y*(u2+y*(u3+y*(u4+y*u5))))); + p2 = one+y*(v1+y*(v2+y*(v3+y*(v4+y*v5)))); + r += (-(float)0.5*y + p1/p2); + } + } + else if(ix<0x41000000) { /* x < 8.0 */ + i = (__int32_t)x; + t = zero; + y = x-(float)i; + p = y*(s0+y*(s1+y*(s2+y*(s3+y*(s4+y*(s5+y*s6)))))); + q = one+y*(r1+y*(r2+y*(r3+y*(r4+y*(r5+y*r6))))); + r = half*y+p/q; + z = one; /* lgamma(1+s) = log(s) + lgamma(s) */ + switch(i) { + case 7: z *= (y+(float)6.0); /* FALLTHRU */ + case 6: z *= (y+(float)5.0); /* FALLTHRU */ + case 5: z *= (y+(float)4.0); /* FALLTHRU */ + case 4: z *= (y+(float)3.0); /* FALLTHRU */ + case 3: z *= (y+(float)2.0); /* FALLTHRU */ + r += __ieee754_logf(z); break; + } + /* 8.0 <= x < 2**58 */ + } else if (ix < 0x5c800000) { + t = __ieee754_logf(x); + z = one/x; + y = z*z; + w = w0+z*(w1+y*(w2+y*(w3+y*(w4+y*(w5+y*w6))))); + r = (x-half)*(t-one)+w; + } else + /* 2**58 <= x <= inf */ + r = x*(__ieee754_logf(x)-one); + if(hx<0) r = nadj - r; + return r; +} + +#endif // ifdef CYGPKG_LIBM + +// EOF ef_lgamma_r.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-core/ef_log.c @@ -0,0 +1,159 @@ +//=========================================================================== +// +// ef_log.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* ef_log.c -- float version of e_log.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +ln2_hi = 6.9313812256e-01, /* 0x3f317180 */ +ln2_lo = 9.0580006145e-06, /* 0x3717f7d1 */ +two25 = 3.355443200e+07, /* 0x4c000000 */ +Lg1 = 6.6666668653e-01, /* 3F2AAAAB */ +Lg2 = 4.0000000596e-01, /* 3ECCCCCD */ +Lg3 = 2.8571429849e-01, /* 3E924925 */ +Lg4 = 2.2222198546e-01, /* 3E638E29 */ +Lg5 = 1.8183572590e-01, /* 3E3A3325 */ +Lg6 = 1.5313838422e-01, /* 3E1CD04F */ +Lg7 = 1.4798198640e-01; /* 3E178897 */ + +#ifdef __STDC__ +static const float zero = 0.0; +#else +static float zero = 0.0; +#endif + +#ifdef __STDC__ + float __ieee754_logf(float x) +#else + float __ieee754_logf(x) + float x; +#endif +{ + float hfsq,f,s,z,R,w,t1,t2,dk; + __int32_t k,ix,i,j; + + ix = CYG_LIBM_WORD(x); + + k=0; + if (FLT_UWORD_IS_ZERO(ix&0x7fffffff)) + return -two25/zero; /* log(+-0)=-inf */ + if (ix<0) return (x-x)/zero; /* log(-#) = NaN */ + if (!FLT_UWORD_IS_FINITE(ix)) return x+x; + if (FLT_UWORD_IS_SUBNORMAL(ix)) { + k -= 25; x *= two25; /* subnormal number, scale up x */ + ix = CYG_LIBM_WORD(x); + } + k += (ix>>23)-127; + ix &= 0x007fffff; + i = (ix+(0x95f64<<3))&0x800000; + SET_FLOAT_WORD(x,ix|(i^0x3f800000)); /* normalize x or x/2 */ + k += (i>>23); + f = x-(float)1.0; + if((0x007fffff&(15+ix))<16) { /* |f| < 2**-20 */ + if(f==zero) { if(k==0) return zero; else {dk=(float)k; + return dk*ln2_hi+dk*ln2_lo;}} + R = f*f*((float)0.5-(float)0.33333333333333333*f); + if(k==0) return f-R; else {dk=(float)k; + return dk*ln2_hi-((R-dk*ln2_lo)-f);} + } + s = f/((float)2.0+f); + dk = (float)k; + z = s*s; + i = ix-(0x6147a<<3); + w = z*z; + j = (0x6b851<<3)-ix; + t1= w*(Lg2+w*(Lg4+w*Lg6)); + t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7))); + i |= j; + R = t2+t1; + if(i>0) { + hfsq=(float)0.5*f*f; + if(k==0) return f-(hfsq-s*(hfsq+R)); else + return dk*ln2_hi-((hfsq-(s*(hfsq+R)+dk*ln2_lo))-f); + } else { + if(k==0) return f-s*(f-R); else + return dk*ln2_hi-((s*(f-R)-dk*ln2_lo)-f); + } +} + +#endif // ifdef CYGPKG_LIBM + +// EOF ef_log.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-core/ef_log10.c @@ -0,0 +1,129 @@ +//=========================================================================== +// +// ef_log10.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* ef_log10.c -- float version of e_log10.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +two25 = 3.3554432000e+07, /* 0x4c000000 */ +ivln10 = 4.3429449201e-01, /* 0x3ede5bd9 */ +log10_2hi = 3.0102920532e-01, /* 0x3e9a2080 */ +log10_2lo = 7.9034151668e-07; /* 0x355427db */ + +#ifdef __STDC__ +static const float zero = 0.0; +#else +static float zero = 0.0; +#endif + +#ifdef __STDC__ + float __ieee754_log10f(float x) +#else + float __ieee754_log10f(x) + float x; +#endif +{ + float y,z; + __int32_t i,k,hx; + + hx = CYG_LIBM_WORD(x); + + k=0; + if (FLT_UWORD_IS_ZERO(hx&0x7fffffff)) + return -two25/zero; /* log(+-0)=-inf */ + if (hx<0) return (x-x)/zero; /* log(-#) = NaN */ + if (!FLT_UWORD_IS_FINITE(hx)) return x+x; + if (FLT_UWORD_IS_SUBNORMAL(hx)) { + k -= 25; x *= two25; /* subnormal number, scale up x */ + hx = CYG_LIBM_WORD(x); + } + k += (hx>>23)-127; + i = ((__uint32_t)k&0x80000000)>>31; + hx = (hx&0x007fffff)|((0x7f-i)<<23); + y = (float)(k+i); + SET_FLOAT_WORD(x,hx); + z = y*log10_2lo + ivln10*__ieee754_logf(x); + return z+y*log10_2hi; +} + +#endif // ifdef CYGPKG_LIBM + +// EOF ef_log10.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-core/ef_pow.c @@ -0,0 +1,325 @@ +//======================================================================== +// +// ef_pow.c +// +// Part of the standard mathematical function library +// +//======================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2001-07-20 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +/* ef_pow.c -- float version of e_pow.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#include <pkgconf/libm.h> // Configuration header + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +bp[] = {1.0, 1.5,}, +dp_h[] = { 0.0, 5.84960938e-01,}, /* 0x3f15c000 */ +dp_l[] = { 0.0, 1.56322085e-06,}, /* 0x35d1cfdc */ +zero = 0.0, +one = 1.0, +two = 2.0, +two24 = 16777216.0, /* 0x4b800000 */ +huge = 1.0e30, +tiny = 1.0e-30, + /* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */ +L1 = 6.0000002384e-01, /* 0x3f19999a */ +L2 = 4.2857143283e-01, /* 0x3edb6db7 */ +L3 = 3.3333334327e-01, /* 0x3eaaaaab */ +L4 = 2.7272811532e-01, /* 0x3e8ba305 */ +L5 = 2.3066075146e-01, /* 0x3e6c3255 */ +L6 = 2.0697501302e-01, /* 0x3e53f142 */ +P1 = 1.6666667163e-01, /* 0x3e2aaaab */ +P2 = -2.7777778450e-03, /* 0xbb360b61 */ +P3 = 6.6137559770e-05, /* 0x388ab355 */ +P4 = -1.6533901999e-06, /* 0xb5ddea0e */ +P5 = 4.1381369442e-08, /* 0x3331bb4c */ +lg2 = 6.9314718246e-01, /* 0x3f317218 */ +lg2_h = 6.93145752e-01, /* 0x3f317200 */ +lg2_l = 1.42860654e-06, /* 0x35bfbe8c */ +ovt = 4.2995665694e-08, /* -(128-log2(ovfl+.5ulp)) */ +cp = 9.6179670095e-01, /* 0x3f76384f =2/(3ln2) */ +cp_h = 9.6179199219e-01, /* 0x3f763800 =head of cp */ +cp_l = 4.7017383622e-06, /* 0x369dc3a0 =tail of cp_h */ +ivln2 = 1.4426950216e+00, /* 0x3fb8aa3b =1/ln2 */ +ivln2_h = 1.4426879883e+00, /* 0x3fb8aa00 =16b 1/ln2*/ +ivln2_l = 7.0526075433e-06; /* 0x36eca570 =1/ln2 tail*/ + +/* VAE +static float +my_abs_f( float x ) +{ + Cyg_libm_ieee_float_shape_type t; + + t.value = x; + + t.number.sign = 0; + + return t.value; +} // my_abs_f() +*/ + +#ifdef __STDC__ + float __ieee754_powf(float x, float y) +#else + float __ieee754_powf(x,y) + float x, y; +#endif +{ + float z,ax,z_h,z_l,p_h,p_l; + float y1,t1,t2,r,s,t,u,v,w; + __int32_t i,j,k,yisint,n; + __int32_t hx,hy,ix,iy,is; + + hx = CYG_LIBM_WORD(x); + hy = CYG_LIBM_WORD(y); + ix = hx&0x7fffffff; iy = hy&0x7fffffff; + + /* y==zero: x**0 = 1 */ + if(FLT_UWORD_IS_ZERO(iy)) return one; + + /* x|y==NaN return NaN unless x==1 then return 1 */ + if(FLT_UWORD_IS_NAN(ix) || + FLT_UWORD_IS_NAN(iy)) { // VAE + if(ix==0x3f800000) return one; + else return 2143289344u; + } + /* determine if y is an odd int when x < 0 + * yisint = 0 ... y is not an integer + * yisint = 1 ... y is an odd int + * yisint = 2 ... y is an even int + */ + yisint = 0; + if(hx<0) { + if(iy>=0x4b800000) yisint = 2; /* even integer y */ + else if(iy>=0x3f800000) { + k = (iy>>23)-0x7f; /* exponent */ + j = iy>>(23-k); + if((j<<(23-k))==iy) yisint = 2-(j&1); + } + } + + /* special value of y */ + if (FLT_UWORD_IS_INFINITE(iy)) { /* y is +-inf */ + if (ix==0x3f800000) + return one; /* +-1**+-inf = 1 */ + else if (ix > 0x3f800000)/* (|x|>1)**+-inf = inf,0 */ + return (hy>=0)? y: zero; + else /* (|x|<1)**-,+inf = inf,0 */ + return (hy<0)?-y: zero; + } + if(iy==0x3f800000) { /* y is +-1 */ + if(hy<0) return one/x; else return x; + } + if(hy==0x40000000) return x*x; /* y is 2 */ + if(hy==0x3f000000) { /* y is 0.5 */ + if(hx>=0) /* x >= +0 */ + return __ieee754_sqrtf(x); + } + + ax = fabsf(x); + /* special value of x */ + if(FLT_UWORD_IS_INFINITE(ix)||FLT_UWORD_IS_ZERO(ix)||ix==0x3f800000){ + z = ax; /*x is +-0,+-inf,+-1*/ + if(hy<0) z = one/z; /* z = (1/|x|) */ + if(hx<0) { + if(((ix-0x3f800000)|yisint)==0) { + z = (z-z)/(z-z); /* (-1)**non-int is NaN */ + } else if(yisint==1) + z = -z; /* (x<0)**odd = -(|x|**odd) */ + } + return z; + } + + /* (x<0)**(non-int) is NaN */ + if(((((__uint32_t)hx>>31)-1)|yisint)==0) return (x-x)/(x-x); + + /* |y| is huge */ + if(iy>0x4d000000) { /* if |y| > 2**27 */ + /* over/underflow if x is not close to one */ + if(ix<0x3f7ffff8) return (hy<0)? huge*huge:tiny*tiny; + if(ix>0x3f800007) return (hy>0)? huge*huge:tiny*tiny; + /* now |1-x| is tiny <= 2**-20, suffice to compute + log(x) by x-x^2/2+x^3/3-x^4/4 */ + t = ax-1; /* t has 20 trailing zeros */ + w = (t*t)*((float)0.5-t*((float)0.333333333333-t*(float)0.25)); + u = ivln2_h*t; /* ivln2_h has 16 sig. bits */ + v = t*ivln2_l-w*ivln2; + t1 = u+v; + is = CYG_LIBM_WORD(t1); + SET_FLOAT_WORD(t1,is&0xfffff000); + t2 = v-(t1-u); + } else { + float s2,s_h,s_l,t_h,t_l; + n = 0; + /* take care subnormal number */ + if(FLT_UWORD_IS_SUBNORMAL(ix)) + {ax *= two24; n -= 24; ix = CYG_LIBM_WORD(ax); } + n += ((ix)>>23)-0x7f; + j = ix&0x007fffff; + /* determine interval */ + ix = j|0x3f800000; /* normalize ix */ + if(j<=0x1cc471) k=0; /* |x|<sqrt(3/2) */ + else if(j<0x5db3d7) k=1; /* |x|<sqrt(3) */ + else {k=0;n+=1;ix -= 0x00800000;} + SET_FLOAT_WORD(ax,ix); + + /* compute s = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */ + u = ax-bp[k]; /* bp[0]=1.0, bp[1]=1.5 */ + v = one/(ax+bp[k]); + s = u*v; + s_h = s; + is = CYG_LIBM_WORD(s_h); + SET_FLOAT_WORD(s_h,is&0xfffff000); + /* t_h=ax+bp[k] High */ + SET_FLOAT_WORD(t_h,((ix>>1)|0x20000000)+0x0040000+(k<<21)); + t_l = ax - (t_h-bp[k]); + s_l = v*((u-s_h*t_h)-s_h*t_l); + /* compute log(ax) */ + s2 = s*s; + r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6))))); + r += s_l*(s_h+s); + s2 = s_h*s_h; + t_h = (float)3.0+s2+r; + is = CYG_LIBM_WORD(t_h); + SET_FLOAT_WORD(t_h,is&0xfffff000); + t_l = r-((t_h-(float)3.0)-s2); + /* u+v = s*(1+...) */ + u = s_h*t_h; + v = s_l*t_h+t_l*s; + /* 2/(3log2)*(s+...) */ + p_h = u+v; + is = CYG_LIBM_WORD(p_h); + SET_FLOAT_WORD(p_h,is&0xfffff000); + p_l = v-(p_h-u); + z_h = cp_h*p_h; /* cp_h+cp_l = 2/(3*log2) */ + z_l = cp_l*p_h+p_l*cp+dp_l[k]; + /* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */ + t = (float)n; + t1 = (((z_h+z_l)+dp_h[k])+t); + is = CYG_LIBM_WORD(t1); + SET_FLOAT_WORD(t1,is&0xfffff000); + t2 = z_l-(((t1-t)-dp_h[k])-z_h); + } + + s = one; /* s (sign of result -ve**odd) = -1 else = 1 */ + if(((((__uint32_t)hx>>31)-1)|(yisint-1))==0) + s = -one; /* (-ve)**(odd int) */ + + /* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */ + is = CYG_LIBM_WORD(y); + SET_FLOAT_WORD(y1,is&0xfffff000); + p_l = (y-y1)*t1+y*t2; + p_h = y1*t1; + z = p_l+p_h; + j = CYG_LIBM_WORD(z); + i = j&0x7fffffff; + if (j>0) { + if (i>FLT_UWORD_EXP_MAX) + return s*huge*huge; /* overflow */ + else if (i==FLT_UWORD_EXP_MAX) + if(p_l+ovt>z-p_h) return s*huge*huge; /* overflow */ + } else { + if (i>FLT_UWORD_EXP_MIN) + return s*tiny*tiny; /* underflow */ + else if (i==FLT_UWORD_EXP_MIN) + if(p_l<=z-p_h) return s*tiny*tiny; /* underflow */ + } + /* + * compute 2**(p_h+p_l) + */ + k = (i>>23)-0x7f; + n = 0; + if(i>0x3f000000) { /* if |z| > 0.5, set n = [z+0.5] */ + n = j+(0x00800000>>(k+1)); + k = ((n&0x7fffffff)>>23)-0x7f; /* new k for n */ + SET_FLOAT_WORD(t,n&~(0x007fffff>>k)); + n = ((n&0x007fffff)|0x00800000)>>(23-k); + if(j<0) n = -n; + p_h -= t; + } + t = p_l+p_h; + is = CYG_LIBM_WORD(t); + SET_FLOAT_WORD(t,is&0xfffff000); + u = t*lg2_h; + v = (p_l-(t-p_h))*lg2+t*lg2_l; + z = u+v; + w = v-(z-u); + t = z*z; + t1 = z - t*(P1+t*(P2+t*(P3+t*(P4+t*P5)))); + r = (z*t1)/(t1-two)-(w+z*w); + z = one-(r-z); + j = CYG_LIBM_WORD(z); + j += (n<<23); + if((j>>23)<=0) z = scalbn(z,(int)n); /* subnormal output */ + else SET_FLOAT_WORD(z,j); + return s*z; +} + +// EOF ef_pow.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-core/ef_rem_pio2.c @@ -0,0 +1,260 @@ +//=========================================================================== +// +// ef_rem_pio2.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* ef_rem_pio2.c -- float version of e_rem_pio2.c + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + * + */ + +/* __ieee754_rem_pio2f(x,y) + * + * return the remainder of x rem pi/2 in y[0]+y[1] + * use __kernel_rem_pio2f() + */ + + +#include "mathincl/fdlibm.h" + +/* + * Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi + */ +#ifdef __STDC__ +static const __int32_t two_over_pi[] = { +#else +static __int32_t two_over_pi[] = { +#endif +0xA2, 0xF9, 0x83, 0x6E, 0x4E, 0x44, 0x15, 0x29, 0xFC, +0x27, 0x57, 0xD1, 0xF5, 0x34, 0xDD, 0xC0, 0xDB, 0x62, +0x95, 0x99, 0x3C, 0x43, 0x90, 0x41, 0xFE, 0x51, 0x63, +0xAB, 0xDE, 0xBB, 0xC5, 0x61, 0xB7, 0x24, 0x6E, 0x3A, +0x42, 0x4D, 0xD2, 0xE0, 0x06, 0x49, 0x2E, 0xEA, 0x09, +0xD1, 0x92, 0x1C, 0xFE, 0x1D, 0xEB, 0x1C, 0xB1, 0x29, +0xA7, 0x3E, 0xE8, 0x82, 0x35, 0xF5, 0x2E, 0xBB, 0x44, +0x84, 0xE9, 0x9C, 0x70, 0x26, 0xB4, 0x5F, 0x7E, 0x41, +0x39, 0x91, 0xD6, 0x39, 0x83, 0x53, 0x39, 0xF4, 0x9C, +0x84, 0x5F, 0x8B, 0xBD, 0xF9, 0x28, 0x3B, 0x1F, 0xF8, +0x97, 0xFF, 0xDE, 0x05, 0x98, 0x0F, 0xEF, 0x2F, 0x11, +0x8B, 0x5A, 0x0A, 0x6D, 0x1F, 0x6D, 0x36, 0x7E, 0xCF, +0x27, 0xCB, 0x09, 0xB7, 0x4F, 0x46, 0x3F, 0x66, 0x9E, +0x5F, 0xEA, 0x2D, 0x75, 0x27, 0xBA, 0xC7, 0xEB, 0xE5, +0xF1, 0x7B, 0x3D, 0x07, 0x39, 0xF7, 0x8A, 0x52, 0x92, +0xEA, 0x6B, 0xFB, 0x5F, 0xB1, 0x1F, 0x8D, 0x5D, 0x08, +0x56, 0x03, 0x30, 0x46, 0xFC, 0x7B, 0x6B, 0xAB, 0xF0, +0xCF, 0xBC, 0x20, 0x9A, 0xF4, 0x36, 0x1D, 0xA9, 0xE3, +0x91, 0x61, 0x5E, 0xE6, 0x1B, 0x08, 0x65, 0x99, 0x85, +0x5F, 0x14, 0xA0, 0x68, 0x40, 0x8D, 0xFF, 0xD8, 0x80, +0x4D, 0x73, 0x27, 0x31, 0x06, 0x06, 0x15, 0x56, 0xCA, +0x73, 0xA8, 0xC9, 0x60, 0xE2, 0x7B, 0xC0, 0x8C, 0x6B, +}; + +/* This array is like the one in e_rem_pio2.c, but the numbers are + single precision and the last 8 bits are forced to 0. */ +#ifdef __STDC__ +static const __int32_t npio2_hw[] = { +#else +static __int32_t npio2_hw[] = { +#endif +0x3fc90f00, 0x40490f00, 0x4096cb00, 0x40c90f00, 0x40fb5300, 0x4116cb00, +0x412fed00, 0x41490f00, 0x41623100, 0x417b5300, 0x418a3a00, 0x4196cb00, +0x41a35c00, 0x41afed00, 0x41bc7e00, 0x41c90f00, 0x41d5a000, 0x41e23100, +0x41eec200, 0x41fb5300, 0x4203f200, 0x420a3a00, 0x42108300, 0x4216cb00, +0x421d1400, 0x42235c00, 0x4229a500, 0x422fed00, 0x42363600, 0x423c7e00, +0x4242c700, 0x42490f00 +}; + +/* + * invpio2: 24 bits of 2/pi + * pio2_1: first 17 bit of pi/2 + * pio2_1t: pi/2 - pio2_1 + * pio2_2: second 17 bit of pi/2 + * pio2_2t: pi/2 - (pio2_1+pio2_2) + * pio2_3: third 17 bit of pi/2 + * pio2_3t: pi/2 - (pio2_1+pio2_2+pio2_3) + */ + +#ifdef __STDC__ +static const float +#else +static float +#endif +zero = 0.0000000000e+00, /* 0x00000000 */ +half = 5.0000000000e-01, /* 0x3f000000 */ +two8 = 2.5600000000e+02, /* 0x43800000 */ +invpio2 = 6.3661980629e-01, /* 0x3f22f984 */ +pio2_1 = 1.5707855225e+00, /* 0x3fc90f80 */ +pio2_1t = 1.0804334124e-05, /* 0x37354443 */ +pio2_2 = 1.0804273188e-05, /* 0x37354400 */ +pio2_2t = 6.0770999344e-11, /* 0x2e85a308 */ +pio2_3 = 6.0770943833e-11, /* 0x2e85a300 */ +pio2_3t = 6.1232342629e-17; /* 0x248d3132 */ + +#ifdef __STDC__ + __int32_t __ieee754_rem_pio2f(float x, float *y) +#else + __int32_t __ieee754_rem_pio2f(x,y) + float x,y[]; +#endif +{ + float z,w,t,r,fn; + float tx[3]; + __int32_t i,j,n,ix,hx; + int e0,nx; + + hx = CYG_LIBM_WORD(x); + ix = hx&0x7fffffff; + if(ix<=0x3f490fd8) /* |x| ~<= pi/4 , no need for reduction */ + {y[0] = x; y[1] = 0; return 0;} + if(ix<0x4016cbe4) { /* |x| < 3pi/4, special case with n=+-1 */ + if(hx>0) { + z = x - pio2_1; + if((ix&0xfffffff0)!=0x3fc90fd0) { /* 24+24 bit pi OK */ + y[0] = z - pio2_1t; + y[1] = (z-y[0])-pio2_1t; + } else { /* near pi/2, use 24+24+24 bit pi */ + z -= pio2_2; + y[0] = z - pio2_2t; + y[1] = (z-y[0])-pio2_2t; + } + return 1; + } else { /* negative x */ + z = x + pio2_1; + if((ix&0xfffffff0)!=0x3fc90fd0) { /* 24+24 bit pi OK */ + y[0] = z + pio2_1t; + y[1] = (z-y[0])+pio2_1t; + } else { /* near pi/2, use 24+24+24 bit pi */ + z += pio2_2; + y[0] = z + pio2_2t; + y[1] = (z-y[0])+pio2_2t; + } + return -1; + } + } + if(ix<=0x43490f80) { /* |x| ~<= 2^7*(pi/2), medium size */ + t = fabsf(x); + n = (__int32_t) (t*invpio2+half); + fn = (float)n; + r = t-fn*pio2_1; + w = fn*pio2_1t; /* 1st round good to 40 bit */ + if(n<32&&(ix&0xffffff00)!=npio2_hw[n-1]) { + y[0] = r-w; /* quick check no cancellation */ + } else { + __uint32_t high; + j = ix>>23; + y[0] = r-w; + high = CYG_LIBM_WORD(y[0]); + i = j-((high>>23)&0xff); + if(i>8) { /* 2nd iteration needed, good to 57 */ + t = r; + w = fn*pio2_2; + r = t-w; + w = fn*pio2_2t-((t-r)-w); + y[0] = r-w; + high = CYG_LIBM_WORD(y[0]); + i = j-((high>>23)&0xff); + if(i>25) { /* 3rd iteration need, 74 bits acc */ + t = r; /* will cover all possible cases */ + w = fn*pio2_3; + r = t-w; + w = fn*pio2_3t-((t-r)-w); + y[0] = r-w; + } + } + } + y[1] = (r-y[0])-w; + if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;} + else return n; + } + /* + * all other (large) arguments + */ + if(!FLT_UWORD_IS_FINITE(ix)) { + y[0]=y[1]=x-x; return 0; + } + /* set z = scalbn(|x|,ilogb(x)-7) */ + e0 = (int)((ix>>23)-134); /* e0 = ilogb(z)-7; */ + SET_FLOAT_WORD(z, ix - ((__int32_t)e0<<23)); + for(i=0;i<2;i++) { + tx[i] = (float)((__int32_t)(z)); + z = (z-tx[i])*two8; + } + tx[2] = z; + nx = 3; + while(tx[nx-1]==zero) nx--; /* skip zero term */ + n = __kernel_rem_pio2f(tx,y,e0,nx,2,two_over_pi); + if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;} + return n; +} + +#endif // ifdef CYGPKG_LIBM + +// EOF ef_rem_pio2.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-core/ef_remainder.c @@ -0,0 +1,135 @@ +//=========================================================================== +// +// ef_remainder.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* ef_remainder.c -- float version of e_remainder.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static const float zero = 0.0; +#else +static float zero = 0.0; +#endif + + +#ifdef __STDC__ + float __ieee754_remainderf(float x, float p) +#else + float __ieee754_remainderf(x,p) + float x,p; +#endif +{ + __int32_t hx,hp; + __uint32_t sx; + float p_half; + + hx = CYG_LIBM_WORD(x); + hp = CYG_LIBM_WORD(p); + sx = hx&0x80000000; + hp &= 0x7fffffff; + hx &= 0x7fffffff; + + /* purge off exception values */ + if(FLT_UWORD_IS_ZERO(hp)|| + !FLT_UWORD_IS_FINITE(hx)|| + FLT_UWORD_IS_NAN(hp)) + return (x*p)/(x*p); + + + if (hp<=FLT_UWORD_HALF_MAX) x = __ieee754_fmodf(x,p+p); /* now x < 2p */ + if ((hx-hp)==0) return zero*x; + x = fabsf(x); + p = fabsf(p); + if (hp<0x01000000) { + if(x+x>p) { + x-=p; + if(x+x>=p) x -= p; + } + } else { + p_half = (float)0.5*p; + if(x>p_half) { + x-=p; + if(x>=p_half) x -= p; + } + } + hx = CYG_LIBM_WORD(x); + SET_FLOAT_WORD(x,hx^sx); + return x; +} + +#endif // ifdef CYGPKG_LIBM + +// EOF ef_remainder.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-core/ef_scalb.c @@ -0,0 +1,118 @@ +//=========================================================================== +// +// ef_scalb.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* ef_scalb.c -- float version of e_scalb.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" + +#ifdef CYGFUN_LIBM_SVID3_scalb +#ifdef __STDC__ + float __ieee754_scalbf(float x, float fn) +#else + float __ieee754_scalbf(float x, int fn) +#endif +#else +#ifdef __STDC__ + float __ieee754_scalbf(float x, float fn) +#else + float __ieee754_scalbf(x,fn) + float x, fn; +#endif +#endif +{ +#ifdef CYGFUN_LIBM_SVID3_scalb + return scalbnf(x,fn); +#else + if (isnan(x)||isnan(fn)) return x*fn; + if (!finitef(fn)) { + if(fn>(float)0.0) return x*fn; + else return x/(-fn); + } + if (rintf(fn)!=fn) return (fn-fn)/(fn-fn); +#if INT_MAX > 65000 + if ( fn > (float)65000.0) return scalbnf(x, 65000); + if (-fn > (float)65000.0) return scalbnf(x,-65000); +#else + if ( fn > (float)32000.0) return scalbnf(x, 32000); + if (-fn > (float)32000.0) return scalbnf(x,-32000); +#endif + return scalbnf(x,(int)fn); +#endif +} + +#endif // ifdef CYGPKG_LIBM + +// EOF e_scalb.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-core/ef_sinh.c @@ -0,0 +1,130 @@ +//=========================================================================== +// +// ef_sinh.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* ef_sinh.c -- float version of e_sinh.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static const float one = 1.0, shuge = 1.0e37; +#else +static float one = 1.0, shuge = 1.0e37; +#endif + +#ifdef __STDC__ + float __ieee754_sinhf(float x) +#else + float __ieee754_sinhf(x) + float x; +#endif +{ + float t,w,h; + __int32_t ix,jx; + + jx = CYG_LIBM_WORD(x); + ix = jx&0x7fffffff; + + /* x is INF or NaN */ + if(!FLT_UWORD_IS_FINITE(ix)) return x+x; + + h = 0.5; + if (jx<0) h = -h; + /* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */ + if (ix < 0x41b00000) { /* |x|<22 */ + if (ix<0x31800000) /* |x|<2**-28 */ + if(shuge+x>one) return x;/* sinh(tiny) = tiny with inexact */ + t = expm1f(fabsf(x)); + if(ix<0x3f800000) return h*((float)2.0*t-t*t/(t+one)); + return h*(t+t/(t+one)); + } + + /* |x| in [22, log(maxdouble)] return 0.5*exp(|x|) */ + if (ix<=FLT_UWORD_LOG_MAX) return h*__ieee754_expf(fabsf(x)); + + /* |x| in [log(maxdouble), overflowthresold] */ + if (ix<=FLT_UWORD_LOG_2MAX) { + w = __ieee754_expf((float)0.5*fabsf(x)); + t = h*w; + return t*w; + } + + /* |x| > overflowthresold, sinh(x) overflow */ + return x*shuge; +} + +#endif // ifdef CYGPKG_LIBM + +// EOF ef_sinh.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/ieee754-core/ef_sqrt.c @@ -0,0 +1,148 @@ +//=========================================================================== +// +// ef_sqrt.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* ef_sqrtf.c -- float version of e_sqrt.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" + +static const float one = 1.0, tiny=1.0e-30; + +float __ieee754_sqrtf(float x) +{ + float z; + cyg_uint32 r,hx; + cyg_int32 ix,s,q,m,t,i; + + ix = CYG_LIBM_WORD(x); + + hx = ix&0x7fffffff; + + /* take care of Inf and NaN */ + if(!FLT_UWORD_IS_FINITE(hx)) + return x*x+x; /* sqrt(NaN)=NaN, sqrt(+inf)=+inf + sqrt(-inf)=sNaN */ + /* take care of zero and -ves */ + if(FLT_UWORD_IS_ZERO(hx)) return x;/* sqrt(+-0) = +-0 */ + if(ix<0) return (x-x)/(x-x); /* sqrt(-ve) = sNaN */ + + /* normalize x */ + m = (ix>>23); + if(FLT_UWORD_IS_SUBNORMAL(hx)) { /* subnormal x */ + for(i=0;(ix&0x00800000L)==0;i++) ix<<=1; + m -= i-1; + } + m -= 127; /* unbias exponent */ + ix = (ix&0x007fffffL)|0x00800000L; + if(m&1) /* odd m, double x to make it even */ + ix += ix; + m >>= 1; /* m = [m/2] */ + + /* generate sqrt(x) bit by bit */ + ix += ix; + q = s = 0; /* q = sqrt(x) */ + r = 0x01000000L; /* r = moving bit from right to left */ + + while(r!=0) { + t = s+r; + if(t<=ix) { + s = t+r; + ix -= t; + q += r; + } + ix += ix; + r>>=1; + } + + /* use floating add to find out rounding direction */ + if(ix!=0) { + z = one-tiny; /* trigger inexact flag */ + if (z>=one) { + z = one+tiny; + if (z>one) + q += 2; + else + q += (q&1); + } + } + ix = (q>>1)+0x3f000000L; + ix += (m <<23); + SET_FLOAT_WORD(z,ix); + return z; +} + +#endif // ifdef CYGPKG_LIBM + +// EOF ef_sqrt.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/internal/kf_cos.c @@ -0,0 +1,126 @@ +//=========================================================================== +// +// kf_cos.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* kf_cos.c -- float version of k_cos.c + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +one = 1.0000000000e+00, /* 0x3f800000 */ +C1 = 4.1666667908e-02, /* 0x3d2aaaab */ +C2 = -1.3888889225e-03, /* 0xbab60b61 */ +C3 = 2.4801587642e-05, /* 0x37d00d01 */ +C4 = -2.7557314297e-07, /* 0xb493f27c */ +C5 = 2.0875723372e-09, /* 0x310f74f6 */ +C6 = -1.1359647598e-11; /* 0xad47d74e */ + +#ifdef __STDC__ + float __kernel_cosf(float x, float y) +#else + float __kernel_cosf(x, y) + float x,y; +#endif +{ + float a,hz,z,r,qx; + __int32_t ix; + ix = CYG_LIBM_WORD(x); + ix &= 0x7fffffff; /* ix = |x|'s high word*/ + if(ix<0x32000000) { /* if x < 2**27 */ + if(((int)x)==0) return one; /* generate inexact */ + } + z = x*x; + r = z*(C1+z*(C2+z*(C3+z*(C4+z*(C5+z*C6))))); + if(ix < 0x3e99999a) /* if |x| < 0.3 */ + return one - ((float)0.5*z - (z*r - x*y)); + else { + if(ix > 0x3f480000) { /* x > 0.78125 */ + qx = (float)0.28125; + } else { + SET_FLOAT_WORD(qx,ix-0x01000000); /* x/4 */ + } + hz = (float)0.5*z-qx; + a = one-qx; + return a - (hz - (z*r-x*y)); + } +} + +#endif // ifdef CYGPKG_LIBM + +// EOF kf_cos.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/internal/kf_rem_pio2.c @@ -0,0 +1,275 @@ +//=========================================================================== +// +// kf_rem_pio2.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* kf_rem_pio2.c -- float version of k_rem_pio2.c + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" + +/* In the float version, the input parameter x contains 8 bit + integers, not 24 bit integers. 113 bit precision is not supported. */ + +#ifdef __STDC__ +static const int init_jk[] = {4,7,9}; /* initial value for jk */ +#else +static int init_jk[] = {4,7,9}; +#endif + +#ifdef __STDC__ +static const float PIo2[] = { +#else +static float PIo2[] = { +#endif + 1.5703125000e+00, /* 0x3fc90000 */ + 4.5776367188e-04, /* 0x39f00000 */ + 2.5987625122e-05, /* 0x37da0000 */ + 7.5437128544e-08, /* 0x33a20000 */ + 6.0026650317e-11, /* 0x2e840000 */ + 7.3896444519e-13, /* 0x2b500000 */ + 5.3845816694e-15, /* 0x27c20000 */ + 5.6378512969e-18, /* 0x22d00000 */ + 8.3009228831e-20, /* 0x1fc40000 */ + 3.2756352257e-22, /* 0x1bc60000 */ + 6.3331015649e-25, /* 0x17440000 */ +}; + +#ifdef __STDC__ +static const float +#else +static float +#endif +zero = 0.0, +one = 1.0, +two8 = 2.5600000000e+02, /* 0x43800000 */ +twon8 = 3.9062500000e-03; /* 0x3b800000 */ + +#ifdef __STDC__ + int __kernel_rem_pio2f(float *x, float *y, int e0, int nx, int prec, const __int32_t *ipio2) +#else + int __kernel_rem_pio2f(x,y,e0,nx,prec,ipio2) + float x[], y[]; int e0,nx,prec; __int32_t ipio2[]; +#endif +{ + __int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih; + float z,fw,f[20],fq[20],q[20]; + + /* initialize jk*/ + jk = init_jk[prec]; + jp = jk; + + /* determine jx,jv,q0, note that 3>q0 */ + jx = nx-1; + jv = (e0-3)/8; if(jv<0) jv=0; + q0 = e0-8*(jv+1); + + /* set up f[0] to f[jx+jk] where f[jx+jk] = ipio2[jv+jk] */ + j = jv-jx; m = jx+jk; + for(i=0;i<=m;i++,j++) f[i] = (j<0)? zero : (float) ipio2[j]; + + /* compute q[0],q[1],...q[jk] */ + for (i=0;i<=jk;i++) { + for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw; + } + + jz = jk; +recompute: + /* distill q[] into iq[] reversingly */ + for(i=0,j=jz,z=q[jz];j>0;i++,j--) { + fw = (float)((__int32_t)(twon8* z)); + iq[i] = (__int32_t)(z-two8*fw); + z = q[j-1]+fw; + } + + /* compute n */ + z = scalbnf(z,(int)q0); /* actual value of z */ + z -= (float)8.0*floorf(z*(float)0.125); /* trim off integer >= 8 */ + n = (__int32_t) z; + z -= (float)n; + ih = 0; + if(q0>0) { /* need iq[jz-1] to determine n */ + i = (iq[jz-1]>>(8-q0)); n += i; + iq[jz-1] -= i<<(8-q0); + ih = iq[jz-1]>>(7-q0); + } + else if(q0==0) ih = iq[jz-1]>>8; + else if(z>=(float)0.5) ih=2; + + if(ih>0) { /* q > 0.5 */ + n += 1; carry = 0; + for(i=0;i<jz ;i++) { /* compute 1-q */ + j = iq[i]; + if(carry==0) { + if(j!=0) { + carry = 1; iq[i] = 0x100- j; + } + } else iq[i] = 0xff - j; + } + if(q0>0) { /* rare case: chance is 1 in 12 */ + switch(q0) { + case 1: + iq[jz-1] &= 0x7f; break; + case 2: + iq[jz-1] &= 0x3f; break; + } + } + if(ih==2) { + z = one - z; + if(carry!=0) z -= scalbnf(one,(int)q0); + } + } + + /* check if recomputation is needed */ + if(z==zero) { + j = 0; + for (i=jz-1;i>=jk;i--) j |= iq[i]; + if(j==0) { /* need recomputation */ + for(k=1;iq[jk-k]==0;k++); /* k = no. of terms needed */ + + for(i=jz+1;i<=jz+k;i++) { /* add q[jz+1] to q[jz+k] */ + f[jx+i] = (float) ipio2[jv+i]; + for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; + q[i] = fw; + } + jz += k; + goto recompute; + } + } + + /* chop off zero terms */ + if(z==(float)0.0) { + jz -= 1; q0 -= 8; + while(iq[jz]==0) { jz--; q0-=8;} + } else { /* break z into 8-bit if necessary */ + z = scalbnf(z,-(int)q0); + if(z>=two8) { + fw = (float)((__int32_t)(twon8*z)); + iq[jz] = (__int32_t)(z-two8*fw); + jz += 1; q0 += 8; + iq[jz] = (__int32_t) fw; + } else iq[jz] = (__int32_t) z ; + } + + /* convert integer "bit" chunk to floating-point value */ + fw = scalbnf(one,(int)q0); + for(i=jz;i>=0;i--) { + q[i] = fw*(float)iq[i]; fw*=twon8; + } + + /* compute PIo2[0,...,jp]*q[jz,...,0] */ + for(i=jz;i>=0;i--) { + for(fw=0.0,k=0;k<=jp&&k<=jz-i;k++) fw += PIo2[k]*q[i+k]; + fq[jz-i] = fw; + } + + /* compress fq[] into y[] */ + switch(prec) { + case 0: + fw = 0.0; + for (i=jz;i>=0;i--) fw += fq[i]; + y[0] = (ih==0)? fw: -fw; + break; + case 1: + case 2: + fw = 0.0; + for (i=jz;i>=0;i--) fw += fq[i]; + y[0] = (ih==0)? fw: -fw; + fw = fq[0]-fw; + for (i=1;i<=jz;i++) fw += fq[i]; + y[1] = (ih==0)? fw: -fw; + break; + case 3: /* painful */ + for (i=jz;i>0;i--) { + fw = fq[i-1]+fq[i]; + fq[i] += fq[i-1]-fw; + fq[i-1] = fw; + } + for (i=jz;i>1;i--) { + fw = fq[i-1]+fq[i]; + fq[i] += fq[i-1]-fw; + fq[i-1] = fw; + } + for (fw=0.0,i=jz;i>=2;i--) fw += fq[i]; + if(ih==0) { + y[0] = fq[0]; y[1] = fq[1]; y[2] = fw; + } else { + y[0] = -fq[0]; y[1] = -fq[1]; y[2] = -fw; + } + } + return n&7; +} + +#endif // ifdef CYGPKG_LIBM + +// EOF kf_rem_pio2.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/internal/kf_sin.c @@ -0,0 +1,116 @@ +//=========================================================================== +// +// kf_sin.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* kf_sin.c -- float version of k_sin.c + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +half = 5.0000000000e-01,/* 0x3f000000 */ +S1 = -1.6666667163e-01, /* 0xbe2aaaab */ +S2 = 8.3333337680e-03, /* 0x3c088889 */ +S3 = -1.9841270114e-04, /* 0xb9500d01 */ +S4 = 2.7557314297e-06, /* 0x3638ef1b */ +S5 = -2.5050759689e-08, /* 0xb2d72f34 */ +S6 = 1.5896910177e-10; /* 0x2f2ec9d3 */ + +#ifdef __STDC__ + float __kernel_sinf(float x, float y, int iy) +#else + float __kernel_sinf(x, y, iy) + float x,y; int iy; /* iy=0 if y is zero */ +#endif +{ + float z,r,v; + __int32_t ix; + ix = CYG_LIBM_WORD(x); + ix &= 0x7fffffff; /* high word of x */ + if(ix<0x32000000) /* |x| < 2**-27 */ + {if((int)x==0) return x;} /* generate inexact */ + z = x*x; + v = z*x; + r = S2+z*(S3+z*(S4+z*(S5+z*S6))); + if(iy==0) return x+v*(S1+z*r); + else return x-((z*(half*y-v*r)-y)-v*S1); +} + +#endif // ifdef CYGPKG_LIBM + +// EOF kf_sin.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/internal/kf_tan.c @@ -0,0 +1,163 @@ +//=========================================================================== +// +// kf_tan.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* kf_tan.c -- float version of k_tan.c + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" +#ifdef __STDC__ +static const float +#else +static float +#endif +one = 1.0000000000e+00, /* 0x3f800000 */ +pio4 = 7.8539812565e-01, /* 0x3f490fda */ +pio4lo= 3.7748947079e-08, /* 0x33222168 */ +T[] = { + 3.3333334327e-01, /* 0x3eaaaaab */ + 1.3333334029e-01, /* 0x3e088889 */ + 5.3968254477e-02, /* 0x3d5d0dd1 */ + 2.1869488060e-02, /* 0x3cb327a4 */ + 8.8632395491e-03, /* 0x3c11371f */ + 3.5920790397e-03, /* 0x3b6b6916 */ + 1.4562094584e-03, /* 0x3abede48 */ + 5.8804126456e-04, /* 0x3a1a26c8 */ + 2.4646313977e-04, /* 0x398137b9 */ + 7.8179444245e-05, /* 0x38a3f445 */ + 7.1407252108e-05, /* 0x3895c07a */ + -1.8558637748e-05, /* 0xb79bae5f */ + 2.5907305826e-05, /* 0x37d95384 */ +}; + +#ifdef __STDC__ + float __kernel_tanf(float x, float y, int iy) +#else + float __kernel_tanf(x, y, iy) + float x,y; int iy; +#endif +{ + float z,r,v,w,s; + __int32_t ix,hx; + hx = CYG_LIBM_WORD(x); + ix = hx&0x7fffffff; /* high word of |x| */ + if(ix<0x31800000) /* x < 2**-28 */ + {if((int)x==0) { /* generate inexact */ + if((ix|(iy+1))==0) return one/fabsf(x); + else return (iy==1)? x: -one/x; + } + } + if(ix>=0x3f2ca140) { /* |x|>=0.6744 */ + if(hx<0) {x = -x; y = -y;} + z = pio4-x; + w = pio4lo-y; + x = z+w; y = 0.0; + } + z = x*x; + w = z*z; + /* Break x^5*(T[1]+x^2*T[2]+...) into + * x^5(T[1]+x^4*T[3]+...+x^20*T[11]) + + * x^5(x^2*(T[2]+x^4*T[4]+...+x^22*[T12])) + */ + r = T[1]+w*(T[3]+w*(T[5]+w*(T[7]+w*(T[9]+w*T[11])))); + v = z*(T[2]+w*(T[4]+w*(T[6]+w*(T[8]+w*(T[10]+w*T[12]))))); + s = z*x; + r = y + z*(s*(r+v)+y); + r += T[0]*s; + w = x+r; + if(ix>=0x3f2ca140) { + v = (float)iy; + return (float)(1-((hx>>30)&2))*(v-(float)2.0*(x-(w*w/(w+v)-r))); + } + if(iy==1) return w; + else { /* if allow error up to 2 ulp, + simply return -1.0/(x+r) here */ + /* compute -1.0/(x+r) accurately */ + float a,t; + __int32_t i; + z = w; + i = CYG_LIBM_WORD(z); + SET_FLOAT_WORD(z,i&0xfffff000); + v = r-(z - x); /* z+v = r+x */ + t = a = -(float)1.0/w; /* a = -1.0/w */ + i = CYG_LIBM_WORD(t); + SET_FLOAT_WORD(t,i&0xfffff000); + s = (float)1.0+t*z; + return t+a*(s+t*v); + } +} + +#endif // ifdef CYGPKG_LIBM + +// EOF kf_tan.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/portable-api/sf_asinh.c @@ -0,0 +1,118 @@ +//=========================================================================== +// +// sf_asinh.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* sf_asinh.c -- float version of s_asinh.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +one = 1.0000000000e+00, /* 0x3F800000 */ +ln2 = 6.9314718246e-01, /* 0x3f317218 */ +huge= 1.0000000000e+30; + +#ifdef __STDC__ + float asinhf(float x) +#else + float asinhf(x) + float x; +#endif +{ + float t,w; + __int32_t hx,ix; + hx = CYG_LIBM_WORD(x); + ix = hx&0x7fffffff; + if(!FLT_UWORD_IS_FINITE(ix)) return x+x; /* x is inf or NaN */ + if(ix< 0x31800000) { /* |x|<2**-28 */ + if(huge+x>one) return x; /* return x inexact except 0 */ + } + if(ix>0x4d800000) { /* |x| > 2**28 */ + w = __ieee754_logf(fabsf(x))+ln2; + } else if (ix>0x40000000) { /* 2**28 > |x| > 2.0 */ + t = fabsf(x); + w = __ieee754_logf((float)2.0*t+one/(__ieee754_sqrtf(x*x+one)+t)); + } else { /* 2.0 > |x| > 2**-28 */ + t = x*x; + w =log1pf(fabsf(x)+t/(one+__ieee754_sqrtf(one+t))); + } + if(hx>0) return w; else return -w; +} + +#endif // ifdef CYGPKG_LIBM + +// EOF sf_asinh.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/portable-api/sf_atan.c @@ -0,0 +1,183 @@ +//=========================================================================== +// +// sf_atan.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* sf_atan.c -- float version of s_atan.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + * + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static const float atanhi[] = { +#else +static float atanhi[] = { +#endif + 4.6364760399e-01, /* atan(0.5)hi 0x3eed6338 */ + 7.8539812565e-01, /* atan(1.0)hi 0x3f490fda */ + 9.8279368877e-01, /* atan(1.5)hi 0x3f7b985e */ + 1.5707962513e+00, /* atan(inf)hi 0x3fc90fda */ +}; + +#ifdef __STDC__ +static const float atanlo[] = { +#else +static float atanlo[] = { +#endif + 5.0121582440e-09, /* atan(0.5)lo 0x31ac3769 */ + 3.7748947079e-08, /* atan(1.0)lo 0x33222168 */ + 3.4473217170e-08, /* atan(1.5)lo 0x33140fb4 */ + 7.5497894159e-08, /* atan(inf)lo 0x33a22168 */ +}; + +#ifdef __STDC__ +static const float aT[] = { +#else +static float aT[] = { +#endif + 3.3333334327e-01, /* 0x3eaaaaaa */ + -2.0000000298e-01, /* 0xbe4ccccd */ + 1.4285714924e-01, /* 0x3e124925 */ + -1.1111110449e-01, /* 0xbde38e38 */ + 9.0908870101e-02, /* 0x3dba2e6e */ + -7.6918758452e-02, /* 0xbd9d8795 */ + 6.6610731184e-02, /* 0x3d886b35 */ + -5.8335702866e-02, /* 0xbd6ef16b */ + 4.9768779427e-02, /* 0x3d4bda59 */ + -3.6531571299e-02, /* 0xbd15a221 */ + 1.6285819933e-02, /* 0x3c8569d7 */ +}; + +#ifdef __STDC__ + static const float +#else + static float +#endif +one = 1.0, +huge = 1.0e30; + +#ifdef __STDC__ + float atanf(float x) +#else + float atanf(x) + float x; +#endif +{ + float w,s1,s2,z; + __int32_t ix,hx,id; + + hx = CYG_LIBM_WORD(x); + ix = hx&0x7fffffff; + if(ix>=0x50800000) { /* if |x| >= 2^34 */ + if(FLT_UWORD_IS_NAN(ix)) + return x+x; /* NaN */ + if(hx>0) return atanhi[3]+atanlo[3]; + else return -atanhi[3]-atanlo[3]; + } if (ix < 0x3ee00000) { /* |x| < 0.4375 */ + if (ix < 0x31000000) { /* |x| < 2^-29 */ + if(huge+x>one) return x; /* raise inexact */ + } + id = -1; + } else { + x = fabsf(x); + if (ix < 0x3f980000) { /* |x| < 1.1875 */ + if (ix < 0x3f300000) { /* 7/16 <=|x|<11/16 */ + id = 0; x = ((float)2.0*x-one)/((float)2.0+x); + } else { /* 11/16<=|x|< 19/16 */ + id = 1; x = (x-one)/(x+one); + } + } else { + if (ix < 0x401c0000) { /* |x| < 2.4375 */ + id = 2; x = (x-(float)1.5)/(one+(float)1.5*x); + } else { /* 2.4375 <= |x| < 2^66 */ + id = 3; x = -(float)1.0/x; + } + }} + /* end of argument reduction */ + z = x*x; + w = z*z; + /* break sum from i=0 to 10 aT[i]z**(i+1) into odd and even poly */ + s1 = z*(aT[0]+w*(aT[2]+w*(aT[4]+w*(aT[6]+w*(aT[8]+w*aT[10]))))); + s2 = w*(aT[1]+w*(aT[3]+w*(aT[5]+w*(aT[7]+w*aT[9])))); + if (id<0) return x - x*(s1+s2); + else { + z = atanhi[id] - ((x*(s1+s2) - atanlo[id]) - x); + return (hx<0)? -z:z; + } +} + + +#endif // ifdef CYGPKG_LIBM + +// EOF sf_atan.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/portable-api/sf_cbrt.c @@ -0,0 +1,147 @@ +//=========================================================================== +// +// sf_cbrt.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* sf_cbrt.c -- float version of s_cbrt.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + * + */ + + +#include "mathincl/fdlibm.h" + +/* cbrtf(x) + * Return cube root of x + */ +#ifdef __STDC__ +static const __uint32_t +#else +static __uint32_t +#endif + B1 = 709958130, /* B1 = (84+2/3-0.03306235651)*2**23 */ + B2 = 642849266; /* B2 = (76+2/3-0.03306235651)*2**23 */ + +#ifdef __STDC__ +static const float +#else +static float +#endif +C = 5.4285717010e-01, /* 19/35 = 0x3f0af8b0 */ +D = -7.0530611277e-01, /* -864/1225 = 0xbf348ef1 */ +E = 1.4142856598e+00, /* 99/70 = 0x3fb50750 */ +F = 1.6071428061e+00, /* 45/28 = 0x3fcdb6db */ +G = 3.5714286566e-01; /* 5/14 = 0x3eb6db6e */ + +#ifdef __STDC__ + float cbrtf(float x) +#else + float cbrtf(x) + float x; +#endif +{ + __int32_t hx; + float r,s,t; + __uint32_t sign; + __uint32_t high; + + hx = CYG_LIBM_WORD(x); + sign=hx&0x80000000; /* sign= sign(x) */ + hx ^=sign; + if(!FLT_UWORD_IS_FINITE(hx)) + return(x+x); /* cbrt(NaN,INF) is itself */ + if(FLT_UWORD_IS_ZERO(hx)) + return(x); /* cbrt(0) is itself */ + + SET_FLOAT_WORD(x,hx); /* x <- |x| */ + /* rough cbrt to 5 bits */ + if(FLT_UWORD_IS_SUBNORMAL(hx)) /* subnormal number */ + {SET_FLOAT_WORD(t,0x4b800000); /* set t= 2**24 */ + t*=x; high = CYG_LIBM_WORD(t); SET_FLOAT_WORD(t,high/3+B2); + } + else + SET_FLOAT_WORD(t,hx/3+B1); + + + /* new cbrt to 23 bits */ + r=t*t/x; + s=C+r*t; + t*=G+F/(s+E+D/s); + + /* retore the sign bit */ + high = CYG_LIBM_WORD(t); + SET_FLOAT_WORD(t,high|sign); + return(t); +} + +#endif // ifdef CYGPKG_LIBM + +// EOF sf_cbrt.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/portable-api/sf_ceil.c @@ -0,0 +1,124 @@ +//=========================================================================== +// +// sf_ceil.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* sf_ceil.c -- float version of s_ceil.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static const float huge = 1.0e30; +#else +static float huge = 1.0e30; +#endif + +#ifdef __STDC__ + float ceilf(float x) +#else + float ceilf(x) + float x; +#endif +{ + __int32_t i0,j0; + __uint32_t i,ix; + i0 = CYG_LIBM_WORD(x); + ix = (i0&0x7fffffff); + j0 = (ix>>23)-0x7f; + if(j0<23) { + if(j0<0) { /* raise inexact if x != 0 */ + if(huge+x>(float)0.0) {/* return 0*sign(x) if |x|<1 */ + if(i0<0) {i0=0x80000000;} + else if(!FLT_UWORD_IS_ZERO(ix)) { i0=0x3f800000;} + } + } else { + i = (0x007fffff)>>j0; + if((i0&i)==0) return x; /* x is integral */ + if(huge+x>(float)0.0) { /* raise inexact flag */ + if(i0>0) i0 += (0x00800000)>>j0; + i0 &= (~i); + } + } + } else { + if(!FLT_UWORD_IS_FINITE(ix)) return x+x; /* inf or NaN */ + else return x; /* x is integral */ + } + SET_FLOAT_WORD(x,i0); + return x; +} + + +#endif // ifdef CYGPKG_LIBM + +// EOF sf_ceil.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/portable-api/sf_copysign.c @@ -0,0 +1,103 @@ +//=========================================================================== +// +// sf_copysign.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* sf_copysign.c -- float version of s_copysign.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * copysignf(float x, float y) + * copysignf(x,y) returns a value with the magnitude of x and + * with the sign bit of y. + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ + float copysignf(float x, float y) +#else + float copysignf(x,y) + float x,y; +#endif +{ + __uint32_t ix,iy; + ix = CYG_LIBM_WORD(x); + iy = CYG_LIBM_WORD(y); + SET_FLOAT_WORD(x,(ix&0x7fffffff)|(iy&0x80000000)); + return x; +} + +#endif // ifdef CYGPKG_LIBM + +// EOF sf_copysign.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/portable-api/sf_cos.c @@ -0,0 +1,120 @@ +//=========================================================================== +// +// sf_cos.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + +/* sf_cos.c -- float version of s_cos.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static const float one=1.0; +#else +static float one=1.0; +#endif + +#ifdef __STDC__ + float cosf(float x) +#else + float cosf(x) + float x; +#endif +{ + float y[2],z=0.0; + __int32_t n,ix; + + ix = CYG_LIBM_WORD(x); + + /* |x| ~< pi/4 */ + ix &= 0x7fffffff; + if(ix <= 0x3f490fd8) return __kernel_cosf(x,z); + + /* cos(Inf or NaN) is NaN */ + else if (!FLT_UWORD_IS_FINITE(ix)) return x-x; + + /* argument reduction needed */ + else { + n = __ieee754_rem_pio2f(x,y); + switch(n&3) { + case 0: return __kernel_cosf(y[0],y[1]); + case 1: return -__kernel_sinf(y[0],y[1],1); + case 2: return -__kernel_cosf(y[0],y[1]); + default: + return __kernel_sinf(y[0],y[1],1); + } + } +} + +#endif // ifdef CYGPKG_LIBM + +// EOF sf_cos.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/portable-api/sf_erf.c @@ -0,0 +1,285 @@ +//=========================================================================== +// +// sf_erf.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* sf_erf.c -- float version of s_erf.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +tiny = 1e-30, +half= 5.0000000000e-01, /* 0x3F000000 */ +one = 1.0000000000e+00, /* 0x3F800000 */ +two = 2.0000000000e+00, /* 0x40000000 */ + /* c = (subfloat)0.84506291151 */ +erx = 8.4506291151e-01, /* 0x3f58560b */ +/* + * Coefficients for approximation to erf on [0,0.84375] + */ +efx = 1.2837916613e-01, /* 0x3e0375d4 */ +efx8= 1.0270333290e+00, /* 0x3f8375d4 */ +pp0 = 1.2837916613e-01, /* 0x3e0375d4 */ +pp1 = -3.2504209876e-01, /* 0xbea66beb */ +pp2 = -2.8481749818e-02, /* 0xbce9528f */ +pp3 = -5.7702702470e-03, /* 0xbbbd1489 */ +pp4 = -2.3763017452e-05, /* 0xb7c756b1 */ +qq1 = 3.9791721106e-01, /* 0x3ecbbbce */ +qq2 = 6.5022252500e-02, /* 0x3d852a63 */ +qq3 = 5.0813062117e-03, /* 0x3ba68116 */ +qq4 = 1.3249473704e-04, /* 0x390aee49 */ +qq5 = -3.9602282413e-06, /* 0xb684e21a */ +/* + * Coefficients for approximation to erf in [0.84375,1.25] + */ +pa0 = -2.3621185683e-03, /* 0xbb1acdc6 */ +pa1 = 4.1485610604e-01, /* 0x3ed46805 */ +pa2 = -3.7220788002e-01, /* 0xbebe9208 */ +pa3 = 3.1834661961e-01, /* 0x3ea2fe54 */ +pa4 = -1.1089469492e-01, /* 0xbde31cc2 */ +pa5 = 3.5478305072e-02, /* 0x3d1151b3 */ +pa6 = -2.1663755178e-03, /* 0xbb0df9c0 */ +qa1 = 1.0642088205e-01, /* 0x3dd9f331 */ +qa2 = 5.4039794207e-01, /* 0x3f0a5785 */ +qa3 = 7.1828655899e-02, /* 0x3d931ae7 */ +qa4 = 1.2617121637e-01, /* 0x3e013307 */ +qa5 = 1.3637083583e-02, /* 0x3c5f6e13 */ +qa6 = 1.1984500103e-02, /* 0x3c445aa3 */ +/* + * Coefficients for approximation to erfc in [1.25,1/0.35] + */ +ra0 = -9.8649440333e-03, /* 0xbc21a093 */ +ra1 = -6.9385856390e-01, /* 0xbf31a0b7 */ +ra2 = -1.0558626175e+01, /* 0xc128f022 */ +ra3 = -6.2375331879e+01, /* 0xc2798057 */ +ra4 = -1.6239666748e+02, /* 0xc322658c */ +ra5 = -1.8460508728e+02, /* 0xc3389ae7 */ +ra6 = -8.1287437439e+01, /* 0xc2a2932b */ +ra7 = -9.8143291473e+00, /* 0xc11d077e */ +sa1 = 1.9651271820e+01, /* 0x419d35ce */ +sa2 = 1.3765776062e+02, /* 0x4309a863 */ +sa3 = 4.3456588745e+02, /* 0x43d9486f */ +sa4 = 6.4538726807e+02, /* 0x442158c9 */ +sa5 = 4.2900814819e+02, /* 0x43d6810b */ +sa6 = 1.0863500214e+02, /* 0x42d9451f */ +sa7 = 6.5702495575e+00, /* 0x40d23f7c */ +sa8 = -6.0424413532e-02, /* 0xbd777f97 */ +/* + * Coefficients for approximation to erfc in [1/.35,28] + */ +rb0 = -9.8649431020e-03, /* 0xbc21a092 */ +rb1 = -7.9928326607e-01, /* 0xbf4c9dd4 */ +rb2 = -1.7757955551e+01, /* 0xc18e104b */ +rb3 = -1.6063638306e+02, /* 0xc320a2ea */ +rb4 = -6.3756646729e+02, /* 0xc41f6441 */ +rb5 = -1.0250950928e+03, /* 0xc480230b */ +rb6 = -4.8351919556e+02, /* 0xc3f1c275 */ +sb1 = 3.0338060379e+01, /* 0x41f2b459 */ +sb2 = 3.2579251099e+02, /* 0x43a2e571 */ +sb3 = 1.5367296143e+03, /* 0x44c01759 */ +sb4 = 3.1998581543e+03, /* 0x4547fdbb */ +sb5 = 2.5530502930e+03, /* 0x451f90ce */ +sb6 = 4.7452853394e+02, /* 0x43ed43a7 */ +sb7 = -2.2440952301e+01; /* 0xc1b38712 */ + +#ifdef __STDC__ + float erff(float x) +#else + float erff(x) + float x; +#endif +{ + __int32_t hx,ix,i; + float R,S,P,Q,s,y,z,r; + hx = CYG_LIBM_WORD(x); + ix = hx&0x7fffffff; + if(!FLT_UWORD_IS_FINITE(ix)) { /* erf(nan)=nan */ + i = ((__uint32_t)hx>>31)<<1; + return (float)(1-i)+one/x; /* erf(+-inf)=+-1 */ + } + + if(ix < 0x3f580000) { /* |x|<0.84375 */ + if(ix < 0x31800000) { /* |x|<2**-28 */ + if (ix < 0x04000000) + /*avoid underflow */ + return (float)0.125*((float)8.0*x+efx8*x); + return x + efx*x; + } + z = x*x; + r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4))); + s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5)))); + y = r/s; + return x + x*y; + } + if(ix < 0x3fa00000) { /* 0.84375 <= |x| < 1.25 */ + s = fabsf(x)-one; + P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6))))); + Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6))))); + if(hx>=0) return erx + P/Q; else return -erx - P/Q; + } + if (ix >= 0x40c00000) { /* inf>|x|>=6 */ + if(hx>=0) return one-tiny; else return tiny-one; + } + x = fabsf(x); + s = one/(x*x); + if(ix< 0x4036DB6E) { /* |x| < 1/0.35 */ + R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*( + ra5+s*(ra6+s*ra7)))))); + S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*( + sa5+s*(sa6+s*(sa7+s*sa8))))))); + } else { /* |x| >= 1/0.35 */ + R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*( + rb5+s*rb6))))); + S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*( + sb5+s*(sb6+s*sb7)))))); + } + ix = CYG_LIBM_WORD(x); + SET_FLOAT_WORD(z,ix&0xfffff000); + r = __ieee754_expf(-z*z-(float)0.5625)*__ieee754_expf((z-x)*(z+x)+R/S); + if(hx>=0) return one-r/x; else return r/x-one; +} + +#ifdef __STDC__ + float erfcf(float x) +#else + float erfcf(x) + float x; +#endif +{ + __int32_t hx,ix; + float R,S,P,Q,s,y,z,r; + hx = CYG_LIBM_WORD(x); + ix = hx&0x7fffffff; + if(!FLT_UWORD_IS_FINITE(ix)) { /* erfc(nan)=nan */ + /* erfc(+-inf)=0,2 */ + return (float)(((__uint32_t)hx>>31)<<1)+one/x; + } + + if(ix < 0x3f580000) { /* |x|<0.84375 */ + if(ix < 0x23800000) /* |x|<2**-56 */ + return one-x; + z = x*x; + r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4))); + s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5)))); + y = r/s; + if(hx < 0x3e800000) { /* x<1/4 */ + return one-(x+x*y); + } else { + r = x*y; + r += (x-half); + return half - r ; + } + } + if(ix < 0x3fa00000) { /* 0.84375 <= |x| < 1.25 */ + s = fabsf(x)-one; + P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6))))); + Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6))))); + if(hx>=0) { + z = one-erx; return z - P/Q; + } else { + z = erx+P/Q; return one+z; + } + } + if (ix < 0x41e00000) { /* |x|<28 */ + x = fabsf(x); + s = one/(x*x); + if(ix< 0x4036DB6D) { /* |x| < 1/.35 ~ 2.857143*/ + R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*( + ra5+s*(ra6+s*ra7)))))); + S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*( + sa5+s*(sa6+s*(sa7+s*sa8))))))); + } else { /* |x| >= 1/.35 ~ 2.857143 */ + if(hx<0&&ix>=0x40c00000) return two-tiny;/* x < -6 */ + R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*( + rb5+s*rb6))))); + S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*( + sb5+s*(sb6+s*sb7)))))); + } + ix = CYG_LIBM_WORD(x); + SET_FLOAT_WORD(z,ix&0xfffff000); + r = __ieee754_expf(-z*z-(float)0.5625)* + __ieee754_expf((z-x)*(z+x)+R/S); + if(hx>0) return r/x; else return two-r/x; + } else { + if(hx>0) return tiny*tiny; else return two-tiny; + } +} + +#endif // ifdef CYGPKG_LIBM + +// EOF sf_erf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/portable-api/sf_expm1.c @@ -0,0 +1,186 @@ +//=========================================================================== +// +// s_expm1.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2001-07-20 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +/* sf_expm1.c -- float version of s_expm1.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +one = 1.0, +huge = 1.0e+30, +tiny = 1.0e-30, +ln2_hi = 6.9313812256e-01,/* 0x3f317180 */ +ln2_lo = 9.0580006145e-06,/* 0x3717f7d1 */ +invln2 = 1.4426950216e+00,/* 0x3fb8aa3b */ + /* scaled coefficients related to expm1 */ +Q1 = -3.3333335072e-02, /* 0xbd088889 */ +Q2 = 1.5873016091e-03, /* 0x3ad00d01 */ +Q3 = -7.9365076090e-05, /* 0xb8a670cd */ +Q4 = 4.0082177293e-06, /* 0x36867e54 */ +Q5 = -2.0109921195e-07; /* 0xb457edbb */ + +#ifdef __STDC__ + float expm1f(float x) +#else + float expm1f(x) + float x; +#endif +{ + float y,hi,lo,c,t,e,hxs,hfx,r1; + __int32_t k,xsb; + __uint32_t hx; + + hx = CYG_LIBM_WORD(x); + xsb = hx&0x80000000; /* sign bit of x */ + if(xsb==0) y=x; else y= -x; /* y = |x| */ + hx &= 0x7fffffff; /* high word of |x| */ + + /* filter out huge and non-finite argument */ + if(hx >= 0x4195b844) { /* if |x|>=27*ln2 */ + if(FLT_UWORD_IS_NAN(hx)) + return x+x; + if(FLT_UWORD_IS_INFINITE(hx)) + return (xsb==0)? x:-1.0;/* exp(+-inf)={inf,-1} */ + if(xsb == 0 && hx > FLT_UWORD_LOG_MAX) /* if x>=o_threshold */ + return huge*huge; /* overflow */ + if(xsb!=0) { /* x < -27*ln2, return -1.0 with inexact */ + if(x+tiny<(float)0.0) /* raise inexact */ + return tiny-one; /* return -1 */ + } + } + + /* argument reduction */ + if(hx > 0x3eb17218) { /* if |x| > 0.5 ln2 */ + if(hx < 0x3F851592) { /* and |x| < 1.5 ln2 */ + if(xsb==0) + {hi = x - ln2_hi; lo = ln2_lo; k = 1;} + else + {hi = x + ln2_hi; lo = -ln2_lo; k = -1;} + } else { + k = invln2*x+((xsb==0)?(float)0.5:(float)-0.5); + t = k; + hi = x - t*ln2_hi; /* t*ln2_hi is exact here */ + lo = t*ln2_lo; + } + x = hi - lo; + c = (hi-x)-lo; + } + else if(hx < 0x33000000) { /* when |x|<2**-25, return x */ + t = huge+x; /* return x with inexact flags when x!=0 */ + return x - (t-(huge+x)); + } + else k = 0; + + /* x is now in primary range */ + hfx = (float)0.5*x; + hxs = x*hfx; + r1 = one+hxs*(Q1+hxs*(Q2+hxs*(Q3+hxs*(Q4+hxs*Q5)))); + t = (float)3.0-r1*hfx; + e = hxs*((r1-t)/((float)6.0 - x*t)); + if(k==0) return x - (x*e-hxs); /* c is 0 */ + else { + e = (x*(e-c)-c); + e -= hxs; + if(k== -1) return (float)0.5*(x-e)-(float)0.5; + if(k==1) { + if(x < (float)-0.25) return -(float)2.0*(e-(x+(float)0.5)); + else return one+(float)2.0*(x-e); + } + if (k <= -2 || k>56) { /* suffice to return exp(x)-1 */ + __int32_t i; + y = one-(e-x); + i = CYG_LIBM_WORD(y); + SET_FLOAT_WORD(y,i+(k<<23)); /* add k to y's exponent */ + return y-one; + } + t = one; + if(k<23) { + __int32_t i; + SET_FLOAT_WORD(t,0x3f800000 - (0x1000000>>k)); /* t=1-2^-k */ + y = t-(e-x); + i = CYG_LIBM_WORD(y); + SET_FLOAT_WORD(y,i+(k<<23)); /* add k to y's exponent */ + } else { + __int32_t i; + SET_FLOAT_WORD(t,((0x7f-k)<<23)); /* 2^-k */ + y = x-(e+t); + y += one; + i = CYG_LIBM_WORD(y); + SET_FLOAT_WORD(y,i+(k<<23)); /* add k to y's exponent */ + } + } + return y; +} +
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/portable-api/sf_fabs.c @@ -0,0 +1,100 @@ +//=========================================================================== +// +// sf_fabs.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* sf_fabs.c -- float version of s_fabs.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * fabsf(x) returns the absolute value of x. + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ + float fabsf(float x) +#else + float fabsf(x) + float x; +#endif +{ + __uint32_t ix; + ix = CYG_LIBM_WORD(x); + SET_FLOAT_WORD(x,ix&0x7fffffff); + return x; +} + +#endif // ifdef CYGPKG_LIBM + +// EOF sf_fabs.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/portable-api/sf_finite.c @@ -0,0 +1,101 @@ +//=========================================================================== +// +// sf_finite.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* sf_finite.c -- float version of s_finite.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * finitef(x) returns 1 is x is finite, else 0; + * no branching! + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ + int finitef(float x) +#else + int finitef(x) + float x; +#endif +{ + __int32_t ix; + ix = CYG_LIBM_WORD(x); + ix &= 0x7fffffff; + return (FLT_UWORD_IS_FINITE(ix)); +} + +#endif // ifdef CYGPKG_LIBM + +// EOF sf_finite.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/portable-api/sf_floor.c @@ -0,0 +1,133 @@ +//=========================================================================== +// +// sf_floor.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* sf_floor.c -- float version of s_floor.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * floorf(x) + * Return x rounded toward -inf to integral value + * Method: + * Bit twiddling. + * Exception: + * Inexact flag raised if x not equal to floorf(x). + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static const float huge = 1.0e30; +#else +static float huge = 1.0e30; +#endif + +#ifdef __STDC__ + float floorf(float x) +#else + float floorf(x) + float x; +#endif +{ + __int32_t i0,j0; + __uint32_t i,ix; + i0 = CYG_LIBM_WORD(x); + ix = (i0&0x7fffffff); + j0 = (ix>>23)-0x7f; + if(j0<23) { + if(j0<0) { /* raise inexact if x != 0 */ + if(huge+x>(float)0.0) {/* return 0*sign(x) if |x|<1 */ + if(i0>=0) {i0=0;} + else if(!FLT_UWORD_IS_ZERO(ix)) + { i0=0xbf800000;} + } + } else { + i = (0x007fffff)>>j0; + if((i0&i)==0) return x; /* x is integral */ + if(huge+x>(float)0.0) { /* raise inexact flag */ + if(i0<0) i0 += (0x00800000)>>j0; + i0 &= (~i); + } + } + } else { + if(!FLT_UWORD_IS_FINITE(ix)) return x+x; /* inf or NaN */ + else return x; /* x is integral */ + } + SET_FLOAT_WORD(x,i0); + return x; +} + +#endif // ifdef CYGPKG_LIBM + +// EOF sf_floor.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/portable-api/sf_frexp.c @@ -0,0 +1,113 @@ +//=========================================================================== +// +// sf_frexp.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + +/* sf_frexp.c -- float version of s_frexp.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +two25 = 3.3554432000e+07; /* 0x4c000000 */ + +#ifdef __STDC__ + float frexpf(float x, int *eptr) +#else + float frexpf(x, eptr) + float x; int *eptr; +#endif +{ + __int32_t hx, ix; + hx = CYG_LIBM_WORD(x); + ix = 0x7fffffff&hx; + *eptr = 0; + if(!FLT_UWORD_IS_FINITE(ix)||FLT_UWORD_IS_ZERO(ix)) return x; /* 0,inf,nan */ + if (FLT_UWORD_IS_SUBNORMAL(ix)) { /* subnormal */ + x *= two25; + hx = CYG_LIBM_WORD(x); + ix = hx&0x7fffffff; + *eptr = -25; + } + *eptr += (ix>>23)-126; + hx = (hx&0x807fffff)|0x3f000000; + SET_FLOAT_WORD(x,hx); + return x; +} + +#endif // ifdef CYGPKG_LIBM + +// EOF sf_frexp.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/portable-api/sf_ilogb.c @@ -0,0 +1,109 @@ +//=========================================================================== +// +// sf_ilogb.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* sf_ilogb.c -- float version of s_ilogb.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include <limits.h> +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ + int ilogbf(float x) +#else + int ilogbf(x) + float x; +#endif +{ + __int32_t hx,ix; + + hx = CYG_LIBM_WORD(x); + hx &= 0x7fffffff; + if(FLT_UWORD_IS_ZERO(hx)) + return 0x80000001; /* ilogb(0) = special case error */ + if(FLT_UWORD_IS_SUBNORMAL(hx)) { + for (ix = -126,hx<<=8; hx>0; hx<<=1) ix -=1; + return ix; + } + #if FP_ILOGBNAN != INT_MAX + else if (FLT_UWORD_IS_NAN(hx)) return FP_ILOGBNAN; /* NAN */ + #endif + else if (!FLT_UWORD_IS_FINITE(hx)) return INT_MAX; + else + return (hx>>=23)-127; +} + +#endif // ifdef CYGPKG_LIBM + +// EOF sf_ilogb.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/portable-api/sf_isnan.c @@ -0,0 +1,99 @@ +//=========================================================================== +// +// sf_isnan.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* sf_c_isnan.c -- float version of s_c_isnan.c. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * isnanf(x) returns 1 is x is nan, else 0; + * + * isnanf is an extension declared in <ieeefp.h>. + */ + + +#include "mathincl/fdlibm.h" +//#include <ieeefp.h> + +#undef isnanf + + int isnanf(float x) +{ + __int32_t ix; + ix = CYG_LIBM_WORD(x); + ix &= 0x7fffffff; + return FLT_UWORD_IS_NAN(ix); +} + +#endif // ifdef CYGPKG_LIBM + +// EOF sf_isnan.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/portable-api/sf_ldexp.c @@ -0,0 +1,109 @@ +//=========================================================================== +// +// sf_ldexp.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* sf_ldexp.c -- float version of s_ldexp.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" +#include <errno.h> + +#ifdef __STDC__ + float ldexpf(float value, int exp) +#else + float ldexpf(value, exp) + float value; int exp; +#endif +{ + float z; + + z = scalbnf(value,exp); + +#ifndef CYGSEM_LIBM_COMPAT_IEEE_ONLY + if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE) return z; + if(!(finitef(z)||isnanf(z))&&finitef(value)) { + return __kernel_standard(value,(float)exp,43); /* ldexp overflow */ + } + if(z==0.0&&z!=value) { + return __kernel_standard(value,(float)exp,44); /* ldexp underflow */ + } +#endif + + return z; +} + + +#endif // ifdef CYGPKG_LIBM + +// EOF sf_ldexp.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/portable-api/sf_log1p.c @@ -0,0 +1,174 @@ +//=========================================================================== +// +// sf_log1p.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* sf_log1p.c -- float version of s_log1p.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +ln2_hi = 6.9313812256e-01, /* 0x3f317180 */ +ln2_lo = 9.0580006145e-06, /* 0x3717f7d1 */ +two25 = 3.355443200e+07, /* 0x4c000000 */ +Lp1 = 6.6666668653e-01, /* 3F2AAAAB */ +Lp2 = 4.0000000596e-01, /* 3ECCCCCD */ +Lp3 = 2.8571429849e-01, /* 3E924925 */ +Lp4 = 2.2222198546e-01, /* 3E638E29 */ +Lp5 = 1.8183572590e-01, /* 3E3A3325 */ +Lp6 = 1.5313838422e-01, /* 3E1CD04F */ +Lp7 = 1.4798198640e-01; /* 3E178897 */ + +#ifdef __STDC__ +static const float zero = 0.0; +#else +static float zero = 0.0; +#endif + +#ifdef __STDC__ + float log1pf(float x) +#else + float log1pf(x) + float x; +#endif +{ + float hfsq,f,c,s,z,R,u; + __int32_t k,hx,hu,ax; + + hx = CYG_LIBM_WORD(x); + ax = hx&0x7fffffff; + + k = 1; + if (!FLT_UWORD_IS_FINITE(hx)) return x+x; + if (hx < 0x3ed413d7) { /* x < 0.41422 */ + if(ax>=0x3f800000) { /* x <= -1.0 */ + if(x==(float)-1.0) return -two25/zero; /* log1p(-1)=+inf */ + else return (x-x)/(x-x); /* log1p(x<-1)=NaN */ + } + if(ax<0x31000000) { /* |x| < 2**-29 */ + if(two25+x>zero /* raise inexact */ + &&ax<0x24800000) /* |x| < 2**-54 */ + return x; + else + return x - x*x*(float)0.5; + } + if(hx>0||hx<=((__int32_t)0xbe95f61f)) { + k=0;f=x;hu=1;} /* -0.2929<x<0.41422 */ + } + if(k!=0) { + if(hx<0x5a000000) { + u = (float)1.0+x; + hu = CYG_LIBM_WORD(u); + k = (hu>>23)-127; + /* correction term */ + c = (k>0)? (float)1.0-(u-x):x-(u-(float)1.0); + c /= u; + } else { + u = x; + hu = CYG_LIBM_WORD(u); + k = (hu>>23)-127; + c = 0; + } + hu &= 0x007fffff; + if(hu<0x3504f7) { + SET_FLOAT_WORD(u,hu|0x3f800000);/* normalize u */ + } else { + k += 1; + SET_FLOAT_WORD(u,hu|0x3f000000); /* normalize u/2 */ + hu = (0x00800000-hu)>>2; + } + f = u-(float)1.0; + } + hfsq=(float)0.5*f*f; + if(hu==0) { /* |f| < 2**-20 */ + if(f==zero) { if(k==0) return zero; + else {c += k*ln2_lo; return k*ln2_hi+c;}} + R = hfsq*((float)1.0-(float)0.66666666666666666*f); + if(k==0) return f-R; else + return k*ln2_hi-((R-(k*ln2_lo+c))-f); + } + s = f/((float)2.0+f); + z = s*s; + R = z*(Lp1+z*(Lp2+z*(Lp3+z*(Lp4+z*(Lp5+z*(Lp6+z*Lp7)))))); + if(k==0) return f-(hfsq-s*(hfsq+R)); else + return k*ln2_hi-((hfsq-(s*(hfsq+R)+(k*ln2_lo+c)))-f); +} + +#endif // ifdef CYGPKG_LIBM + +// EOF sf_log1p.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/portable-api/sf_logb.c @@ -0,0 +1,114 @@ +//=========================================================================== +// +// sf_logb.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + +/* 2009 for Newlib: Sun's sf_ilogb.c converted to be sf_logb.c. */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* float logb(float x) + * return the binary exponent of non-zero x + * logbf(0) = -inf, raise divide-by-zero floating point exception + * logbf(+inf|-inf) = +inf (no signal is raised) + * logbf(NaN) = NaN (no signal is raised) + * Per C99 recommendation, a NaN argument is returned unchanged. + */ + + +#include "mathincl/fdlibm.h" + +float +#ifdef __STDC__ +logbf(float x) +#else +logbf(x) +float x; +#endif +{ + __int32_t hx,ix; + + hx = CYG_LIBM_WORD(x); + hx &= 0x7fffffff; + if(FLT_UWORD_IS_ZERO(hx)) { + float xx; + /* arg==0: return -inf and raise divide-by-zero exception */ + SET_FLOAT_WORD(xx,hx); /* +0.0 */ + return -1./xx; /* logbf(0) = -inf */ + } + if(FLT_UWORD_IS_SUBNORMAL(hx)) { + for (ix = -126,hx<<=8; hx>0; hx<<=1) ix -=1; + return (float) ix; + } + else if (FLT_UWORD_IS_INFINITE(hx)) return HUGE_VALF; /* x==+|-inf */ + else if (FLT_UWORD_IS_NAN(hx)) return x; + else return (float) ((hx>>23)-127); +} + +#endif // ifdef CYGPKG_LIBM + +// EOF sf_logb.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/portable-api/sf_modf.c @@ -0,0 +1,126 @@ +//=========================================================================== +// +// sf_modf.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* sf_modf.c -- float version of s_modf.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static const float one = 1.0; +#else +static float one = 1.0; +#endif + +#ifdef __STDC__ + float modff(float x, float *iptr) +#else + float modff(x, iptr) + float x,*iptr; +#endif +{ + __int32_t i0,j0; + __uint32_t i; + i0 = CYG_LIBM_WORD(x); + j0 = ((i0>>23)&0xff)-0x7f; /* exponent of x */ + if(j0<23) { /* integer part in x */ + if(j0<0) { /* |x|<1 */ + SET_FLOAT_WORD(*iptr,i0&0x80000000); /* *iptr = +-0 */ + return x; + } else { + i = (0x007fffff)>>j0; + if((i0&i)==0) { /* x is integral */ + __uint32_t ix; + *iptr = x; + ix = CYG_LIBM_WORD(x); + SET_FLOAT_WORD(x,ix&0x80000000); /* return +-0 */ + return x; + } else { + SET_FLOAT_WORD(*iptr,i0&(~i)); + return x - *iptr; + } + } + } else { /* no fraction part */ + __uint32_t ix; + *iptr = x*one; + ix = CYG_LIBM_WORD(x); + SET_FLOAT_WORD(x,ix&0x80000000); /* return +-0 */ + return x; + } +} + +#endif // ifdef CYGPKG_LIBM + +// EOF sf_modf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/portable-api/sf_nextafter.c @@ -0,0 +1,132 @@ +//=========================================================================== +// +// sf_nextafter.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* sf_nextafter.c -- float version of s_nextafter.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ + float nextafterf(float x, float y) +#else + float nextafterf(x,y) + float x,y; +#endif +{ + __int32_t hx,hy,ix,iy; + + hx = CYG_LIBM_WORD(x); + hy = CYG_LIBM_WORD(y); + ix = hx&0x7fffffff; /* |x| */ + iy = hy&0x7fffffff; /* |y| */ + + if(FLT_UWORD_IS_NAN(ix) || + FLT_UWORD_IS_NAN(iy)) + return x+y; + if(x==y) return x; /* x=y, return x */ + if(FLT_UWORD_IS_ZERO(ix)) { /* x == 0 */ + SET_FLOAT_WORD(x,(hy&0x80000000)|FLT_UWORD_MIN); + y = x*x; + if(y==x) return y; else return x; /* raise underflow flag */ + } + if(hx>=0) { /* x > 0 */ + if(hx>hy) { /* x > y, x -= ulp */ + hx -= 1; + } else { /* x < y, x += ulp */ + hx += 1; + } + } else { /* x < 0 */ + if(hy>=0||hx>hy){ /* x < y, x -= ulp */ + hx -= 1; + } else { /* x > y, x += ulp */ + hx += 1; + } + } + hy = hx&0x7f800000; + if(hy>FLT_UWORD_MAX) return x+x; /* overflow */ + if(hy<0x00800000) { /* underflow */ + y = x*x; + if(y!=x) { /* raise underflow flag */ + SET_FLOAT_WORD(y,hx); + return y; + } + } + SET_FLOAT_WORD(x,hx); + return x; +} + +#endif // ifdef CYGPKG_LIBM + +// EOF sf_nextafter.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/portable-api/sf_rint.c @@ -0,0 +1,137 @@ +//=========================================================================== +// +// sf_rint.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* sf_rint.c -- float version of s_rint.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +TWO23[2]={ + 8.3886080000e+06, /* 0x4b000000 */ + -8.3886080000e+06, /* 0xcb000000 */ +}; + +#ifdef __STDC__ + float rintf(float x) +#else + float rintf(x) + float x; +#endif +{ + __int32_t i0,j0,sx; + __uint32_t i,i1,ix; + float t; + volatile float w; + i0 = CYG_LIBM_WORD(x); + sx = (i0>>31)&1; + ix = (i0&0x7fffffff); + j0 = (ix>>23)-0x7f; + if(j0<23) { + if(FLT_UWORD_IS_ZERO(ix)) + return x; + if(j0<0) { + i1 = (i0&0x07fffff); + i0 &= 0xfff00000; + i0 |= ((i1|-i1)>>9)&0x400000; + SET_FLOAT_WORD(x,i0); + w = TWO23[sx]+x; + t = w-TWO23[sx]; + i0 = CYG_LIBM_WORD(t); + SET_FLOAT_WORD(t,(i0&0x7fffffff)|(sx<<31)); + return t; + } else { + i = (0x007fffff)>>j0; + if((i0&i)==0) return x; /* x is integral */ + i>>=1; + if((i0&i)!=0) i0 = (i0&(~i))|((0x200000)>>j0); + } + } else { + if(!FLT_UWORD_IS_FINITE(ix)) return x+x; /* inf or NaN */ + else + return x; /* x is integral */ + } + SET_FLOAT_WORD(x,i0); + w = TWO23[sx]+x; + return w-TWO23[sx]; +} + +#endif // ifdef CYGPKG_LIBM + +// EOF sf_rint.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/portable-api/sf_scalbn.c @@ -0,0 +1,136 @@ +//=========================================================================== +// +// sf_scalbn.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* sf_scalbn.c -- float version of s_scalbn.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" + +// VAE #if INT_MAX > 50000 +#define OVERFLOW_INT 50000 +//#else +//#define OVERFLOW_INT 30000 +//#endif + +#ifdef __STDC__ +static const float +#else +static float +#endif +two25 = 3.355443200e+07, /* 0x4c000000 */ +twom25 = 2.9802322388e-08, /* 0x33000000 */ +huge = 1.0e+30, +tiny = 1.0e-30; + +#ifdef __STDC__ + float scalbnf (float x, int n) +#else + float scalbnf (x,n) + float x; int n; +#endif +{ + __int32_t k,ix; + __uint32_t hx; + + ix = CYG_LIBM_WORD(x); + hx = ix&0x7fffffff; + k = hx>>23; /* extract exponent */ + if (FLT_UWORD_IS_ZERO(hx)) + return x; + if (!FLT_UWORD_IS_FINITE(hx)) + return x+x; /* NaN or Inf */ + if (FLT_UWORD_IS_SUBNORMAL(hx)) { + x *= two25; + ix = CYG_LIBM_WORD(x); + k = ((ix&0x7f800000)>>23) - 25; + if (n< -50000) return tiny*x; /*underflow*/ + } + k = k+n; + if (k > FLT_LARGEST_EXP) return huge*copysignf(huge,x); /* overflow */ + if (k > 0) /* normal result */ + {SET_FLOAT_WORD(x,(ix&0x807fffff)|(k<<23)); return x;} + if (k < FLT_SMALLEST_EXP) { + if (n > OVERFLOW_INT) /* in case integer overflow in n+k */ + return huge*copysignf(huge,x); /*overflow*/ + else return tiny*copysignf(tiny,x); /*underflow*/ + } + k += 25; /* subnormal result */ + SET_FLOAT_WORD(x,(ix&0x807fffff)|(k<<23)); + return x*twom25; +} + +#endif // ifdef CYGPKG_LIBM + +// EOF sf_scalbn.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/portable-api/sf_significand.c @@ -0,0 +1,93 @@ +//=========================================================================== +// +// sf_significand.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* sf_signif.c -- float version of s_signif.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#include "mathincl/fdlibm.h" + + +#ifdef __STDC__ + float significandf(float x) +#else + float significandf(x) + float x; +#endif +{ + return __ieee754_scalbf(x,(float) -ilogbf(x)); +} + +#endif // ifdef CYGPKG_LIBM + +// EOF sf_significand.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/portable-api/sf_sin.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// sf_sin.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* sf_sin.c -- float version of s_sin.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ + float sinf(float x) +#else + float sinf(x) + float x; +#endif +{ + float y[2],z=0.0; + __int32_t n,ix; + + ix = CYG_LIBM_WORD(x); + + /* |x| ~< pi/4 */ + ix &= 0x7fffffff; + if(ix <= 0x3f490fd8) return __kernel_sinf(x,z,0); + + /* sin(Inf or NaN) is NaN */ + else if (!FLT_UWORD_IS_FINITE(ix)) return x-x; + + /* argument reduction needed */ + else { + n = __ieee754_rem_pio2f(x,y); + switch(n&3) { + case 0: return __kernel_sinf(y[0],y[1],1); + case 1: return __kernel_cosf(y[0],y[1]); + case 2: return -__kernel_sinf(y[0],y[1],1); + default: + return -__kernel_cosf(y[0],y[1]); + } + } +} + +#endif // ifdef CYGPKG_LIBM + +// EOF sf_cos.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/portable-api/sf_tan.c @@ -0,0 +1,110 @@ +//=========================================================================== +// +// sf_tan.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* sf_tan.c -- float version of s_tan.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ + float tanf(float x) +#else + float tanf(x) + float x; +#endif +{ + float y[2],z=0.0; + __int32_t n,ix; + + ix = CYG_LIBM_WORD(x); + + /* |x| ~< pi/4 */ + ix &= 0x7fffffff; + if(ix <= 0x3f490fda) return __kernel_tanf(x,z,1); + + /* tan(Inf or NaN) is NaN */ + else if (!FLT_UWORD_IS_FINITE(ix)) return x-x; /* NaN */ + + /* argument reduction needed */ + else { + n = __ieee754_rem_pio2f(x,y); + return __kernel_tanf(y[0],y[1],1-((n&1)<<1)); /* 1 -- n even + -1 -- n odd */ + } +} + +#endif // ifdef CYGPKG_LIBM + +// EOF sf_tan.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/float/portable-api/sf_tanh.c @@ -0,0 +1,126 @@ +//=========================================================================== +// +// sf_tanh.c +// +// Part of the standard mathematical function library +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 2012-03-08 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// Derived from code with the following copyright + + +/* sf_tanh.c -- float version of s_tanh.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "mathincl/fdlibm.h" + +#ifdef __STDC__ +static const float one=1.0, two=2.0, tiny = 1.0e-30; +#else +static float one=1.0, two=2.0, tiny = 1.0e-30; +#endif + +#ifdef __STDC__ + float tanhf(float x) +#else + float tanhf(x) + float x; +#endif +{ + float t,z; + __int32_t jx,ix; + + jx = CYG_LIBM_WORD(x); + ix = jx&0x7fffffff; + + /* x is INF or NaN */ + if(!FLT_UWORD_IS_FINITE(ix)) { + if (jx>=0) return one/x+one; /* tanh(+-inf)=+-1 */ + else return one/x-one; /* tanh(NaN) = NaN */ + } + + /* |x| < 22 */ + if (ix < 0x41b00000) { /* |x|<22 */ + if (ix<0x24000000) /* |x|<2**-55 */ + return x*(one+x); /* tanh(small) = small */ + if (ix>=0x3f800000) { /* |x|>=1 */ + t = expm1f(two*fabsf(x)); + z = one - two/(t+two); + } else { + t = expm1f(-two*fabsf(x)); + z= -t/(t+two); + } + /* |x| > 22, return +-1 */ + } else { + z = one - tiny; /* raised inexact flag */ + } + return (jx>=0)? z: -z; +} + +#endif // ifdef CYGPKG_LIBM + +// EOF sf_tanh.c
--- a/packages/language/c/libm/current/src/mathincl/fdlibm.h +++ b/packages/language/c/libm/current/src/mathincl/fdlibm.h @@ -84,6 +84,111 @@ typedef cyg_int32 __int32_t; typedef cyg_uint32 __uint32_t; typedef Cyg_libm_ieee_double_shape_type ieee_double_shape_type; +typedef Cyg_libm_ieee_float_shape_type ieee_float_shape_type; + +/* Most routines need to check whether a float is finite, infinite, or not a + number, and many need to know whether the result of an operation will + overflow. These conditions depend on whether the largest exponent is + used for NaNs & infinities, or whether it's used for finite numbers. The + macros below wrap up that kind of information: + + FLT_UWORD_IS_FINITE(X) + True if a positive float with bitmask X is finite. + + FLT_UWORD_IS_NAN(X) + True if a positive float with bitmask X is not a number. + + FLT_UWORD_IS_INFINITE(X) + True if a positive float with bitmask X is +infinity. + + FLT_UWORD_MAX + The bitmask of FLT_MAX. + + FLT_UWORD_HALF_MAX + The bitmask of FLT_MAX/2. + + FLT_UWORD_EXP_MAX + The bitmask of the largest finite exponent (129 if the largest + exponent is used for finite numbers, 128 otherwise). + + FLT_UWORD_LOG_MAX + The bitmask of log(FLT_MAX), rounded down. This value is the largest + input that can be passed to exp() without producing overflow. + + FLT_UWORD_LOG_2MAX + The bitmask of log(2*FLT_MAX), rounded down. This value is the + largest input than can be passed to cosh() without producing + overflow. + + FLT_LARGEST_EXP + The largest biased exponent that can be used for finite numbers + (255 if the largest exponent is used for finite numbers, 254 + otherwise) */ + +#ifdef _FLT_LARGEST_EXPONENT_IS_NORMAL +#define FLT_UWORD_IS_FINITE(x) 1 +#define FLT_UWORD_IS_NAN(x) 0 +#define FLT_UWORD_IS_INFINITE(x) 0 +#define FLT_UWORD_MAX 0x7fffffff +#define FLT_UWORD_EXP_MAX 0x43010000 +#define FLT_UWORD_LOG_MAX 0x42b2d4fc +#define FLT_UWORD_LOG_2MAX 0x42b437e0 +//#define HUGE ((float)0X1.FFFFFEP128) +#else +#define FLT_UWORD_IS_FINITE(x) ((x)<0x7f800000L) +#define FLT_UWORD_IS_NAN(x) ((x)>0x7f800000L) +#define FLT_UWORD_IS_INFINITE(x) ((x)==0x7f800000L) +#define FLT_UWORD_MAX 0x7f7fffffL +#define FLT_UWORD_EXP_MAX 0x43000000 +#define FLT_UWORD_LOG_MAX 0x42b17217 +#define FLT_UWORD_LOG_2MAX 0x42b2d4fc +//#define HUGE ((float)3.40282346638528860e+38) +#endif +#define FLT_UWORD_HALF_MAX (FLT_UWORD_MAX-(1L<<23)) +#define FLT_LARGEST_EXP (FLT_UWORD_MAX>>23) + +/* Many routines check for zero and subnormal numbers. Such things depend + on whether the target supports denormals or not: + + FLT_UWORD_IS_ZERO(X) + True if a positive float with bitmask X is +0. Without denormals, + any float with a zero exponent is a +0 representation. With + denormals, the only +0 representation is a 0 bitmask. + + FLT_UWORD_IS_SUBNORMAL(X) + True if a non-zero positive float with bitmask X is subnormal. + (Routines should check for zeros first.) + + FLT_UWORD_MIN + The bitmask of the smallest float above +0. Call this number + REAL_FLT_MIN... + + FLT_UWORD_EXP_MIN + The bitmask of the float representation of REAL_FLT_MIN's exponent. + + FLT_UWORD_LOG_MIN + The bitmask of |log(REAL_FLT_MIN)|, rounding down. + + FLT_SMALLEST_EXP + REAL_FLT_MIN's exponent - EXP_BIAS (1 if denormals are not supported, + -22 if they are). +*/ + +#ifdef _FLT_NO_DENORMALS +#define FLT_UWORD_IS_ZERO(x) ((x)<0x00800000L) +#define FLT_UWORD_IS_SUBNORMAL(x) 0 +#define FLT_UWORD_MIN 0x00800000 +#define FLT_UWORD_EXP_MIN 0x42fc0000 +#define FLT_UWORD_LOG_MIN 0x42aeac50 +#define FLT_SMALLEST_EXP 1 +#else +#define FLT_UWORD_IS_ZERO(x) ((x)==0) +#define FLT_UWORD_IS_SUBNORMAL(x) ((x)<0x00800000L) +#define FLT_UWORD_MIN 0x00000001 +#define FLT_UWORD_EXP_MIN 0x43160000 +#define FLT_UWORD_LOG_MIN 0x42cff1b5 +#define FLT_SMALLEST_EXP -22 +#endif // MACRO DEFINITIONS @@ -95,7 +200,25 @@ typedef Cyg_libm_ieee_double_shape_type #define CYG_LIBM_HIp(__x) (((Cyg_libm_ieee_double_shape_type *)__x)->parts.msw) #define CYG_LIBM_LOp(__x) (((Cyg_libm_ieee_double_shape_type *)__x)->parts.lsw) +#define CYG_LIBM_WORD(__x) (((Cyg_libm_ieee_float_shape_type *)&__x)->asi32) +/* Get a 32 bit int from a float. */ + +#define GET_FLOAT_WORD(i,f) \ +do { \ + Cyg_libm_ieee_float_shape_type gf_u; \ + gf_u.value = (f); \ + (i) = gf_u.asi32; \ +} while (0) + +/* Set a float from a 32 bit int. */ + +#define SET_FLOAT_WORD(f,i) \ +do { \ + Cyg_libm_ieee_float_shape_type sf_u; \ + sf_u.asi32 = (i); \ + (f) = sf_u.value; \ +} while (0) /* Get two 32 bit ints from a double. */ @@ -179,9 +302,19 @@ struct exception { externC int matherr( struct exception * ); // User-overridable error handling - see // <pkgconf/libm.h> for a discussion +struct exceptionf { + int type; // One of DOMAIN, SING, OVERFLOW, UNDERFLOW, TLOSS, PLOSS + char *name; // Name of the function generating the exception + float arg1; // First argument to the function + float arg2; // Second argument to the function + float retval; // Value to be returned - can be altered by matherr() +}; + +externC int +matherrf( struct exceptionf * ); + #endif // ifdef CYGSYM_LIBM_NO_XOPEN_SVID_NAMESPACE_POLLUTION - // FUNCTION PROTOTYPES // IEEE-754 style elementary functions */ @@ -289,6 +422,85 @@ externC double externC int __kernel_rem_pio2( double *, double *, int, int, int, const int * ); +/* ieee style elementary float functions */ +externC float __ieee754_sqrtf (float); +externC float __ieee754_acosf (float); +externC float __ieee754_acoshf (float); +externC float __ieee754_logf (float); +externC float __ieee754_atanhf (float); +externC float __ieee754_asinf (float); +externC float __ieee754_atan2f (float,float); +externC float __ieee754_expf (float); +externC float __ieee754_coshf (float); +externC float __ieee754_fmodf (float,float); +externC float __ieee754_powf (float,float); +externC float +__ieee754_lgammaf_r( float, int * ); + +externC float +__ieee754_gammaf_r( float, int * ); + +externC float +__ieee754_lgammaf( float ); + +externC float +__ieee754_gammaf( float ); +externC float __ieee754_log10f (float); +externC float __ieee754_sinhf (float); +externC float __ieee754_hypotf (float,float); +externC float __ieee754_j0f (float); +externC float __ieee754_j1f (float); +externC float __ieee754_y0f (float); +externC float __ieee754_y1f (float); +externC float __ieee754_jnf (int,float); +externC float __ieee754_ynf (int,float); +externC float __ieee754_remainderf (float,float); +externC cyg_int32 __ieee754_rem_pio2f (float,float*); +#ifdef _SCALB_INT +externC float __ieee754_scalbf ((float,int)); +#else +externC float __ieee754_scalbf (float,float); +#endif + +/* float versions of fdlibm kernel functions */ +externC float __kernel_standard_float( float, float, int ); +externC float __kernel_sinf (float,float,int); +externC float __kernel_cosf (float,float); +externC float __kernel_tanf (float,float,int); +externC int __kernel_rem_pio2f (float*,float*,int,int,int,const cyg_int32*); + +#ifdef _COMPLEX_H + +/* + * Quoting from ISO/IEC 9899:TC2: + * + * 6.2.5.13 Types + * Each complex type has the same representation and alignment requirements as + * an array type containing exactly two elements of the corresponding real type; + * the first element is equal to the real part, and the second element to the + * imaginary part, of the complex number. + */ +typedef union { + float complex z; + float parts[2]; +} float_complex; + +typedef union { + double complex z; + double parts[2]; +} double_complex; + +typedef union { + long double complex z; + long double parts[2]; +} long_double_complex; + +#define REAL_PART(z) ((z).parts[0]) +#define IMAG_PART(z) ((z).parts[1]) + +#endif /* _COMPLEX_H */ + + #endif // ifdef CYGPKG_LIBM #endif // CYGONCE_LIBM_MATHINCL_FDLIBM_H multiple inclusion protection
--- a/packages/language/c/libm/current/src/misc/matherr.c +++ b/packages/language/c/libm/current/src/misc/matherr.c @@ -74,13 +74,28 @@ matherr( struct exception *x ) { CYG_REPORT_FUNCNAMETYPE( "matherr", "returning %d" ); - CYG_UNUSED_PARAM( struct exception *, x ); +// CYG_UNUSED_PARAM( struct exception *, x ); CYG_EMPTY_STATEMENT; CYG_REPORT_RETVAL( 0 ); return 0; } // matherr() +int +matherrf( struct exceptionf *x ) __attribute__ ((weak)); + +int +matherrf( struct exceptionf *x ) +{ + CYG_REPORT_FUNCNAMETYPE( "matherrf", "returning %d" ); + +// CYG_UNUSED_PARAM( struct exceptionf *, x ); + CYG_EMPTY_STATEMENT; + + CYG_REPORT_RETVAL( 0 ); + return 0; +} // matherrf() + #endif // if defined(CYGPKG_LIBM)
--- a/packages/language/c/libm/current/src/misc/standard.c +++ b/packages/language/c/libm/current/src/misc/standard.c @@ -1,14 +1,14 @@ //=========================================================================== // -// signgam.cxx +// standard_float.c // -// Support sign of the gamma*() functions in Math library +// Standard conformance (non-IEEE) on exception cases. // //=========================================================================== // ####ECOSGPLCOPYRIGHTBEGIN#### // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. -// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2013 Free Software Foundation, Inc. // // eCos is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -39,793 +39,21 @@ //=========================================================================== //#####DESCRIPTIONBEGIN#### // -// Author(s): jlarmour -// Contributors: jlarmour -// Date: 1998-02-13 +// Author(s): ilijak +// Contributors: +// Date: 2013-06-17 // Purpose: -// Description: Contains the accessor functions to get and set the stored sign -// of the gamma*() functions in the math library +// Description: +// // Usage: // //####DESCRIPTIONEND#### // //=========================================================================== -/* @(#)k_standard.c 1.3 95/01/18 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunSoft, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - * - */ - -// CONFIGURATION - -#include <pkgconf/libm.h> // Configuration header - -// Include the Math library? -#ifdef CYGPKG_LIBM - -// INCLUDES - -#include <cyg/infra/cyg_type.h> // Common type definitions and support -#include <cyg/infra/cyg_trac.h> // Tracing macros - -#include <math.h> // Main header for math library -#include "mathincl/fdlibm.h" // Internal header for math library - -#include <cyg/error/codes.h> // standard error codes - -#ifndef CYGSEM_LIBM_COMPAT_IEEE_ONLY -#include <errno.h> -#else -static int errno; // this whole file won't be used if we're IEEE only, but - // doing this keeps the compiler happy -#endif - -#ifdef CYGSEM_LIBM_USE_STDERR - -#include <stdio.h> -#define WRITE2(u,v) fputs(u, stderr) - -#else - -#define WRITE2(u,v) 0 - -#endif // ifdef CYGSEM_LIBM_USE_STDERR - - -// GLOBALS - -static const double zero = 0.0; - -// FUNCTIONS - -/* - * Standard conformance (non-IEEE) on exception cases. - * Mapping: - * 1 -- acos(|x|>1) - * 2 -- asin(|x|>1) - * 3 -- atan2(+-0,+-0) - * 4 -- hypot overflow - * 5 -- cosh overflow - * 6 -- exp overflow - * 7 -- exp underflow - * 8 -- y0(0) - * 9 -- y0(-ve) - * 10-- y1(0) - * 11-- y1(-ve) - * 12-- yn(0) - * 13-- yn(-ve) - * 14-- lgamma(finite) overflow - * 15-- lgamma(-integer) - * 16-- log(0) - * 17-- log(x<0) - * 18-- log10(0) - * 19-- log10(x<0) - * 20-- pow(0.0,0.0) - * 21-- pow(x,y) overflow - * 22-- pow(x,y) underflow - * 23-- pow(0,negative) - * 24-- pow(neg,non-integral) - * 25-- sinh(finite) overflow - * 26-- sqrt(negative) - * 27-- fmod(x,0) - * 28-- remainder(x,0) - * 29-- acosh(x<1) - * 30-- atanh(|x|>1) - * 31-- atanh(|x|=1) - * 32-- scalb overflow - * 33-- scalb underflow - * 34-- j0(|x|>X_TLOSS) - * 35-- y0(x>X_TLOSS) - * 36-- j1(|x|>X_TLOSS) - * 37-- y1(x>X_TLOSS) - * 38-- jn(|x|>X_TLOSS, n) - * 39-- yn(x>X_TLOSS, n) - * 40-- gamma(finite) overflow - * 41-- gamma(-integer) - * 42-- pow(NaN,0.0) - * 43-- ldexp overflow - * 44-- ldexp underflow - */ - - -double -__kernel_standard(double x, double y, int type) -{ - struct exception exc; +#define CYG_STANDARD_FLOAT_T double +#define CYGSTR_FLOAT_SUFFIX +#define MATHERR(__exc_p) matherr(__exc_p) +#include "standard.inl" -#ifdef CYGSEM_LIBM_USE_STDERR - (void) fflush(stdout); -#endif - exc.arg1 = x; - exc.arg2 = y; - switch(type) { - case 1: - /* acos(|x|>1) */ - exc.type = DOMAIN; - exc.name = "acos"; - exc.retval = zero; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = EDOM; - else if (!matherr(&exc)) { - if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { - (void) WRITE2("acos: DOMAIN error\n", 19); - } - errno = EDOM; - } - break; - case 2: - /* asin(|x|>1) */ - exc.type = DOMAIN; - exc.name = "asin"; - exc.retval = zero; - if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = EDOM; - else if (!matherr(&exc)) { - if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { - (void) WRITE2("asin: DOMAIN error\n", 19); - } - errno = EDOM; - } - break; - case 3: - /* atan2(+-0,+-0) */ - exc.arg1 = y; - exc.arg2 = x; - exc.type = DOMAIN; - exc.name = "atan2"; - exc.retval = zero; - if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = EDOM; - else if (!matherr(&exc)) { - if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { - (void) WRITE2("atan2: DOMAIN error\n", 20); - } - errno = EDOM; - } - break; - case 4: - /* hypot(finite,finite) overflow */ - exc.type = OVERFLOW; - exc.name = "hypot"; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) - exc.retval = HUGE; - else - exc.retval = HUGE_VAL; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - case 5: - /* cosh(finite) overflow */ - exc.type = OVERFLOW; - exc.name = "cosh"; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) - exc.retval = HUGE; - else - exc.retval = HUGE_VAL; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - case 6: - /* exp(finite) overflow */ - exc.type = OVERFLOW; - exc.name = "exp"; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) - exc.retval = HUGE; - else - exc.retval = HUGE_VAL; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - case 7: - /* exp(finite) underflow */ - exc.type = UNDERFLOW; - exc.name = "exp"; - exc.retval = zero; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - case 8: - /* y0(0) = -inf */ - exc.type = DOMAIN; /* should be SING for IEEE */ - exc.name = "y0"; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) - exc.retval = -HUGE; - else - exc.retval = -HUGE_VAL; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = EDOM; - else if (!matherr(&exc)) { - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { - (void) WRITE2("y0: DOMAIN error\n", 17); - } - errno = EDOM; - } - break; - case 9: - /* y0(x<0) = NaN */ - exc.type = DOMAIN; - exc.name = "y0"; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) - exc.retval = -HUGE; - else - exc.retval = -HUGE_VAL; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = EDOM; - else if (!matherr(&exc)) { - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { - (void) WRITE2("y0: DOMAIN error\n", 17); - } - errno = EDOM; - } - break; - case 10: - /* y1(0) = -inf */ - exc.type = DOMAIN; /* should be SING for IEEE */ - exc.name = "y1"; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) - exc.retval = -HUGE; - else - exc.retval = -HUGE_VAL; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = EDOM; - else if (!matherr(&exc)) { - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { - (void) WRITE2("y1: DOMAIN error\n", 17); - } - errno = EDOM; - } - break; - case 11: - /* y1(x<0) = NaN */ - exc.type = DOMAIN; - exc.name = "y1"; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) - exc.retval = -HUGE; - else - exc.retval = -HUGE_VAL; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = EDOM; - else if (!matherr(&exc)) { - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { - (void) WRITE2("y1: DOMAIN error\n", 17); - } - errno = EDOM; - } - break; - case 12: - /* yn(n,0) = -inf */ - exc.type = DOMAIN; /* should be SING for IEEE */ - exc.name = "yn"; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) - exc.retval = -HUGE; - else - exc.retval = -HUGE_VAL; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = EDOM; - else if (!matherr(&exc)) { - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { - (void) WRITE2("yn: DOMAIN error\n", 17); - } - errno = EDOM; - } - break; - case 13: - /* yn(x<0) = NaN */ - exc.type = DOMAIN; - exc.name = "yn"; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) - exc.retval = -HUGE; - else - exc.retval = -HUGE_VAL; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = EDOM; - else if (!matherr(&exc)) { - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { - (void) WRITE2("yn: DOMAIN error\n", 17); - } - errno = EDOM; - } - break; - case 14: - /* lgamma(finite) overflow */ - exc.type = OVERFLOW; - exc.name = "lgamma"; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) - exc.retval = HUGE; - else - exc.retval = HUGE_VAL; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - case 15: - /* lgamma(-integer) or lgamma(0) */ - exc.type = SING; - exc.name = "lgamma"; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) - exc.retval = HUGE; - else - exc.retval = HUGE_VAL; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = EDOM; - else if (!matherr(&exc)) { - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { - (void) WRITE2("lgamma: SING error\n", 19); - } - errno = EDOM; - } - break; - case 16: - /* log(0) */ - exc.type = SING; - exc.name = "log"; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) - exc.retval = -HUGE; - else - exc.retval = -HUGE_VAL; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = ERANGE; - else if (!matherr(&exc)) { - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { - (void) WRITE2("log: SING error\n", 16); - } - errno = EDOM; - } - break; - case 17: - /* log(x<0) */ - exc.type = DOMAIN; - exc.name = "log"; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) - exc.retval = -HUGE; - else - exc.retval = -HUGE_VAL; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = EDOM; - else if (!matherr(&exc)) { - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { - (void) WRITE2("log: DOMAIN error\n", 18); - } - errno = EDOM; - } - break; - case 18: - /* log10(0) */ - exc.type = SING; - exc.name = "log10"; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) - exc.retval = -HUGE; - else - exc.retval = -HUGE_VAL; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = ERANGE; - else if (!matherr(&exc)) { - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { - (void) WRITE2("log10: SING error\n", 18); - } - errno = EDOM; - } - break; - case 19: - /* log10(x<0) */ - exc.type = DOMAIN; - exc.name = "log10"; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) - exc.retval = -HUGE; - else - exc.retval = -HUGE_VAL; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = EDOM; - else if (!matherr(&exc)) { - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { - (void) WRITE2("log10: DOMAIN error\n", 20); - } - errno = EDOM; - } - break; - case 20: - /* pow(0.0,0.0) */ - /* error only if cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID */ - exc.type = DOMAIN; - exc.name = "pow"; - exc.retval = zero; - if (cyg_libm_get_compat_mode() != CYGNUM_LIBM_COMPAT_SVID) exc.retval = 1.0; - else if (!matherr(&exc)) { - (void) WRITE2("pow(0,0): DOMAIN error\n", 23); - errno = EDOM; - } - break; - case 21: - /* pow(x,y) overflow */ - exc.type = OVERFLOW; - exc.name = "pow"; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { - exc.retval = HUGE; - y *= 0.5; - if(x<zero&&rint(y)!=y) exc.retval = -HUGE; - } else { - exc.retval = HUGE_VAL; - y *= 0.5; - if(x<zero&&rint(y)!=y) exc.retval = -HUGE_VAL; - } - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - case 22: - /* pow(x,y) underflow */ - exc.type = UNDERFLOW; - exc.name = "pow"; - exc.retval = zero; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - case 23: - /* 0**neg */ - exc.type = DOMAIN; - exc.name = "pow"; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) - exc.retval = zero; - else - exc.retval = -HUGE_VAL; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = EDOM; - else if (!matherr(&exc)) { - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { - (void) WRITE2("pow(0,neg): DOMAIN error\n", 25); - } - errno = EDOM; - } - break; - case 24: - /* neg**non-integral */ - exc.type = DOMAIN; - exc.name = "pow"; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) - exc.retval = zero; - else - exc.retval = zero/zero; /* X/Open allow NaN */ - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = EDOM; - else if (!matherr(&exc)) { - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { - (void) WRITE2("neg**non-integral: DOMAIN error\n", 32); - } - errno = EDOM; - } - break; - case 25: - /* sinh(finite) overflow */ - exc.type = OVERFLOW; - exc.name = "sinh"; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) - exc.retval = ( (x>zero) ? HUGE : -HUGE); - else - exc.retval = ( (x>zero) ? HUGE_VAL : -HUGE_VAL); - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - case 26: - /* sqrt(x<0) */ - exc.type = DOMAIN; - exc.name = "sqrt"; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) - exc.retval = zero; - else - exc.retval = zero/zero; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = EDOM; - else if (!matherr(&exc)) { - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { - (void) WRITE2("sqrt: DOMAIN error\n", 19); - } - errno = EDOM; - } - break; - case 27: - /* fmod(x,0) */ - exc.type = DOMAIN; - exc.name = "fmod"; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) - exc.retval = x; - else - exc.retval = zero/zero; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = EDOM; - else if (!matherr(&exc)) { - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { - (void) WRITE2("fmod: DOMAIN error\n", 20); - } - errno = EDOM; - } - break; - case 28: - /* remainder(x,0) */ - exc.type = DOMAIN; - exc.name = "remainder"; - exc.retval = zero/zero; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = EDOM; - else if (!matherr(&exc)) { - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { - (void) WRITE2("remainder: DOMAIN error\n", 24); - } - errno = EDOM; - } - break; - case 29: - /* acosh(x<1) */ - exc.type = DOMAIN; - exc.name = "acosh"; - exc.retval = zero/zero; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = EDOM; - else if (!matherr(&exc)) { - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { - (void) WRITE2("acosh: DOMAIN error\n", 20); - } - errno = EDOM; - } - break; - case 30: - /* atanh(|x|>1) */ - exc.type = DOMAIN; - exc.name = "atanh"; - exc.retval = zero/zero; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = EDOM; - else if (!matherr(&exc)) { - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { - (void) WRITE2("atanh: DOMAIN error\n", 20); - } - errno = EDOM; - } - break; - case 31: - /* atanh(|x|=1) */ - exc.type = SING; - exc.name = "atanh"; - exc.retval = x/zero; /* sign(x)*inf */ - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = EDOM; - else if (!matherr(&exc)) { - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { - (void) WRITE2("atanh: SING error\n", 18); - } - errno = EDOM; - } - break; - case 32: - /* scalb overflow; SVID also returns +-HUGE_VAL */ - exc.type = OVERFLOW; - exc.name = "scalb"; - exc.retval = x > zero ? HUGE_VAL : -HUGE_VAL; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - case 33: - /* scalb underflow */ - exc.type = UNDERFLOW; - exc.name = "scalb"; - exc.retval = copysign(zero,x); - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - case 34: - /* j0(|x|>X_TLOSS) */ - exc.type = TLOSS; - exc.name = "j0"; - exc.retval = zero; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = ERANGE; - else if (!matherr(&exc)) { - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { - (void) WRITE2(exc.name, 2); - (void) WRITE2(": TLOSS error\n", 14); - } - errno = ERANGE; - } - break; - case 35: - /* y0(x>X_TLOSS) */ - exc.type = TLOSS; - exc.name = "y0"; - exc.retval = zero; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = ERANGE; - else if (!matherr(&exc)) { - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { - (void) WRITE2(exc.name, 2); - (void) WRITE2(": TLOSS error\n", 14); - } - errno = ERANGE; - } - break; - case 36: - /* j1(|x|>X_TLOSS) */ - exc.type = TLOSS; - exc.name = "j1"; - exc.retval = zero; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = ERANGE; - else if (!matherr(&exc)) { - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { - (void) WRITE2(exc.name, 2); - (void) WRITE2(": TLOSS error\n", 14); - } - errno = ERANGE; - } - break; - case 37: - /* y1(x>X_TLOSS) */ - exc.type = TLOSS; - exc.name = "y1"; - exc.retval = zero; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = ERANGE; - else if (!matherr(&exc)) { - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { - (void) WRITE2(exc.name, 2); - (void) WRITE2(": TLOSS error\n", 14); - } - errno = ERANGE; - } - break; - case 38: - /* jn(|x|>X_TLOSS) */ - exc.type = TLOSS; - exc.name = "jn"; - exc.retval = zero; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = ERANGE; - else if (!matherr(&exc)) { - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { - (void) WRITE2(exc.name, 2); - (void) WRITE2(": TLOSS error\n", 14); - } - errno = ERANGE; - } - break; - case 39: - /* yn(x>X_TLOSS) */ - exc.type = TLOSS; - exc.name = "yn"; - exc.retval = zero; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = ERANGE; - else if (!matherr(&exc)) { - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { - (void) WRITE2(exc.name, 2); - (void) WRITE2(": TLOSS error\n", 14); - } - errno = ERANGE; - } - break; - case 40: - /* gamma(finite) overflow */ - exc.type = OVERFLOW; - exc.name = "gamma"; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) - exc.retval = HUGE; - else - exc.retval = HUGE_VAL; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - case 41: - /* gamma(-integer) or gamma(0) */ - exc.type = SING; - exc.name = "gamma"; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) - exc.retval = HUGE; - else - exc.retval = HUGE_VAL; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = EDOM; - else if (!matherr(&exc)) { - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { - (void) WRITE2("gamma: SING error\n", 18); - } - errno = EDOM; - } - break; - case 42: - /* pow(NaN,0.0) */ - /* error only if cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID & CYGNUM_LIBM_COMPAT_XOPEN */ - exc.type = DOMAIN; - exc.name = "pow"; - exc.retval = x; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE || - cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) exc.retval = 1.0; - else if (!matherr(&exc)) { - errno = EDOM; - } - break; - case 43: - /* ldexp overflow; SVID also returns +-HUGE_VAL */ - exc.type = OVERFLOW; - exc.name = "ldexp"; - exc.retval = x > zero ? HUGE_VAL : -HUGE_VAL; - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - case 44: - /* ldexp underflow */ - exc.type = UNDERFLOW; - exc.name = "ldexp"; - exc.retval = copysign(zero,x); - if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - } - return exc.retval; -} - -#endif // ifdef CYGPKG_LIBM - -// EOF standard.c +// EOF standard_float.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/misc/standard.inl @@ -0,0 +1,860 @@ +//=========================================================================== +// +// standard.inl +// +// +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2013 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// +// Usage: This file is included by standard.c and standard_float.c +// Note: The contents of this file originally existed in standard.c +// with addition of single precision math library the body was +// transfered here, while standard.c and standard_float.c include +// and instantiate this file for double and single precision floats +// respectively. +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +/* @(#)k_standard.c 1.3 95/01/18 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + * + */ + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + +// Include the Math library? +#ifdef CYGPKG_LIBM + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/cyg_trac.h> // Tracing macros + +#include <math.h> // Main header for math library +#include "mathincl/fdlibm.h" // Internal header for math library + +#include <cyg/error/codes.h> // standard error codes + +#ifndef CYGSEM_LIBM_COMPAT_IEEE_ONLY +#include <errno.h> +#else +static int errno; // this whole file won't be used if we're IEEE only, but + // doing this keeps the compiler happy +#endif + +#ifdef CYGSEM_LIBM_USE_STDERR + +#include <stdio.h> +#define WRITE2(u,v) fputs(u, stderr) + +#else + +#define WRITE2(u,v) 0 + +#endif // ifdef CYGSEM_LIBM_USE_STDERR + + +// GLOBALS + +static const CYG_STANDARD_FLOAT_T zero = (CYG_STANDARD_FLOAT_T)0.0; + +// FUNCTIONS + +/* + * Standard conformance (non-IEEE) on exception cases. + * Mapping: + * 1 -- acos(|x|>1) + * 2 -- asin(|x|>1) + * 3 -- atan2(+-0,+-0) + * 4 -- hypot overflow + * 5 -- cosh overflow + * 6 -- exp overflow + * 7 -- exp underflow + * 8 -- y0(0) + * 9 -- y0(-ve) + * 10-- y1(0) + * 11-- y1(-ve) + * 12-- yn(0) + * 13-- yn(-ve) + * 14-- lgamma(finite) overflow + * 15-- lgamma(-integer) + * 16-- log(0) + * 17-- log(x<0) + * 18-- log10(0) + * 19-- log10(x<0) + * 20-- pow(0.0,0.0) + * 21-- pow(x,y) overflow + * 22-- pow(x,y) underflow + * 23-- pow(0,negative) + * 24-- pow(neg,non-integral) + * 25-- sinh(finite) overflow + * 26-- sqrt(negative) + * 27-- fmod(x,0) + * 28-- remainder(x,0) + * 29-- acosh(x<1) + * 30-- atanh(|x|>1) + * 31-- atanh(|x|=1) + * 32-- scalb overflow + * 33-- scalb underflow + * 34-- j0(|x|>X_TLOSS) + * 35-- y0(x>X_TLOSS) + * 36-- j1(|x|>X_TLOSS) + * 37-- y1(x>X_TLOSS) + * 38-- jn(|x|>X_TLOSS, n) + * 39-- yn(x>X_TLOSS, n) + * 40-- gamma(finite) overflow + * 41-- gamma(-integer) + * 42-- pow(NaN,0.0) + * 43-- ldexp overflow + * 44-- ldexp underflow + */ + +#ifdef FLOAT_SINGLE_PRECISION +float +__kernel_standard_float(float x, float y, int type) +{ + struct exceptionf exc; + +#else +double +__kernel_standard(double x, double y, int type) +{ + struct exception exc; + +#endif + +#ifdef CYGSEM_LIBM_USE_STDERR + (void) fflush(stdout); +#endif + exc.arg1 = x; + exc.arg2 = y; + switch(type) { + case 1: + /* acos(|x|>1) */ + exc.type = DOMAIN; + exc.name = "acos" CYGSTR_FLOAT_SUFFIX; +#ifdef CYGOPT_LIBM_COMPAT_POSIX_IEEE + exc.retval = (x-x)/(x-x); +#else + exc.retval = zero; +#endif + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = EDOM; + else if (!MATHERR(&exc)) { + if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { + (void) WRITE2("acos: DOMAIN error\n", 19); + } + errno = EDOM; + } + break; + case 2: + /* asin(|x|>1) */ + exc.type = DOMAIN; + exc.name = "asin" CYGSTR_FLOAT_SUFFIX; +#ifdef CYGOPT_LIBM_COMPAT_POSIX_IEEE + exc.retval = (x-x)/(x-x); +#else + exc.retval = zero; +#endif + if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = EDOM; + else if (!MATHERR(&exc)) { + if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { + (void) WRITE2("asin: DOMAIN error\n", 19); + } + errno = EDOM; + } + break; + case 3: + /* atan2(+-0,+-0) */ + exc.arg1 = y; + exc.arg2 = x; + exc.type = DOMAIN; + exc.name = "atan2" CYGSTR_FLOAT_SUFFIX; + exc.retval = zero; + if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = EDOM; + else if (!MATHERR(&exc)) { + if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { + (void) WRITE2("atan2: DOMAIN error\n", 20); + } + errno = EDOM; + } + break; + case 4: + /* hypot(finite,finite) overflow */ + exc.type = OVERFLOW; + exc.name = "hypot" CYGSTR_FLOAT_SUFFIX; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) + exc.retval = HUGE; + else + exc.retval = HUGE_VAL; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = ERANGE; + else if (!MATHERR(&exc)) { + errno = ERANGE; + } + break; + case 5: + /* cosh(finite) overflow */ + exc.type = OVERFLOW; + exc.name = "cosh" CYGSTR_FLOAT_SUFFIX; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) + exc.retval = HUGE; + else + exc.retval = HUGE_VAL; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = ERANGE; + else if (!MATHERR(&exc)) { + errno = ERANGE; + } + break; + case 6: + /* exp(finite) overflow */ + exc.type = OVERFLOW; + exc.name = "exp" CYGSTR_FLOAT_SUFFIX; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) + exc.retval = HUGE; + else + exc.retval = HUGE_VAL; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = ERANGE; + else if (!MATHERR(&exc)) { + errno = ERANGE; + } + break; + case 7: + /* exp(finite) underflow */ + exc.type = UNDERFLOW; + exc.name = "exp" CYGSTR_FLOAT_SUFFIX; + exc.retval = zero; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = ERANGE; + else if (!MATHERR(&exc)) { + errno = ERANGE; + } + break; + case 8: + /* y0(0) = -inf */ + exc.type = DOMAIN; /* should be SING for IEEE */ + exc.name = "y0" CYGSTR_FLOAT_SUFFIX; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) + exc.retval = -HUGE; + else + exc.retval = -HUGE_VAL; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = EDOM; + else if (!MATHERR(&exc)) { + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { + (void) WRITE2("y0: DOMAIN error\n", 17); + } + errno = EDOM; + } + break; + case 9: + /* y0(x<0) = NaN */ + exc.type = DOMAIN; + exc.name = "y0" CYGSTR_FLOAT_SUFFIX; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) + exc.retval = -HUGE; + else + exc.retval = -HUGE_VAL; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = EDOM; + else if (!MATHERR(&exc)) { + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { + (void) WRITE2("y0: DOMAIN error\n", 17); + } + errno = EDOM; + } + break; + case 10: + /* y1(0) = -inf */ + exc.type = DOMAIN; /* should be SING for IEEE */ + exc.name = "y1" CYGSTR_FLOAT_SUFFIX; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) + exc.retval = -HUGE; + else + exc.retval = -HUGE_VAL; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = EDOM; + else if (!MATHERR(&exc)) { + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { + (void) WRITE2("y1: DOMAIN error\n", 17); + } + errno = EDOM; + } + break; + case 11: + /* y1(x<0) = NaN */ + exc.type = DOMAIN; + exc.name = "y1" CYGSTR_FLOAT_SUFFIX; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) + exc.retval = -HUGE; + else + exc.retval = -HUGE_VAL; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = EDOM; + else if (!MATHERR(&exc)) { + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { + (void) WRITE2("y1: DOMAIN error\n", 17); + } + errno = EDOM; + } + break; + case 12: + /* yn(n,0) = -inf */ + exc.type = DOMAIN; /* should be SING for IEEE */ + exc.name = "yn" CYGSTR_FLOAT_SUFFIX; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) + exc.retval = -HUGE; + else + exc.retval = -HUGE_VAL; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = EDOM; + else if (!MATHERR(&exc)) { + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { + (void) WRITE2("yn: DOMAIN error\n", 17); + } + errno = EDOM; + } + break; + case 13: + /* yn(x<0) = NaN */ + exc.type = DOMAIN; + exc.name = "yn" CYGSTR_FLOAT_SUFFIX; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) + exc.retval = -HUGE; + else + exc.retval = -HUGE_VAL; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = EDOM; + else if (!MATHERR(&exc)) { + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { + (void) WRITE2("yn: DOMAIN error\n", 17); + } + errno = EDOM; + } + break; + case 14: + /* lgamma(finite) overflow */ + exc.type = OVERFLOW; + exc.name = "lgamma" CYGSTR_FLOAT_SUFFIX; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) + exc.retval = HUGE; + else + exc.retval = HUGE_VAL; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = ERANGE; + else if (!MATHERR(&exc)) { + errno = ERANGE; + } + break; + case 15: + /* lgamma(-integer) or lgamma(0) */ + exc.type = SING; + exc.name = "lgamma" CYGSTR_FLOAT_SUFFIX; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) + exc.retval = HUGE; + else + exc.retval = HUGE_VAL; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = EDOM; + else if (!MATHERR(&exc)) { + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { + (void) WRITE2("lgamma: SING error\n", 19); + } + errno = EDOM; + } + break; + case 16: + /* log(0) */ + exc.type = SING; + exc.name = "log" CYGSTR_FLOAT_SUFFIX; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) + exc.retval = -HUGE; + else + exc.retval = -HUGE_VAL; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = ERANGE; + else if (!MATHERR(&exc)) { + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { + (void) WRITE2("log: SING error\n", 16); + } + errno = EDOM; + } + break; + case 17: + /* log(x<0) */ + exc.type = DOMAIN; + exc.name = "log" CYGSTR_FLOAT_SUFFIX; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) + exc.retval = -HUGE; + else +#ifdef CYGOPT_LIBM_COMPAT_POSIX_IEEE + exc.retval = (x-x)/(x-x); +#else + exc.retval = -HUGE_VAL; +#endif + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = EDOM; + else if (!MATHERR(&exc)) { + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { + (void) WRITE2("log: DOMAIN error\n", 18); + } + errno = EDOM; + } + break; + case 18: + /* log10(0) */ + exc.type = SING; + exc.name = "log10" CYGSTR_FLOAT_SUFFIX; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) + exc.retval = -HUGE; + else + exc.retval = -HUGE_VAL; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = ERANGE; + else if (!MATHERR(&exc)) { + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { + (void) WRITE2("log10: SING error\n", 18); + } + errno = EDOM; + } + break; + case 19: + /* log10(x<0) */ + exc.type = DOMAIN; + exc.name = "log10" CYGSTR_FLOAT_SUFFIX; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) + exc.retval = -HUGE; + else +#ifdef CYGOPT_LIBM_COMPAT_POSIX_IEEE + exc.retval = (x-x)/(x-x); +#else + exc.retval = -HUGE_VAL; +#endif + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = EDOM; + else if (!MATHERR(&exc)) { + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { + (void) WRITE2("log10: DOMAIN error\n", 20); + } + errno = EDOM; + } + break; + case 20: + /* pow(0.0,0.0) */ + /* error only if cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID */ + exc.type = DOMAIN; + exc.name = "pow" CYGSTR_FLOAT_SUFFIX; + exc.retval = zero; + if (cyg_libm_get_compat_mode() != CYGNUM_LIBM_COMPAT_SVID) exc.retval = 1.0; + else if (!MATHERR(&exc)) { + (void) WRITE2("pow(0,0): DOMAIN error\n", 23); + errno = EDOM; + } + break; + case 21: + /* pow(x,y) overflow */ + exc.type = OVERFLOW; + exc.name = "pow" CYGSTR_FLOAT_SUFFIX; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { + exc.retval = HUGE; + y *= 0.5; + if(x<zero&&rint(y)!=y) exc.retval = -HUGE; + } else { + exc.retval = HUGE_VAL; + y *= 0.5; + if(x<zero&&rint(y)!=y) exc.retval = -HUGE_VAL; + } + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = ERANGE; + else if (!MATHERR(&exc)) { + errno = ERANGE; + } + break; + case 22: + /* pow(x,y) underflow */ + exc.type = UNDERFLOW; + exc.name = "pow" CYGSTR_FLOAT_SUFFIX; + exc.retval = zero; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = ERANGE; + else if (!MATHERR(&exc)) { + errno = ERANGE; + } + break; + case 23: + /* 0**neg */ + exc.type = DOMAIN; + exc.name = "pow" CYGSTR_FLOAT_SUFFIX; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) + exc.retval = zero; + else + exc.retval = -HUGE_VAL; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = EDOM; + else if (!MATHERR(&exc)) { + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { + (void) WRITE2("pow(0,neg): DOMAIN error\n", 25); + } + errno = EDOM; + } + break; + case 24: + /* neg**non-integral */ + exc.type = DOMAIN; + exc.name = "pow" CYGSTR_FLOAT_SUFFIX; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) + exc.retval = zero; + else + exc.retval = zero/zero; /* X/Open allow NaN */ + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = EDOM; + else if (!MATHERR(&exc)) { + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { + (void) WRITE2("neg**non-integral: DOMAIN error\n", 32); + } + errno = EDOM; + } + break; + case 25: + /* sinh(finite) overflow */ + exc.type = OVERFLOW; + exc.name = "sinh" CYGSTR_FLOAT_SUFFIX; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) + exc.retval = ( (x>zero) ? HUGE : -HUGE); + else + exc.retval = ( (x>zero) ? HUGE_VAL : -HUGE_VAL); + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = ERANGE; + else if (!MATHERR(&exc)) { + errno = ERANGE; + } + break; + case 26: + /* sqrt(x<0) */ + exc.type = DOMAIN; + exc.name = "sqrt" CYGSTR_FLOAT_SUFFIX; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) + exc.retval = zero; + else + exc.retval = zero/zero; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = EDOM; + else if (!MATHERR(&exc)) { + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { + (void) WRITE2("sqrt: DOMAIN error\n", 19); + } + errno = EDOM; + } + break; + case 27: + /* fmod(x,0) */ + exc.type = DOMAIN; + exc.name = "fmod" CYGSTR_FLOAT_SUFFIX; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) + exc.retval = x; + else + exc.retval = zero/zero; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = EDOM; + else if (!MATHERR(&exc)) { + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { + (void) WRITE2("fmod: DOMAIN error\n", 20); + } + errno = EDOM; + } + break; + case 28: + /* remainder(x,0) */ + exc.type = DOMAIN; + exc.name = "remainder" CYGSTR_FLOAT_SUFFIX; + exc.retval = zero/zero; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = EDOM; + else if (!MATHERR(&exc)) { + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { + (void) WRITE2("remainder: DOMAIN error\n", 24); + } + errno = EDOM; + } + break; + case 29: + /* acosh(x<1) */ + exc.type = DOMAIN; + exc.name = "acosh" CYGSTR_FLOAT_SUFFIX; + exc.retval = zero/zero; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = EDOM; + else if (!MATHERR(&exc)) { + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { + (void) WRITE2("acosh: DOMAIN error\n", 20); + } + errno = EDOM; + } + break; + case 30: + /* atanh(|x|>1) */ + exc.type = DOMAIN; + exc.name = "atanh" CYGSTR_FLOAT_SUFFIX; + exc.retval = zero/zero; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = EDOM; + else if (!MATHERR(&exc)) { + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { + (void) WRITE2("atanh: DOMAIN error\n", 20); + } + errno = EDOM; + } + break; + case 31: + /* atanh(|x|=1) */ + exc.type = SING; + exc.name = "atanh" CYGSTR_FLOAT_SUFFIX; + exc.retval = x/zero; /* sign(x)*inf */ + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = EDOM; + else if (!MATHERR(&exc)) { + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { + (void) WRITE2("atanh: SING error\n", 18); + } + errno = EDOM; + } + break; + case 32: + /* scalb overflow; SVID also returns +-HUGE_VAL */ + exc.type = OVERFLOW; + exc.name = "scalb" CYGSTR_FLOAT_SUFFIX; + exc.retval = x > zero ? HUGE_VAL : -HUGE_VAL; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = ERANGE; + else if (!MATHERR(&exc)) { + errno = ERANGE; + } + break; + case 33: + /* scalb underflow */ + exc.type = UNDERFLOW; + exc.name = "scalb" CYGSTR_FLOAT_SUFFIX; + exc.retval = copysign(zero,x); + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = ERANGE; + else if (!MATHERR(&exc)) { + errno = ERANGE; + } + break; + case 34: + /* j0(|x|>X_TLOSS) */ + exc.type = TLOSS; + exc.name = "j0" CYGSTR_FLOAT_SUFFIX; + exc.retval = zero; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = ERANGE; + else if (!MATHERR(&exc)) { + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { + (void) WRITE2(exc.name, 2); + (void) WRITE2(": TLOSS error\n", 14); + } + errno = ERANGE; + } + break; + case 35: + /* y0(x>X_TLOSS) */ + exc.type = TLOSS; + exc.name = "y0" CYGSTR_FLOAT_SUFFIX; + exc.retval = zero; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = ERANGE; + else if (!MATHERR(&exc)) { + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { + (void) WRITE2(exc.name, 2); + (void) WRITE2(": TLOSS error\n", 14); + } + errno = ERANGE; + } + break; + case 36: + /* j1(|x|>X_TLOSS) */ + exc.type = TLOSS; + exc.name = "j1" CYGSTR_FLOAT_SUFFIX; + exc.retval = zero; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = ERANGE; + else if (!MATHERR(&exc)) { + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { + (void) WRITE2(exc.name, 2); + (void) WRITE2(": TLOSS error\n", 14); + } + errno = ERANGE; + } + break; + case 37: + /* y1(x>X_TLOSS) */ + exc.type = TLOSS; + exc.name = "y1" CYGSTR_FLOAT_SUFFIX; + exc.retval = zero; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = ERANGE; + else if (!MATHERR(&exc)) { + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { + (void) WRITE2(exc.name, 2); + (void) WRITE2(": TLOSS error\n", 14); + } + errno = ERANGE; + } + break; + case 38: + /* jn(|x|>X_TLOSS) */ + exc.type = TLOSS; + exc.name = "jn" CYGSTR_FLOAT_SUFFIX; + exc.retval = zero; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = ERANGE; + else if (!MATHERR(&exc)) { + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { + (void) WRITE2(exc.name, 2); + (void) WRITE2(": TLOSS error\n", 14); + } + errno = ERANGE; + } + break; + case 39: + /* yn(x>X_TLOSS) */ + exc.type = TLOSS; + exc.name = "yn" CYGSTR_FLOAT_SUFFIX; + exc.retval = zero; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = ERANGE; + else if (!MATHERR(&exc)) { + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { + (void) WRITE2(exc.name, 2); + (void) WRITE2(": TLOSS error\n", 14); + } + errno = ERANGE; + } + break; + case 40: + /* gamma(finite) overflow */ + exc.type = OVERFLOW; + exc.name = "gamma" CYGSTR_FLOAT_SUFFIX; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) + exc.retval = HUGE; + else + exc.retval = HUGE_VAL; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = ERANGE; + else if (!MATHERR(&exc)) { + errno = ERANGE; + } + break; + case 41: + /* gamma(-integer) or gamma(0) */ + exc.type = SING; + exc.name = "gamma" CYGSTR_FLOAT_SUFFIX; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) + exc.retval = HUGE; + else + exc.retval = HUGE_VAL; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = EDOM; + else if (!MATHERR(&exc)) { + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) { + (void) WRITE2("gamma: SING error\n", 18); + } + errno = EDOM; + } + break; + case 42: + /* pow(NaN,0.0) */ + /* error only if cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID & CYGNUM_LIBM_COMPAT_XOPEN */ + exc.type = DOMAIN; + exc.name = "pow" CYGSTR_FLOAT_SUFFIX; + exc.retval = x; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE || + cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) exc.retval = 1.0; + else if (!MATHERR(&exc)) { + errno = EDOM; + } + break; + case 43: + /* ldexp overflow; SVID also returns +-HUGE_VAL */ + exc.type = OVERFLOW; + exc.name = "ldexp" CYGSTR_FLOAT_SUFFIX; + exc.retval = x > zero ? HUGE_VAL : -HUGE_VAL; + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = ERANGE; + else if (!MATHERR(&exc)) { + errno = ERANGE; + } + break; + case 44: + /* ldexp underflow */ + exc.type = UNDERFLOW; + exc.name = "ldexp" CYGSTR_FLOAT_SUFFIX; + exc.retval = copysign(zero,x); + if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) + errno = ERANGE; + else if (!MATHERR(&exc)) { + errno = ERANGE; + } + break; + } + return exc.retval; +} + +#endif // ifdef CYGPKG_LIBM + +// EOF standard.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/src/misc/standard_float.c @@ -0,0 +1,60 @@ +//=========================================================================== +// +// standard_float.c +// +// Standard conformance (non-IEEE) on exception cases. +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2013 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ilijak +// Contributors: +// Date: 2013-06-17 +// Purpose: +// Description: +// +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +#define FLOAT_SINGLE_PRECISION +#define CYG_STANDARD_FLOAT_T float +#define CYGSTR_FLOAT_SUFFIX "f" +#define MATHERR(__exc_p) matherrf(__exc_p) +#include "standard.inl" + +// EOF standard_float.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/acosf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// acosf.c +// +// Test of acosf() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/acosf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(acosf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &acosf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_FLOAT, + &acosf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("acosf() is stable"); + } // if + else + { + CYG_TEST_FAIL("acosf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library acosf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "acosf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF acosf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/acoshf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// acoshf.c +// +// Test of acoshf() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/acoshf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(acoshf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &acoshf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_FLOAT, + &acoshf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("acoshf() is stable"); + } // if + else + { + CYG_TEST_FAIL("acoshf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library acoshf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "acoshf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF acoshf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/asinf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// asin.c +// +// Test of asin() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_double_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/asinf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(asinf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &asinf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_FLOAT, + &asinf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("asinf() is stable"); + } // if + else + { + CYG_TEST_FAIL("asinf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library asinf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "asinf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF asin.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/asinhf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// asin.c +// +// Test of asin() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_double_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/asinhf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(asinhf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &asinhf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_FLOAT, + &asinhf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("asinhf() is stable"); + } // if + else + { + CYG_TEST_FAIL("asinhf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library asinhf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "asinhf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF asin.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/atan2f.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// atan2f.c +// +// Test of atan2f() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/atan2f.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(atan2f_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &atan2f, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_FLOAT, CYG_LIBM_TEST_VEC_FLOAT, + &atan2f_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("atan2f() is stable"); + } // if + else + { + CYG_TEST_FAIL("atan2f() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library atan2f() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "atan2f() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF atan2f.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/atanf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// atanf.c +// +// Test of atanf() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_double_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/atanf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(atanf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &atanf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_FLOAT, + &atanf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("atanf() is stable"); + } // if + else + { + CYG_TEST_FAIL("atanf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library atanf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "atanf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF atanf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/atanhf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// atanhf.c +// +// Test of atanhf() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/atanhf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(atanhf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &atanhf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_FLOAT, + &atanhf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("atanhf() is stable"); + } // if + else + { + CYG_TEST_FAIL("atanhf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library atanhf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "atanhf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF atanhf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/cbrtf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// cbrtf.c +// +// Test of cbrtf() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_double_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/cbrtf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(cbrtf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &cbrtf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_FLOAT, + &cbrtf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("cbrtf() is stable"); + } // if + else + { + CYG_TEST_FAIL("cbrtf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library cbrtf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "cbrtf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF cbrtf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/ceilf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// ceilf.c +// +// Test of ceilf() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/ceilf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(ceilf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &ceilf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_FLOAT, + &ceilf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("ceilf() is stable"); + } // if + else + { + CYG_TEST_FAIL("ceilf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library ceilf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "ceilf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF ceilf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/copysignf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// copysignf.c +// +// Test of copysignf() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/copysignf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(copysignf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) ©signf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_FLOAT, CYG_LIBM_TEST_VEC_FLOAT, + ©signf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("copysignf() is stable"); + } // if + else + { + CYG_TEST_FAIL("copysignf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library copysignf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "copysignf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF copysignf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/cosf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// cosf.c +// +// Test of cosf() math library function +// +//=========================================================================== +// ####ECOSFGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSFGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/cosf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(cosf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &cosf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_FLOAT, + &cosf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("cosf() is stable"); + } // if + else + { + CYG_TEST_FAIL("cosf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library cosf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "cosf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF cosf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/coshf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// coshf.c +// +// Test of coshf() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/coshf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(coshf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &coshf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_FLOAT, + &coshf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("coshf() is stable"); + } // if + else + { + CYG_TEST_FAIL("coshf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library coshf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "coshf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF coshf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/erfcf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// erfcf.c +// +// Test of erfcf() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####EERFFGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/erfcf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(erfcf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &erfcf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_FLOAT, + &erfcf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("erfcf() is stable"); + } // if + else + { + CYG_TEST_FAIL("erfcf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library erfcf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "erfcf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF erfcf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/erff.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// erff.c +// +// Test of erff() math library function +// +//=========================================================================== +// ####EERFFGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####EERFFGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/erff.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(erff_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &erff, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_FLOAT, + &erff_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("erff() is stable"); + } // if + else + { + CYG_TEST_FAIL("erff() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library erff() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "erff() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF erff.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/expf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// expf.c +// +// Test of expf() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_double_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/expf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(expf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &expf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_FLOAT, + &expf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("expf() is stable"); + } // if + else + { + CYG_TEST_FAIL("expf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library exp() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "exp() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF expf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/expm1f.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// expm1f.c +// +// Test of expm1f() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/expm1f.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(expm1f_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &expm1f, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_FLOAT, + &expm1f_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("expm1f() is stable"); + } // if + else + { + CYG_TEST_FAIL("expm1f() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library expm1f() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "expm1f() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF expm1f.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/fabsf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// fabsf.c +// +// Test of fabsf() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/fabsf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(fabsf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &fabsf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_FLOAT, + &fabsf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("fabsf() is stable"); + } // if + else + { + CYG_TEST_FAIL("fabsf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library fabsf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "fabsf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF fabsf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/finitef.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// finitef.c +// +// Test of finitef() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/finitef.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(finitef_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &finitef, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_FLOAT, + &finitef_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("finitef() is stable"); + } // if + else + { + CYG_TEST_FAIL("finitef() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library finitef() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "finitef() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF finitef.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/floorf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// floorf.c +// +// Test of floorf() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/floorf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(floorf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &floorf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_FLOAT, + &floorf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("floorf() is stable"); + } // if + else + { + CYG_TEST_FAIL("floorf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library floorf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "floorf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF floorf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/fmodf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// fmod.c +// +// Test of fmod() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_double_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/fmodf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(fmodf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &fmodf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_FLOAT, CYG_LIBM_TEST_VEC_FLOAT, + &fmodf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("fmodf() is stable"); + } // if + else + { + CYG_TEST_FAIL("fmodf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library fmodf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "fmod() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF fmod.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/frexpf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// frexpf.c +// +// Test of frexpf() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/frexpf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(frexpf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &frexpf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_INT_P, CYG_LIBM_TEST_VEC_FLOAT, + &frexpf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("frexpf() is stable"); + } // if + else + { + CYG_TEST_FAIL("frexpf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library frexpf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "frexpf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF frexpf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/gammaf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// gammaf.c +// +// Test of gammaf() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/gammaf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(gammaf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &gammaf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_FLOAT, + &gammaf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("gammaf() is stable"); + } // if + else + { + CYG_TEST_FAIL("gammaf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library gammaf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "gammaf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF gammaf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/hypotf.c @@ -0,0 +1,58 @@ +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_double_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/hypotf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(hypotf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &hypotf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_FLOAT, CYG_LIBM_TEST_VEC_FLOAT, + &hypotf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("hypotf() is stable"); + } // if + else + { + CYG_TEST_FAIL("hypotf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library hypotf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "hypotf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF log10.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/ilogbf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// ilogbf.c +// +// Test of ilogbf() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vetors/ilogbf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(ilogbf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &ilogbf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_INT, + &ilogbf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("ilogbf() is stable"); + } // if + else + { + CYG_TEST_FAIL("ilogbf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library ilogbf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "ilogbf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF ilogbf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/isnanf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// isnanf.c +// +// Test of isnanf() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/isnanf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(isnanf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &isnanf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_INT, + &isnanf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("isnanf() is stable"); + } // if + else + { + CYG_TEST_FAIL("isnanf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library isnanf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "isnanf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF isnanf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/j0f.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// j0f.c +// +// Test of j0f() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/j0f.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(j0f_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &j0f, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_FLOAT, + &j0f_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("j0f() is stable"); + } // if + else + { + CYG_TEST_FAIL("j0f() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library j0f() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "j0f() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF j0f.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/j1f.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// j1f.c +// +// Test of j1f() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/j1f.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(j1f_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &j1f, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_FLOAT, + &j1f_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("j1f() is stable"); + } // if + else + { + CYG_TEST_FAIL("j1f() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library j1f() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "j1f() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF j1f.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/jnf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// jnf.c +// +// Test of jnf() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/jnf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(jnf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &jnf, CYG_LIBM_TEST_VEC_INT, + CYG_LIBM_TEST_VEC_FLOAT, CYG_LIBM_TEST_VEC_FLOAT, + &jnf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("jnf() is stable"); + } // if + else + { + CYG_TEST_FAIL("jnf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library jnf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "jnf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF jnf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/ldexpf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// ldexpf.c +// +// Test of ldexpf() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/ldexpf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(ldexpf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &ldexpf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_INT, CYG_LIBM_TEST_VEC_FLOAT, + &ldexpf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("ldexpf() is stable"); + } // if + else + { + CYG_TEST_FAIL("ldexpf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library ldexpf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "ldexpf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF ldexpf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/log10f.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// log10.c +// +// Test of log10() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_double_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/log10f.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(log10f_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &log10f, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_FLOAT, + &log10f_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("log10f() is stable"); + } // if + else + { + CYG_TEST_FAIL("log10f() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library log10f() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "log10() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF log10.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/log1pf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// log1pf.c +// +// Test of log1pf() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/log1pf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(log1pf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &log1pf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_FLOAT, + &log1pf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("log1pf() is stable"); + } // if + else + { + CYG_TEST_FAIL("log1pf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library log1pf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "log1pf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF log1pf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/logbf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// logbf.c +// +// Test of logbf() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/logbf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(logbf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &logbf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_FLOAT, + &logbf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("logbf() is stable"); + } // if + else + { + CYG_TEST_FAIL("logbf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library logbf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "logbf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF logbf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/logf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// log.c +// +// Test of log() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_double_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/logf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(logf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &logf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_FLOAT, + &logf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("logf() is stable"); + } // if + else + { + CYG_TEST_FAIL("logf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library log() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "log() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF log.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/modff.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// modff.c +// +// Test of modff() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/modff.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(modff_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &modff, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_FLOAT_P, CYG_LIBM_TEST_VEC_FLOAT, + &modff_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("modff() is stable"); + } // if + else + { + CYG_TEST_FAIL("modff() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library modff() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "modff() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF modff.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/nextafterf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// nextafterf.c +// +// Test of nextafterf() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/nextafterf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(nextafterf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &nextafterf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_FLOAT, CYG_LIBM_TEST_VEC_FLOAT, + &nextafterf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("nextafterf() is stable"); + } // if + else + { + CYG_TEST_FAIL("nextafterf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library nextafterf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "nextafterf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF nextafterf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/powf.c @@ -0,0 +1,114 @@ +//=========================================================================== +// +// pow.c +// +// Test of pow() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_double_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/powf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(pow_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &powf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_FLOAT, + &pow_vec[0], vec_size ); + + if (ret==true) { + CYG_TEST_PASS("powf() is stable"); + } // if + else { + CYG_TEST_FAIL("powf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library powf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "pow() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF pow.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/remainderf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// remainderf.c +// +// Test of remainderf() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/remainderf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(remainderf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &remainderf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_FLOAT, CYG_LIBM_TEST_VEC_FLOAT, + &remainderf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("remainderf() is stable"); + } // if + else + { + CYG_TEST_FAIL("remainderf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library remainderf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "remainderf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF remainderf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/rintf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// rintf.c +// +// Test of rintf() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/rintf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(rintf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &rintf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_FLOAT, + &rintf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("rintf() is stable"); + } // if + else + { + CYG_TEST_FAIL("rintf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library rintf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "rintf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF rintf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/scalbf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// scalbf.c +// +// Test of scalbf() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/scalbf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(scalbf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &scalbf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_FLOAT, CYG_LIBM_TEST_VEC_FLOAT, + &scalbf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("scalbf() is stable"); + } // if + else + { + CYG_TEST_FAIL("scalbf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library scalbf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "scalbf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF scalbf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/scalbnf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// scalbnf.c +// +// Test of scalbnf() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/scalbnf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(scalbnf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &scalbnf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_INT, CYG_LIBM_TEST_VEC_FLOAT, + &scalbnf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("scalbnf() is stable"); + } // if + else + { + CYG_TEST_FAIL("scalbnf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library scalbnf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "scalbnf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF scalbnf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/significandf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// significandf.c +// +// Test of significandf() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/significandf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(significandf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &significandf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_FLOAT, + &significandf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("significandf() is stable"); + } // if + else + { + CYG_TEST_FAIL("significandf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library significandf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "significandf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF significandf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/sinf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// sinf.c +// +// Test of sinf() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/sinf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(sinf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &sinf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_FLOAT, + &sinf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("sinf() is stable"); + } // if + else + { + CYG_TEST_FAIL("sinf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library sinf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "sinf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF sinf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/sinhf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// sinhf.c +// +// Test of sinhf() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/sinhf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(sinhf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &sinhf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_FLOAT, + &sinhf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("sinhf() is stable"); + } // if + else + { + CYG_TEST_FAIL("sinhf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library sinhf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "sinhf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF sinhf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/sqrtf.c @@ -0,0 +1,127 @@ +//=========================================================================== +// +// sqrtf.c +// +// Test of sqrtf() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_double_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/sqrtf.h" + +// FUNCTIONS + +#ifdef CYGSEM_LIBM_IEEE_API_INLINE +float Sqrtf(float x) +{ + return sqrtf(x); +} +#endif + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(sqrtf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( +#ifndef CYGSEM_LIBM_IEEE_API_INLINE + (CYG_ADDRWORD) &sqrtf, +#else + (CYG_ADDRWORD) &Sqrtf, +#endif + CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_FLOAT, + &sqrtf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("sqrtf() is stable"); + } // if + else + { + CYG_TEST_FAIL("sqrtf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library sqrtf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "sqrtf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + +// EOF sqrtf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/tanf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// tanf.c +// +// Test of tanf() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/tanf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(tanf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &tanf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_FLOAT, + &tanf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("tanf() is stable"); + } // if + else + { + CYG_TEST_FAIL("tanf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library tanf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "tanf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF tanf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/tanhf.c @@ -0,0 +1,115 @@ +//=========================================================================== +// +// tanhf.c +// +// Test of tanhf() math library function +// +//=========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: visar, ilijak +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// Declarations for test system: +// +// TESTCASE_TYPE=CYG_TEST_MODULE + + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header + + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_float_shape_type +#include "vectors/vector_support_float.h"// extra support for math tests + +#include "vectors/tanhf.h" + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + cyg_ucount32 vec_size; + cyg_bool ret; + + vec_size = sizeof(tanhf_vec) / sizeof(Cyg_libm_test_float_vec_t); + ret = doTestVecFloat( (CYG_ADDRWORD) &tanhf, CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_NONE, CYG_LIBM_TEST_VEC_FLOAT, + &tanhf_vec[0], vec_size ); + + if (ret==true) + { + CYG_TEST_PASS("tanhf() is stable"); + } // if + else + { + CYG_TEST_FAIL("tanhf() failed tests"); + } // else + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for Math " + "library tanhf() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for Math library " + "tanhf() function"); + + START_TEST( test ); + + CYG_TEST_PASS_FINISH("Testing is not applicable to this configuration"); + +} // main() + + +// EOF tanhf.c
new file mode 100644 --- /dev/null +++ b/packages/language/c/libm/current/tests/vectors/vector_support_float.h @@ -0,0 +1,550 @@ +#ifndef CYGONCE_LIBM_VECTOR_SUPPORT_H +#define CYGONCE_LIBM_VECTOR_SUPPORT_H + +//======================================================================== +// +// vector_support_float.h +// +// Support for testing of the math library using test vectors +// +//======================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 1998, 1999, 2000, 2001, 2002 2012, 2013 Free Software Foundation, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: jlarmour, visar, ilijak +// Date: 1999-01-21 +// Purpose: +// Description: +// Usage: #include "vectors/vector_support_float.h" +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include <pkgconf/libm.h> // Configuration header +#include <pkgconf/isoinfra.h> // CYGINT_ISO_MAIN_STARTUP + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/testcase.h> // Test infrastructure +#include <math.h> // Header for this package +#include <sys/ieeefp.h> // Cyg_libm_ieee_double_shape_type +#include <cyg/infra/diag.h> + +#ifndef CYGSEM_LIBM_COMPAT_IEEE_ONLY +# include <errno.h> // For Cyg_ErrNo +#else +# ifndef EDOM +# define EDOM 33 +# endif +#endif + +// CONSTANTS + +#define PROBLEM_THRESHOLD 10 // Number of test vectors allowed to fail + // before we give up completely + +// HOW TO START TESTS + +#if CYGINT_ISO_MAIN_STARTUP + +# define START_TEST( test ) test(0) + +#elif defined(CYGFUN_KERNEL_API_C) + +# include <cyg/hal/hal_arch.h> +# include <cyg/kernel/kapi.h> + +# define STACKSIZE CYGNUM_HAL_STACK_SIZE_TYPICAL + +static cyg_uint8 stack[STACKSIZE]; +static cyg_handle_t thr_handle; +static cyg_thread thr; + +# define START_TEST( test ) CYG_MACRO_START \ + cyg_thread_create( 4, &test, (cyg_addrword_t)0, "test", \ + &stack[0], STACKSIZE, &thr_handle, &thr ); \ + cyg_thread_resume( thr_handle ); \ + cyg_scheduler_start(); \ + CYG_MACRO_END + +externC int main( int, char ** ); + +externC void +cyg_user_start( void ) +{ + (void) main(0, NULL); +} // cyg_user_start() + +#else // !defined(CYGFUN_KERNEL_API_C) + +externC int main( int, char ** ); + +externC void +cyg_user_start( void ) +{ + (void) main(0, NULL); +} // cyg_user_start() + +# define START_TEST( test ) test(0) + +#endif + +// TYPE DEFINITIONS + + +typedef enum { + CYG_LIBM_TEST_VEC_NONE, // this indicates whether the "double" + CYG_LIBM_TEST_VEC_INT, // is being used to store a double, an + CYG_LIBM_TEST_VEC_FLOAT, + CYG_LIBM_TEST_VEC_INT_P, // int pointer + CYG_LIBM_TEST_VEC_FLOAT_P +} Cyg_libm_test_arg_type; + + +// Define a type for a test vector record +// Define a floattype for a test vector record + +typedef struct { + cyg_ucount32 vector_num; // id number of this test vector record + + // if any of the following arguments are ints rather than doubles, then + // use the lsw part to store it + + cyg_uint32 arg1; // first argument + cyg_uint32 arg2; // second argument + cyg_uint32 result; // expected return value + +#ifndef CYGSEM_LIBM_COMPAT_IEEE_ONLY + Cyg_ErrNo errno_val; // expected value of errno. 0==unchanged +#else + cyg_uint32 errno_val; +#endif + + float tolerance; // relative amount that it is allowed + // to vary. i.e. the value should be + // plus or minus result*tolerance + + int matherr_type; // if testing the matherr() function, + // what type should the exception be +} Cyg_libm_test_float_vec_t; + +// types to cope with the different forms of function to be called by the +// test vector + +typedef float (*fffn) ( float, float ); +typedef float (*fifn) ( float, int ); +typedef float (*ffn) ( float ); +typedef float (*ffpfn) ( float, float *); +typedef float (*fipfn) ( float, int *); +typedef float (*iffn) ( int, float ); +typedef int (*i_ffn) (float); + +// STATIC FUNCTIONS + +// equivalent of abs() for doubles. We want to be independent of fabs() + +static float +my_abs_f( float x ) +{ + Cyg_libm_ieee_float_shape_type t; + + t.value = x; + + t.number.sign = 0; + + return t.value; +} // my_abs_f() + + +static cyg_bool +checkErrorAcceptableFloat( Cyg_libm_ieee_float_shape_type is, + Cyg_libm_ieee_float_shape_type shouldbe, + float tolerance) // _relative_ amount it can vary +{ + Cyg_libm_ieee_float_shape_type temp_flt; + + // first do a short-circuit check if its identical + if ( (is.asi32 == shouldbe.asi32) ) + return false; + + // now check special cases + + // +0 == -0 + if ( ((is.asi32 & 0x7fffffff) == 0) && + ((shouldbe.asi32 & 0x7fffffff) == 0) ) + return false; + + // +-infinity == +-infinity + if ((is.number.fraction0 == 0) && (shouldbe.number.fraction0 == 0) && + (is.number.exponent == 255) && (shouldbe.number.exponent == 255)) + { + return (is.number.sign != shouldbe.number.sign); + } // if + + // both NaN. Assumes isnan works, but its pretty safe + if ( isnanf(is.value) && isnanf(shouldbe.value) ) + return false; + else if (isnanf(is.value) || isnanf(shouldbe.value) ) + return true; + + // check same sign. Even around small values close to 0 we would want + // it to be on the right _side_ of 0 + if ( is.number.sign != shouldbe.number.sign ) + return true; + + // okay, now work out what tolerance means for us + + // find out what the difference is in the first place + temp_flt.value = my_abs_f( shouldbe.value - is.value ); + + // Check "both ways round" to deal with both under and overflow cases + if ( ((temp_flt.value / tolerance) < my_abs_f(shouldbe.value)) || + (temp_flt.value < (my_abs_f(shouldbe.value) * tolerance)) ) + return false; + else + return true; // so its not close enough + +} // checkErrorAcceptableFloat() + + +static cyg_bool +doTestVecFloat( CYG_ADDRESS func_ptr, + Cyg_libm_test_arg_type arg1_type, + Cyg_libm_test_arg_type arg2_type, + Cyg_libm_test_arg_type result_type, + const Cyg_libm_test_float_vec_t *vectors, + cyg_ucount32 num_vectors ) +{ + cyg_ucount32 problems=0; + cyg_ucount32 i; + Cyg_libm_ieee_float_shape_type arg1, arg2, result_wanted, ret; + cyg_ucount32 alive_count = num_vectors / 10; + + if (arg1_type == CYG_LIBM_TEST_VEC_INT) { + iffn fn = (iffn) func_ptr; + + for (i=0; + (i < num_vectors) && (problems < PROBLEM_THRESHOLD); + i++) { + + if (0 == i % alive_count) + CYG_TEST_STILL_ALIVE(i, "Still crunching, please wait..."); + + arg1.asi32 = vectors[i].arg1; + arg2.asi32 = vectors[i].arg2; + + result_wanted.asi32 = vectors[i].result; + + ret.value = (*fn)( (int)arg1.value, arg2.value ); + + if ((vectors[i].errno_val) != 0) { + +#ifndef CYGSEM_LIBM_COMPAT_IEEE_ONLY + // In IEEE-mode we can't check the answer if this + // is an error case + + if ((cyg_libm_get_compat_mode() != + CYGNUM_LIBM_COMPAT_IEEE) && + (errno != vectors[i].errno_val)) { + + ++problems; + diag_printf("Vector #%d\n", i+1); + CYG_TEST_FAIL( "error not set correctly"); + + } // if +#endif + + continue; // no point checking value in an error case + } // if + if (checkErrorAcceptableFloat( ret, result_wanted, + vectors[i].tolerance) ) { + ++problems; + diag_printf("Vector #%d\n", i+1); + CYG_TEST_FAIL( "Result out of tolerance"); + } // if + } // for + if (problems != 0) + return false; + else + return true; + } + if ((arg1_type != CYG_LIBM_TEST_VEC_FLOAT) || + (result_type != CYG_LIBM_TEST_VEC_FLOAT && + result_type != CYG_LIBM_TEST_VEC_INT)) { + CYG_TEST_FAIL("Test vector arguments are not correct type!"); + return false; + } // if + + switch (arg2_type) { + case CYG_LIBM_TEST_VEC_FLOAT: + + { + fffn fn = (fffn) func_ptr; + + for (i=0; + (i < num_vectors) && (problems < PROBLEM_THRESHOLD); + i++) { + + if (0 == i % alive_count) + CYG_TEST_STILL_ALIVE(i, "Still crunching, please wait..."); + + arg1.asi32 = vectors[i].arg1; + arg2.asi32 = vectors[i].arg2; + + result_wanted.asi32 = vectors[i].result; + + ret.value = (*fn)( arg1.value, arg2.value ); + + if ((vectors[i].errno_val) != 0) { + +#ifndef CYGSEM_LIBM_COMPAT_IEEE_ONLY + // In IEEE-mode we can't check the answer if this + // is an error case + + if ((cyg_libm_get_compat_mode() != + CYGNUM_LIBM_COMPAT_IEEE) && + (errno != vectors[i].errno_val)) { + + ++problems; + diag_printf("Vector #%d\n", i+1); + CYG_TEST_FAIL( "error not set correctly"); + + } // if +#endif + + continue; // no point checking value in an error case + } // if + if (checkErrorAcceptableFloat( ret, result_wanted, + vectors[i].tolerance) ) { + ++problems; + diag_printf("Vector #%d\n", i+1); + CYG_TEST_FAIL( "Result out of tolerance"); + } // if + } // for + + } // compound + + break; + + case CYG_LIBM_TEST_VEC_INT: + + { + fifn fn = (fifn) func_ptr; + + for (i=0; + (i < num_vectors) && (problems < PROBLEM_THRESHOLD); + i++) { + + if (0 == i % alive_count) + CYG_TEST_STILL_ALIVE(i, "Still crunching, please wait..."); + + arg1.asi32 = vectors[i].arg1; + + result_wanted.asi32 = vectors[i].result; + + ret.value = (*fn)( arg1.value, vectors[i].arg2 ); + + if (checkErrorAcceptableFloat( ret, result_wanted, + vectors[i].tolerance) ) { + ++problems; + diag_printf("Vector #%d\n", i+1); + CYG_TEST_FAIL( "Result out of tolerance"); + } // if + } // for + + } // compound + + break; + + case CYG_LIBM_TEST_VEC_INT_P: + + { + fipfn fn = (fipfn) func_ptr; + int my_int; + Cyg_libm_ieee_float_shape_type my_flt1, my_flt2; + + for (i=0; + (i < num_vectors) && (problems < PROBLEM_THRESHOLD); + i++) { + + if (0 == i % alive_count) + CYG_TEST_STILL_ALIVE(i, "Still crunching, please wait..."); + + arg1.asi32 = vectors[i].arg1; + + result_wanted.asi32 = vectors[i].result; + + ret.value = (*fn)( arg1.value, &my_int ); + + if (checkErrorAcceptableFloat( ret, result_wanted, + vectors[i].tolerance) ) { + ++problems; + diag_printf("Vector #%d\n", i+1); + CYG_TEST_FAIL( "Result out of tolerance"); + } // if + + my_flt1.value = (float) my_int; + my_flt2.value = (float) (signed)vectors[i].arg2; + + if (checkErrorAcceptableFloat( my_flt1, my_flt2, + vectors[i].tolerance) ) { + ++problems; + diag_printf("Vector #%d\n", i+1); + CYG_TEST_FAIL( "Integer result out of tolerance"); + } // if + + + } // for + + } // compound + + break; + + case CYG_LIBM_TEST_VEC_FLOAT_P: + + { + ffpfn fn = (ffpfn) func_ptr; + Cyg_libm_ieee_float_shape_type my_flt1; + + for (i=0; + (i < num_vectors) && (problems < PROBLEM_THRESHOLD); + i++) { + + if (0 == i % alive_count) + CYG_TEST_STILL_ALIVE(i, "Still crunching, please wait..."); + + arg1.asi32 = vectors[i].arg1; + arg2.asi32 = vectors[i].arg2; + + result_wanted.asi32 = vectors[i].result; + + ret.value = (*fn)( arg1.value, &my_flt1.value ); + if (checkErrorAcceptableFloat( ret, result_wanted, + vectors[i].tolerance) ) { + ++problems; + diag_printf("Vector #%d\n", i+1); + CYG_TEST_FAIL( "Result out of tolerance"); + } // if + + if (checkErrorAcceptableFloat( my_flt1, arg2, + vectors[i].tolerance) ) { + ++problems; + diag_printf("Vector #%d\n", i+1); + CYG_TEST_FAIL( "Returned float result out of " + "tolerance"); + } // if + + + } // for + + } // compound + + break; + + case CYG_LIBM_TEST_VEC_NONE: + + { + if (result_type == CYG_LIBM_TEST_VEC_INT) { + i_ffn fn = (i_ffn) func_ptr; + + for (i=0; + (i < num_vectors) && (problems < PROBLEM_THRESHOLD); + i++) { + + if (0 == i % alive_count) + CYG_TEST_STILL_ALIVE(i, "Still crunching, please wait..."); + + arg1.asi32 = vectors[i].arg1; + + result_wanted.asi32 = vectors[i].result; + ret.value = (*fn)( arg1.value ); + /* Get a 32 bit int from a float. */ + + if (checkErrorAcceptableFloat( ret, result_wanted, + vectors[i].tolerance) ) { + ++problems; + diag_printf("Vector #%d\n", i+1); + CYG_TEST_FAIL( "Result out of tolerance"); + } // if + } // for + } + else + { + ffn fn = (ffn) func_ptr; + + for (i=0; + (i < num_vectors) && (problems < PROBLEM_THRESHOLD); + i++) { + + if (0 == i % alive_count) + CYG_TEST_STILL_ALIVE(i, "Still crunching, please wait..."); + + arg1.asi32 = vectors[i].arg1; + + result_wanted.asi32 = vectors[i].result; + ret.value = (*fn)( arg1.value ); + /* Get a 32 bit int from a float. */ + + if (checkErrorAcceptableFloat( ret, result_wanted, + vectors[i].tolerance) ) { + ++problems; + diag_printf("Vector #%d\n", i+1); + CYG_TEST_FAIL( "Result out of tolerance"); + } // if + } // for + } + } // compound + + break; + + default: + CYG_TEST_FAIL("Second argument of unknown type!"); + return false; + } // switch + + if (problems != 0) + return false; + else + return true; + +} // doTestVecFloat() + +#endif // CYGONCE_LIBM_VECTOR_SUPPORT_H multiple inclusion protection + +// EOF vector_support_float.h
