summaryrefslogtreecommitdiff
path: root/libc/math
diff options
context:
space:
mode:
Diffstat (limited to 'libc/math')
-rw-r--r--libc/math/Makefile8
-rw-r--r--libc/math/Versions30
-rw-r--r--libc/math/bits/math-finite.h322
-rw-r--r--libc/math/bits/mathcalls.h5
-rw-r--r--libc/math/divtc3.c16
-rw-r--r--libc/math/e_acoshl.c1
-rw-r--r--libc/math/e_acosl.c1
-rw-r--r--libc/math/e_asinl.c1
-rw-r--r--libc/math/e_atan2l.c1
-rw-r--r--libc/math/e_atanhl.c1
-rw-r--r--libc/math/e_coshl.c1
-rw-r--r--libc/math/e_exp10.c5
-rw-r--r--libc/math/e_exp10f.c5
-rw-r--r--libc/math/e_exp10l.c5
-rw-r--r--libc/math/e_exp2l.c3
-rw-r--r--libc/math/e_expl.c1
-rw-r--r--libc/math/e_fmodl.c1
-rw-r--r--libc/math/e_gammal_r.c1
-rw-r--r--libc/math/e_hypotl.c1
-rw-r--r--libc/math/e_j0l.c4
-rw-r--r--libc/math/e_j1l.c4
-rw-r--r--libc/math/e_jnl.c4
-rw-r--r--libc/math/e_lgammal_r.c3
-rw-r--r--libc/math/e_log10l.c1
-rw-r--r--libc/math/e_log2l.c1
-rw-r--r--libc/math/e_logl.c1
-rw-r--r--libc/math/e_powl.c1
-rw-r--r--libc/math/e_rem_pio2l.c2
-rw-r--r--libc/math/e_scalb.c114
-rw-r--r--libc/math/e_scalbf.c111
-rw-r--r--libc/math/e_scalbl.c116
-rw-r--r--libc/math/e_sinhl.c1
-rw-r--r--libc/math/e_sqrtl.c1
-rw-r--r--libc/math/k_cosl.c2
-rw-r--r--libc/math/k_sinl.c2
-rw-r--r--libc/math/k_tanl.c2
-rw-r--r--libc/math/libm-test.inc31
-rw-r--r--libc/math/math.h19
-rw-r--r--libc/math/math_private.h45
-rw-r--r--libc/math/multc3.c17
-rw-r--r--libc/math/s_cacosh.c3
-rw-r--r--libc/math/s_cacoshf.c2
-rw-r--r--libc/math/s_cacoshl.c3
-rw-r--r--libc/math/s_casin.c5
-rw-r--r--libc/math/s_casinf.c5
-rw-r--r--libc/math/s_casinh.c3
-rw-r--r--libc/math/s_casinhf.c3
-rw-r--r--libc/math/s_casinhl.c3
-rw-r--r--libc/math/s_casinl.c5
-rw-r--r--libc/math/s_catan.c9
-rw-r--r--libc/math/s_catanf.c9
-rw-r--r--libc/math/s_catanh.c17
-rw-r--r--libc/math/s_catanhf.c17
-rw-r--r--libc/math/s_catanhl.c17
-rw-r--r--libc/math/s_catanl.c9
-rw-r--r--libc/math/s_ccos.c51
-rw-r--r--libc/math/s_ccosf.c51
-rw-r--r--libc/math/s_ccosh.c26
-rw-r--r--libc/math/s_ccoshf.c26
-rw-r--r--libc/math/s_ccoshl.c28
-rw-r--r--libc/math/s_ccosl.c51
-rw-r--r--libc/math/s_cexp.c19
-rw-r--r--libc/math/s_cexpf.c19
-rw-r--r--libc/math/s_cexpl.c19
-rw-r--r--libc/math/s_clog.c9
-rw-r--r--libc/math/s_clog10.c9
-rw-r--r--libc/math/s_clog10f.c9
-rw-r--r--libc/math/s_clog10l.c9
-rw-r--r--libc/math/s_clogf.c8
-rw-r--r--libc/math/s_clogl.c9
-rw-r--r--libc/math/s_csin.c14
-rw-r--r--libc/math/s_csinf.c14
-rw-r--r--libc/math/s_csinh.c28
-rw-r--r--libc/math/s_csinhf.c28
-rw-r--r--libc/math/s_csinhl.c28
-rw-r--r--libc/math/s_csinl.c14
-rw-r--r--libc/math/s_csqrt.c11
-rw-r--r--libc/math/s_csqrtf.c11
-rw-r--r--libc/math/s_csqrtl.c11
-rw-r--r--libc/math/s_ctan.c12
-rw-r--r--libc/math/s_ctanf.c13
-rw-r--r--libc/math/s_ctanh.c13
-rw-r--r--libc/math/s_ctanhf.c13
-rw-r--r--libc/math/s_ctanhl.c13
-rw-r--r--libc/math/s_ctanl.c12
-rw-r--r--libc/math/s_ldexp.c2
-rw-r--r--libc/math/s_ldexpf.c2
-rw-r--r--libc/math/s_ldexpl.c2
-rw-r--r--libc/math/s_nan.c1
-rw-r--r--libc/math/s_nanf.c1
-rw-r--r--libc/math/s_nanl.c1
-rw-r--r--libc/math/s_significand.c2
-rw-r--r--libc/math/s_significandf.c2
-rw-r--r--libc/math/s_significandl.c2
-rw-r--r--libc/math/w_acos.c64
-rw-r--r--libc/math/w_acosf.c66
-rw-r--r--libc/math/w_acosh.c61
-rw-r--r--libc/math/w_acoshf.c64
-rw-r--r--libc/math/w_acoshl.c63
-rw-r--r--libc/math/w_acosl.c66
-rw-r--r--libc/math/w_asin.c63
-rw-r--r--libc/math/w_asinf.c67
-rw-r--r--libc/math/w_asinl.c67
-rw-r--r--libc/math/w_atan2.c55
-rw-r--r--libc/math/w_atan2f.c56
-rw-r--r--libc/math/w_atan2l.c57
-rw-r--r--libc/math/w_atanh.c66
-rw-r--r--libc/math/w_atanhf.c69
-rw-r--r--libc/math/w_atanhl.c68
-rw-r--r--libc/math/w_cosh.c33
-rw-r--r--libc/math/w_coshf.c37
-rw-r--r--libc/math/w_coshl.c32
-rw-r--r--libc/math/w_dremf.c2
-rw-r--r--libc/math/w_exp10.c60
-rw-r--r--libc/math/w_exp10f.c65
-rw-r--r--libc/math/w_exp10l.c63
-rw-r--r--libc/math/w_exp2.c28
-rw-r--r--libc/math/w_exp2f.c28
-rw-r--r--libc/math/w_exp2l.c22
-rw-r--r--libc/math/w_fmod.c63
-rw-r--r--libc/math/w_fmodf.c64
-rw-r--r--libc/math/w_fmodl.c65
-rw-r--r--libc/math/w_hypot.c31
-rw-r--r--libc/math/w_hypotf.c33
-rw-r--r--libc/math/w_hypotl.c28
-rw-r--r--libc/math/w_j0.c106
-rw-r--r--libc/math/w_j0f.c112
-rw-r--r--libc/math/w_j0l.c110
-rw-r--r--libc/math/w_j1.c107
-rw-r--r--libc/math/w_j1f.c112
-rw-r--r--libc/math/w_j1l.c110
-rw-r--r--libc/math/w_jn.c129
-rw-r--r--libc/math/w_jnf.c111
-rw-r--r--libc/math/w_jnl.c2
-rw-r--r--libc/math/w_lgamma.c45
-rw-r--r--libc/math/w_lgamma_r.c37
-rw-r--r--libc/math/w_lgammaf.c47
-rw-r--r--libc/math/w_lgammaf_r.c45
-rw-r--r--libc/math/w_lgammal.c45
-rw-r--r--libc/math/w_lgammal_r.c38
-rw-r--r--libc/math/w_log.c71
-rw-r--r--libc/math/w_log10.c74
-rw-r--r--libc/math/w_log10f.c77
-rw-r--r--libc/math/w_log10l.c76
-rw-r--r--libc/math/w_log2.c51
-rw-r--r--libc/math/w_log2f.c55
-rw-r--r--libc/math/w_log2l.c53
-rw-r--r--libc/math/w_logf.c74
-rw-r--r--libc/math/w_logl.c73
-rw-r--r--libc/math/w_pow.c113
-rw-r--r--libc/math/w_powf.c124
-rw-r--r--libc/math/w_powl.c117
-rw-r--r--libc/math/w_remainder.c62
-rw-r--r--libc/math/w_remainderf.c64
-rw-r--r--libc/math/w_remainderl.c65
-rw-r--r--libc/math/w_scalb.c96
-rw-r--r--libc/math/w_scalbf.c99
-rw-r--r--libc/math/w_scalbl.c98
-rw-r--r--libc/math/w_sinh.c31
-rw-r--r--libc/math/w_sinhf.c36
-rw-r--r--libc/math/w_sinhl.c31
-rw-r--r--libc/math/w_sqrt.c60
-rw-r--r--libc/math/w_sqrtf.c62
-rw-r--r--libc/math/w_sqrtl.c62
-rw-r--r--libc/math/w_tgamma.c28
-rw-r--r--libc/math/w_tgammaf.c36
-rw-r--r--libc/math/w_tgammal.c30
167 files changed, 2859 insertions, 3315 deletions
diff --git a/libc/math/Makefile b/libc/math/Makefile
index 7900a8470..95fd6b066 100644
--- a/libc/math/Makefile
+++ b/libc/math/Makefile
@@ -1,5 +1,4 @@
-# Copyright (C) 1996-2001,2002,2003,2004,2005,2006
-# Free Software Foundation, Inc.
+# Copyright (C) 1996-2006,2011 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
@@ -27,7 +26,8 @@ include ../option-groups.mak
headers := math.h bits/mathcalls.h bits/mathinline.h bits/huge_val.h \
bits/huge_valf.h bits/huge_vall.h bits/inf.h bits/nan.h \
fpu_control.h complex.h bits/cmathcalls.h fenv.h \
- bits/fenv.h bits/fenvinline.h bits/mathdef.h tgmath.h
+ bits/fenv.h bits/fenvinline.h bits/mathdef.h tgmath.h \
+ bits/math-finite.h
# Internal header files.
distribute := math_ldbl.h math_private.h machine/asm.h
@@ -62,7 +62,7 @@ libm-calls = e_acos e_acosh e_asin e_atan2 e_atanh e_cosh e_exp e_fmod \
s_catan s_casin s_ccos s_csin s_ctan s_ctanh s_cacos \
s_casinh s_cacosh s_catanh s_csqrt s_cpow s_cproj s_clog10 \
s_fma s_lrint s_llrint s_lround s_llround e_exp10 w_log2 \
- $(calls:s_%=m_%)
+ s_isinf_ns $(calls:s_%=m_%)
include ../Makeconfig
diff --git a/libc/math/Versions b/libc/math/Versions
index 39c47626f..09888510b 100644
--- a/libc/math/Versions
+++ b/libc/math/Versions
@@ -168,4 +168,34 @@ libm {
# puts exp2l in GLIBC_2.1, which will override this entry.
exp2l;
}
+ GLIBC_2.15 {
+ # Optimized -ffinite-math-only entry points
+ __acos_finite; __acosf_finite; __acosl_finite;
+ __acosh_finite; __acoshf_finite; __acoshl_finite;
+ __asin_finite; __asinf_finite; __asinl_finite;
+ __atan2_finite; __atan2f_finite; __atan2l_finite;
+ __atanh_finite; __atanhf_finite; __atanhl_finite;
+ __cosh_finite; __coshf_finite; __coshl_finite;
+ __exp10_finite; __exp10f_finite; __exp10l_finite;
+ __exp2_finite; __exp2f_finite; __exp2l_finite;
+ __fmod_finite; __fmodf_finite; __fmodl_finite;
+ __hypot_finite; __hypotf_finite; __hypotl_finite;
+ __j0_finite; __j0f_finite; __j0l_finite;
+ __y0_finite; __y0f_finite; __y0l_finite;
+ __j1_finite; __j1f_finite; __j1l_finite;
+ __y1_finite; __y1f_finite; __y1l_finite;
+ __jn_finite; __jnf_finite; __jnl_finite;
+ __yn_finite; __ynf_finite; __ynl_finite;
+ __lgamma_r_finite; __lgammaf_r_finite; __lgammal_r_finite;
+ __log_finite; __logf_finite; __logl_finite;
+ __log10_finite; __log10f_finite; __log10l_finite;
+ __log2_finite; __log2f_finite; __log2l_finite;
+ __pow_finite; __powf_finite; __powl_finite;
+ __remainder_finite; __remainderf_finite; __remainderl_finite;
+ __scalb_finite; __scalbf_finite; __scalbl_finite;
+ __sinh_finite; __sinhf_finite; __sinhl_finite;
+ __sqrt_finite; __sqrtf_finite; __sqrtl_finite;
+ __gamma_r_finite; __gammaf_r_finite; __gammal_r_finite;
+ __exp_finite; __expf_finite; __expl_finite;
+ }
}
diff --git a/libc/math/bits/math-finite.h b/libc/math/bits/math-finite.h
new file mode 100644
index 000000000..7443d26ad
--- /dev/null
+++ b/libc/math/bits/math-finite.h
@@ -0,0 +1,322 @@
+/* Entry points to finite-math-only compiler runs.
+ Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _MATH_H
+# error "Never use <bits/math-finite.h> directly; include <math.h> instead."
+#endif
+
+/* acos. */
+extern double acos (double) __asm__ ("__acos_finite");
+extern float acosf (float) __asm__ ("__acosf_finite");
+#ifdef __MATH_DECLARE_LDOUBLE
+extern long double acosl (long double) __asm__ ("__acosl_finite");
+#endif
+
+#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
+/* acosh. */
+extern double acosh (double) __asm__ ("__acosh_finite");
+extern float acoshf (float) __asm__ ("__acoshf_finite");
+# ifdef __MATH_DECLARE_LDOUBLE
+extern long double acoshl (long double) __asm__ ("__acoshl_finite");
+# endif
+#endif
+
+/* asin. */
+extern double asin (double) __asm__ ("__asin_finite");
+extern float asinf (float) __asm__ ("__asinf_finite");
+#ifdef __MATH_DECLARE_LDOUBLE
+extern long double asinl (long double) __asm__ ("__asinl_finite");
+#endif
+
+/* atan2. */
+extern double atan2 (double, double) __asm__ ("__atan2_finite");
+extern float atan2f (float, float) __asm__ ("__atan2f_finite");
+#ifdef __MATH_DECLARE_LDOUBLE
+extern long double atan2l (long double, long double) __asm__ ("__atan2l_finite");
+#endif
+
+#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
+/* atanh. */
+extern double atanh (double) __asm__ ("__atanh_finite");
+extern float atanhf (float) __asm__ ("__atanhf_finite");
+# ifdef __MATH_DECLARE_LDOUBLE
+extern long double atanhl (long double) __asm__ ("__atanhl_finite");
+# endif
+#endif
+
+/* cosh. */
+extern double cosh (double) __asm__ ("__cosh_finite");
+extern float coshf (float) __asm__ ("__coshf_finite");
+#ifdef __MATH_DECLARE_LDOUBLE
+extern long double coshl (long double) __asm__ ("__coshl_finite");
+#endif
+
+/* exp. */
+extern double exp (double) __asm__ ("__exp_finite");
+extern float expf (float) __asm__ ("__expf_finite");
+#ifdef __MATH_DECLARE_LDOUBLE
+extern long double expl (long double) __asm__ ("__expl_finite");
+#endif
+
+#ifdef __USE_GNU
+/* exp10. */
+extern double exp10 (double) __asm__ ("__exp10_finite");
+extern float exp10f (float) __asm__ ("__exp10f_finite");
+# ifdef __MATH_DECLARE_LDOUBLE
+extern long double exp10l (long double) __asm__ ("__exp10l_finite");
+# endif
+
+/* pow10. */
+extern double pow10 (double) __asm__ ("__exp10_finite");
+extern float pow10f (float) __asm__ ("__exp10f_finite");
+# ifdef __MATH_DECLARE_LDOUBLE
+extern long double pow10l (long double) __asm__ ("__exp10l_finite");
+# endif
+#endif
+
+#ifdef __USE_ISOC99
+/* exp2. */
+extern double exp2 (double) __asm__ ("__exp2_finite");
+extern float exp2f (float) __asm__ ("__exp2f_finite");
+# ifdef __MATH_DECLARE_LDOUBLE
+extern long double exp2l (long double) __asm__ ("__exp2l_finite");
+# endif
+#endif
+
+/* fmod. */
+extern double fmod (double, double) __asm__ ("__fmod_finite");
+extern float fmodf (float, float) __asm__ ("__fmodf_finite");
+#ifdef __MATH_DECLARE_LDOUBLE
+extern long double fmodl (long double, long double) __asm__ ("__fmodl_finite");
+#endif
+
+#ifdef __USE_ISOC99
+/* hypot. */
+extern double hypot (double, double) __asm__ ("__hypot_finite");
+extern float hypotf (float, float) __asm__ ("__hypotf_finite");
+# ifdef __MATH_DECLARE_LDOUBLE
+extern long double hypotl (long double, long double) __asm__ ("__hypotl_finite");
+# endif
+#endif
+
+#if defined __USE_MISC || defined __USE_XOPEN
+/* j0. */
+extern double j0 (double) __asm__ ("__j0_finite");
+extern float j0f (float) __asm__ ("__j0f_finite");
+# ifdef __MATH_DECLARE_LDOUBLE
+extern long double j0l (long double) __asm__ ("__j0l_finite");
+# endif
+
+/* y0. */
+extern double y0 (double) __asm__ ("__y0_finite");
+extern float y0f (float) __asm__ ("__y0f_finite");
+# ifdef __MATH_DECLARE_LDOUBLE
+extern long double y0l (long double) __asm__ ("__y0l_finite");
+# endif
+
+/* j1. */
+extern double j1 (double) __asm__ ("__j1_finite");
+extern float j1f (float) __asm__ ("__j1f_finite");
+# ifdef __MATH_DECLARE_LDOUBLE
+extern long double j1l (long double) __asm__ ("__j1l_finite");
+# endif
+
+/* y1. */
+extern double y1 (double) __asm__ ("__y1_finite");
+extern float y1f (float) __asm__ ("__y1f_finite");
+# ifdef __MATH_DECLARE_LDOUBLE
+extern long double y1l (long double) __asm__ ("__y1l_finite");
+# endif
+
+/* jn. */
+extern double jn (int, double) __asm__ ("__jn_finite");
+extern float jnf (int, float) __asm__ ("__jnf_finite");
+# ifdef __MATH_DECLARE_LDOUBLE
+extern long double jnl (int, long double) __asm__ ("__jnl_finite");
+# endif
+
+/* yn. */
+extern double yn (int, double) __asm__ ("__yn_finite");
+extern float ynf (int, float) __asm__ ("__ynf_finite");
+# ifdef __MATH_DECLARE_LDOUBLE
+extern long double ynl (int, long double) __asm__ ("__ynl_finite");
+# endif
+#endif
+
+#ifdef __USE_MISC
+/* lgamma_r. */
+extern double lgamma_r (double, int *) __asm__ ("__lgamma_r_finite");
+extern float lgammaf_r (float, int *) __asm__ ("__lgammaf_r_finite");
+# ifdef __MATH_DECLARE_LDOUBLE
+extern long double lgammal_r (long double, int *) __asm__ ("__lgammal_r_finite");
+# endif
+#endif
+
+#if defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC99
+/* lgamma. */
+__extern_always_inline double lgamma (double __d)
+{
+# ifdef __USE_ISOC99
+ int __local_signgam = 0;
+ return lgamma_r (__d, &__local_signgam);
+# else
+ return lgamma_r (__d, &signgam);
+# endif
+}
+__extern_always_inline float lgammaf (float __d)
+{
+# ifdef __USE_ISOC99
+ int __local_signgam = 0;
+ return lgammaf_r (__d, &__local_signgam);
+# else
+ return lgammaf_r (__d, &signgam);
+# endif
+}
+# ifdef __MATH_DECLARE_LDOUBLE
+__extern_always_inline long double lgammal (long double __d)
+{
+# ifdef __USE_ISOC99
+ int __local_signgam = 0;
+ return lgammal_r (__d, &__local_signgam);
+# else
+ return lgammal_r (__d, &signgam);
+# endif
+}
+# endif
+#endif
+
+#if defined __USE_MISC || defined __USE_XOPEN
+/* gamma. */
+__extern_always_inline double gamma (double __d)
+{
+# ifdef __USE_ISOC99
+ int __local_signgam = 0;
+ return lgamma_r (__d, &__local_signgam);
+# else
+ return lgamma_r (__d, &signgam);
+# endif
+}
+__extern_always_inline float gammaf (float __d)
+{
+# ifdef __USE_ISOC99
+ int __local_signgam = 0;
+ return lgammaf_r (__d, &__local_signgam);
+# else
+ return lgammaf_r (__d, &signgam);
+# endif
+}
+# ifdef __MATH_DECLARE_LDOUBLE
+__extern_always_inline long double gammal (long double __d)
+{
+# ifdef __USE_ISOC99
+ int __local_signgam = 0;
+ return lgammal_r (__d, &__local_signgam);
+# else
+ return lgammal_r (__d, &signgam);
+# endif
+}
+# endif
+#endif
+
+/* log. */
+extern double log (double) __asm__ ("__log_finite");
+extern float logf (float) __asm__ ("__logf_finite");
+#ifdef __MATH_DECLARE_LDOUBLE
+extern long double logl (long double) __asm__ ("__logl_finite");
+#endif
+
+/* log10. */
+extern double log10 (double) __asm__ ("__log10_finite");
+extern float log10f (float) __asm__ ("__log10f_finite");
+#ifdef __MATH_DECLARE_LDOUBLE
+extern long double log10l (long double) __asm__ ("__log10l_finite");
+#endif
+
+#ifdef __USE_ISOC99
+/* log2. */
+extern double log2 (double) __asm__ ("__log2_finite");
+extern float log2f (float) __asm__ ("__log2f_finite");
+# ifdef __MATH_DECLARE_LDOUBLE
+extern long double log2l (long double) __asm__ ("__log2l_finite");
+# endif
+#endif
+
+/* pow. */
+extern double pow (double, double) __asm__ ("__pow_finite");
+extern float powf (float, float) __asm__ ("__powf_finite");
+#ifdef __MATH_DECLARE_LDOUBLE
+extern long double powl (long double, long double) __asm__ ("__powl_finite");
+#endif
+
+/* remainder. */
+extern double remainder (double, double) __asm__ ("__remainder_finite");
+extern float remainderf (float, float) __asm__ ("__remainderf_finite");
+#ifdef __MATH_DECLARE_LDOUBLE
+extern long double remainderl (long double, long double) __asm__ ("__remainderl_finite");
+#endif
+
+#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
+/* scalb. */
+extern double scalb (double, double) __asm__ ("__scalb_finite");
+extern float scalbf (float, float) __asm__ ("__scalbf_finite");
+# ifdef __MATH_DECLARE_LDOUBLE
+extern long double scalbl (long double, long double) __asm__ ("__scalbl_finite");
+# endif
+#endif
+
+/* sinh. */
+extern double sinh (double) __asm__ ("__sinh_finite");
+extern float sinhf (float) __asm__ ("__sinhf_finite");
+#ifdef __MATH_DECLARE_LDOUBLE
+extern long double sinhl (long double) __asm__ ("__sinhl_finite");
+#endif
+
+/* sqrt. */
+extern double sqrt (double) __asm__ ("__sqrt_finite");
+extern float sqrtf (float) __asm__ ("__sqrtf_finite");
+#ifdef __MATH_DECLARE_LDOUBLE
+extern long double sqrtl (long double) __asm__ ("__sqrtl_finite");
+#endif
+
+#ifdef __USE_ISOC99
+/* tgamma. */
+extern double __gamma_r_finite (double, int *);
+__extern_always_inline double tgamma (double __d)
+{
+ int __local_signgam = 0;
+ double __res = __gamma_r_finite (__d, &__local_signgam);
+ return __local_signgam < 0 ? -__res : __res;
+}
+extern float __gammaf_r_finite (float, int *);
+__extern_always_inline float tgammaf (float __d)
+{
+ int __local_signgam = 0;
+ float __res = __gammaf_r_finite (__d, &__local_signgam);
+ return __local_signgam < 0 ? -__res : __res;
+}
+# ifdef __MATH_DECLARE_LDOUBLE
+extern long double __gammal_r_finite (long double, int *);
+__extern_always_inline long double tgammal (long double __d)
+{
+ int __local_signgam = 0;
+ long double __res = __gammal_r_finite (__d, &__local_signgam);
+ return __local_signgam < 0 ? -__res : __res;
+}
+# endif
+#endif
diff --git a/libc/math/bits/mathcalls.h b/libc/math/bits/mathcalls.h
index 64da6276f..4f22abf74 100644
--- a/libc/math/bits/mathcalls.h
+++ b/libc/math/bits/mathcalls.h
@@ -1,5 +1,5 @@
/* Prototype declarations for math functions; helper file for <math.h>.
- Copyright (C) 1996-2002, 2003, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1996-2002, 2003, 2006, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -113,7 +113,8 @@ __MATHCALL (log,, (_Mdouble_ __x));
__MATHCALL (log10,, (_Mdouble_ __x));
/* Break VALUE into integral and fractional parts. */
-__MATHCALL (modf,, (_Mdouble_ __x, _Mdouble_ *__iptr));
+__MATHCALL (modf,, (_Mdouble_ __x, _Mdouble_ *__iptr))
+ __attribute__ ((__nonnull__ (2)));
_Mdouble_END_NAMESPACE
#ifdef __USE_GNU
diff --git a/libc/math/divtc3.c b/libc/math/divtc3.c
index d974ae645..72bca66d4 100644
--- a/libc/math/divtc3.c
+++ b/libc/math/divtc3.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2006, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Richard Henderson <rth@redhat.com>, 2005.
@@ -55,17 +55,19 @@ __divtc3 (long double a, long double b, long double c, long double d)
x = __copysignl (INFINITY, c) * a;
y = __copysignl (INFINITY, c) * b;
}
- else if ((isinf (a) || isinf (b)) && isfinite (c) && isfinite (d))
+ else if ((__isinf_nsl (a) || __isinf_nsl (b))
+ && isfinite (c) && isfinite (d))
{
- a = __copysignl (isinf (a) ? 1 : 0, a);
- b = __copysignl (isinf (b) ? 1 : 0, b);
+ a = __copysignl (__isinf_nsl (a) ? 1 : 0, a);
+ b = __copysignl (__isinf_nsl (b) ? 1 : 0, b);
x = INFINITY * (a * c + b * d);
y = INFINITY * (b * c - a * d);
}
- else if ((isinf (c) || isinf (d)) && isfinite (a) && isfinite (b))
+ else if ((__isinf_nsl (c) || __isinf_nsl (d))
+ && isfinite (a) && isfinite (b))
{
- c = __copysignl (isinf (c) ? 1 : 0, c);
- d = __copysignl (isinf (d) ? 1 : 0, d);
+ c = __copysignl (__isinf_nsl (c) ? 1 : 0, c);
+ d = __copysignl (__isinf_nsl (d) ? 1 : 0, d);
x = 0.0 * (a * c + b * d);
y = 0.0 * (b * c - a * d);
}
diff --git a/libc/math/e_acoshl.c b/libc/math/e_acoshl.c
index 2c2fbe8eb..490fd10fd 100644
--- a/libc/math/e_acoshl.c
+++ b/libc/math/e_acoshl.c
@@ -9,6 +9,7 @@ __ieee754_acoshl (long double x)
__set_errno (ENOSYS);
return 0.0;
}
+strong_alias (__ieee754_acoshl, __acoshl_finite)
stub_warning (acoshl)
#include <stub-tag.h>
diff --git a/libc/math/e_acosl.c b/libc/math/e_acosl.c
index d844d885b..55d9ab0f6 100644
--- a/libc/math/e_acosl.c
+++ b/libc/math/e_acosl.c
@@ -9,6 +9,7 @@ __ieee754_acosl (long double x)
__set_errno (ENOSYS);
return 0.0;
}
+strong_alias (__ieee754_acosl, __acosl_finite)
stub_warning (acosl)
#include <stub-tag.h>
diff --git a/libc/math/e_asinl.c b/libc/math/e_asinl.c
index 3b26f030e..8e6c47e70 100644
--- a/libc/math/e_asinl.c
+++ b/libc/math/e_asinl.c
@@ -9,6 +9,7 @@ __ieee754_asinl (long double x)
__set_errno (ENOSYS);
return 0.0;
}
+strong_alias (__ieee754_asinl, __asinl_finite)
stub_warning (asinl)
#include <stub-tag.h>
diff --git a/libc/math/e_atan2l.c b/libc/math/e_atan2l.c
index 0caed8a32..8ca37622f 100644
--- a/libc/math/e_atan2l.c
+++ b/libc/math/e_atan2l.c
@@ -9,6 +9,7 @@ __ieee754_atan2l (long double x, long double y)
__set_errno (ENOSYS);
return 0.0;
}
+strong_alias (__ieee754_atan2l, __atan2l_finite)
stub_warning (atan2l)
#include <stub-tag.h>
diff --git a/libc/math/e_atanhl.c b/libc/math/e_atanhl.c
index 625d42db3..26c52e793 100644
--- a/libc/math/e_atanhl.c
+++ b/libc/math/e_atanhl.c
@@ -9,6 +9,7 @@ __ieee754_atanhl (long double x)
__set_errno (ENOSYS);
return 0.0;
}
+strong_alias (__ieee754_atanhl, __atanhl_finite)
stub_warning (__ieee754_atanhl)
#include <stub-tag.h>
diff --git a/libc/math/e_coshl.c b/libc/math/e_coshl.c
index 0da319b78..92bfd7a18 100644
--- a/libc/math/e_coshl.c
+++ b/libc/math/e_coshl.c
@@ -9,6 +9,7 @@ __ieee754_coshl (long double x)
__set_errno (ENOSYS);
return 0.0;
}
+strong_alias (__ieee754_coshl, __coshl_finite)
stub_warning (__ieee754_coshl)
#include <stub-tag.h>
diff --git a/libc/math/e_exp10.c b/libc/math/e_exp10.c
index a3eccbb9e..ce14ea5f1 100644
--- a/libc/math/e_exp10.c
+++ b/libc/math/e_exp10.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
@@ -18,7 +18,7 @@
02111-1307 USA. */
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
double
@@ -28,3 +28,4 @@ __ieee754_exp10 (double arg)
replaced sometime (soon?). */
return __ieee754_exp (M_LN10 * arg);
}
+strong_alias (__ieee754_exp10, __exp10_finite)
diff --git a/libc/math/e_exp10f.c b/libc/math/e_exp10f.c
index 7d06d074b..68e9723b8 100644
--- a/libc/math/e_exp10f.c
+++ b/libc/math/e_exp10f.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
@@ -18,7 +18,7 @@
02111-1307 USA. */
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
float
@@ -28,3 +28,4 @@ __ieee754_exp10f (float arg)
replaced sometime (soon?). */
return __ieee754_expf (M_LN10 * arg);
}
+strong_alias (__ieee754_exp10f, __exp10f_finite)
diff --git a/libc/math/e_exp10l.c b/libc/math/e_exp10l.c
index 56f0cfec2..6bd859fde 100644
--- a/libc/math/e_exp10l.c
+++ b/libc/math/e_exp10l.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
@@ -18,7 +18,7 @@
02111-1307 USA. */
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
long double
@@ -28,3 +28,4 @@ __ieee754_exp10l (long double arg)
replaced sometime (soon?). */
return __ieee754_expl (M_LN10l * arg);
}
+strong_alias (__ieee754_exp10l, __exp10l_finite)
diff --git a/libc/math/e_exp2l.c b/libc/math/e_exp2l.c
index 7e598d8d2..e7e493933 100644
--- a/libc/math/e_exp2l.c
+++ b/libc/math/e_exp2l.c
@@ -1,5 +1,5 @@
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
long double
__ieee754_exp2l (long double x)
@@ -8,3 +8,4 @@ __ieee754_exp2l (long double x)
replaced sometime (soon?). */
return __ieee754_expl (M_LN2l * x);
}
+strong_alias (__ieee754_exp2l, __exp2l_finite)
diff --git a/libc/math/e_expl.c b/libc/math/e_expl.c
index f9467c38a..5ba6eb584 100644
--- a/libc/math/e_expl.c
+++ b/libc/math/e_expl.c
@@ -9,6 +9,7 @@ __ieee754_expl (long double x)
__set_errno (ENOSYS);
return 0.0;
}
+strong_alias (__ieee754_expl, __expl_finite)
stub_warning (expl)
#include <stub-tag.h>
diff --git a/libc/math/e_fmodl.c b/libc/math/e_fmodl.c
index 380da24e4..dbd361ebc 100644
--- a/libc/math/e_fmodl.c
+++ b/libc/math/e_fmodl.c
@@ -9,6 +9,7 @@ __ieee754_fmodl (long double x, long double y)
__set_errno (ENOSYS);
return 0.0;
}
+strong_alias (__ieee754_fmodl, __fmodl_finite)
stub_warning (fmodl)
#include <stub-tag.h>
diff --git a/libc/math/e_gammal_r.c b/libc/math/e_gammal_r.c
index 1c45c8421..c0ae70426 100644
--- a/libc/math/e_gammal_r.c
+++ b/libc/math/e_gammal_r.c
@@ -10,6 +10,7 @@ __ieee754_gammal_r (long double x, int *signgamp)
__set_errno (ENOSYS);
return 0.0;
}
+strong_alias (__ieee754_gammal_r, __gammal_r_finite)
stub_warning (__ieee754_gammal_r)
#include <stub-tag.h>
diff --git a/libc/math/e_hypotl.c b/libc/math/e_hypotl.c
index 07df22eb3..73bad6277 100644
--- a/libc/math/e_hypotl.c
+++ b/libc/math/e_hypotl.c
@@ -9,6 +9,7 @@ __ieee754_hypotl (long double x, long double y)
__set_errno (ENOSYS);
return 0.0;
}
+strong_alias (__ieee754_hypotl, __hypotl_finite)
stub_warning (__ieee754_hypotl)
#include <stub-tag.h>
diff --git a/libc/math/e_j0l.c b/libc/math/e_j0l.c
index 1bf0a1de7..eb01ba67c 100644
--- a/libc/math/e_j0l.c
+++ b/libc/math/e_j0l.c
@@ -1,7 +1,7 @@
#include <math.h>
#include <stdio.h>
#include <errno.h>
-#include "math_private.h"
+#include <math_private.h>
long double
__ieee754_j0l (long double x)
@@ -10,6 +10,7 @@ __ieee754_j0l (long double x)
__set_errno (ENOSYS);
return 0.0;
}
+strong_alias (__ieee754_j0l, __j0l_finite)
stub_warning (j0l)
@@ -20,6 +21,7 @@ __ieee754_y0l (long double x)
__set_errno (ENOSYS);
return 0.0;
}
+strong_alias (__ieee754_y0l, __y0l_finite)
stub_warning (y0l)
#include <stub-tag.h>
diff --git a/libc/math/e_j1l.c b/libc/math/e_j1l.c
index 656abeba5..7701f49ff 100644
--- a/libc/math/e_j1l.c
+++ b/libc/math/e_j1l.c
@@ -1,7 +1,7 @@
#include <math.h>
#include <stdio.h>
#include <errno.h>
-#include "math_private.h"
+#include <math_private.h>
long double
__ieee754_j1l (long double x)
@@ -10,6 +10,7 @@ __ieee754_j1l (long double x)
__set_errno (ENOSYS);
return 0.0;
}
+strong_alias (__ieee754_j1l, __j1l_finite)
stub_warning (j1l)
@@ -20,6 +21,7 @@ __ieee754_y1l (long double x)
__set_errno (ENOSYS);
return 0.0;
}
+strong_alias (__ieee754_y1l, __y1l_finite)
stub_warning (y1l)
#include <stub-tag.h>
diff --git a/libc/math/e_jnl.c b/libc/math/e_jnl.c
index 1bfc0695a..059b1db6b 100644
--- a/libc/math/e_jnl.c
+++ b/libc/math/e_jnl.c
@@ -1,7 +1,7 @@
#include <math.h>
#include <stdio.h>
#include <errno.h>
-#include "math_private.h"
+#include <math_private.h>
long double
__ieee754_jnl (int n, long double x)
@@ -10,6 +10,7 @@ __ieee754_jnl (int n, long double x)
__set_errno (ENOSYS);
return 0.0;
}
+strong_alias (__ieee754_jnl, __jnl_finite)
stub_warning (jnl)
@@ -20,6 +21,7 @@ __ieee754_ynl (int n, long double x)
__set_errno (ENOSYS);
return 0.0;
}
+strong_alias (__ieee754_ynl, __ynl_finite)
stub_warning (ynl)
#include <stub-tag.h>
diff --git a/libc/math/e_lgammal_r.c b/libc/math/e_lgammal_r.c
index 1784b2663..92e7700e2 100644
--- a/libc/math/e_lgammal_r.c
+++ b/libc/math/e_lgammal_r.c
@@ -1,7 +1,7 @@
#include <math.h>
#include <stdio.h>
#include <errno.h>
-#include "math_private.h"
+#include <math_private.h>
long double
__ieee754_lgammal_r (long double x, int *signgamp)
@@ -11,6 +11,7 @@ __ieee754_lgammal_r (long double x, int *signgamp)
__set_errno (ENOSYS);
return 0.0;
}
+strong_alias (__ieee754_lgammal_r, __lgammal_r_finite)
stub_warning (lgammal)
stub_warning (lgammal_r)
diff --git a/libc/math/e_log10l.c b/libc/math/e_log10l.c
index 5bc264b32..2c7ff72c2 100644
--- a/libc/math/e_log10l.c
+++ b/libc/math/e_log10l.c
@@ -9,6 +9,7 @@ __ieee754_log10l (long double x)
__set_errno (ENOSYS);
return 0.0;
}
+strong_alias (__ieee754_log10l, __log10l_finite)
stub_warning (log10l)
#include <stub-tag.h>
diff --git a/libc/math/e_log2l.c b/libc/math/e_log2l.c
index 681904bfb..95929c360 100644
--- a/libc/math/e_log2l.c
+++ b/libc/math/e_log2l.c
@@ -9,6 +9,7 @@ __ieee754_log2l (long double x)
__set_errno (ENOSYS);
return 0.0;
}
+strong_alias (__ieee754_log2l, __log2l_finite)
stub_warning (log2l)
#include <stub-tag.h>
diff --git a/libc/math/e_logl.c b/libc/math/e_logl.c
index 9ba9cfc79..95608ab55 100644
--- a/libc/math/e_logl.c
+++ b/libc/math/e_logl.c
@@ -9,6 +9,7 @@ __ieee754_logl (long double x)
__set_errno (ENOSYS);
return 0.0;
}
+strong_alias (__ieee754_logl, __logl_finite)
stub_warning (logl)
#include <stub-tag.h>
diff --git a/libc/math/e_powl.c b/libc/math/e_powl.c
index afc2248b6..ab79b1a4b 100644
--- a/libc/math/e_powl.c
+++ b/libc/math/e_powl.c
@@ -9,6 +9,7 @@ __ieee754_powl (long double x, long double y)
__set_errno (ENOSYS);
return 0.0;
}
+strong_alias (__ieee754_powl, __powl_finite)
stub_warning (powl)
#include <stub-tag.h>
diff --git a/libc/math/e_rem_pio2l.c b/libc/math/e_rem_pio2l.c
index 617215516..7fa515df2 100644
--- a/libc/math/e_rem_pio2l.c
+++ b/libc/math/e_rem_pio2l.c
@@ -1,7 +1,7 @@
#include <math.h>
#include <stdio.h>
#include <errno.h>
-#include "math_private.h"
+#include <math_private.h>
int
__ieee754_rem_pio2l (long double x, long double *y)
diff --git a/libc/math/e_scalb.c b/libc/math/e_scalb.c
index 606af5372..3b81dd565 100644
--- a/libc/math/e_scalb.c
+++ b/libc/math/e_scalb.c
@@ -1,71 +1,59 @@
-/* @(#)e_scalb.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: e_scalb.c,v 1.6 1995/05/10 20:46:09 jtc Exp $";
-#endif
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-/*
- * __ieee754_scalb(x, fn) is provide for
- * passing various standard test suite. One
- * should use scalbn() instead.
- */
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
+
-#ifdef _SCALB_INT
-#ifdef __STDC__
- double __ieee754_scalb(double x, int fn)
-#else
- double __ieee754_scalb(x,fn)
- double x; int fn;
-#endif
-#else
-#ifdef __STDC__
- double __ieee754_scalb(double x, double fn)
-#else
- double __ieee754_scalb(x,fn)
- double x, fn;
-#endif
-#endif
+static double
+__attribute__ ((noinline))
+invalid_fn (double x, double fn)
{
-#ifdef _SCALB_INT
- return __scalbn(x,fn);
-#else
- if (__isnan(x)||__isnan(fn)) return x*fn;
- if (!__finite(fn)) {
- if(fn>0.0) return x*fn;
- else if (x == 0)
- return x;
- else if (!__finite (x))
- {
-# ifdef FE_INVALID
- feraiseexcept (FE_INVALID);
-# endif
- return __nan ("");
- }
- else return x/(-fn);
- }
- if (__rint(fn)!=fn)
- {
-# ifdef FE_INVALID
- feraiseexcept (FE_INVALID);
-# endif
- return __nan ("");
- }
- if ( fn > 65000.0) return __scalbn(x, 65000);
- if (-fn > 65000.0) return __scalbn(x,-65000);
- return __scalbn(x,(int)fn);
-#endif
+ if (__rint (fn) != fn)
+ {
+ feraiseexcept (FE_INVALID);
+ return __nan ("");
+ }
+ else if (fn > 65000.0)
+ return __scalbn (x, 65000);
+ else
+ return __scalbn (x,-65000);
+}
+
+
+double
+__ieee754_scalb (double x, double fn)
+{
+ if (__builtin_expect (__isnan (x), 0))
+ return x * fn;
+ if (__builtin_expect (!__finite (fn), 0))
+ {
+ if (__isnan (fn) || fn > 0.0)
+ return x * fn;
+ if (x == 0.0)
+ return x;
+ return x / -fn;
+ }
+ if (__builtin_expect ((double) (int) fn != fn, 0))
+ return invalid_fn (x, fn);
+
+ return __scalbn (x, (int) fn);
}
+strong_alias (__ieee754_scalb, __scalb_finite)
diff --git a/libc/math/e_scalbf.c b/libc/math/e_scalbf.c
index 95a72eb56..61847d9a5 100644
--- a/libc/math/e_scalbf.c
+++ b/libc/math/e_scalbf.c
@@ -1,68 +1,59 @@
-/* e_scalbf.c -- float version of e_scalb.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: e_scalbf.c,v 1.3 1995/05/10 20:46:12 jtc Exp $";
-#endif
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
+
-#ifdef _SCALB_INT
-#ifdef __STDC__
- float __ieee754_scalbf(float x, int fn)
-#else
- float __ieee754_scalbf(x,fn)
- 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
+static float
+__attribute__ ((noinline))
+invalid_fn (float x, float fn)
{
-#ifdef _SCALB_INT
- return __scalbnf(x,fn);
-#else
- if (__isnanf(x)||__isnanf(fn)) return x*fn;
- if (!__finitef(fn)) {
- if(fn>(float)0.0) return x*fn;
- else if (x == 0)
- return x;
- else if (!__finitef (x))
- {
-# ifdef FE_INVALID
- feraiseexcept (FE_INVALID);
-# endif
- return __nanf ("");
- }
- else return x/(-fn);
- }
- if (__rintf(fn)!=fn)
- {
-# ifdef FE_INVALID
- feraiseexcept (FE_INVALID);
-# endif
- return __nanf ("");
- }
- if ( fn > (float)65000.0) return __scalbnf(x, 65000);
- if (-fn > (float)65000.0) return __scalbnf(x,-65000);
- return __scalbnf(x,(int)fn);
-#endif
+ if (__rintf (fn) != fn)
+ {
+ feraiseexcept (FE_INVALID);
+ return __nan ("");
+ }
+ else if (fn > 65000.0f)
+ return __scalbnf (x, 65000);
+ else
+ return __scalbnf (x,-65000);
+}
+
+
+float
+__ieee754_scalbf (float x, float fn)
+{
+ if (__builtin_expect (__isnanf (x), 0))
+ return x * fn;
+ if (__builtin_expect (!__finitef (fn), 0))
+ {
+ if (__isnanf (fn) || fn > 0.0f)
+ return x * fn;
+ if (x == 0.0f)
+ return x;
+ return x / -fn;
+ }
+ if (__builtin_expect ((float) (int) fn != fn, 0))
+ return invalid_fn (x, fn);
+
+ return __scalbnf (x, (int) fn);
}
+strong_alias (__ieee754_scalbf, __scalbf_finite)
diff --git a/libc/math/e_scalbl.c b/libc/math/e_scalbl.c
index 1f5677d9f..6b36b7122 100644
--- a/libc/math/e_scalbl.c
+++ b/libc/math/e_scalbl.c
@@ -1,75 +1,59 @@
-/* e_scalbl.c -- long double version of s_scalb.c.
- * Conversion to long double by Ulrich Drepper,
- * Cygnus Support, drepper@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: $";
-#endif
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * __ieee754_scalbl(x, fn) is provide for
- * passing various standard test suite. One
- * should use scalbnl() instead.
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef _SCALB_INT
-#ifdef __STDC__
- long double __ieee754_scalbl(long double x, int fn)
-#else
- long double __ieee754_scalbl(x,fn)
- long double x; int fn;
-#endif
-#else
-#ifdef __STDC__
- long double __ieee754_scalbl(long double x, long double fn)
-#else
- long double __ieee754_scalbl(x,fn)
- long double x, fn;
-#endif
-#endif
+
+static long double
+__attribute__ ((noinline))
+invalid_fn (long double x, long double fn)
+{
+ if (__rintl (fn) != fn)
+ {
+ feraiseexcept (FE_INVALID);
+ return __nan ("");
+ }
+ else if (fn > 65000.0L)
+ return __scalbnl (x, 65000);
+ else
+ return __scalbnl (x,-65000);
+}
+
+
+long double
+__ieee754_scalbl (long double x, long double fn)
{
-#ifdef _SCALB_INT
- return __scalbnl(x,fn);
-#else
- if (__isnanl(x)||__isnanl(fn)) return x*fn;
- if (!__finitel(fn)) {
- if(fn>0.0) return x*fn;
- else if (x == 0)
- return x;
- else if (!__finitel (x))
- {
-# ifdef FE_INVALID
- feraiseexcept (FE_INVALID);
-# endif
- return __nanl ("");
- }
- else return x/(-fn);
- }
- if (__rintl(fn)!=fn)
- {
-# ifdef FE_INVALID
- feraiseexcept (FE_INVALID);
-# endif
- return __nanl ("");
- }
- if ( fn > 65000.0) return __scalbnl(x, 65000);
- if (-fn > 65000.0) return __scalbnl(x,-65000);
- return __scalbnl(x,(int)fn);
-#endif
+ if (__builtin_expect (__isnanl (x), 0))
+ return x * fn;
+ if (__builtin_expect (!__finitel (fn), 0))
+ {
+ if (__isnanl (fn) || fn > 0.0L)
+ return x * fn;
+ if (x == 0.0L)
+ return x;
+ return x / -fn;
+ }
+ if (__builtin_expect ((long double) (int) fn != fn, 0))
+ return invalid_fn (x, fn);
+
+ return __scalbnl (x, (int) fn);
}
+strong_alias (__ieee754_scalbl, __scalbl_finite)
diff --git a/libc/math/e_sinhl.c b/libc/math/e_sinhl.c
index 4cec79cb2..fc756c9eb 100644
--- a/libc/math/e_sinhl.c
+++ b/libc/math/e_sinhl.c
@@ -9,6 +9,7 @@ __ieee754_sinhl (long double x)
__set_errno (ENOSYS);
return 0.0;
}
+strong_alias (__ieee754_sinhl, __sinhl_finite)
stub_warning (__ieee754_sinhl)
#include <stub-tag.h>
diff --git a/libc/math/e_sqrtl.c b/libc/math/e_sqrtl.c
index 7680bdb14..af9c2b51b 100644
--- a/libc/math/e_sqrtl.c
+++ b/libc/math/e_sqrtl.c
@@ -9,6 +9,7 @@ __ieee754_sqrtl (long double x)
__set_errno (ENOSYS);
return 0.0;
}
+strong_alias (__ieee754_sqrtl, __sqrtl_finite)
stub_warning (sqrtl)
#include <stub-tag.h>
diff --git a/libc/math/k_cosl.c b/libc/math/k_cosl.c
index 29b83d627..bf3708b15 100644
--- a/libc/math/k_cosl.c
+++ b/libc/math/k_cosl.c
@@ -1,7 +1,7 @@
#include <math.h>
#include <stdio.h>
#include <errno.h>
-#include "math_private.h"
+#include <math_private.h>
long double
__kernel_cosl (long double x, long double y)
diff --git a/libc/math/k_sinl.c b/libc/math/k_sinl.c
index ea1d71f61..e95c71c4c 100644
--- a/libc/math/k_sinl.c
+++ b/libc/math/k_sinl.c
@@ -1,7 +1,7 @@
#include <math.h>
#include <stdio.h>
#include <errno.h>
-#include "math_private.h"
+#include <math_private.h>
long double
__kernel_sinl (long double x, long double y, int iy)
diff --git a/libc/math/k_tanl.c b/libc/math/k_tanl.c
index 9993c6b99..891d3ab40 100644
--- a/libc/math/k_tanl.c
+++ b/libc/math/k_tanl.c
@@ -1,7 +1,7 @@
#include <math.h>
#include <stdio.h>
#include <errno.h>
-#include "math_private.h"
+#include <math_private.h>
long double
__kernel_tanl (long double x, long double y, int iy)
diff --git a/libc/math/libm-test.inc b/libc/math/libm-test.inc
index 453088528..f1ecdcd78 100644
--- a/libc/math/libm-test.inc
+++ b/libc/math/libm-test.inc
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997-2006, 2007, 2009, 2010 Free Software Foundation, Inc.
+/* Copyright (C) 1997-2006, 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Andreas Jaeger <aj@suse.de>, 1997.
@@ -191,7 +191,7 @@ static FLOAT max_error, real_max_error, imag_max_error;
#if __OPTION_EGLIBC_LIBM_BIG
#define MANT_DIG CHOOSE ((LDBL_MANT_DIG-1), (DBL_MANT_DIG-1), (FLT_MANT_DIG-1), \
- (LDBL_MANT_DIG-1), (DBL_MANT_DIG-1), (FLT_MANT_DIG-1))
+ (LDBL_MANT_DIG-1), (DBL_MANT_DIG-1), (FLT_MANT_DIG-1))
#else
/* Reduce precision to which the results are checked against
expected values. */
@@ -3298,6 +3298,16 @@ jn_test (void)
TEST_ff_f (jn, 10, 2.0, 0.251538628271673670963516093751820639e-6L);
TEST_ff_f (jn, 10, 10.0, 0.207486106633358857697278723518753428L);
+ /* BZ #11589 .*/
+ TEST_ff_f (jn, 2, 2.4048255576957729, 0.43175480701968038399746111312430703L);
+ TEST_ff_f (jn, 3, 2.4048255576957729, 0.19899990535769083404042146764530813L);
+ TEST_ff_f (jn, 4, 2.4048255576957729, 0.647466661641779720084932282551219891E-1L);
+ TEST_ff_f (jn, 5, 2.4048255576957729, 0.163892432048058525099230549946147698E-1L);
+ TEST_ff_f (jn, 6, 2.4048255576957729, 0.34048184720278336646673682895929161E-2L);
+ TEST_ff_f (jn, 7, 2.4048255576957729, 0.60068836573295394221291569249883076E-3L);
+ TEST_ff_f (jn, 8, 2.4048255576957729, 0.92165786705344923232879022467054148E-4L);
+ TEST_ff_f (jn, 9, 2.4048255576957729, 0.12517270977961513005428966643852564E-4L)
+
END (jn);
}
@@ -4399,6 +4409,7 @@ lround_test (void)
TEST_f_l (lround, 1073741824.01, 1073741824);
# if LONG_MAX > 281474976710656
TEST_f_l (lround, 281474976710656.025, 281474976710656);
+ TEST_f_l (llround, -3.65309740835E17, -365309740835000000);
# endif
TEST_f_l (lround, 2097152.5, 2097153);
TEST_f_l (lround, -2097152.5, -2097153);
@@ -4942,11 +4953,27 @@ remainder_test (void)
START (remainder);
+ errno = 0;
TEST_ff_f (remainder, 1, 0, nan_value, INVALID_EXCEPTION);
+ check_int ("errno for remainder(1, 0) = EDOM ", errno, EDOM, 0, 0, 0);
+ errno = 0;
TEST_ff_f (remainder, 1, minus_zero, nan_value, INVALID_EXCEPTION);
+ check_int ("errno for remainder(1, -0) = EDOM ", errno, EDOM, 0, 0, 0);
+ errno = 0;
TEST_ff_f (remainder, plus_infty, 1, nan_value, INVALID_EXCEPTION);
+ check_int ("errno for remainder(INF, 1) = EDOM ", errno, EDOM, 0, 0, 0);
+ errno = 0;
TEST_ff_f (remainder, minus_infty, 1, nan_value, INVALID_EXCEPTION);
+ check_int ("errno for remainder(-INF, 1) = EDOM ", errno, EDOM, 0, 0, 0);
+ errno = 0;
TEST_ff_f (remainder, nan_value, nan_value, nan_value);
+ check_int ("errno for remainder(NAN, NAN) unchanged", errno, 0, 0, 0, 0);
+ errno = 0;
+ TEST_ff_f (remainder, 0, nan_value, nan_value);
+ check_int ("errno for remainder(0, NAN) unchanged", errno, 0, 0, 0, 0);
+ errno = 0;
+ TEST_ff_f (remainder, nan_value, 0, nan_value);
+ check_int ("errno for remainder(NaN, 0) unchanged", errno, 0, 0, 0, 0);
TEST_ff_f (remainder, 1.625, 1.0, -0.375);
TEST_ff_f (remainder, -1.625, 1.0, 0.375);
diff --git a/libc/math/math.h b/libc/math/math.h
index 272cea719..7b5988114 100644
--- a/libc/math/math.h
+++ b/libc/math/math.h
@@ -1,5 +1,5 @@
/* Declarations for math functions.
- Copyright (C) 1991-1993, 1995-1999, 2001, 2002, 2004, 2006, 2009
+ Copyright (C) 1991-1993, 1995-1999, 2001, 2002, 2004, 2006, 2009, 2011
Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -64,10 +64,10 @@ __BEGIN_DECLS
#define __MATHDECL_1(type, function,suffix, args) \
extern type __MATH_PRECNAME(function,suffix) args __THROW
-#define _Mdouble_ double
+#define _Mdouble_ double
#define __MATH_PRECNAME(name,r) __CONCAT(name,r)
-# define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_STD
-# define _Mdouble_END_NAMESPACE __END_NAMESPACE_STD
+#define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_STD
+#define _Mdouble_END_NAMESPACE __END_NAMESPACE_STD
#include <bits/mathcalls.h>
#undef _Mdouble_
#undef _Mdouble_BEGIN_NAMESPACE
@@ -83,7 +83,7 @@ __BEGIN_DECLS
# ifndef _Mfloat_
# define _Mfloat_ float
# endif
-# define _Mdouble_ _Mfloat_
+# define _Mdouble_ _Mfloat_
# ifdef __STDC__
# define __MATH_PRECNAME(name,r) name##f##r
# else
@@ -134,7 +134,7 @@ extern long double __REDIRECT_NTH (nexttowardl,
# ifndef _Mlong_double_
# define _Mlong_double_ long double
# endif
-# define _Mdouble_ _Mlong_double_
+# define _Mdouble_ _Mlong_double_
# ifdef __STDC__
# define __MATH_PRECNAME(name,r) name##l##r
# else
@@ -142,6 +142,7 @@ extern long double __REDIRECT_NTH (nexttowardl,
# endif
# define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_C99
# define _Mdouble_END_NAMESPACE __END_NAMESPACE_C99
+# define __MATH_DECLARE_LDOUBLE 1
# include <bits/mathcalls.h>
# undef _Mdouble_
# undef _Mdouble_BEGIN_NAMESPACE
@@ -420,6 +421,12 @@ extern int matherr (struct exception *__exc);
# include <bits/mathinline.h>
#endif
+/* Define special entry points to use when the compiler got told to
+ only expect finite results. */
+#if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0
+# include <bits/math-finite.h>
+#endif
+
#ifdef __USE_ISOC99
/* If we've still got undefined comparison macros, provide defaults. */
diff --git a/libc/math/math_private.h b/libc/math/math_private.h
index e5ca61f0b..4cb81ea41 100644
--- a/libc/math/math_private.h
+++ b/libc/math/math_private.h
@@ -202,6 +202,7 @@ extern double __ieee754_scalb (double,double);
/* fdlibm kernel function */
extern double __kernel_standard (double,double,int);
+extern float __kernel_standard_f (float,float,int);
extern double __kernel_sin (double,double,int);
extern double __kernel_cos (double,double);
extern double __kernel_tan (double,double,int);
@@ -357,4 +358,48 @@ extern void __docos (double __x, double __dx, double __v[]);
#define math_force_eval(x) __asm __volatile ("" : : "m" (x))
#endif
+
+/* The standards only specify one variant of the fenv.h interfaces.
+ But at least for some architectures we can be more efficient if we
+ know what operations are going to be performed. Therefore we
+ define additional interfaces. By default they refer to the normal
+ interfaces. */
+#define libc_fegetround() fegetround ()
+#define libc_fegetroundf() fegetround ()
+#define libc_fegetroundl() fegetround ()
+
+#define libc_fesetround(r) (void) fesetround (r)
+#define libc_fesetroundf(r) (void) fesetround (r)
+#define libc_fesetroundl(r) (void) fesetround (r)
+
+#define libc_feholdexcept(e) (void) feholdexcept (e)
+#define libc_feholdexceptf(e) (void) feholdexcept (e)
+#define libc_feholdexceptl(e) (void) feholdexcept (e)
+
+#define libc_feholdexcept_setround(e, r) \
+ do { feholdexcept (e); fesetround (r); } while (0)
+#define libc_feholdexcept_setroundf(e, r) \
+ do { feholdexcept (e); fesetround (r); } while (0)
+#define libc_feholdexcept_setroundl(e, r) \
+ do { feholdexcept (e); fesetround (r); } while (0)
+
+#define libc_fetestexcept(e) fetestexcept (e)
+#define libc_fetestexceptf(e) fetestexcept (e)
+#define libc_fetestexceptl(e) fetestexcept (e)
+
+#define libc_fesetenv(e) (void) fesetenv (e)
+#define libc_fesetenvf(e) (void) fesetenv (e)
+#define libc_fesetenvl(e) (void) fesetenv (e)
+
+#define libc_feupdateenv(e) (void) feupdateenv (e)
+#define libc_feupdateenvf(e) (void) feupdateenv (e)
+#define libc_feupdateenvl(e) (void) feupdateenv (e)
+
+#define __nan(str) \
+ (__builtin_constant_p (str) && str[0] == '\0' ? NAN : __nan (str))
+#define __nanf(str) \
+ (__builtin_constant_p (str) && str[0] == '\0' ? NAN : __nan (str))
+#define __nanl(str) \
+ (__builtin_constant_p (str) && str[0] == '\0' ? NAN : __nan (str))
+
#endif /* _MATH_PRIVATE_H_ */
diff --git a/libc/math/multc3.c b/libc/math/multc3.c
index 6369f48f2..351dccf80 100644
--- a/libc/math/multc3.c
+++ b/libc/math/multc3.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2006, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Richard Henderson <rth@redhat.com>, 2005.
@@ -39,28 +39,29 @@ __multc3 (long double a, long double b, long double c, long double d)
{
/* Recover infinities that computed as NaN + iNaN. */
bool recalc = 0;
- if (isinf (a) || isinf (b))
+ if (__isinf_nsl (a) || __isinf_nsl (b))
{
/* z is infinite. "Box" the infinity and change NaNs in
the other factor to 0. */
- a = __copysignl (isinf (a) ? 1 : 0, a);
- b = __copysignl (isinf (b) ? 1 : 0, b);
+ a = __copysignl (__isinf_nsl (a) ? 1 : 0, a);
+ b = __copysignl (__isinf_nsl (b) ? 1 : 0, b);
if (isnan (c)) c = __copysignl (0, c);
if (isnan (d)) d = __copysignl (0, d);
recalc = 1;
}
- if (isinf (c) || isinf (d))
+ if (__isinf_nsl (c) || __isinf_nsl (d))
{
/* w is infinite. "Box" the infinity and change NaNs in
the other factor to 0. */
- c = __copysignl (isinf (c) ? 1 : 0, c);
- d = __copysignl (isinf (d) ? 1 : 0, d);
+ c = __copysignl (__isinf_nsl (c) ? 1 : 0, c);
+ d = __copysignl (__isinf_nsl (d) ? 1 : 0, d);
if (isnan (a)) a = __copysignl (0, a);
if (isnan (b)) b = __copysignl (0, b);
recalc = 1;
}
if (!recalc
- && (isinf (ac) || isinf (bd) || isinf (ad) || isinf (bc)))
+ && (__isinf_nsl (ac) || __isinf_nsl (bd)
+ || __isinf_nsl (ad) || __isinf_nsl (bc)))
{
/* Recover infinities from overflow by changing NaNs to 0. */
if (isnan (a)) a = __copysignl (0, a);
diff --git a/libc/math/s_cacosh.c b/libc/math/s_cacosh.c
index ada7ca5af..bec6d3827 100644
--- a/libc/math/s_cacosh.c
+++ b/libc/math/s_cacosh.c
@@ -1,5 +1,5 @@
/* Return arc hyperbole cosine for double value.
- Copyright (C) 1997, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2006, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -20,6 +20,7 @@
#include <complex.h>
#include <math.h>
+#include <math_private.h>
__complex__ double
diff --git a/libc/math/s_cacoshf.c b/libc/math/s_cacoshf.c
index a062ffc6f..0d6bd75dd 100644
--- a/libc/math/s_cacoshf.c
+++ b/libc/math/s_cacoshf.c
@@ -21,7 +21,7 @@
#include <complex.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
__complex__ float
__cacoshf (__complex__ float x)
diff --git a/libc/math/s_cacoshl.c b/libc/math/s_cacoshl.c
index da23c8d8a..36f7a5f70 100644
--- a/libc/math/s_cacoshl.c
+++ b/libc/math/s_cacoshl.c
@@ -1,5 +1,5 @@
/* Return arc hyperbole cosine for long double value.
- Copyright (C) 1997, 1998, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 2006, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -20,6 +20,7 @@
#include <complex.h>
#include <math.h>
+#include <math_private.h>
__complex__ long double
diff --git a/libc/math/s_casin.c b/libc/math/s_casin.c
index 2d5b06cf7..02a215ab5 100644
--- a/libc/math/s_casin.c
+++ b/libc/math/s_casin.c
@@ -1,5 +1,5 @@
/* Return arc sine of complex double value.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -20,6 +20,7 @@
#include <complex.h>
#include <math.h>
+#include <math_private.h>
__complex__ double
@@ -33,7 +34,7 @@ __casin (__complex__ double x)
{
res = x;
}
- else if (__isinf (__real__ x) || __isinf (__imag__ x))
+ else if (__isinf_ns (__real__ x) || __isinf_ns (__imag__ x))
{
__real__ res = __nan ("");
__imag__ res = __copysign (HUGE_VAL, __imag__ x);
diff --git a/libc/math/s_casinf.c b/libc/math/s_casinf.c
index 5278dbbf7..56c618fcf 100644
--- a/libc/math/s_casinf.c
+++ b/libc/math/s_casinf.c
@@ -1,5 +1,5 @@
/* Return arc sine of complex float value.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -20,6 +20,7 @@
#include <complex.h>
#include <math.h>
+#include <math_private.h>
__complex__ float
@@ -33,7 +34,7 @@ __casinf (__complex__ float x)
{
res = x;
}
- else if (__isinff (__real__ x) || __isinff (__imag__ x))
+ else if (__isinf_nsf (__real__ x) || __isinf_nsf (__imag__ x))
{
__real__ res = __nanf ("");
__imag__ res = __copysignf (HUGE_VALF, __imag__ x);
diff --git a/libc/math/s_casinh.c b/libc/math/s_casinh.c
index a574add70..db340ac1b 100644
--- a/libc/math/s_casinh.c
+++ b/libc/math/s_casinh.c
@@ -1,5 +1,5 @@
/* Return arc hyperbole sine for double value.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -20,6 +20,7 @@
#include <complex.h>
#include <math.h>
+#include <math_private.h>
__complex__ double
diff --git a/libc/math/s_casinhf.c b/libc/math/s_casinhf.c
index 7037ab937..f545d8e2e 100644
--- a/libc/math/s_casinhf.c
+++ b/libc/math/s_casinhf.c
@@ -1,5 +1,5 @@
/* Return arc hyperbole sine for float value.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -20,6 +20,7 @@
#include <complex.h>
#include <math.h>
+#include <math_private.h>
__complex__ float
diff --git a/libc/math/s_casinhl.c b/libc/math/s_casinhl.c
index 376b2347a..b8e391829 100644
--- a/libc/math/s_casinhl.c
+++ b/libc/math/s_casinhl.c
@@ -1,5 +1,5 @@
/* Return arc hyperbole sine for long double value.
- Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -20,6 +20,7 @@
#include <complex.h>
#include <math.h>
+#include <math_private.h>
__complex__ long double
diff --git a/libc/math/s_casinl.c b/libc/math/s_casinl.c
index f303c05ae..431e9a241 100644
--- a/libc/math/s_casinl.c
+++ b/libc/math/s_casinl.c
@@ -1,5 +1,5 @@
/* Return arc sine of complex long double value.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -20,6 +20,7 @@
#include <complex.h>
#include <math.h>
+#include <math_private.h>
__complex__ long double
@@ -33,7 +34,7 @@ __casinl (__complex__ long double x)
{
res = x;
}
- else if (__isinfl (__real__ x) || __isinfl (__imag__ x))
+ else if (__isinf_nsl (__real__ x) || __isinf_nsl (__imag__ x))
{
__real__ res = __nanl ("");
__imag__ res = __copysignl (HUGE_VALL, __imag__ x);
diff --git a/libc/math/s_catan.c b/libc/math/s_catan.c
index 1d0673ad6..1a458a383 100644
--- a/libc/math/s_catan.c
+++ b/libc/math/s_catan.c
@@ -1,5 +1,5 @@
/* Return arc tangent of complex double value.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -20,8 +20,7 @@
#include <complex.h>
#include <math.h>
-
-#include "math_private.h"
+#include <math_private.h>
__complex__ double
@@ -31,7 +30,7 @@ __catan (__complex__ double x)
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
- if (rcls <= FP_INFINITE || icls <= FP_INFINITE)
+ if (__builtin_expect (rcls <= FP_INFINITE || icls <= FP_INFINITE, 0))
{
if (rcls == FP_INFINITE)
{
@@ -57,7 +56,7 @@ __catan (__complex__ double x)
__imag__ res = __nan ("");
}
}
- else if (rcls == FP_ZERO && icls == FP_ZERO)
+ else if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0))
{
res = x;
}
diff --git a/libc/math/s_catanf.c b/libc/math/s_catanf.c
index 25eec2b1b..defcf18c6 100644
--- a/libc/math/s_catanf.c
+++ b/libc/math/s_catanf.c
@@ -1,5 +1,5 @@
/* Return arc tangent of complex float value.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -20,8 +20,7 @@
#include <complex.h>
#include <math.h>
-
-#include "math_private.h"
+#include <math_private.h>
__complex__ float
@@ -31,7 +30,7 @@ __catanf (__complex__ float x)
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
- if (rcls <= FP_INFINITE || icls <= FP_INFINITE)
+ if (__builtin_expect (rcls <= FP_INFINITE || icls <= FP_INFINITE, 0))
{
if (rcls == FP_INFINITE)
{
@@ -57,7 +56,7 @@ __catanf (__complex__ float x)
__imag__ res = __nanf ("");
}
}
- else if (rcls == FP_ZERO && icls == FP_ZERO)
+ else if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0))
{
res = x;
}
diff --git a/libc/math/s_catanh.c b/libc/math/s_catanh.c
index e15c073f9..22ade15fa 100644
--- a/libc/math/s_catanh.c
+++ b/libc/math/s_catanh.c
@@ -1,5 +1,5 @@
/* Return arc hyperbole tangent for double value.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -20,8 +20,7 @@
#include <complex.h>
#include <math.h>
-
-#include "math_private.h"
+#include <math_private.h>
__complex__ double
@@ -31,7 +30,7 @@ __catanh (__complex__ double x)
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
- if (rcls <= FP_INFINITE || icls <= FP_INFINITE)
+ if (__builtin_expect (rcls <= FP_INFINITE || icls <= FP_INFINITE, 0))
{
if (icls == FP_INFINITE)
{
@@ -52,20 +51,18 @@ __catanh (__complex__ double x)
__imag__ res = __nan ("");
}
}
- else if (rcls == FP_ZERO && icls == FP_ZERO)
+ else if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0))
{
res = x;
}
else
{
- double i2, num, den;
-
- i2 = __imag__ x * __imag__ x;
+ double i2 = __imag__ x * __imag__ x;
- num = 1.0 + __real__ x;
+ double num = 1.0 + __real__ x;
num = i2 + num * num;
- den = 1.0 - __real__ x;
+ double den = 1.0 - __real__ x;
den = i2 + den * den;
__real__ res = 0.25 * (__ieee754_log (num) - __ieee754_log (den));
diff --git a/libc/math/s_catanhf.c b/libc/math/s_catanhf.c
index d2422e611..f3d07f235 100644
--- a/libc/math/s_catanhf.c
+++ b/libc/math/s_catanhf.c
@@ -1,5 +1,5 @@
/* Return arc hyperbole tangent for float value.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -20,8 +20,7 @@
#include <complex.h>
#include <math.h>
-
-#include "math_private.h"
+#include <math_private.h>
__complex__ float
@@ -31,7 +30,7 @@ __catanhf (__complex__ float x)
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
- if (rcls <= FP_INFINITE || icls <= FP_INFINITE)
+ if (__builtin_expect (rcls <= FP_INFINITE || icls <= FP_INFINITE, 0))
{
if (icls == FP_INFINITE)
{
@@ -52,20 +51,18 @@ __catanhf (__complex__ float x)
__imag__ res = __nanf ("");
}
}
- else if (rcls == FP_ZERO && icls == FP_ZERO)
+ else if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0))
{
res = x;
}
else
{
- float i2, num, den;
-
- i2 = __imag__ x * __imag__ x;
+ float i2 = __imag__ x * __imag__ x;
- num = 1.0 + __real__ x;
+ float num = 1.0 + __real__ x;
num = i2 + num * num;
- den = 1.0 - __real__ x;
+ float den = 1.0 - __real__ x;
den = i2 + den * den;
__real__ res = 0.25 * (__ieee754_logf (num) - __ieee754_logf (den));
diff --git a/libc/math/s_catanhl.c b/libc/math/s_catanhl.c
index c3fb0ce5f..af48f1a55 100644
--- a/libc/math/s_catanhl.c
+++ b/libc/math/s_catanhl.c
@@ -1,5 +1,5 @@
/* Return arc hyperbole tangent for long double value.
- Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -20,8 +20,7 @@
#include <complex.h>
#include <math.h>
-
-#include "math_private.h"
+#include <math_private.h>
__complex__ long double
@@ -31,7 +30,7 @@ __catanhl (__complex__ long double x)
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
- if (rcls <= FP_INFINITE || icls <= FP_INFINITE)
+ if (__builtin_expect (rcls <= FP_INFINITE || icls <= FP_INFINITE, 0))
{
if (icls == FP_INFINITE)
{
@@ -52,20 +51,18 @@ __catanhl (__complex__ long double x)
__imag__ res = __nanl ("");
}
}
- else if (rcls == FP_ZERO && icls == FP_ZERO)
+ else if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0))
{
res = x;
}
else
{
- long double i2, num, den;
-
- i2 = __imag__ x * __imag__ x;
+ long double i2 = __imag__ x * __imag__ x;
- num = 1.0 + __real__ x;
+ long double num = 1.0 + __real__ x;
num = i2 + num * num;
- den = 1.0 - __real__ x;
+ long double den = 1.0 - __real__ x;
den = i2 + den * den;
__real__ res = 0.25 * (__ieee754_logl (num) - __ieee754_logl (den));
diff --git a/libc/math/s_catanl.c b/libc/math/s_catanl.c
index 6cb45e5be..47df85cc7 100644
--- a/libc/math/s_catanl.c
+++ b/libc/math/s_catanl.c
@@ -1,5 +1,5 @@
/* Return arc tangent of complex long double value.
- Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -20,8 +20,7 @@
#include <complex.h>
#include <math.h>
-
-#include "math_private.h"
+#include <math_private.h>
__complex__ long double
@@ -31,7 +30,7 @@ __catanl (__complex__ long double x)
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
- if (rcls <= FP_INFINITE || icls <= FP_INFINITE)
+ if (__builtin_expect (rcls <= FP_INFINITE || icls <= FP_INFINITE, 0))
{
if (rcls == FP_INFINITE)
{
@@ -57,7 +56,7 @@ __catanl (__complex__ long double x)
__imag__ res = __nanl ("");
}
}
- else if (rcls == FP_ZERO && icls == FP_ZERO)
+ else if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0))
{
res = x;
}
diff --git a/libc/math/s_ccos.c b/libc/math/s_ccos.c
index 1b244d707..4612eb33c 100644
--- a/libc/math/s_ccos.c
+++ b/libc/math/s_ccos.c
@@ -1,5 +1,5 @@
/* Return cosine of complex double value.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -21,57 +21,18 @@
#include <complex.h>
#include <fenv.h>
#include <math.h>
+#include <math_private.h>
__complex__ double
__ccos (__complex__ double x)
{
- __complex__ double res;
+ __complex__ double y;
- if (!isfinite (__real__ x) || __isnan (__imag__ x))
- {
- if (__real__ x == 0.0 || __imag__ x == 0.0)
- {
- __real__ res = __nan ("");
- __imag__ res = 0.0;
+ __real__ y = -__imag__ x;
+ __imag__ y = __real__ x;
-#ifdef FE_INVALID
- if (__isinf (__real__ x))
- feraiseexcept (FE_INVALID);
-#endif
- }
- else if (__isinf (__imag__ x))
- {
- __real__ res = HUGE_VAL;
- __imag__ res = __nan ("");
-
-#ifdef FE_INVALID
- if (__isinf (__real__ x))
- feraiseexcept (FE_INVALID);
-#endif
- }
- else
- {
- __real__ res = __nan ("");
- __imag__ res = __nan ("");
-
-#ifdef FE_INVALID
- if (isfinite (__imag__ x))
- feraiseexcept (FE_INVALID);
-#endif
- }
- }
- else
- {
- __complex__ double y;
-
- __real__ y = -__imag__ x;
- __imag__ y = __real__ x;
-
- res = __ccosh (y);
- }
-
- return res;
+ return __ccosh (y);
}
weak_alias (__ccos, ccos)
#ifdef NO_LONG_DOUBLE
diff --git a/libc/math/s_ccosf.c b/libc/math/s_ccosf.c
index 4b154deac..1ee932486 100644
--- a/libc/math/s_ccosf.c
+++ b/libc/math/s_ccosf.c
@@ -1,5 +1,5 @@
/* Return cosine of complex float value.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -21,57 +21,18 @@
#include <complex.h>
#include <fenv.h>
#include <math.h>
+#include <math_private.h>
__complex__ float
__ccosf (__complex__ float x)
{
- __complex__ float res;
+ __complex__ float y;
- if (!isfinite (__real__ x) || __isnanf (__imag__ x))
- {
- if (__real__ x == 0.0 || __imag__ x == 0.0)
- {
- __real__ res = __nanf ("");
- __imag__ res = 0.0;
+ __real__ y = -__imag__ x;
+ __imag__ y = __real__ x;
-#ifdef FE_INVALID
- if (__isinff (__real__ x))
- feraiseexcept (FE_INVALID);
-#endif
- }
- else if (__isinff (__imag__ x))
- {
- __real__ res = HUGE_VALF;
- __imag__ res = __nanf ("");
-
-#ifdef FE_INVALID
- if (__isinff (__real__ x))
- feraiseexcept (FE_INVALID);
-#endif
- }
- else
- {
- __real__ res = __nanf ("");
- __imag__ res = __nanf ("");
-
-#ifdef FE_INVALID
- if (isfinite (__imag__ x))
- feraiseexcept (FE_INVALID);
-#endif
- }
- }
- else
- {
- __complex__ float y;
-
- __real__ y = -__imag__ x;
- __imag__ y = __real__ x;
-
- res = __ccoshf (y);
- }
-
- return res;
+ return __ccoshf (y);
}
#ifndef __ccosf
weak_alias (__ccosf, ccosf)
diff --git a/libc/math/s_ccosh.c b/libc/math/s_ccosh.c
index f5b29db24..c10e5d899 100644
--- a/libc/math/s_ccosh.c
+++ b/libc/math/s_ccosh.c
@@ -1,5 +1,5 @@
/* Complex cosine hyperbole function for double.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -22,7 +22,7 @@
#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
__complex__ double
@@ -32,10 +32,10 @@ __ccosh (__complex__ double x)
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
- if (rcls >= FP_ZERO)
+ if (__builtin_expect (rcls >= FP_ZERO, 1))
{
/* Real part is finite. */
- if (icls >= FP_ZERO)
+ if (__builtin_expect (icls >= FP_ZERO, 1))
{
/* Imaginary part is finite. */
double sinh_val = __ieee754_sinh (__real__ x);
@@ -52,22 +52,14 @@ __ccosh (__complex__ double x)
__imag__ retval = __real__ x == 0.0 ? 0.0 : __nan ("");
__real__ retval = __nan ("") + __nan ("");
-#ifdef FE_INVALID
if (icls == FP_INFINITE)
feraiseexcept (FE_INVALID);
-#endif
}
}
else if (rcls == FP_INFINITE)
{
/* Real part is infinite. */
- if (icls == FP_ZERO)
- {
- /* Imaginary part is 0.0. */
- __real__ retval = HUGE_VAL;
- __imag__ retval = __imag__ x * __copysign (1.0, __real__ x);
- }
- else if (icls > FP_ZERO)
+ if (__builtin_expect (icls > FP_ZERO, 1))
{
/* Imaginary part is finite. */
double sinix, cosix;
@@ -78,16 +70,20 @@ __ccosh (__complex__ double x)
__imag__ retval = (__copysign (HUGE_VAL, sinix)
* __copysign (1.0, __real__ x));
}
+ else if (icls == FP_ZERO)
+ {
+ /* Imaginary part is 0.0. */
+ __real__ retval = HUGE_VAL;
+ __imag__ retval = __imag__ x * __copysign (1.0, __real__ x);
+ }
else
{
/* The addition raises the invalid exception. */
__real__ retval = HUGE_VAL;
__imag__ retval = __nan ("") + __nan ("");
-#ifdef FE_INVALID
if (icls == FP_INFINITE)
feraiseexcept (FE_INVALID);
-#endif
}
}
else
diff --git a/libc/math/s_ccoshf.c b/libc/math/s_ccoshf.c
index f400d34f0..6aae5d854 100644
--- a/libc/math/s_ccoshf.c
+++ b/libc/math/s_ccoshf.c
@@ -1,5 +1,5 @@
/* Complex cosine hyperbole function for float.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -22,7 +22,7 @@
#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
__complex__ float
@@ -32,10 +32,10 @@ __ccoshf (__complex__ float x)
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
- if (rcls >= FP_ZERO)
+ if (__builtin_expect (rcls >= FP_ZERO, 1))
{
/* Real part is finite. */
- if (icls >= FP_ZERO)
+ if (__builtin_expect (icls >= FP_ZERO, 1))
{
/* Imaginary part is finite. */
float sinh_val = __ieee754_sinhf (__real__ x);
@@ -52,22 +52,14 @@ __ccoshf (__complex__ float x)
__imag__ retval = __real__ x == 0.0 ? 0.0 : __nanf ("");
__real__ retval = __nanf ("");
-#ifdef FE_INVALID
if (icls == FP_INFINITE)
feraiseexcept (FE_INVALID);
-#endif
}
}
- else if (rcls == FP_INFINITE)
+ else if (__builtin_expect (rcls == FP_INFINITE, 1))
{
/* Real part is infinite. */
- if (icls == FP_ZERO)
- {
- /* Imaginary part is 0.0. */
- __real__ retval = HUGE_VALF;
- __imag__ retval = __imag__ x * __copysignf (1.0, __real__ x);
- }
- else if (icls > FP_ZERO)
+ if (__builtin_expect (icls > FP_ZERO, 1))
{
/* Imaginary part is finite. */
float sinix, cosix;
@@ -78,6 +70,12 @@ __ccoshf (__complex__ float x)
__imag__ retval = (__copysignf (HUGE_VALF, sinix)
* __copysignf (1.0, __real__ x));
}
+ else if (icls == FP_ZERO)
+ {
+ /* Imaginary part is 0.0. */
+ __real__ retval = HUGE_VALF;
+ __imag__ retval = __imag__ x * __copysignf (1.0, __real__ x);
+ }
else
{
/* The addition raises the invalid exception. */
diff --git a/libc/math/s_ccoshl.c b/libc/math/s_ccoshl.c
index 61ffb49ca..ed1bc459d 100644
--- a/libc/math/s_ccoshl.c
+++ b/libc/math/s_ccoshl.c
@@ -1,5 +1,5 @@
/* Complex cosine hyperbole function for long double.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -22,7 +22,7 @@
#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
__complex__ long double
@@ -32,10 +32,10 @@ __ccoshl (__complex__ long double x)
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
- if (rcls >= FP_ZERO)
+ if (__builtin_expect (rcls >= FP_ZERO, 1))
{
/* Real part is finite. */
- if (icls >= FP_ZERO)
+ if (__builtin_expect (icls >= FP_ZERO, 1))
{
/* Imaginary part is finite. */
long double sinh_val = __ieee754_sinhl (__real__ x);
@@ -52,22 +52,14 @@ __ccoshl (__complex__ long double x)
__imag__ retval = __real__ x == 0.0 ? 0.0 : __nanl ("");
__real__ retval = __nanl ("") + __nanl ("");
-#ifdef FE_INVALID
if (icls == FP_INFINITE)
feraiseexcept (FE_INVALID);
-#endif
}
}
- else if (rcls == FP_INFINITE)
+ else if (__builtin_expect (rcls == FP_INFINITE, 1))
{
/* Real part is infinite. */
- if (icls == FP_ZERO)
- {
- /* Imaginary part is 0.0. */
- __real__ retval = HUGE_VALL;
- __imag__ retval = __imag__ x * __copysignl (1.0, __real__ x);
- }
- else if (icls > FP_ZERO)
+ if (__builtin_expect (icls > FP_ZERO, 1))
{
/* Imaginary part is finite. */
long double sinix, cosix;
@@ -78,16 +70,20 @@ __ccoshl (__complex__ long double x)
__imag__ retval = (__copysignl (HUGE_VALL, sinix)
* __copysignl (1.0, __real__ x));
}
+ else if (icls == FP_ZERO)
+ {
+ /* Imaginary part is 0.0. */
+ __real__ retval = HUGE_VALL;
+ __imag__ retval = __imag__ x * __copysignl (1.0, __real__ x);
+ }
else
{
/* The addition raises the invalid exception. */
__real__ retval = HUGE_VALL;
__imag__ retval = __nanl ("") + __nanl ("");
-#ifdef FE_INVALID
if (icls == FP_INFINITE)
feraiseexcept (FE_INVALID);
-#endif
}
}
else
diff --git a/libc/math/s_ccosl.c b/libc/math/s_ccosl.c
index 4ebe2c347..153a60b08 100644
--- a/libc/math/s_ccosl.c
+++ b/libc/math/s_ccosl.c
@@ -1,5 +1,5 @@
/* Return cosine of complex long double value.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -21,56 +21,17 @@
#include <complex.h>
#include <fenv.h>
#include <math.h>
+#include <math_private.h>
__complex__ long double
__ccosl (__complex__ long double x)
{
- __complex__ long double res;
+ __complex__ long double y;
- if (!isfinite (__real__ x) || __isnanl (__imag__ x))
- {
- if (__real__ x == 0.0 || __imag__ x == 0.0)
- {
- __real__ res = __nanl ("");
- __imag__ res = 0.0;
+ __real__ y = -__imag__ x;
+ __imag__ y = __real__ x;
-#ifdef FE_INVALID
- if (__isinfl (__real__ x))
- feraiseexcept (FE_INVALID);
-#endif
- }
- else if (__isinfl (__imag__ x))
- {
- __real__ res = HUGE_VALL;
- __imag__ res = __nanl ("");
-
-#ifdef FE_INVALID
- if (__isinfl (__real__ x))
- feraiseexcept (FE_INVALID);
-#endif
- }
- else
- {
- __real__ res = __nanl ("");
- __imag__ res = __nanl ("");
-
-#ifdef FE_INVALID
- if (isfinite (__imag__ x))
- feraiseexcept (FE_INVALID);
-#endif
- }
- }
- else
- {
- __complex__ long double y;
-
- __real__ y = -__imag__ x;
- __imag__ y = __real__ x;
-
- res = __ccoshl (y);
- }
-
- return res;
+ return __ccoshl (y);
}
weak_alias (__ccosl, ccosl)
diff --git a/libc/math/s_cexp.c b/libc/math/s_cexp.c
index 5a299b768..0d1ec2985 100644
--- a/libc/math/s_cexp.c
+++ b/libc/math/s_cexp.c
@@ -1,5 +1,5 @@
/* Return value of complex exponential function for double complex value.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -21,8 +21,7 @@
#include <complex.h>
#include <fenv.h>
#include <math.h>
-
-#include "math_private.h"
+#include <math_private.h>
__complex__ double
@@ -32,10 +31,10 @@ __cexp (__complex__ double x)
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
- if (rcls >= FP_ZERO)
+ if (__builtin_expect (rcls >= FP_ZERO, 1))
{
/* Real part is finite. */
- if (icls >= FP_ZERO)
+ if (__builtin_expect (icls >= FP_ZERO, 1))
{
/* Imaginary part is finite. */
double exp_val = __ieee754_exp (__real__ x);
@@ -61,15 +60,13 @@ __cexp (__complex__ double x)
__real__ retval = __nan ("");
__imag__ retval = __nan ("");
-#ifdef FE_INVALID
feraiseexcept (FE_INVALID);
-#endif
}
}
- else if (rcls == FP_INFINITE)
+ else if (__builtin_expect (rcls == FP_INFINITE, 1))
{
/* Real part is infinite. */
- if (icls >= FP_ZERO)
+ if (__builtin_expect (icls >= FP_ZERO, 1))
{
/* Imaginary part is finite. */
double value = signbit (__real__ x) ? 0.0 : HUGE_VAL;
@@ -95,10 +92,8 @@ __cexp (__complex__ double x)
__real__ retval = HUGE_VAL;
__imag__ retval = __nan ("");
-#ifdef FE_INVALID
if (icls == FP_INFINITE)
feraiseexcept (FE_INVALID);
-#endif
}
else
{
@@ -112,10 +107,8 @@ __cexp (__complex__ double x)
__real__ retval = __nan ("");
__imag__ retval = __nan ("");
-#ifdef FE_INVALID
if (rcls != FP_NAN || icls != FP_NAN)
feraiseexcept (FE_INVALID);
-#endif
}
return retval;
diff --git a/libc/math/s_cexpf.c b/libc/math/s_cexpf.c
index 7b68fc365..652fe3d5b 100644
--- a/libc/math/s_cexpf.c
+++ b/libc/math/s_cexpf.c
@@ -1,5 +1,5 @@
/* Return value of complex exponential function for float complex value.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -21,8 +21,7 @@
#include <complex.h>
#include <fenv.h>
#include <math.h>
-
-#include "math_private.h"
+#include <math_private.h>
__complex__ float
@@ -32,10 +31,10 @@ __cexpf (__complex__ float x)
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
- if (rcls >= FP_ZERO)
+ if (__builtin_expect (rcls >= FP_ZERO, 1))
{
/* Real part is finite. */
- if (icls >= FP_ZERO)
+ if (__builtin_expect (icls >= FP_ZERO, 1))
{
/* Imaginary part is finite. */
float exp_val = __ieee754_expf (__real__ x);
@@ -61,15 +60,13 @@ __cexpf (__complex__ float x)
__real__ retval = __nanf ("");
__imag__ retval = __nanf ("");
-#ifdef FE_INVALID
feraiseexcept (FE_INVALID);
-#endif
}
}
- else if (rcls == FP_INFINITE)
+ else if (__builtin_expect (rcls == FP_INFINITE, 1))
{
/* Real part is infinite. */
- if (icls >= FP_ZERO)
+ if (__builtin_expect (icls >= FP_ZERO, 1))
{
/* Imaginary part is finite. */
float value = signbit (__real__ x) ? 0.0 : HUGE_VALF;
@@ -95,10 +92,8 @@ __cexpf (__complex__ float x)
__real__ retval = HUGE_VALF;
__imag__ retval = __nanf ("");
-#ifdef FE_INVALID
if (icls == FP_INFINITE)
feraiseexcept (FE_INVALID);
-#endif
}
else
{
@@ -112,10 +107,8 @@ __cexpf (__complex__ float x)
__real__ retval = __nanf ("");
__imag__ retval = __nanf ("");
-#ifdef FE_INVALID
if (rcls != FP_NAN || icls != FP_NAN)
feraiseexcept (FE_INVALID);
-#endif
}
return retval;
diff --git a/libc/math/s_cexpl.c b/libc/math/s_cexpl.c
index cf6bc974a..6bb56c02f 100644
--- a/libc/math/s_cexpl.c
+++ b/libc/math/s_cexpl.c
@@ -1,5 +1,5 @@
/* Return value of complex exponential function for long double complex value.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -21,8 +21,7 @@
#include <complex.h>
#include <fenv.h>
#include <math.h>
-
-#include "math_private.h"
+#include <math_private.h>
__complex__ long double
@@ -32,10 +31,10 @@ __cexpl (__complex__ long double x)
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
- if (rcls >= FP_ZERO)
+ if (__builtin_expect (rcls >= FP_ZERO, 1))
{
/* Real part is finite. */
- if (icls >= FP_ZERO)
+ if (__builtin_expect (icls >= FP_ZERO, 1))
{
/* Imaginary part is finite. */
long double exp_val = __ieee754_expl (__real__ x);
@@ -61,15 +60,13 @@ __cexpl (__complex__ long double x)
__real__ retval = __nanl ("");
__imag__ retval = __nanl ("");
-#ifdef FE_INVALID
feraiseexcept (FE_INVALID);
-#endif
}
}
- else if (rcls == FP_INFINITE)
+ else if (__builtin_expect (rcls == FP_INFINITE, 1))
{
/* Real part is infinite. */
- if (icls >= FP_ZERO)
+ if (__builtin_expect (icls >= FP_ZERO, 1))
{
/* Imaginary part is finite. */
long double value = signbit (__real__ x) ? 0.0 : HUGE_VALL;
@@ -95,10 +92,8 @@ __cexpl (__complex__ long double x)
__real__ retval = HUGE_VALL;
__imag__ retval = __nanl ("");
-#ifdef FE_INVALID
if (icls == FP_INFINITE)
feraiseexcept (FE_INVALID);
-#endif
}
else
{
@@ -112,10 +107,8 @@ __cexpl (__complex__ long double x)
__real__ retval = __nanl ("");
__imag__ retval = __nanl ("");
-#ifdef FE_INVALID
if (rcls != FP_NAN || icls != FP_NAN)
feraiseexcept (FE_INVALID);
-#endif
}
return retval;
diff --git a/libc/math/s_clog.c b/libc/math/s_clog.c
index f796024b4..ba27140b4 100644
--- a/libc/math/s_clog.c
+++ b/libc/math/s_clog.c
@@ -1,5 +1,5 @@
/* Compute complex natural logarithm.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -20,8 +20,7 @@
#include <complex.h>
#include <math.h>
-
-#include "math_private.h"
+#include <math_private.h>
__complex__ double
@@ -31,7 +30,7 @@ __clog (__complex__ double x)
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
- if (rcls == FP_ZERO && icls == FP_ZERO)
+ if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0))
{
/* Real and imaginary part are 0.0. */
__imag__ result = signbit (__real__ x) ? M_PI : 0.0;
@@ -39,7 +38,7 @@ __clog (__complex__ double x)
/* Yes, the following line raises an exception. */
__real__ result = -1.0 / fabs (__real__ x);
}
- else if (rcls != FP_NAN && icls != FP_NAN)
+ else if (__builtin_expect (rcls != FP_NAN && icls != FP_NAN, 1))
{
/* Neither real nor imaginary part is NaN. */
__real__ result = __ieee754_log (__ieee754_hypot (__real__ x,
diff --git a/libc/math/s_clog10.c b/libc/math/s_clog10.c
index 62c2ca724..4b741fab5 100644
--- a/libc/math/s_clog10.c
+++ b/libc/math/s_clog10.c
@@ -1,5 +1,5 @@
/* Compute complex base 10 logarithm.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -20,8 +20,7 @@
#include <complex.h>
#include <math.h>
-
-#include "math_private.h"
+#include <math_private.h>
__complex__ double
@@ -31,7 +30,7 @@ __clog10 (__complex__ double x)
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
- if (rcls == FP_ZERO && icls == FP_ZERO)
+ if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0))
{
/* Real and imaginary part are 0.0. */
__imag__ result = signbit (__real__ x) ? M_PI : 0.0;
@@ -39,7 +38,7 @@ __clog10 (__complex__ double x)
/* Yes, the following line raises an exception. */
__real__ result = -1.0 / fabs (__real__ x);
}
- else if (rcls != FP_NAN && icls != FP_NAN)
+ else if (__builtin_expect (rcls != FP_NAN && icls != FP_NAN, 1))
{
/* Neither real nor imaginary part is NaN. */
__real__ result = __ieee754_log10 (__ieee754_hypot (__real__ x,
diff --git a/libc/math/s_clog10f.c b/libc/math/s_clog10f.c
index eed81f368..fe38f9e8d 100644
--- a/libc/math/s_clog10f.c
+++ b/libc/math/s_clog10f.c
@@ -1,5 +1,5 @@
/* Compute complex base 10 logarithm.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -20,8 +20,7 @@
#include <complex.h>
#include <math.h>
-
-#include "math_private.h"
+#include <math_private.h>
__complex__ float
@@ -31,7 +30,7 @@ __clog10f (__complex__ float x)
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
- if (rcls == FP_ZERO && icls == FP_ZERO)
+ if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0))
{
/* Real and imaginary part are 0.0. */
__imag__ result = signbit (__real__ x) ? M_PI : 0.0;
@@ -39,7 +38,7 @@ __clog10f (__complex__ float x)
/* Yes, the following line raises an exception. */
__real__ result = -1.0 / fabsf (__real__ x);
}
- else if (rcls != FP_NAN && icls != FP_NAN)
+ else if (__builtin_expect (rcls != FP_NAN && icls != FP_NAN, 1))
{
/* Neither real nor imaginary part is NaN. */
__real__ result = __ieee754_log10f (__ieee754_hypotf (__real__ x,
diff --git a/libc/math/s_clog10l.c b/libc/math/s_clog10l.c
index f901543d0..990913e7b 100644
--- a/libc/math/s_clog10l.c
+++ b/libc/math/s_clog10l.c
@@ -1,5 +1,5 @@
/* Compute complex base 10 logarithm.
- Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -20,8 +20,7 @@
#include <complex.h>
#include <math.h>
-
-#include "math_private.h"
+#include <math_private.h>
__complex__ long double
@@ -31,7 +30,7 @@ __clog10l (__complex__ long double x)
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
- if (rcls == FP_ZERO && icls == FP_ZERO)
+ if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0))
{
/* Real and imaginary part are 0.0. */
__imag__ result = signbit (__real__ x) ? M_PIl : 0.0;
@@ -39,7 +38,7 @@ __clog10l (__complex__ long double x)
/* Yes, the following line raises an exception. */
__real__ result = -1.0 / fabsl (__real__ x);
}
- else if (rcls != FP_NAN && icls != FP_NAN)
+ else if (__builtin_expect (rcls != FP_NAN && icls != FP_NAN, 1))
{
/* Neither real nor imaginary part is NaN. */
__real__ result = __ieee754_log10l (__ieee754_hypotl (__real__ x,
diff --git a/libc/math/s_clogf.c b/libc/math/s_clogf.c
index 21e3b57b7..fdda83e54 100644
--- a/libc/math/s_clogf.c
+++ b/libc/math/s_clogf.c
@@ -1,5 +1,5 @@
/* Compute complex natural logarithm.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -21,7 +21,7 @@
#include <complex.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
__complex__ float
@@ -31,7 +31,7 @@ __clogf (__complex__ float x)
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
- if (rcls == FP_ZERO && icls == FP_ZERO)
+ if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0))
{
/* Real and imaginary part are 0.0. */
__imag__ result = signbit (__real__ x) ? M_PI : 0.0;
@@ -39,7 +39,7 @@ __clogf (__complex__ float x)
/* Yes, the following line raises an exception. */
__real__ result = -1.0 / fabsf (__real__ x);
}
- else if (rcls != FP_NAN && icls != FP_NAN)
+ else if (__builtin_expect (rcls != FP_NAN && icls != FP_NAN, 1))
{
/* Neither real nor imaginary part is NaN. */
__real__ result = __ieee754_logf (__ieee754_hypotf (__real__ x,
diff --git a/libc/math/s_clogl.c b/libc/math/s_clogl.c
index 43118f768..396ba9180 100644
--- a/libc/math/s_clogl.c
+++ b/libc/math/s_clogl.c
@@ -1,5 +1,5 @@
/* Compute complex natural logarithm.
- Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -20,8 +20,7 @@
#include <complex.h>
#include <math.h>
-
-#include "math_private.h"
+#include <math_private.h>
__complex__ long double
@@ -31,7 +30,7 @@ __clogl (__complex__ long double x)
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
- if (rcls == FP_ZERO && icls == FP_ZERO)
+ if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0))
{
/* Real and imaginary part are 0.0. */
__imag__ result = signbit (__real__ x) ? M_PIl : 0.0;
@@ -39,7 +38,7 @@ __clogl (__complex__ long double x)
/* Yes, the following line raises an exception. */
__real__ result = -1.0 / fabsl (__real__ x);
}
- else if (rcls != FP_NAN && icls != FP_NAN)
+ else if (__builtin_expect (rcls != FP_NAN && icls != FP_NAN, 1))
{
/* Neither real nor imaginary part is NaN. */
__real__ result = __ieee754_logl (__ieee754_hypotl (__real__ x,
diff --git a/libc/math/s_csin.c b/libc/math/s_csin.c
index eb380e2c3..07a78c438 100644
--- a/libc/math/s_csin.c
+++ b/libc/math/s_csin.c
@@ -1,5 +1,5 @@
/* Complex sine function for double.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -22,7 +22,7 @@
#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
__complex__ double
@@ -35,10 +35,10 @@ __csin (__complex__ double x)
__real__ x = fabs (__real__ x);
- if (icls >= FP_ZERO)
+ if (__builtin_expect (icls >= FP_ZERO, 1))
{
/* Imaginary part is finite. */
- if (rcls >= FP_ZERO)
+ if (__builtin_expect (rcls >= FP_ZERO, 1))
{
/* Real part is finite. */
double sinh_val = __ieee754_sinh (__imag__ x);
@@ -61,19 +61,15 @@ __csin (__complex__ double x)
__real__ retval = __nan ("");
__imag__ retval = __imag__ x;
-#ifdef FE_INVALID
if (rcls == FP_INFINITE)
feraiseexcept (FE_INVALID);
-#endif
}
else
{
__real__ retval = __nan ("");
__imag__ retval = __nan ("");
-#ifdef FE_INVALID
feraiseexcept (FE_INVALID);
-#endif
}
}
}
@@ -107,10 +103,8 @@ __csin (__complex__ double x)
__real__ retval = __nan ("");
__imag__ retval = HUGE_VAL;
-#ifdef FE_INVALID
if (rcls == FP_INFINITE)
feraiseexcept (FE_INVALID);
-#endif
}
}
else
diff --git a/libc/math/s_csinf.c b/libc/math/s_csinf.c
index 8004743bd..4f4dfb8ea 100644
--- a/libc/math/s_csinf.c
+++ b/libc/math/s_csinf.c
@@ -1,5 +1,5 @@
/* Complex sine function for float.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -22,7 +22,7 @@
#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
__complex__ float
@@ -35,10 +35,10 @@ __csinf (__complex__ float x)
__real__ x = fabsf (__real__ x);
- if (icls >= FP_ZERO)
+ if (__builtin_expect (icls >= FP_ZERO, 1))
{
/* Imaginary part is finite. */
- if (rcls >= FP_ZERO)
+ if (__builtin_expect (rcls >= FP_ZERO, 1))
{
/* Real part is finite. */
float sinh_val = __ieee754_sinhf (__imag__ x);
@@ -61,19 +61,15 @@ __csinf (__complex__ float x)
__real__ retval = __nanf ("");
__imag__ retval = __imag__ x;
-#ifdef FE_INVALID
if (rcls == FP_INFINITE)
feraiseexcept (FE_INVALID);
-#endif
}
else
{
__real__ retval = __nanf ("");
__imag__ retval = __nanf ("");
-#ifdef FE_INVALID
feraiseexcept (FE_INVALID);
-#endif
}
}
}
@@ -107,10 +103,8 @@ __csinf (__complex__ float x)
__real__ retval = __nanf ("");
__imag__ retval = HUGE_VALF;
-#ifdef FE_INVALID
if (rcls == FP_INFINITE)
feraiseexcept (FE_INVALID);
-#endif
}
}
else
diff --git a/libc/math/s_csinh.c b/libc/math/s_csinh.c
index f0e0cc61f..2eec065a8 100644
--- a/libc/math/s_csinh.c
+++ b/libc/math/s_csinh.c
@@ -1,5 +1,5 @@
/* Complex sine hyperbole function for double.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -22,7 +22,7 @@
#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
__complex__ double
@@ -35,10 +35,10 @@ __csinh (__complex__ double x)
__real__ x = fabs (__real__ x);
- if (rcls >= FP_ZERO)
+ if (__builtin_expect (rcls >= FP_ZERO, 1))
{
/* Real part is finite. */
- if (icls >= FP_ZERO)
+ if (__builtin_expect (icls >= FP_ZERO, 1))
{
/* Imaginary part is finite. */
double sinh_val = __ieee754_sinh (__real__ x);
@@ -61,32 +61,22 @@ __csinh (__complex__ double x)
__real__ retval = __copysign (0.0, negate ? -1.0 : 1.0);
__imag__ retval = __nan ("") + __nan ("");
-#ifdef FE_INVALID
if (icls == FP_INFINITE)
feraiseexcept (FE_INVALID);
-#endif
}
else
{
__real__ retval = __nan ("");
__imag__ retval = __nan ("");
-#ifdef FE_INVALID
feraiseexcept (FE_INVALID);
-#endif
}
}
}
else if (rcls == FP_INFINITE)
{
/* Real part is infinite. */
- if (icls == FP_ZERO)
- {
- /* Imaginary part is 0.0. */
- __real__ retval = negate ? -HUGE_VAL : HUGE_VAL;
- __imag__ retval = __imag__ x;
- }
- else if (icls > FP_ZERO)
+ if (__builtin_expect (icls > FP_ZERO, 1))
{
/* Imaginary part is finite. */
double sinix, cosix;
@@ -99,16 +89,20 @@ __csinh (__complex__ double x)
if (negate)
__real__ retval = -__real__ retval;
}
+ else if (icls == FP_ZERO)
+ {
+ /* Imaginary part is 0.0. */
+ __real__ retval = negate ? -HUGE_VAL : HUGE_VAL;
+ __imag__ retval = __imag__ x;
+ }
else
{
/* The addition raises the invalid exception. */
__real__ retval = HUGE_VAL;
__imag__ retval = __nan ("") + __nan ("");
-#ifdef FE_INVALID
if (icls == FP_INFINITE)
feraiseexcept (FE_INVALID);
-#endif
}
}
else
diff --git a/libc/math/s_csinhf.c b/libc/math/s_csinhf.c
index e4bb70426..51e837b14 100644
--- a/libc/math/s_csinhf.c
+++ b/libc/math/s_csinhf.c
@@ -1,5 +1,5 @@
/* Complex sine hyperbole function for float.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -22,7 +22,7 @@
#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
__complex__ float
@@ -35,10 +35,10 @@ __csinhf (__complex__ float x)
__real__ x = fabsf (__real__ x);
- if (rcls >= FP_ZERO)
+ if (__builtin_expect (rcls >= FP_ZERO, 1))
{
/* Real part is finite. */
- if (icls >= FP_ZERO)
+ if (__builtin_expect (icls >= FP_ZERO, 1))
{
/* Imaginary part is finite. */
float sinh_val = __ieee754_sinhf (__real__ x);
@@ -61,32 +61,22 @@ __csinhf (__complex__ float x)
__real__ retval = __copysignf (0.0, negate ? -1.0 : 1.0);
__imag__ retval = __nanf ("") + __nanf ("");
-#ifdef FE_INVALID
if (icls == FP_INFINITE)
feraiseexcept (FE_INVALID);
-#endif
}
else
{
__real__ retval = __nanf ("");
__imag__ retval = __nanf ("");
-#ifdef FE_INVALID
feraiseexcept (FE_INVALID);
-#endif
}
}
}
- else if (rcls == FP_INFINITE)
+ else if (__builtin_expect (rcls == FP_INFINITE, 1))
{
/* Real part is infinite. */
- if (icls == FP_ZERO)
- {
- /* Imaginary part is 0.0. */
- __real__ retval = negate ? -HUGE_VALF : HUGE_VALF;
- __imag__ retval = __imag__ x;
- }
- else if (icls > FP_ZERO)
+ if (__builtin_expect (icls > FP_ZERO, 1))
{
/* Imaginary part is finite. */
float sinix, cosix;
@@ -99,6 +89,12 @@ __csinhf (__complex__ float x)
if (negate)
__real__ retval = -__real__ retval;
}
+ else if (icls == FP_ZERO)
+ {
+ /* Imaginary part is 0.0. */
+ __real__ retval = negate ? -HUGE_VALF : HUGE_VALF;
+ __imag__ retval = __imag__ x;
+ }
else
{
/* The addition raises the invalid exception. */
diff --git a/libc/math/s_csinhl.c b/libc/math/s_csinhl.c
index 226075634..d2964f8a2 100644
--- a/libc/math/s_csinhl.c
+++ b/libc/math/s_csinhl.c
@@ -1,5 +1,5 @@
/* Complex sine hyperbole function for long double.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -22,7 +22,7 @@
#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
__complex__ long double
@@ -35,10 +35,10 @@ __csinhl (__complex__ long double x)
__real__ x = fabsl (__real__ x);
- if (rcls >= FP_ZERO)
+ if (__builtin_expect (rcls >= FP_ZERO, 1))
{
/* Real part is finite. */
- if (icls >= FP_ZERO)
+ if (__builtin_expect (icls >= FP_ZERO, 1))
{
/* Imaginary part is finite. */
long double sinh_val = __ieee754_sinhl (__real__ x);
@@ -61,32 +61,22 @@ __csinhl (__complex__ long double x)
__real__ retval = __copysignl (0.0, negate ? -1.0 : 1.0);
__imag__ retval = __nanl ("") + __nanl ("");
-#ifdef FE_INVALID
if (icls == FP_INFINITE)
feraiseexcept (FE_INVALID);
-#endif
}
else
{
__real__ retval = __nanl ("");
__imag__ retval = __nanl ("");
-#ifdef FE_INVALID
feraiseexcept (FE_INVALID);
-#endif
}
}
}
- else if (rcls == FP_INFINITE)
+ else if (__builtin_expect (rcls == FP_INFINITE, 1))
{
/* Real part is infinite. */
- if (icls == FP_ZERO)
- {
- /* Imaginary part is 0.0. */
- __real__ retval = negate ? -HUGE_VALL : HUGE_VALL;
- __imag__ retval = __imag__ x;
- }
- else if (icls > FP_ZERO)
+ if (__builtin_expect (icls > FP_ZERO, 1))
{
/* Imaginary part is finite. */
long double sinix, cosix;
@@ -99,6 +89,12 @@ __csinhl (__complex__ long double x)
if (negate)
__real__ retval = -__real__ retval;
}
+ else if (icls == FP_ZERO)
+ {
+ /* Imaginary part is 0.0. */
+ __real__ retval = negate ? -HUGE_VALL : HUGE_VALL;
+ __imag__ retval = __imag__ x;
+ }
else
{
/* The addition raises the invalid exception. */
diff --git a/libc/math/s_csinl.c b/libc/math/s_csinl.c
index f7a1c4360..300035c69 100644
--- a/libc/math/s_csinl.c
+++ b/libc/math/s_csinl.c
@@ -1,5 +1,5 @@
/* Complex sine function for long double.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -22,7 +22,7 @@
#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
__complex__ long double
@@ -35,10 +35,10 @@ __csinl (__complex__ long double x)
__real__ x = fabsl (__real__ x);
- if (icls >= FP_ZERO)
+ if (__builtin_expect (icls >= FP_ZERO, 1))
{
/* Imaginary part is finite. */
- if (rcls >= FP_ZERO)
+ if (__builtin_expect (rcls >= FP_ZERO, 1))
{
/* Real part is finite. */
long double sinh_val = __ieee754_sinhl (__imag__ x);
@@ -61,19 +61,15 @@ __csinl (__complex__ long double x)
__real__ retval = __nanl ("");
__imag__ retval = __imag__ x;
-#ifdef FE_INVALID
if (rcls == FP_INFINITE)
feraiseexcept (FE_INVALID);
-#endif
}
else
{
__real__ retval = __nanl ("");
__imag__ retval = __nanl ("");
-#ifdef FE_INVALID
feraiseexcept (FE_INVALID);
-#endif
}
}
}
@@ -107,10 +103,8 @@ __csinl (__complex__ long double x)
__real__ retval = __nanl ("");
__imag__ retval = HUGE_VALL;
-#ifdef FE_INVALID
if (rcls == FP_INFINITE)
feraiseexcept (FE_INVALID);
-#endif
}
}
else
diff --git a/libc/math/s_csqrt.c b/libc/math/s_csqrt.c
index 04ed410a1..1691a01ec 100644
--- a/libc/math/s_csqrt.c
+++ b/libc/math/s_csqrt.c
@@ -1,5 +1,5 @@
/* Complex square root of double value.
- Copyright (C) 1997, 1998, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 2005, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Based on an algorithm by Stephen L. Moshier <moshier@world.std.com>.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -21,8 +21,7 @@
#include <complex.h>
#include <math.h>
-
-#include "math_private.h"
+#include <math_private.h>
__complex__ double
@@ -32,7 +31,7 @@ __csqrt (__complex__ double x)
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
- if (rcls <= FP_INFINITE || icls <= FP_INFINITE)
+ if (__builtin_expect (rcls <= FP_INFINITE || icls <= FP_INFINITE, 0))
{
if (icls == FP_INFINITE)
{
@@ -61,7 +60,7 @@ __csqrt (__complex__ double x)
}
else
{
- if (icls == FP_ZERO)
+ if (__builtin_expect (icls == FP_ZERO, 0))
{
if (__real__ x < 0.0)
{
@@ -75,7 +74,7 @@ __csqrt (__complex__ double x)
__imag__ res = __copysign (0.0, __imag__ x);
}
}
- else if (rcls == FP_ZERO)
+ else if (__builtin_expect (rcls == FP_ZERO, 0))
{
double r = __ieee754_sqrt (0.5 * fabs (__imag__ x));
diff --git a/libc/math/s_csqrtf.c b/libc/math/s_csqrtf.c
index 2fba69ce1..1613192a5 100644
--- a/libc/math/s_csqrtf.c
+++ b/libc/math/s_csqrtf.c
@@ -1,5 +1,5 @@
/* Complex square root of float value.
- Copyright (C) 1997, 1998, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 2005, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Based on an algorithm by Stephen L. Moshier <moshier@world.std.com>.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -21,8 +21,7 @@
#include <complex.h>
#include <math.h>
-
-#include "math_private.h"
+#include <math_private.h>
__complex__ float
@@ -32,7 +31,7 @@ __csqrtf (__complex__ float x)
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
- if (rcls <= FP_INFINITE || icls <= FP_INFINITE)
+ if (__builtin_expect (rcls <= FP_INFINITE || icls <= FP_INFINITE, 0))
{
if (icls == FP_INFINITE)
{
@@ -61,7 +60,7 @@ __csqrtf (__complex__ float x)
}
else
{
- if (icls == FP_ZERO)
+ if (__builtin_expect (icls == FP_ZERO, 0))
{
if (__real__ x < 0.0)
{
@@ -75,7 +74,7 @@ __csqrtf (__complex__ float x)
__imag__ res = __copysignf (0.0, __imag__ x);
}
}
- else if (rcls == FP_ZERO)
+ else if (__builtin_expect (rcls == FP_ZERO, 0))
{
float r = __ieee754_sqrtf (0.5 * fabsf (__imag__ x));
diff --git a/libc/math/s_csqrtl.c b/libc/math/s_csqrtl.c
index 9d00946c5..9b93ef66b 100644
--- a/libc/math/s_csqrtl.c
+++ b/libc/math/s_csqrtl.c
@@ -1,5 +1,5 @@
/* Complex square root of long double value.
- Copyright (C) 1997, 1998, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 2005, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Based on an algorithm by Stephen L. Moshier <moshier@world.std.com>.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -21,8 +21,7 @@
#include <complex.h>
#include <math.h>
-
-#include "math_private.h"
+#include <math_private.h>
__complex__ long double
@@ -32,7 +31,7 @@ __csqrtl (__complex__ long double x)
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
- if (rcls <= FP_INFINITE || icls <= FP_INFINITE)
+ if (__builtin_expect (rcls <= FP_INFINITE || icls <= FP_INFINITE, 0))
{
if (icls == FP_INFINITE)
{
@@ -61,7 +60,7 @@ __csqrtl (__complex__ long double x)
}
else
{
- if (icls == FP_ZERO)
+ if (__builtin_expect (icls == FP_ZERO, 0))
{
if (__real__ x < 0.0)
{
@@ -75,7 +74,7 @@ __csqrtl (__complex__ long double x)
__imag__ res = __copysignl (0.0, __imag__ x);
}
}
- else if (rcls == FP_ZERO)
+ else if (__builtin_expect (rcls == FP_ZERO, 0))
{
long double r = __ieee754_sqrtl (0.5 * fabsl (__imag__ x));
diff --git a/libc/math/s_ctan.c b/libc/math/s_ctan.c
index 0464ab86d..41958516f 100644
--- a/libc/math/s_ctan.c
+++ b/libc/math/s_ctan.c
@@ -1,5 +1,5 @@
/* Complex tangent function for double.
- Copyright (C) 1997, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2005, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -22,7 +22,7 @@
#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
__complex__ double
@@ -30,9 +30,9 @@ __ctan (__complex__ double x)
{
__complex__ double res;
- if (!isfinite (__real__ x) || !isfinite (__imag__ x))
+ if (__builtin_expect (!isfinite (__real__ x) || !isfinite (__imag__ x), 0))
{
- if (__isinf (__imag__ x))
+ if (__isinf_ns (__imag__ x))
{
__real__ res = __copysign (0.0, __real__ x);
__imag__ res = __copysign (1.0, __imag__ x);
@@ -46,10 +46,8 @@ __ctan (__complex__ double x)
__real__ res = __nan ("");
__imag__ res = __nan ("");
-#ifdef FE_INVALID
- if (__isinf (__real__ x))
+ if (__isinf_ns (__real__ x))
feraiseexcept (FE_INVALID);
-#endif
}
}
else
diff --git a/libc/math/s_ctanf.c b/libc/math/s_ctanf.c
index 58d9d1329..7063e38d8 100644
--- a/libc/math/s_ctanf.c
+++ b/libc/math/s_ctanf.c
@@ -1,5 +1,5 @@
/* Complex tangent function for float.
- Copyright (C) 1997, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2005, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -21,8 +21,7 @@
#include <complex.h>
#include <fenv.h>
#include <math.h>
-
-#include "math_private.h"
+#include <math_private.h>
__complex__ float
@@ -30,9 +29,9 @@ __ctanf (__complex__ float x)
{
__complex__ float res;
- if (!isfinite (__real__ x) || !isfinite (__imag__ x))
+ if (__builtin_expect (!isfinite (__real__ x) || !isfinite (__imag__ x), 0))
{
- if (__isinff (__imag__ x))
+ if (__isinf_nsf (__imag__ x))
{
__real__ res = __copysignf (0.0, __real__ x);
__imag__ res = __copysignf (1.0, __imag__ x);
@@ -46,10 +45,8 @@ __ctanf (__complex__ float x)
__real__ res = __nanf ("");
__imag__ res = __nanf ("");
-#ifdef FE_INVALID
- if (__isinff (__real__ x))
+ if (__isinf_nsf (__real__ x))
feraiseexcept (FE_INVALID);
-#endif
}
}
else
diff --git a/libc/math/s_ctanh.c b/libc/math/s_ctanh.c
index fe38dae29..9d31c43cd 100644
--- a/libc/math/s_ctanh.c
+++ b/libc/math/s_ctanh.c
@@ -1,5 +1,5 @@
/* Complex hyperbole tangent for double.
- Copyright (C) 1997, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2005, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -21,8 +21,7 @@
#include <complex.h>
#include <fenv.h>
#include <math.h>
-
-#include "math_private.h"
+#include <math_private.h>
__complex__ double
@@ -30,9 +29,9 @@ __ctanh (__complex__ double x)
{
__complex__ double res;
- if (!isfinite (__real__ x) || !isfinite (__imag__ x))
+ if (__builtin_expect (!isfinite (__real__ x) || !isfinite (__imag__ x), 0))
{
- if (__isinf (__real__ x))
+ if (__isinf_ns (__real__ x))
{
__real__ res = __copysign (1.0, __real__ x);
__imag__ res = __copysign (0.0, __imag__ x);
@@ -46,10 +45,8 @@ __ctanh (__complex__ double x)
__real__ res = __nan ("");
__imag__ res = __nan ("");
-#ifdef FE_INVALID
- if (__isinf (__imag__ x))
+ if (__isinf_ns (__imag__ x))
feraiseexcept (FE_INVALID);
-#endif
}
}
else
diff --git a/libc/math/s_ctanhf.c b/libc/math/s_ctanhf.c
index c331dbaab..6cb3a2cc9 100644
--- a/libc/math/s_ctanhf.c
+++ b/libc/math/s_ctanhf.c
@@ -1,5 +1,5 @@
/* Complex hyperbole tangent for float.
- Copyright (C) 1997, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2005, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -21,8 +21,7 @@
#include <complex.h>
#include <fenv.h>
#include <math.h>
-
-#include "math_private.h"
+#include <math_private.h>
__complex__ float
@@ -30,9 +29,9 @@ __ctanhf (__complex__ float x)
{
__complex__ float res;
- if (!isfinite (__real__ x) || !isfinite (__imag__ x))
+ if (__builtin_expect (!isfinite (__real__ x) || !isfinite (__imag__ x), 0))
{
- if (__isinff (__real__ x))
+ if (__isinf_nsf (__real__ x))
{
__real__ res = __copysignf (1.0, __real__ x);
__imag__ res = __copysignf (0.0, __imag__ x);
@@ -46,10 +45,8 @@ __ctanhf (__complex__ float x)
__real__ res = __nanf ("");
__imag__ res = __nanf ("");
-#ifdef FE_INVALID
- if (__isinff (__imag__ x))
+ if (__isinf_nsf (__imag__ x))
feraiseexcept (FE_INVALID);
-#endif
}
}
else
diff --git a/libc/math/s_ctanhl.c b/libc/math/s_ctanhl.c
index 77ca8f871..0c4641714 100644
--- a/libc/math/s_ctanhl.c
+++ b/libc/math/s_ctanhl.c
@@ -1,5 +1,5 @@
/* Complex hyperbole tangent for long double.
- Copyright (C) 1997, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2005, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -21,8 +21,7 @@
#include <complex.h>
#include <fenv.h>
#include <math.h>
-
-#include "math_private.h"
+#include <math_private.h>
__complex__ long double
@@ -30,9 +29,9 @@ __ctanhl (__complex__ long double x)
{
__complex__ long double res;
- if (!isfinite (__real__ x) || !isfinite (__imag__ x))
+ if (__builtin_expect (!isfinite (__real__ x) || !isfinite (__imag__ x), 0))
{
- if (__isinfl (__real__ x))
+ if (__isinf_nsl (__real__ x))
{
__real__ res = __copysignl (1.0, __real__ x);
__imag__ res = __copysignl (0.0, __imag__ x);
@@ -46,10 +45,8 @@ __ctanhl (__complex__ long double x)
__real__ res = __nanl ("");
__imag__ res = __nanl ("");
-#ifdef FE_INVALID
- if (__isinfl (__imag__ x))
+ if (__isinf_nsl (__imag__ x))
feraiseexcept (FE_INVALID);
-#endif
}
}
else
diff --git a/libc/math/s_ctanl.c b/libc/math/s_ctanl.c
index 89379a5ff..6f49c57c9 100644
--- a/libc/math/s_ctanl.c
+++ b/libc/math/s_ctanl.c
@@ -1,5 +1,5 @@
/* Complex tangent function for long double.
- Copyright (C) 1997, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2005, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -22,7 +22,7 @@
#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
__complex__ long double
@@ -30,9 +30,9 @@ __ctanl (__complex__ long double x)
{
__complex__ long double res;
- if (!isfinite (__real__ x) || !isfinite (__imag__ x))
+ if (__builtin_expect (!isfinite (__real__ x) || !isfinite (__imag__ x), 0))
{
- if (__isinfl (__imag__ x))
+ if (__isinf_nsl (__imag__ x))
{
__real__ res = __copysignl (0.0, __real__ x);
__imag__ res = __copysignl (1.0, __imag__ x);
@@ -46,10 +46,8 @@ __ctanl (__complex__ long double x)
__real__ res = __nanl ("");
__imag__ res = __nanl ("");
-#ifdef FE_INVALID
- if (__isinfl (__real__ x))
+ if (__isinf_nsl (__real__ x))
feraiseexcept (FE_INVALID);
-#endif
}
}
else
diff --git a/libc/math/s_ldexp.c b/libc/math/s_ldexp.c
index 62e123cd0..e99021776 100644
--- a/libc/math/s_ldexp.c
+++ b/libc/math/s_ldexp.c
@@ -15,7 +15,7 @@ static char rcsid[] = "$NetBSD: s_ldexp.c,v 1.6 1995/05/10 20:47:40 jtc Exp $";
#endif
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
#include <errno.h>
#ifdef __STDC__
diff --git a/libc/math/s_ldexpf.c b/libc/math/s_ldexpf.c
index 1ea5e09f8..f312bfe5f 100644
--- a/libc/math/s_ldexpf.c
+++ b/libc/math/s_ldexpf.c
@@ -18,7 +18,7 @@ static char rcsid[] = "$NetBSD: s_ldexpf.c,v 1.3 1995/05/10 20:47:42 jtc Exp $";
#endif
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
#include <errno.h>
#ifdef __STDC__
diff --git a/libc/math/s_ldexpl.c b/libc/math/s_ldexpl.c
index df8b29f94..6a9ea4655 100644
--- a/libc/math/s_ldexpl.c
+++ b/libc/math/s_ldexpl.c
@@ -19,7 +19,7 @@ static char rcsid[] = "$NetBSD: $";
#endif
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
#include <errno.h>
#ifdef __STDC__
diff --git a/libc/math/s_nan.c b/libc/math/s_nan.c
index 9b2c50558..97f9d898a 100644
--- a/libc/math/s_nan.c
+++ b/libc/math/s_nan.c
@@ -25,6 +25,7 @@
#include <ieee754.h>
+#undef __nan
double
__nan (const char *tagp)
{
diff --git a/libc/math/s_nanf.c b/libc/math/s_nanf.c
index 2e1b1eb91..6161bcdd2 100644
--- a/libc/math/s_nanf.c
+++ b/libc/math/s_nanf.c
@@ -25,6 +25,7 @@
#include <ieee754.h>
+#undef __nanf
float
__nanf (const char *tagp)
{
diff --git a/libc/math/s_nanl.c b/libc/math/s_nanl.c
index 9709b9238..1db246426 100644
--- a/libc/math/s_nanl.c
+++ b/libc/math/s_nanl.c
@@ -25,6 +25,7 @@
#include <ieee754.h>
+#undef __nanl
long double
__nanl (const char *tagp)
{
diff --git a/libc/math/s_significand.c b/libc/math/s_significand.c
index 4a02dbcba..197bc9c6e 100644
--- a/libc/math/s_significand.c
+++ b/libc/math/s_significand.c
@@ -21,7 +21,7 @@ static char rcsid[] = "$NetBSD: s_significand.c,v 1.6 1995/05/10 20:48:11 jtc Ex
*/
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
#ifdef __STDC__
double __significand(double x)
diff --git a/libc/math/s_significandf.c b/libc/math/s_significandf.c
index 69de1e6b0..7cbb961ea 100644
--- a/libc/math/s_significandf.c
+++ b/libc/math/s_significandf.c
@@ -18,7 +18,7 @@ static char rcsid[] = "$NetBSD: s_significandf.c,v 1.3 1995/05/10 20:48:13 jtc E
#endif
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
#ifdef __STDC__
float __significandf(float x)
diff --git a/libc/math/s_significandl.c b/libc/math/s_significandl.c
index 238b79ae5..fab5b9fc8 100644
--- a/libc/math/s_significandl.c
+++ b/libc/math/s_significandl.c
@@ -25,7 +25,7 @@ static char rcsid[] = "$NetBSD: $";
*/
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
#ifdef __STDC__
long double __significandl(long double x)
diff --git a/libc/math/w_acos.c b/libc/math/w_acos.c
index f4e6e3c91..617cfdae4 100644
--- a/libc/math/w_acos.c
+++ b/libc/math/w_acos.c
@@ -1,45 +1,39 @@
-/* @(#)w_acos.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_acos.c,v 1.6 1995/05/10 20:48:26 jtc Exp $";
-#endif
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrap_acos(x)
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- double __acos(double x) /* wrapper acos */
-#else
- double __acos(x) /* wrapper acos */
- double x;
-#endif
+/* wrapper acos */
+double
+__acos (double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_acos(x);
-#else
- double z;
- z = __ieee754_acos(x);
- if(_LIB_VERSION == _IEEE_ || __isnan(x)) return z;
- if(fabs(x)>1.0) {
- return __kernel_standard(x,x,1); /* acos(|x|>1) */
- } else
- return z;
-#endif
+ if (__builtin_expect (fabs (x) > 1.0, 0) && _LIB_VERSION != _IEEE_)
+ {
+ /* acos(|x|>1) */
+ feraiseexcept (FE_INVALID);
+ return __kernel_standard (x, x, 1);
+ }
+
+ return __ieee754_acos (x);
}
weak_alias (__acos, acos)
#ifdef NO_LONG_DOUBLE
diff --git a/libc/math/w_acosf.c b/libc/math/w_acosf.c
index a8998efb8..bb3aae001 100644
--- a/libc/math/w_acosf.c
+++ b/libc/math/w_acosf.c
@@ -1,48 +1,38 @@
-/* w_acosf.c -- float version of w_acos.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_acosf.c,v 1.3 1995/05/10 20:48:29 jtc Exp $";
-#endif
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrap_acosf(x)
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- float __acosf(float x) /* wrapper acosf */
-#else
- float __acosf(x) /* wrapper acosf */
- float x;
-#endif
+/* wrapper acosf */
+float
+__acosf (float x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_acosf(x);
-#else
- float z;
- z = __ieee754_acosf(x);
- if(_LIB_VERSION == _IEEE_ || __isnanf(x)) return z;
- if(fabsf(x)>(float)1.0) {
- /* acosf(|x|>1) */
- return (float)__kernel_standard((double)x,(double)x,101);
- } else
- return z;
-#endif
+ if (__builtin_expect (fabsf (x) > 1.0f, 0) && _LIB_VERSION != _IEEE_)
+ {
+ /* acos(|x|>1) */
+ feraiseexcept (FE_INVALID);
+ return __kernel_standard_f (x, x, 101);
+ }
+
+ return __ieee754_acosf (x);
}
weak_alias (__acosf, acosf)
diff --git a/libc/math/w_acosh.c b/libc/math/w_acosh.c
index e8322ec66..50201b4d2 100644
--- a/libc/math/w_acosh.c
+++ b/libc/math/w_acosh.c
@@ -1,44 +1,35 @@
-/* @(#)w_acosh.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_acosh.c,v 1.6 1995/05/10 20:48:31 jtc Exp $";
-#endif
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrapper acosh(x)
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- double __acosh(double x) /* wrapper acosh */
-#else
- double __acosh(x) /* wrapper acosh */
- double x;
-#endif
+
+/* wrapper acosh */
+double
+__acosh (double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_acosh(x);
-#else
- double z;
- z = __ieee754_acosh(x);
- if(_LIB_VERSION == _IEEE_ || __isnan(x)) return z;
- if(x<1.0) {
- return __kernel_standard(x,x,29); /* acosh(x<1) */
- } else
- return z;
-#endif
+ if (__builtin_expect (x < 1.0, 0) && _LIB_VERSION != _IEEE_)
+ /* acosh(x<1) */
+ return __kernel_standard (x, x, 29);
+
+ return __ieee754_acosh (x);
}
weak_alias (__acosh, acosh)
#ifdef NO_LONG_DOUBLE
diff --git a/libc/math/w_acoshf.c b/libc/math/w_acoshf.c
index 62f94b80e..2b07824a0 100644
--- a/libc/math/w_acoshf.c
+++ b/libc/math/w_acoshf.c
@@ -1,48 +1,34 @@
-/* w_acoshf.c -- float version of w_acosh.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * 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.
- * ====================================================
- *
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_acoshf.c,v 1.3 1995/05/10 20:48:33 jtc Exp $";
-#endif
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrapper acoshf(x)
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- float __acoshf(float x) /* wrapper acoshf */
-#else
- float __acoshf(x) /* wrapper acoshf */
- float x;
-#endif
+
+/* wrapper acoshf */
+float
+__acoshf (float x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_acoshf(x);
-#else
- float z;
- z = __ieee754_acoshf(x);
- if(_LIB_VERSION == _IEEE_ || __isnanf(x)) return z;
- if(x<(float)1.0) {
- /* acosh(x<1) */
- return (float)__kernel_standard((double)x,(double)x,129);
- } else
- return z;
-#endif
+ if (__builtin_expect (x < 1.0f, 0) && _LIB_VERSION != _IEEE_)
+ /* acosh(x<1) */
+ return __kernel_standard_f (x, x, 129);
+
+ return __ieee754_acoshf (x);
}
weak_alias (__acoshf, acoshf)
diff --git a/libc/math/w_acoshl.c b/libc/math/w_acoshl.c
index ae67911ae..0f7068a96 100644
--- a/libc/math/w_acoshl.c
+++ b/libc/math/w_acoshl.c
@@ -1,47 +1,34 @@
-/* w_acoshl.c -- long double version of w_acosh.c.
- * Conversion to long double by Ulrich Drepper,
- * Cygnus Support, drepper@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: $";
-#endif
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrapper acoshl(x)
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- long double __acoshl(long double x) /* wrapper acosh */
-#else
- long double __acoshl(x) /* wrapper acosh */
- long double x;
-#endif
+
+/* wrapper acosl */
+long double
+__acoshl (long double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_acoshl(x);
-#else
- long double z;
- z = __ieee754_acoshl(x);
- if(_LIB_VERSION == _IEEE_ || __isnanl(x)) return z;
- if(x<1.0) {
- return __kernel_standard(x,x,229); /* acoshl(x<1) */
- } else
- return z;
-#endif
+ if (__builtin_expect (x < 1.0L, 0) && _LIB_VERSION != _IEEE_)
+ /* acosh(x<1) */
+ return __kernel_standard (x, x, 229);
+
+ return __ieee754_acoshl (x);
}
weak_alias (__acoshl, acoshl)
diff --git a/libc/math/w_acosl.c b/libc/math/w_acosl.c
index 9ab4de899..dd1039ec8 100644
--- a/libc/math/w_acosl.c
+++ b/libc/math/w_acosl.c
@@ -1,48 +1,38 @@
-/* w_acosl.c -- long double version of w_acos.c.
- * Conversion to long double by Ulrich Drepper,
- * Cygnus Support, drepper@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: $";
-#endif
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrap_acosl(x)
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- long double __acosl(long double x) /* wrapper acos */
-#else
- long double __acosl(x) /* wrapper acos */
- long double x;
-#endif
+/* wrapper acosl */
+long double
+__acosl (long double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_acosl(x);
-#else
- long double z;
- z = __ieee754_acosl(x);
- if(_LIB_VERSION == _IEEE_ || __isnanl(x)) return z;
- if(fabsl(x)>1.0) {
- return __kernel_standard(x,x,201); /* acosl(|x|>1) */
- } else
- return z;
-#endif
+ if (__builtin_expect (fabsl (x) > 1.0L, 0) && _LIB_VERSION != _IEEE_)
+ {
+ /* acos(|x|>1) */
+ feraiseexcept (FE_INVALID);
+ return __kernel_standard (x, x, 201);
+ }
+
+ return __ieee754_acosl (x);
}
weak_alias (__acosl, acosl)
diff --git a/libc/math/w_asin.c b/libc/math/w_asin.c
index d531fbd26..feb5c6aaf 100644
--- a/libc/math/w_asin.c
+++ b/libc/math/w_asin.c
@@ -1,46 +1,39 @@
-/* @(#)w_asin.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_asin.c,v 1.6 1995/05/10 20:48:35 jtc Exp $";
-#endif
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-/*
- * wrapper asin(x)
- */
+ The GNU C Library 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
+ Lesser General Public License for more details.
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- double __asin(double x) /* wrapper asin */
-#else
- double __asin(x) /* wrapper asin */
- double x;
-#endif
+/* wrapper asin */
+double
+__asin (double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_asin(x);
-#else
- double z;
- z = __ieee754_asin(x);
- if(_LIB_VERSION == _IEEE_ || __isnan(x)) return z;
- if(fabs(x)>1.0) {
- return __kernel_standard(x,x,2); /* asin(|x|>1) */
- } else
- return z;
-#endif
+ if (__builtin_expect (fabs (x) > 1.0, 0) && _LIB_VERSION != _IEEE_)
+ {
+ /* asin(|x|>1) */
+ feraiseexcept (FE_INVALID);
+ return __kernel_standard (x, x, 2);
+ }
+
+ return __ieee754_asin (x);
}
weak_alias (__asin, asin)
#ifdef NO_LONG_DOUBLE
diff --git a/libc/math/w_asinf.c b/libc/math/w_asinf.c
index b19b5c54e..1a21dc389 100644
--- a/libc/math/w_asinf.c
+++ b/libc/math/w_asinf.c
@@ -1,49 +1,38 @@
-/* w_asinf.c -- float version of w_asin.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_asinf.c,v 1.3 1995/05/10 20:48:37 jtc Exp $";
-#endif
-
-/*
- * wrapper asinf(x)
- */
+ The GNU C Library 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
+ Lesser General Public License for more details.
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- float __asinf(float x) /* wrapper asinf */
-#else
- float __asinf(x) /* wrapper asinf */
- float x;
-#endif
+/* wrapper asinf */
+float
+__asinf (float x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_asinf(x);
-#else
- float z;
- z = __ieee754_asinf(x);
- if(_LIB_VERSION == _IEEE_ || __isnanf(x)) return z;
- if(fabsf(x)>(float)1.0) {
- /* asinf(|x|>1) */
- return (float)__kernel_standard((double)x,(double)x,102);
- } else
- return z;
-#endif
+ if (__builtin_expect (fabsf (x) > 1.0f, 0) && _LIB_VERSION != _IEEE_)
+ {
+ /* asin(|x|>1) */
+ feraiseexcept (FE_INVALID);
+ return __kernel_standard_f (x, x, 102);
+ }
+
+ return __ieee754_asinf (x);
}
weak_alias (__asinf, asinf)
diff --git a/libc/math/w_asinl.c b/libc/math/w_asinl.c
index fb5ee35fc..a9f14fbd6 100644
--- a/libc/math/w_asinl.c
+++ b/libc/math/w_asinl.c
@@ -1,49 +1,38 @@
-/* w_asinl.c -- long double version of w_asin.c.
- * Conversion to long double by Ulrich Drepper,
- * Cygnus Support, drepper@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: $";
-#endif
-
-/*
- * wrapper asinl(x)
- */
+ The GNU C Library 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
+ Lesser General Public License for more details.
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- long double __asinl(long double x) /* wrapper asinl */
-#else
- long double __asinl(x) /* wrapper asinl */
- long double x;
-#endif
+/* wrapper asinl */
+long double
+__asinl (long double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_asinl(x);
-#else
- long double z;
- z = __ieee754_asinl(x);
- if(_LIB_VERSION == _IEEE_ || __isnanl(x)) return z;
- if(fabsl(x)>1.0) {
- return __kernel_standard(x,x,202); /* asinl(|x|>1) */
- } else
- return z;
-#endif
+ if (__builtin_expect (fabsl (x) > 1.0L, 0) && _LIB_VERSION != _IEEE_)
+ {
+ /* asin(|x|>1) */
+ feraiseexcept (FE_INVALID);
+ return __kernel_standard (x, x, 202);
+ }
+
+ return __ieee754_asinl (x);
}
weak_alias (__asinl, asinl)
diff --git a/libc/math/w_atan2.c b/libc/math/w_atan2.c
index f0a10d410..7d61c7279 100644
--- a/libc/math/w_atan2.c
+++ b/libc/math/w_atan2.c
@@ -1,44 +1,37 @@
-/* @(#)w_atan2.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_atan2.c,v 1.6 1995/05/10 20:48:39 jtc Exp $";
-#endif
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
/*
* wrapper atan2(y,x)
*/
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- double __atan2(double y, double x) /* wrapper atan2 */
-#else
- double __atan2(y,x) /* wrapper atan2 */
- double y,x;
-#endif
+double
+__atan2 (double y, double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_atan2(y,x);
-#else
- double z;
- z = __ieee754_atan2(y,x);
- if(_LIB_VERSION != _SVID_||__isnan(x)||__isnan(y)) return z;
- if(x==0.0&&y==0.0)
- return __kernel_standard(y,x,3); /* atan2(+-0,+-0) */
- return z;
-#endif
+ if (__builtin_expect (x == 0.0 && y == 0.0, 0) && _LIB_VERSION == _SVID_)
+ return __kernel_standard (y, x, 3); /* atan2(+-0,+-0) */
+
+ return __ieee754_atan2 (y, x);
}
weak_alias (__atan2, atan2)
#ifdef NO_LONG_DOUBLE
diff --git a/libc/math/w_atan2f.c b/libc/math/w_atan2f.c
index efb08f076..b3c65bfcb 100644
--- a/libc/math/w_atan2f.c
+++ b/libc/math/w_atan2f.c
@@ -1,46 +1,36 @@
-/* w_atan2f.c -- float version of w_atan2.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_atan2f.c,v 1.3 1995/05/10 20:48:42 jtc Exp $";
-#endif
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
/*
* wrapper atan2f(y,x)
*/
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- float __atan2f(float y, float x) /* wrapper atan2f */
-#else
- float __atan2f(y,x) /* wrapper atan2 */
- float y,x;
-#endif
+float
+__atan2f (float y, float x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_atan2f(y,x);
-#else
- float z;
- z = __ieee754_atan2f(y,x);
- if(_LIB_VERSION != _SVID_||__isnanf(x)||__isnanf(y)) return z;
- if(x==0.0&&y==0.0)
- return __kernel_standard(y,x,103); /* atan2(+-0,+-0) */
- return z;
-#endif
+ if (__builtin_expect (x == 0.0f && y == 0.0f, 0) && _LIB_VERSION == _SVID_)
+ return __kernel_standard_f (y, x, 103); /* atan2(+-0,+-0) */
+
+ return __ieee754_atan2f (y, x);
}
weak_alias (__atan2f, atan2f)
diff --git a/libc/math/w_atan2l.c b/libc/math/w_atan2l.c
index 9672e9615..c4854993a 100644
--- a/libc/math/w_atan2l.c
+++ b/libc/math/w_atan2l.c
@@ -1,47 +1,36 @@
-/* w_atan2l.c -- long double version of w_atan2.c.
- * Conversion to long double by Ulrich Drepper,
- * Cygnus Support, drepper@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: $";
-#endif
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
/*
* wrapper atan2l(y,x)
*/
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- long double __atan2l(long double y, long double x) /* wrapper atan2l */
-#else
- long double __atan2l(y,x) /* wrapper atan2l */
- long double y,x;
-#endif
+long double
+__atan2l (long double y, long double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_atan2l(y,x);
-#else
- long double z;
- z = __ieee754_atan2l(y,x);
- if(_LIB_VERSION != _SVID_||__isnanl(x)||__isnanl(y)) return z;
- if(x==0.0&&y==0.0)
- return __kernel_standard(y,x,203); /* atan2(+-0,+-0) */
- return z;
-#endif
+ if (__builtin_expect (x == 0.0L && y == 0.0L, 0) && _LIB_VERSION == _SVID_)
+ return __kernel_standard (y, x, 203); /* atan2(+-0,+-0) */
+
+ return __ieee754_atan2l (y, x);
}
weak_alias (__atan2l, atan2l)
diff --git a/libc/math/w_atanh.c b/libc/math/w_atanh.c
index b81f65c31..61ea0d875 100644
--- a/libc/math/w_atanh.c
+++ b/libc/math/w_atanh.c
@@ -1,49 +1,37 @@
-/* @(#)w_atanh.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_atanh.c,v 1.6 1995/05/10 20:48:43 jtc Exp $";
-#endif
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrapper atanh(x)
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- double __atanh(double x) /* wrapper atanh */
-#else
- double __atanh(x) /* wrapper atanh */
- double x;
-#endif
+/* wrapper atanh */
+double
+__atanh (double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_atanh(x);
-#else
- double z,y;
- z = __ieee754_atanh(x);
- if(_LIB_VERSION == _IEEE_ || __isnan(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
+ if (__builtin_expect (fabs (x) >= 1.0, 0) && _LIB_VERSION != _IEEE_)
+ return __kernel_standard (x, x,
+ fabs (x) > 1.0
+ ? 30 /* atanh(|x|>1) */
+ : 31); /* atanh(|x|==1) */
+
+ return __ieee754_atanh (x);
}
weak_alias (__atanh, atanh)
#ifdef NO_LONG_DOUBLE
diff --git a/libc/math/w_atanhf.c b/libc/math/w_atanhf.c
index 52a144c05..fd1dbaeee 100644
--- a/libc/math/w_atanhf.c
+++ b/libc/math/w_atanhf.c
@@ -1,53 +1,36 @@
-/* w_atanhf.c -- float version of w_atanh.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_atanhf.c,v 1.3 1995/05/10 20:48:45 jtc Exp $";
-#endif
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrapper atanhf(x)
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- float __atanhf(float x) /* wrapper atanhf */
-#else
- float __atanhf(x) /* wrapper atanhf */
- float x;
-#endif
+/* wrapper atanhf */
+float
+__atanhf (float x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_atanhf(x);
-#else
- float z,y;
- z = __ieee754_atanhf(x);
- if(_LIB_VERSION == _IEEE_ || __isnanf(x)) return z;
- y = fabsf(x);
- if(y>=(float)1.0) {
- if(y>(float)1.0)
- /* atanhf(|x|>1) */
- return (float)__kernel_standard((double)x,(double)x,130);
- else
- /* atanhf(|x|==1) */
- return (float)__kernel_standard((double)x,(double)x,131);
- } else
- return z;
-#endif
+ if (__builtin_expect (fabsf (x) >= 1.0f, 0) && _LIB_VERSION != _IEEE_)
+ return __kernel_standard_f (x, x,
+ fabsf (x) > 1.0f
+ ? 130 /* atanh(|x|>1) */
+ : 131); /* atanh(|x|==1) */
+
+ return __ieee754_atanhf (x);
}
weak_alias (__atanhf, atanhf)
diff --git a/libc/math/w_atanhl.c b/libc/math/w_atanhl.c
index 5ce53b847..7c958f131 100644
--- a/libc/math/w_atanhl.c
+++ b/libc/math/w_atanhl.c
@@ -1,52 +1,36 @@
-/* w_atanhl.c -- long double version of w_atanh.c.
- * Conversion to long double by Ulrich Drepper,
- * Cygnus Support, drepper@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: $";
-#endif
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrapper atanhl(x)
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- long double __atanhl(long double x) /* wrapper atanhl */
-#else
- long double __atanhl(x) /* wrapper atanhl */
- long double x;
-#endif
+/* wrapper atanhl */
+long double
+__atanhl (long double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_atanhl(x);
-#else
- long double z,y;
- z = __ieee754_atanhl(x);
- if(_LIB_VERSION == _IEEE_ || __isnanl(x)) return z;
- y = fabsl(x);
- if(y>=1.0) {
- if(y>1.0)
- return __kernel_standard(x,x,230); /* atanhl(|x|>1) */
- else
- return __kernel_standard(x,x,231); /* atanhl(|x|==1) */
- } else
- return z;
-#endif
+ if (__builtin_expect (fabsl (x) >= 1.0L, 0) && _LIB_VERSION != _IEEE_)
+ return __kernel_standard (x, x,
+ fabsl (x) > 1.0L
+ ? 230 /* atanh(|x|>1) */
+ : 231); /* atanh(|x|==1) */
+
+ return __ieee754_atanhl (x);
}
weak_alias (__atanhl, atanhl)
diff --git a/libc/math/w_cosh.c b/libc/math/w_cosh.c
index 033a03405..57010781b 100644
--- a/libc/math/w_cosh.c
+++ b/libc/math/w_cosh.c
@@ -1,4 +1,4 @@
-/* @(#)w_cosh.c 5.1 93/09/24 */
+/* Optimizations bu Ulrich Drepper <drepper@gmail.com>, 2011 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,35 +10,22 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_cosh.c,v 1.6 1995/05/10 20:48:47 jtc Exp $";
-#endif
-
/*
* wrapper cosh(x)
*/
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- double __cosh(double x) /* wrapper cosh */
-#else
- double __cosh(x) /* wrapper cosh */
- double x;
-#endif
+double
+__cosh (double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_cosh(x);
-#else
- double z;
- z = __ieee754_cosh(x);
- if(_LIB_VERSION == _IEEE_ || __isnan(x)) return z;
- if(!__finite(z) && __finite(x)) {
- return __kernel_standard(x,x,5); /* cosh overflow */
- } else
- return z;
-#endif
+ double z = __ieee754_cosh (x);
+ if (__builtin_expect (!__finite (z), 0) && __finite (x)
+ && _LIB_VERSION != _IEEE_)
+ return __kernel_standard (x, x, 5); /* cosh overflow */
+
+ return z;
}
weak_alias (__cosh, cosh)
#ifdef NO_LONG_DOUBLE
diff --git a/libc/math/w_coshf.c b/libc/math/w_coshf.c
index 8e24ca9ad..df1f68120 100644
--- a/libc/math/w_coshf.c
+++ b/libc/math/w_coshf.c
@@ -1,5 +1,6 @@
/* w_coshf.c -- float version of w_cosh.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ * Optimizations by Ulrich Drepper <drepper@gmail.com>, 2011.
*/
/*
@@ -8,40 +9,26 @@
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_coshf.c,v 1.3 1995/05/10 20:48:49 jtc Exp $";
-#endif
-
-/*
+/*
* wrapper coshf(x)
*/
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- float __coshf(float x) /* wrapper coshf */
-#else
- float __coshf(x) /* wrapper coshf */
- float x;
-#endif
+float
+__coshf (float x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_coshf(x);
-#else
- float z;
- z = __ieee754_coshf(x);
- if(_LIB_VERSION == _IEEE_ || __isnanf(x)) return z;
- if(!__finite(z) && __finite(x)) {
- /* cosh overflow */
- return (float)__kernel_standard((double)x,(double)x,105);
- } else
- return z;
-#endif
+ float z = __ieee754_coshf (x);
+ if (__builtin_expect (!__finitef (z), 0) && __finitef (x)
+ && _LIB_VERSION != _IEEE_)
+ return __kernel_standard_f (x, x, 105); /* cosh overflow */
+
+ return z;
}
weak_alias (__coshf, coshf)
diff --git a/libc/math/w_coshl.c b/libc/math/w_coshl.c
index 52b8d9352..abca8b05f 100644
--- a/libc/math/w_coshl.c
+++ b/libc/math/w_coshl.c
@@ -1,6 +1,7 @@
/* w_acoshl.c -- long double version of w_acosh.c.
* Conversion to long double by Ulrich Drepper,
* Cygnus Support, drepper@cygnus.com.
+ * Optimizations bu Ulrich Drepper <drepper@gmail.com>, 2011.
*/
/*
@@ -14,34 +15,21 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: $";
-#endif
-
/*
* wrapper coshl(x)
*/
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- long double __coshl(long double x) /* wrapper coshl */
-#else
- long double __coshl(x) /* wrapper coshl */
- long double x;
-#endif
+long double
+__coshl (long double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_coshl(x);
-#else
- long double z;
- z = __ieee754_coshl(x);
- if(_LIB_VERSION == _IEEE_ || __isnanl(x)) return z;
- if(!__finitel(z) && __finitel(x)) {
- return __kernel_standard(x,x,205); /* cosh overflow */
- } else
- return z;
-#endif
+ long double z = __ieee754_coshl (x);
+ if (__builtin_expect (!__finitel (z), 0) && __finitel (x)
+ && _LIB_VERSION != _IEEE_)
+ return __kernel_standard (x, x, 205); /* cosh overflow */
+
+ return z;
}
weak_alias (__coshl, coshl)
diff --git a/libc/math/w_dremf.c b/libc/math/w_dremf.c
index c3d391d63..4ec4baffd 100644
--- a/libc/math/w_dremf.c
+++ b/libc/math/w_dremf.c
@@ -6,7 +6,7 @@
*/
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
float
__dremf(x, y)
diff --git a/libc/math/w_exp10.c b/libc/math/w_exp10.c
index 9447d8fa2..830b08df1 100644
--- a/libc/math/w_exp10.c
+++ b/libc/math/w_exp10.c
@@ -1,44 +1,40 @@
-/* @(#)w_exp10.c
- * Conversion to exp10 by Ulrich Drepper <drepper@cygnus.com>.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
-/*
- * ====================================================
- * 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 exp10(x)
*/
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- double __exp10(double x) /* wrapper exp10 */
-#else
- double __exp10(x) /* wrapper exp10 */
- double x;
-#endif
+double
+__exp10 (double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_exp10(x);
-#else
- double z;
- z = __ieee754_exp10(x);
- if(_LIB_VERSION == _IEEE_) return z;
- if(!__finite(z) && __finite(x)) {
- /* exp10 overflow (46) if x > 0, underflow (47) if x < 0. */
- return __kernel_standard(x,x,46+!!__signbit(x));
- }
- return z;
-#endif
+ double z = __ieee754_exp10 (x);
+ if (__builtin_expect (!__finite (z), 0)
+ && __finite (x) && _LIB_VERSION != _IEEE_)
+ /* exp10 overflow (46) if x > 0, underflow (47) if x < 0. */
+ return __kernel_standard (x, x, 46 + !!__signbit (x));
+
+ return z;
}
weak_alias (__exp10, exp10)
strong_alias (__exp10, __pow10)
diff --git a/libc/math/w_exp10f.c b/libc/math/w_exp10f.c
index 78e71be06..6fd52f9a3 100644
--- a/libc/math/w_exp10f.c
+++ b/libc/math/w_exp10f.c
@@ -1,45 +1,40 @@
-/* w_exp10f.c -- float version of w_exp10.c.
- * Conversion to exp10 by Ulrich Drepper <drepper@cygnus.com>.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
-/*
- * ====================================================
- * 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 expf10(x)
+ * wrapper exp10f(x)
*/
#include <math.h>
-#include "math_private.h"
-
-#ifdef __STDC__
- float __exp10f(float x) /* wrapper exp10f */
-#else
- float __exp10f(x) /* wrapper exp10f */
- float x;
-#endif
+#include <math_private.h>
+
+float
+__exp10f (float x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_exp10f(x);
-#else
- float z;
- z = __ieee754_exp10f(x);
- if(_LIB_VERSION == _IEEE_) return z;
- if(!__finitef(z) && __finitef(x)) {
- /* exp10f overflow (146) if x > 0, underflow (147) if x < 0. */
- return (float)__kernel_standard((double) x, (double) x,
- 146+!!__signbitf(x));
- }
- return z;
-#endif
+ float z = __ieee754_exp10f (x);
+ if (__builtin_expect (!__finitef (z), 0)
+ && __finitef (x) && _LIB_VERSION != _IEEE_)
+ /* exp10f overflow (146) if x > 0, underflow (147) if x < 0. */
+ return __kernel_standard_f (x, x, 146 + !!__signbitf (x));
+
+ return z;
}
weak_alias (__exp10f, exp10f)
strong_alias (__exp10f, __pow10f)
diff --git a/libc/math/w_exp10l.c b/libc/math/w_exp10l.c
index 368ed7730..0cda27c76 100644
--- a/libc/math/w_exp10l.c
+++ b/libc/math/w_exp10l.c
@@ -1,45 +1,40 @@
-/* w_exp10l.c -- long double version of w_exp10.c.
- * Conversion to long double by Ulrich Drepper,
- * Cygnus Support, drepper@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
-/*
- * ====================================================
- * 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 exp10l(x)
*/
#include <math.h>
-#include "math_private.h"
-
-#ifdef __STDC__
- long double __exp10l(long double x) /* wrapper exp10 */
-#else
- long double __exp10l(x) /* wrapper exp10 */
- long double x;
-#endif
+#include <math_private.h>
+
+long double
+__exp10l (long double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_exp10l(x);
-#else
- long double z;
- z = __ieee754_exp10l(x);
- if(_LIB_VERSION == _IEEE_) return z;
- if(!__finitel(z) && __finitel(x)) {
- /* exp10 overflow (246) if x > 0, underflow (247) if x < 0. */
- return __kernel_standard(x,x,246+__signbitl(x));
- }
- return z;
-#endif
+ long double z = __ieee754_exp10l (x);
+ if (__builtin_expect (!__finitel (z), 0)
+ && __finitel (x) && _LIB_VERSION != _IEEE_)
+ /* exp10l overflow (246) if x > 0, underflow (247) if x < 0. */
+ return __kernel_standard (x, x, 246 + !!__signbitl (x));
+
+ return z;
}
weak_alias (__exp10l, exp10l)
strong_alias (__exp10l, __pow10l)
diff --git a/libc/math/w_exp2.c b/libc/math/w_exp2.c
index 446e5ea91..bf223265c 100644
--- a/libc/math/w_exp2.c
+++ b/libc/math/w_exp2.c
@@ -4,30 +4,20 @@
#include <float.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-static const double o_threshold= (double) DBL_MAX_EXP;
-static const double u_threshold= (double) (DBL_MIN_EXP - DBL_MANT_DIG - 1);
+static const double o_threshold = (double) DBL_MAX_EXP;
+static const double u_threshold = (double) (DBL_MIN_EXP - DBL_MANT_DIG - 1);
double
-__exp2 (double x) /* wrapper exp2 */
+__exp2 (double x)
{
-#ifdef _IEEE_LIBM
+ if (__builtin_expect (x <= u_threshold || x > o_threshold, 0)
+ && _LIB_VERSION != _IEEE_ && __finite (x))
+ /* exp2 overflow: 44, exp2 underflow: 45 */
+ return __kernel_standard (x, x, 44 + (x <= o_threshold));
+
return __ieee754_exp2 (x);
-#else
- double z;
- z = __ieee754_exp2 (x);
- if (_LIB_VERSION != _IEEE_ && __finite (x))
- {
- if (x > o_threshold)
- /* exp2 overflow */
- return __kernel_standard (x, x, 44);
- else if (x <= u_threshold)
- /* exp2 underflow */
- return __kernel_standard (x, x, 45);
- }
- return z;
-#endif
}
weak_alias (__exp2, exp2)
#ifdef NO_LONG_DOUBLE
diff --git a/libc/math/w_exp2f.c b/libc/math/w_exp2f.c
index 9120c88b6..7215fcaf4 100644
--- a/libc/math/w_exp2f.c
+++ b/libc/math/w_exp2f.c
@@ -4,29 +4,19 @@
#include <float.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-static const float o_threshold= (float) FLT_MAX_EXP;
-static const float u_threshold= (float) (FLT_MIN_EXP - FLT_MANT_DIG - 1);
+static const float o_threshold = (float) FLT_MAX_EXP;
+static const float u_threshold = (float) (FLT_MIN_EXP - FLT_MANT_DIG - 1);
float
-__exp2f (float x) /* wrapper exp2f */
+__exp2f (float x)
{
-#ifdef _IEEE_LIBM
+ if (__builtin_expect (x <= u_threshold || x > o_threshold, 0)
+ && _LIB_VERSION != _IEEE_ && __finitef (x))
+ /* exp2 overflow: 144, exp2 underflow: 145 */
+ return __kernel_standard_f (x, x, 144 + (x <= o_threshold));
+
return __ieee754_exp2f (x);
-#else
- float z;
- z = __ieee754_exp2f (x);
- if (_LIB_VERSION != _IEEE_ && __finitef (x))
- {
- if (x > o_threshold)
- /* exp2 overflow */
- return (float) __kernel_standard ((double) x, (double) x, 144);
- else if (x <= u_threshold)
- /* exp2 underflow */
- return (float) __kernel_standard ((double) x, (double) x, 145);
- }
- return z;
-#endif
}
weak_alias (__exp2f, exp2f)
diff --git a/libc/math/w_exp2l.c b/libc/math/w_exp2l.c
index fea5425ac..ac8d231e2 100644
--- a/libc/math/w_exp2l.c
+++ b/libc/math/w_exp2l.c
@@ -4,28 +4,20 @@
#include <float.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
static const long double o_threshold = (long double) LDBL_MAX_EXP;
static const long double u_threshold
= (long double) (LDBL_MIN_EXP - LDBL_MANT_DIG - 1);
long double
-__exp2l (long double x) /* wrapper exp2l */
+__exp2l (long double x)
{
-#ifdef _IEEE_LIBM
+ if (__builtin_expect (x <= u_threshold || x > o_threshold, 0)
+ && _LIB_VERSION != _IEEE_ && __finitel (x))
+ /* exp2 overflow: 244, exp2 underflow: 245 */
+ return __kernel_standard (x, x, 244 + (x <= o_threshold));
+
return __ieee754_exp2l (x);
-#else
- long double z;
- z = __ieee754_exp2l (x);
- if (_LIB_VERSION != _IEEE_ && __finitel (x))
- {
- if (x > o_threshold)
- return __kernel_standard (x, x, 244); /* exp2l overflow */
- else if (x <= u_threshold)
- return __kernel_standard (x, x, 245); /* exp2l underflow */
- }
- return z;
-#endif
}
weak_alias (__exp2l, exp2l)
diff --git a/libc/math/w_fmod.c b/libc/math/w_fmod.c
index ca01cf2ac..d38ae8c5a 100644
--- a/libc/math/w_fmod.c
+++ b/libc/math/w_fmod.c
@@ -1,46 +1,35 @@
-/* @(#)w_fmod.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_fmod.c,v 1.6 1995/05/10 20:48:55 jtc Exp $";
-#endif
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-/*
- * wrapper fmod(x,y)
- */
+ The GNU C Library 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
+ Lesser General Public License for more details.
-#include <math.h>
-#include "math_private.h"
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+#include <math.h>
+#include <math_private.h>
-#ifdef __STDC__
- double __fmod(double x, double y) /* wrapper fmod */
-#else
- double __fmod(x,y) /* wrapper fmod */
- double x,y;
-#endif
+/* wrapper fmod */
+double
+__fmod (double x, double y)
{
-#ifdef _IEEE_LIBM
- return __ieee754_fmod(x,y);
-#else
- double z;
- z = __ieee754_fmod(x,y);
- if(_LIB_VERSION == _IEEE_ ||__isnan(y)||__isnan(x)) return z;
- if(__isinf(x)||y==0.0) {
- /* fmod(+-Inf,y) or fmod(x,0) */
- return __kernel_standard(x,y,27);
- } else
- return z;
-#endif
+ if (__builtin_expect (__isinf_ns (x) || y == 0.0, 0)
+ && _LIB_VERSION != _IEEE_ && !__isnan (y) && !__isnan (x))
+ /* fmod(+-Inf,y) or fmod(x,0) */
+ return __kernel_standard (x, y, 27);
+
+ return __ieee754_fmod (x, y);
}
weak_alias (__fmod, fmod)
#ifdef NO_LONG_DOUBLE
diff --git a/libc/math/w_fmodf.c b/libc/math/w_fmodf.c
index e2e869a3c..c0370cf6f 100644
--- a/libc/math/w_fmodf.c
+++ b/libc/math/w_fmodf.c
@@ -1,48 +1,34 @@
-/* w_fmodf.c -- float version of w_fmod.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_fmodf.c,v 1.3 1995/05/10 20:48:57 jtc Exp $";
-#endif
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrapper fmodf(x,y)
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-
-#ifdef __STDC__
- float __fmodf(float x, float y) /* wrapper fmodf */
-#else
- float __fmodf(x,y) /* wrapper fmodf */
- float x,y;
-#endif
+/* wrapper fmodf */
+float
+__fmodf (float x, float y)
{
-#ifdef _IEEE_LIBM
- return __ieee754_fmodf(x,y);
-#else
- float z;
- z = __ieee754_fmodf(x,y);
- if(_LIB_VERSION == _IEEE_ ||__isnanf(y)||__isnanf(x)) return z;
- if(__isinff(x)||y==(float)0.0) {
- /* fmodf(+-Inf,y) or fmodf(x,0) */
- return (float)__kernel_standard((double)x,(double)y,127);
- } else
- return z;
-#endif
+ if (__builtin_expect (__isinf_nsf (x) || y == 0.0f, 0)
+ && _LIB_VERSION != _IEEE_ && !__isnanf (y) && !__isnanf (x))
+ /* fmod(+-Inf,y) or fmod(x,0) */
+ return __kernel_standard_f (x, y, 127);
+
+ return __ieee754_fmodf (x, y);
}
weak_alias (__fmodf, fmodf)
diff --git a/libc/math/w_fmodl.c b/libc/math/w_fmodl.c
index c39b2852f..d236fb9fd 100644
--- a/libc/math/w_fmodl.c
+++ b/libc/math/w_fmodl.c
@@ -1,49 +1,34 @@
-/* w_fmodl.c -- long double version of w_fmod.c.
- * Conversion to long double by Ulrich Drepper,
- * Cygnus Support, drepper@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: $";
-#endif
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrapper fmodl(x,y)
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-
-#ifdef __STDC__
- long double __fmodl(long double x, long double y)/* wrapper fmodl */
-#else
- long double __fmodl(x,y) /* wrapper fmodl */
- long double x,y;
-#endif
+/* wrapper fmodl */
+long double
+__fmodl (long double x, long double y)
{
-#ifdef _IEEE_LIBM
- return __ieee754_fmodl(x,y);
-#else
- long double z;
- z = __ieee754_fmodl(x,y);
- if(_LIB_VERSION == _IEEE_ ||__isnanl(y)||__isnanl(x)) return z;
- if(__isinfl(x)||y==0.0) {
- /* fmodl(+-Inf,y) or fmodl(x,0) */
- return __kernel_standard(x,y,227);
- } else
- return z;
-#endif
+ if (__builtin_expect (__isinf_nsl (x) || y == 0.0L, 0)
+ && _LIB_VERSION != _IEEE_ && !__isnanl (y) && !__isnanl (x))
+ /* fmod(+-Inf,y) or fmod(x,0) */
+ return __kernel_standard (x, y, 227);
+
+ return __ieee754_fmodl (x, y);
}
weak_alias (__fmodl, fmodl)
diff --git a/libc/math/w_hypot.c b/libc/math/w_hypot.c
index ab929f78a..2c6de2860 100644
--- a/libc/math/w_hypot.c
+++ b/libc/math/w_hypot.c
@@ -10,36 +10,23 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_hypot.c,v 1.6 1995/05/10 20:49:07 jtc Exp $";
-#endif
-
/*
* wrapper hypot(x,y)
*/
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- double __hypot(double x, double y)/* wrapper hypot */
-#else
- double __hypot(x,y) /* wrapper hypot */
- double x,y;
-#endif
+double
+__hypot (double x, double y)
{
-#ifdef _IEEE_LIBM
- return __ieee754_hypot(x,y);
-#else
- double z;
- z = __ieee754_hypot(x,y);
- if(_LIB_VERSION == _IEEE_) return z;
- if((!__finite(z))&&__finite(x)&&__finite(y))
- return __kernel_standard(x,y,4); /* hypot overflow */
- else
- return z;
-#endif
+ double z = __ieee754_hypot(x,y);
+ if(__builtin_expect(!__finite(z), 0)
+ && __finite(x) && __finite(y) && _LIB_VERSION != _IEEE_)
+ return __kernel_standard(x, y, 4); /* hypot overflow */
+
+ return z;
}
weak_alias (__hypot, hypot)
#ifdef NO_LONG_DOUBLE
diff --git a/libc/math/w_hypotf.c b/libc/math/w_hypotf.c
index b6be39e39..6042b8802 100644
--- a/libc/math/w_hypotf.c
+++ b/libc/math/w_hypotf.c
@@ -8,41 +8,28 @@
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_hypotf.c,v 1.3 1995/05/10 20:49:09 jtc Exp $";
-#endif
-
/*
* wrapper hypotf(x,y)
*/
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- float __hypotf(float x, float y) /* wrapper hypotf */
-#else
- float __hypotf(x,y) /* wrapper hypotf */
- float x,y;
-#endif
+float
+__hypotf(float x, float y)
{
-#ifdef _IEEE_LIBM
- return __ieee754_hypotf(x,y);
-#else
- float z;
- z = __ieee754_hypotf(x,y);
- if(_LIB_VERSION == _IEEE_) return z;
- if((!__finitef(z))&&__finitef(x)&&__finitef(y))
+ float z = __ieee754_hypotf(x,y);
+ if(__builtin_expect(!__finitef(z), 0)
+ && __finitef(x) && __finitef(y) && _LIB_VERSION != _IEEE_)
/* hypot overflow */
- return (float)__kernel_standard((double)x,(double)y,104);
- else
- return z;
-#endif
+ return __kernel_standard_f(x, y, 104);
+
+ return z;
}
weak_alias (__hypotf, hypotf)
diff --git a/libc/math/w_hypotl.c b/libc/math/w_hypotl.c
index 916afbd41..522eb63c3 100644
--- a/libc/math/w_hypotl.c
+++ b/libc/math/w_hypotl.c
@@ -14,35 +14,23 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: $";
-#endif
-
/*
* wrapper hypotl(x,y)
*/
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- long double __hypotl(long double x, long double y)/* wrapper hypotl */
-#else
- long double __hypotl(x,y) /* wrapper hypotl */
- long double x,y;
-#endif
+long double
+__hypotl(long double x, long double y)
{
-#ifdef _IEEE_LIBM
- return __ieee754_hypotl(x,y);
-#else
long double z;
z = __ieee754_hypotl(x,y);
- if(_LIB_VERSION == _IEEE_) return z;
- if((!__finitel(z))&&__finitel(x)&&__finitel(y))
- return __kernel_standard(x,y,204); /* hypot overflow */
- else
- return z;
-#endif
+ if(__builtin_expect(!__finitel(z), 0)
+ && __finitel(x) && __finitel(y) && _LIB_VERSION != _IEEE_)
+ return __kernel_standard(x, y, 204); /* hypot overflow */
+
+ return z;
}
weak_alias (__hypotl, hypotl)
diff --git a/libc/math/w_j0.c b/libc/math/w_j0.c
index 5ab3544aa..361352048 100644
--- a/libc/math/w_j0.c
+++ b/libc/math/w_j0.c
@@ -1,75 +1,63 @@
-/* @(#)w_j0.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_j0.c,v 1.6 1995/05/10 20:49:11 jtc Exp $";
-#endif
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrapper j0(double x), y0(double x)
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- double j0(double x) /* wrapper j0 */
-#else
- double j0(x) /* wrapper j0 */
- double x;
-#endif
+
+/* wrapper j0 */
+double
+j0 (double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_j0(x);
-#else
- double z = __ieee754_j0(x);
- if(_LIB_VERSION == _IEEE_ || __isnan(x)) return z;
- if(fabs(x)>X_TLOSS) {
- return __kernel_standard(x,x,34); /* j0(|x|>X_TLOSS) */
- } else
- return z;
-#endif
+ if (__builtin_expect (fabs (x) > X_TLOSS, 0) && _LIB_VERSION != _IEEE_)
+ /* j0(|x|>X_TLOSS) */
+ return __kernel_standard (x, x, 34);
+
+ return __ieee754_j0 (x);
}
#ifdef NO_LONG_DOUBLE
strong_alias (j0, j0l)
#endif
-#ifdef __STDC__
- double y0(double x) /* wrapper y0 */
-#else
- double y0(x) /* wrapper y0 */
- double x;
-#endif
+/* wrapper y0 */
+double
+y0 (double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_y0(x);
-#else
- double z;
- z = __ieee754_y0(x);
- if(_LIB_VERSION == _IEEE_ || __isnan(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
+ if (__builtin_expect (x <= 0.0 || x > X_TLOSS, 0) && _LIB_VERSION != _IEEE_)
+ {
+ if (x < 0.0)
+ {
+ /* d = zero/(x-x) */
+ feraiseexcept (FE_INVALID);
+ return __kernel_standard (x, x, 9);
+ }
+ else if (x == 0.0)
+ /* d = -one/(x-x) */
+ return __kernel_standard (x, x, 8);
+ else
+ /* y0(x>X_TLOSS) */
+ return __kernel_standard (x, x, 35);
+ }
+
+ return __ieee754_y0 (x);
}
#ifdef NO_LONG_DOUBLE
strong_alias (y0, y0l)
diff --git a/libc/math/w_j0f.c b/libc/math/w_j0f.c
index bb2b82f06..ff1ac3ca3 100644
--- a/libc/math/w_j0f.c
+++ b/libc/math/w_j0f.c
@@ -1,74 +1,60 @@
-/* w_j0f.c -- float version of w_j0.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_j0f.c,v 1.3 1995/05/10 20:49:13 jtc Exp $";
-#endif
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrapper j0f(float x), y0f(float x)
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- float j0f(float x) /* wrapper j0f */
-#else
- float j0f(x) /* wrapper j0f */
- float x;
-#endif
+
+/* wrapper j0f */
+float
+j0f (float x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_j0f(x);
-#else
- float z = __ieee754_j0f(x);
- if(_LIB_VERSION == _IEEE_ || __isnanf(x)) return z;
- if(fabsf(x)>(float)X_TLOSS) {
- /* j0f(|x|>X_TLOSS) */
- return (float)__kernel_standard((double)x,(double)x,134);
- } else
- return z;
-#endif
+ if (__builtin_expect (fabsf (x) > (float) X_TLOSS, 0)
+ && _LIB_VERSION != _IEEE_)
+ /* j0(|x|>X_TLOSS) */
+ return __kernel_standard_f (x, x, 134);
+
+ return __ieee754_j0f (x);
}
-#ifdef __STDC__
- float y0f(float x) /* wrapper y0f */
-#else
- float y0f(x) /* wrapper y0f */
- float x;
-#endif
+
+/* wrapper y0f */
+float
+y0f (float x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_y0f(x);
-#else
- float z;
- z = __ieee754_y0f(x);
- if(_LIB_VERSION == _IEEE_ || __isnanf(x) ) return z;
- if(x <= (float)0.0){
- if(x==(float)0.0)
- /* d= -one/(x-x); */
- return (float)__kernel_standard((double)x,(double)x,108);
- else
- /* d = zero/(x-x); */
- return (float)__kernel_standard((double)x,(double)x,109);
- }
- if(x>(float)X_TLOSS) {
- /* y0(x>X_TLOSS) */
- return (float)__kernel_standard((double)x,(double)x,135);
- } else
- return z;
-#endif
+ if (__builtin_expect (x <= 0.0f || x > (float) X_TLOSS, 0)
+ && _LIB_VERSION != _IEEE_)
+ {
+ if (x < 0.0f)
+ {
+ /* d = zero/(x-x) */
+ feraiseexcept (FE_INVALID);
+ return __kernel_standard_f (x, x, 109);
+ }
+ else if (x == 0.0f)
+ /* d = -one/(x-x) */
+ return __kernel_standard_f (x, x, 108);
+ else
+ /* y0(x>X_TLOSS) */
+ return __kernel_standard_f (x, x, 135);
+ }
+
+ return __ieee754_y0f (x);
}
diff --git a/libc/math/w_j0l.c b/libc/math/w_j0l.c
index 1ec6e9e0c..a16363d53 100644
--- a/libc/math/w_j0l.c
+++ b/libc/math/w_j0l.c
@@ -1,76 +1,60 @@
-/* w_j0l.c -- long double version of w_j0.c.
- * Conversion to long double by Ulrich Drepper,
- * Cygnus Support, drepper@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: $";
-#endif
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrapper j0l(long double x), y0l(long double x)
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- long double __j0l(long double x) /* wrapper j0l */
-#else
- long double __j0l(x) /* wrapper j0 */
- long double x;
-#endif
+
+/* wrapper j0l */
+long double
+__j0l (long double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_j0l(x);
-#else
- long double z = __ieee754_j0l(x);
- if(_LIB_VERSION == _IEEE_ || __isnanl(x)) return z;
- if(fabsl(x)>X_TLOSS) {
- return __kernel_standard(x,x,234); /* j0(|x|>X_TLOSS) */
- } else
- return z;
-#endif
+ if (__builtin_expect (fabsl (x) > X_TLOSS, 0) && _LIB_VERSION != _IEEE_)
+ /* j0(|x|>X_TLOSS) */
+ return __kernel_standard (x, x, 234);
+
+ return __ieee754_j0l (x);
}
weak_alias (__j0l, j0l)
-#ifdef __STDC__
- long double __y0l(long double x) /* wrapper y0l */
-#else
- long double __y0l(x) /* wrapper y0 */
- long double x;
-#endif
+
+/* wrapper y0l */
+long double
+__y0l (long double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_y0l(x);
-#else
- long double z;
- z = __ieee754_y0l(x);
- if(_LIB_VERSION == _IEEE_ || __isnanl(x) ) return z;
- if(x <= 0.0){
- if(x==0.0)
- /* d= -one/(x-x); */
- return __kernel_standard(x,x,208);
- else
- /* d = zero/(x-x); */
- return __kernel_standard(x,x,209);
- }
- if(x>X_TLOSS) {
- return __kernel_standard(x,x,235); /* y0(x>X_TLOSS) */
- } else
- return z;
-#endif
-}
+ if (__builtin_expect (x <= 0.0L || x > X_TLOSS, 0) && _LIB_VERSION != _IEEE_)
+ {
+ if (x < 0.0L)
+ {
+ /* d = zero/(x-x) */
+ feraiseexcept (FE_INVALID);
+ return __kernel_standard (x, x, 209);
+ }
+ else if (x == 0.0L)
+ /* d = -one/(x-x) */
+ return __kernel_standard (x, x, 208);
+ else
+ /* y0(x>X_TLOSS) */
+ return __kernel_standard (x, x, 235);
+ }
+ return __ieee754_y0l (x);
+}
weak_alias (__y0l, y0l)
diff --git a/libc/math/w_j1.c b/libc/math/w_j1.c
index db8c4ce33..09cacb82c 100644
--- a/libc/math/w_j1.c
+++ b/libc/math/w_j1.c
@@ -1,76 +1,63 @@
-/* @(#)w_j1.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_j1.c,v 1.6 1995/05/10 20:49:15 jtc Exp $";
-#endif
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrapper of j1,y1
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- double j1(double x) /* wrapper j1 */
-#else
- double j1(x) /* wrapper j1 */
- double x;
-#endif
+
+/* wrapper j1 */
+double
+j1 (double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_j1(x);
-#else
- double z;
- z = __ieee754_j1(x);
- if(_LIB_VERSION == _IEEE_ || __isnan(x) ) return z;
- if(fabs(x)>X_TLOSS) {
- return __kernel_standard(x,x,36); /* j1(|x|>X_TLOSS) */
- } else
- return z;
-#endif
+ if (__builtin_expect (fabs (x) > X_TLOSS, 0) && _LIB_VERSION != _IEEE_)
+ /* j1(|x|>X_TLOSS) */
+ return __kernel_standard (x, x, 36);
+
+ return __ieee754_j1 (x);
}
#ifdef NO_LONG_DOUBLE
strong_alias (j1, j1l)
#endif
-#ifdef __STDC__
- double y1(double x) /* wrapper y1 */
-#else
- double y1(x) /* wrapper y1 */
- double x;
-#endif
+/* wrapper y1 */
+double
+y1 (double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_y1(x);
-#else
- double z;
- z = __ieee754_y1(x);
- if(_LIB_VERSION == _IEEE_ || __isnan(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
+ if (__builtin_expect (x <= 0.0 || x > X_TLOSS, 0) && _LIB_VERSION != _IEEE_)
+ {
+ if (x < 0.0)
+ {
+ /* d = zero/(x-x) */
+ feraiseexcept (FE_INVALID);
+ return __kernel_standard (x, x, 11);
+ }
+ else if (x == 0.0)
+ /* d = -one/(x-x) */
+ return __kernel_standard (x, x, 10);
+ else
+ /* y1(x>X_TLOSS) */
+ return __kernel_standard (x, x, 37);
+ }
+
+ return __ieee754_y1 (x);
}
#ifdef NO_LONG_DOUBLE
strong_alias (y1, y1l)
diff --git a/libc/math/w_j1f.c b/libc/math/w_j1f.c
index 35b186206..40a2cf302 100644
--- a/libc/math/w_j1f.c
+++ b/libc/math/w_j1f.c
@@ -1,75 +1,59 @@
-/* w_j1f.c -- float version of w_j1.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_j1f.c,v 1.3 1995/05/10 20:49:17 jtc Exp $";
-#endif
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrapper of j1f,y1f
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- float j1f(float x) /* wrapper j1f */
-#else
- float j1f(x) /* wrapper j1f */
- float x;
-#endif
+
+/* wrapper j1f */
+float
+j1f (float x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_j1f(x);
-#else
- float z;
- z = __ieee754_j1f(x);
- if(_LIB_VERSION == _IEEE_ || __isnanf(x) ) return z;
- if(fabsf(x)>(float)X_TLOSS) {
- /* j1(|x|>X_TLOSS) */
- return (float)__kernel_standard((double)x,(double)x,136);
- } else
- return z;
-#endif
+ if (__builtin_expect (fabsf (x) > X_TLOSS, 0) && _LIB_VERSION != _IEEE_)
+ /* j1(|x|>X_TLOSS) */
+ return __kernel_standard_f (x, x, 136);
+
+ return __ieee754_j1f (x);
}
-#ifdef __STDC__
- float y1f(float x) /* wrapper y1f */
-#else
- float y1f(x) /* wrapper y1f */
- float x;
-#endif
+
+/* wrapper y1f */
+float
+y1f (float x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_y1f(x);
-#else
- float z;
- z = __ieee754_y1f(x);
- if(_LIB_VERSION == _IEEE_ || __isnanf(x) ) return z;
- if(x <= (float)0.0){
- if(x==(float)0.0)
- /* d= -one/(x-x); */
- return (float)__kernel_standard((double)x,(double)x,110);
- else
- /* d = zero/(x-x); */
- return (float)__kernel_standard((double)x,(double)x,111);
- }
- if(x>(float)X_TLOSS) {
- /* y1(x>X_TLOSS) */
- return (float)__kernel_standard((double)x,(double)x,137);
- } else
- return z;
-#endif
+ if (__builtin_expect (x <= 0.0f || x > (float) X_TLOSS, 0)
+ && _LIB_VERSION != _IEEE_)
+ {
+ if (x < 0.0f)
+ {
+ /* d = zero/(x-x) */
+ feraiseexcept (FE_INVALID);
+ return __kernel_standard_f (x, x, 111);
+ }
+ else if (x == 0.0f)
+ /* d = -one/(x-x) */
+ return __kernel_standard_f (x, x, 110);
+ else
+ /* y1(x>X_TLOSS) */
+ return __kernel_standard_f (x, x, 137);
+ }
+
+ return __ieee754_y1f (x);
}
diff --git a/libc/math/w_j1l.c b/libc/math/w_j1l.c
index 7bd31ad99..91b56e332 100644
--- a/libc/math/w_j1l.c
+++ b/libc/math/w_j1l.c
@@ -1,76 +1,60 @@
-/* w_j1l.c -- long double version of w_j1.c.
- * Conversion to long double by Ulrich Drepper,
- * Cygnus Support, drepper@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: $";
-#endif
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrapper of j1l,y1l
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- long double __j1l(long double x) /* wrapper j1l */
-#else
- long double __j1l(x) /* wrapper j1l */
- long double x;
-#endif
+
+/* wrapper j1l */
+long double
+__j1l (long double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_j1l(x);
-#else
- long double z;
- z = __ieee754_j1l(x);
- if(_LIB_VERSION == _IEEE_ || __isnanl(x) ) return z;
- if(fabsl(x)>X_TLOSS) {
- return __kernel_standard(x,x,236); /* j1(|x|>X_TLOSS) */
- } else
- return z;
-#endif
+ if (__builtin_expect (fabsl (x) > X_TLOSS, 0) && _LIB_VERSION != _IEEE_)
+ /* j1(|x|>X_TLOSS) */
+ return __kernel_standard (x, x, 236);
+
+ return __ieee754_j1l (x);
}
weak_alias (__j1l, j1l)
-#ifdef __STDC__
- long double __y1l(long double x) /* wrapper y1l */
-#else
- long double __y1l(x) /* wrapper y1l */
- long double x;
-#endif
+
+/* wrapper y1l */
+long double
+__y1l (long double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_y1l(x);
-#else
- long double z;
- z = __ieee754_y1l(x);
- if(_LIB_VERSION == _IEEE_ || __isnanl(x) ) return z;
- if(x <= 0.0){
- if(x==0.0)
- /* d= -one/(x-x); */
- return __kernel_standard(x,x,210);
- else
- /* d = zero/(x-x); */
- return __kernel_standard(x,x,211);
- }
- if(x>X_TLOSS) {
- return __kernel_standard(x,x,237); /* y1(x>X_TLOSS) */
- } else
- return z;
-#endif
+ if (__builtin_expect (x <= 0.0L || x > X_TLOSS, 0) && _LIB_VERSION != _IEEE_)
+ {
+ if (x < 0.0L)
+ {
+ /* d = zero/(x-x) */
+ feraiseexcept (FE_INVALID);
+ return __kernel_standard (x, x, 211);
+ }
+ else if (x == 0.0L)
+ /* d = -one/(x-x) */
+ return __kernel_standard (x, x, 210);
+ else
+ /* y1(x>X_TLOSS) */
+ return __kernel_standard (x, x, 237);
+ }
+
+ return __ieee754_y1l (x);
}
weak_alias (__y1l, y1l)
diff --git a/libc/math/w_jn.c b/libc/math/w_jn.c
index 3a28443dc..36fb44816 100644
--- a/libc/math/w_jn.c
+++ b/libc/math/w_jn.c
@@ -1,98 +1,63 @@
-/* @(#)w_jn.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_jn.c,v 1.6 1995/05/10 20:49:19 jtc Exp $";
-#endif
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrapper jn(int n, double x), yn(int n, double x)
- * floating point Bessel's function of the 1st and 2nd kind
- * of order n
- *
- * Special cases:
- * y0(0)=y1(0)=yn(n,0) = -inf with division by zero signal;
- * y0(-ve)=y1(-ve)=yn(n,-ve) are NaN with invalid signal.
- * Note 2. About jn(n,x), yn(n,x)
- * For n=0, j0(x) is called,
- * for n=1, j1(x) is called,
- * for n<x, forward recursion us used starting
- * from values of j0(x) and j1(x).
- * for n>x, a continued fraction approximation to
- * j(n,x)/j(n-1,x) is evaluated and then backward
- * recursion is used starting from a supposed value
- * for j(n,x). The resulting value of j(0,x) is
- * compared with the actual value to correct the
- * supposed value of j(n,x).
- *
- * yn(n,x) is similar in all respects, except
- * that forward recursion is used for all
- * values of n>1.
- *
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- double jn(int n, double x) /* wrapper jn */
-#else
- double jn(n,x) /* wrapper jn */
- double x; int n;
-#endif
+
+/* wrapper jn */
+double
+jn (int n, double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_jn(n,x);
-#else
- double z;
- z = __ieee754_jn(n,x);
- if(_LIB_VERSION == _IEEE_ || __isnan(x) ) return z;
- if(fabs(x)>X_TLOSS) {
- return __kernel_standard((double)n,x,38); /* jn(|x|>X_TLOSS,n) */
- } else
- return z;
-#endif
+ if (__builtin_expect (fabs (x) > X_TLOSS, 0) && _LIB_VERSION != _IEEE_)
+ /* jn(n,|x|>X_TLOSS) */
+ return __kernel_standard (n, x, 38);
+
+ return __ieee754_jn (n, x);
}
#ifdef NO_LONG_DOUBLE
strong_alias (jn, jnl)
#endif
-#ifdef __STDC__
- double yn(int n, double x) /* wrapper yn */
-#else
- double yn(n,x) /* wrapper yn */
- double x; int n;
-#endif
+/* wrapper yn */
+double
+yn (int n, double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_yn(n,x);
-#else
- double z;
- z = __ieee754_yn(n,x);
- if(_LIB_VERSION == _IEEE_ || __isnan(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
+ if (__builtin_expect (x <= 0.0 || x > X_TLOSS, 0) && _LIB_VERSION != _IEEE_)
+ {
+ if (x < 0.0)
+ {
+ /* d = zero/(x-x) */
+ feraiseexcept (FE_INVALID);
+ return __kernel_standard (n, x, 13);
+ }
+ else if (x == 0.0)
+ /* d = -one/(x-x) */
+ return __kernel_standard (n, x, 12);
+ else
+ /* yn(n,x>X_TLOSS) */
+ return __kernel_standard (n, x, 39);
+ }
+
+ return __ieee754_yn (n, x);
}
#ifdef NO_LONG_DOUBLE
strong_alias (yn, ynl)
diff --git a/libc/math/w_jnf.c b/libc/math/w_jnf.c
index 628701d7f..7b359558f 100644
--- a/libc/math/w_jnf.c
+++ b/libc/math/w_jnf.c
@@ -1,71 +1,60 @@
-/* w_jnf.c -- float version of w_jn.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_jnf.c,v 1.3 1995/05/10 20:49:21 jtc Exp $";
-#endif
+ The GNU C Library 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
+ Lesser General Public License for more details.
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
+
-#ifdef __STDC__
- float jnf(int n, float x) /* wrapper jnf */
-#else
- float jnf(n,x) /* wrapper jnf */
- float x; int n;
-#endif
+/* wrapper jnf */
+float
+jnf (int n, float x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_jnf(n,x);
-#else
- float z;
- z = __ieee754_jnf(n,x);
- if(_LIB_VERSION == _IEEE_ || __isnanf(x) ) return z;
- if(fabsf(x)>(float)X_TLOSS) {
- /* jn(|x|>X_TLOSS,n) */
- return (float)__kernel_standard((double)n,(double)x,138);
- } else
- return z;
-#endif
+ if (__builtin_expect (fabsf (x) > (float) X_TLOSS, 0)
+ && _LIB_VERSION != _IEEE_)
+ /* jn(n,|x|>X_TLOSS) */
+ return __kernel_standard_f (n, x, 138);
+
+ return __ieee754_jnf (n, x);
}
-#ifdef __STDC__
- float ynf(int n, float x) /* wrapper ynf */
-#else
- float ynf(n,x) /* wrapper ynf */
- float x; int n;
-#endif
+
+/* wrapper ynf */
+float
+ynf (int n, float x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_ynf(n,x);
-#else
- float z;
- z = __ieee754_ynf(n,x);
- if(_LIB_VERSION == _IEEE_ || __isnanf(x) ) return z;
- if(x <= (float)0.0){
- if(x==(float)0.0)
- /* d= -one/(x-x); */
- return (float)__kernel_standard((double)n,(double)x,112);
- else
- /* d = zero/(x-x); */
- return (float)__kernel_standard((double)n,(double)x,113);
- }
- if(x>(float)X_TLOSS) {
- /* yn(x>X_TLOSS,n) */
- return (float)__kernel_standard((double)n,(double)x,139);
- } else
- return z;
-#endif
+ if (__builtin_expect (x <= 0.0f || x > (float) X_TLOSS, 0)
+ && _LIB_VERSION != _IEEE_)
+ {
+ if (x < 0.0f)
+ {
+ /* d = zero/(x-x) */
+ feraiseexcept (FE_INVALID);
+ return __kernel_standard_f (n, x, 113);
+ }
+ else if (x == 0.0)
+ /* d = -one/(x-x) */
+ return __kernel_standard_f (n, x, 112);
+ else
+ /* yn(n,x>X_TLOSS) */
+ return __kernel_standard_f (n, x, 139);
+ }
+
+ return __ieee754_ynf (n, x);
}
diff --git a/libc/math/w_jnl.c b/libc/math/w_jnl.c
index 4bb4d6b62..1dd9ae151 100644
--- a/libc/math/w_jnl.c
+++ b/libc/math/w_jnl.c
@@ -45,7 +45,7 @@ static char rcsid[] = "$NetBSD: $";
*/
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
#ifdef __STDC__
long double __jnl(int n, long double x) /* wrapper jnl */
diff --git a/libc/math/w_lgamma.c b/libc/math/w_lgamma.c
index ab75f7599..17c546059 100644
--- a/libc/math/w_lgamma.c
+++ b/libc/math/w_lgamma.c
@@ -10,10 +10,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_lgamma.c,v 1.6 1995/05/10 20:49:24 jtc Exp $";
-#endif
-
/* double lgamma(double x)
* Return the logarithm of the Gamma function of x.
*
@@ -21,33 +17,26 @@ static char rcsid[] = "$NetBSD: w_lgamma.c,v 1.6 1995/05/10 20:49:24 jtc Exp $";
*/
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- double __lgamma(double x)
-#else
- double __lgamma(x)
- double x;
-#endif
+double
+__lgamma(double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_lgamma_r(x,&signgam);
-#else
- double y;
int local_signgam = 0;
- y = __ieee754_lgamma_r(x,&local_signgam);
- if (_LIB_VERSION != _ISOC_)
- /* ISO C99 does not define the global variable. */
- signgam = local_signgam;
- if(_LIB_VERSION == _IEEE_) return y;
- if(!__finite(y)&&__finite(x)) {
- if(__floor(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
+ double y = __ieee754_lgamma_r(x,
+ _LIB_VERSION != _ISOC_
+ /* ISO C99 does not define the
+ global variable. */
+ ? &signgam
+ : &local_signgam);
+ if(__builtin_expect(!__finite(y), 0)
+ && __finite(x) && _LIB_VERSION != _IEEE_)
+ return __kernel_standard(x, x,
+ __floor(x)==x&&x<=0.0
+ ? 15 /* lgamma pole */
+ : 14); /* lgamma overflow */
+
+ return y;
}
weak_alias (__lgamma, lgamma)
strong_alias (__lgamma, __gamma)
diff --git a/libc/math/w_lgamma_r.c b/libc/math/w_lgamma_r.c
index 17a7d013e..9d00f58ab 100644
--- a/libc/math/w_lgamma_r.c
+++ b/libc/math/w_lgamma_r.c
@@ -10,39 +10,26 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_lgamma_r.c,v 1.6 1995/05/10 20:49:27 jtc Exp $";
-#endif
-
/*
* wrapper double lgamma_r(double x, int *signgamp)
*/
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- double __lgamma_r(double x, int *signgamp) /* wrapper lgamma_r */
-#else
- double __lgamma_r(x,signgamp) /* wrapper lgamma_r */
- double x; int *signgamp;
-#endif
+double
+__lgamma_r(double x, int *signgamp)
{
-#ifdef _IEEE_LIBM
- return __ieee754_lgamma_r(x,signgamp);
-#else
- double y;
- y = __ieee754_lgamma_r(x,signgamp);
- if(_LIB_VERSION == _IEEE_) return y;
- if(!__finite(y)&&__finite(x)) {
- if(__floor(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
+ double y = __ieee754_lgamma_r(x,signgamp);
+ if(__builtin_expect(!__finite(y), 0)
+ && __finite(x) && _LIB_VERSION != _IEEE_)
+ return __kernel_standard(x, x,
+ __floor(x)==x&&x<=0.0
+ ? 15 /* lgamma pole */
+ : 14); /* lgamma overflow */
+
+ return y;
}
weak_alias (__lgamma_r, lgamma_r)
#ifdef NO_LONG_DOUBLE
diff --git a/libc/math/w_lgammaf.c b/libc/math/w_lgammaf.c
index 7c3c058d7..f3166dfd3 100644
--- a/libc/math/w_lgammaf.c
+++ b/libc/math/w_lgammaf.c
@@ -13,40 +13,27 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_lgammaf.c,v 1.3 1995/05/10 20:49:30 jtc Exp $";
-#endif
-
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- float __lgammaf(float x)
-#else
- float __lgammaf(x)
- float x;
-#endif
+float
+__lgammaf(float x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_lgammaf_r(x,&signgam);
-#else
- float y;
int local_signgam = 0;
- y = __ieee754_lgammaf_r(x,&local_signgam);
- if (_LIB_VERSION != _ISOC_)
- /* ISO C99 does not define the global variable. */
- signgam = local_signgam;
- if(_LIB_VERSION == _IEEE_) return y;
- if(!__finitef(y)&&__finitef(x)) {
- if(__floorf(x)==x&&x<=(float)0.0)
- /* lgamma pole */
- return (float)__kernel_standard((double)x,(double)x,115);
- else
- /* lgamma overflow */
- return (float)__kernel_standard((double)x,(double)x,114);
- } else
- return y;
-#endif
+ float y = __ieee754_lgammaf_r(x,
+ _LIB_VERSION != _ISOC_
+ /* ISO C99 does not define the
+ global variable. */
+ ? &signgam
+ : &local_signgam);
+ if(__builtin_expect(!__finitef(y), 0)
+ && __finitef(x) && _LIB_VERSION != _IEEE_)
+ return __kernel_standard_f(x, x,
+ __floorf(x)==x&&x<=0.0f
+ ? 115 /* lgamma pole */
+ : 114); /* lgamma overflow */
+
+ return y;
}
weak_alias (__lgammaf, lgammaf)
strong_alias (__lgammaf, __gammaf)
diff --git a/libc/math/w_lgammaf_r.c b/libc/math/w_lgammaf_r.c
index a32c32563..683fe72dc 100644
--- a/libc/math/w_lgammaf_r.c
+++ b/libc/math/w_lgammaf_r.c
@@ -8,45 +8,30 @@
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_lgammaf_r.c,v 1.3 1995/05/10 20:49:32 jtc Exp $";
-#endif
-
-/*
+/*
* wrapper float lgammaf_r(float x, int *signgamp)
*/
#include <math.h>
-#include "math_private.h"
+#include <math_private.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
+float
+__lgammaf_r(float x, int *signgamp)
{
-#ifdef _IEEE_LIBM
- return __ieee754_lgammaf_r(x,signgamp);
-#else
- float y;
- y = __ieee754_lgammaf_r(x,signgamp);
- if(_LIB_VERSION == _IEEE_) return y;
- if(!__finitef(y)&&__finitef(x)) {
- if(__floorf(x)==x&&x<=(float)0.0)
- /* lgamma pole */
- return (float)__kernel_standard((double)x,(double)x,115);
- else
- /* lgamma overflow */
- return (float)__kernel_standard((double)x,(double)x,114);
- } else
- return y;
-#endif
-}
+ float y = __ieee754_lgammaf_r(x,signgamp);
+ if(__builtin_expect(!__finitef(y), 0)
+ && __finitef(x) && _LIB_VERSION != _IEEE_)
+ return __kernel_standard_f(x, x,
+ __floorf(x)==x&&x<=0.0f
+ ? 115 /* lgamma pole */
+ : 114); /* lgamma overflow */
+
+ return y;
+}
weak_alias (__lgammaf_r, lgammaf_r)
diff --git a/libc/math/w_lgammal.c b/libc/math/w_lgammal.c
index f250e5038..7df38e761 100644
--- a/libc/math/w_lgammal.c
+++ b/libc/math/w_lgammal.c
@@ -14,10 +14,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: $";
-#endif
-
/* long double lgammal(long double x)
* Return the logarithm of the Gamma function of x.
*
@@ -25,33 +21,26 @@ static char rcsid[] = "$NetBSD: $";
*/
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- long double __lgammal(long double x)
-#else
- long double __lgammal(x)
- long double x;
-#endif
+long double
+__lgammal(long double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_lgammal_r(x,&signgam);
-#else
- long double y;
int local_signgam = 0;
- y = __ieee754_lgammal_r(x,&local_signgam);
- if (_LIB_VERSION != _ISOC_)
- /* ISO C99 does not define the global variable. */
- signgam = local_signgam;
- if(_LIB_VERSION == _IEEE_) return y;
- if(!__finitel(y)&&__finitel(x)) {
- if(__floorl(x)==x&&x<=0.0)
- return __kernel_standard(x,x,215); /* lgamma pole */
- else
- return __kernel_standard(x,x,214); /* lgamma overflow */
- } else
- return y;
-#endif
+ long double y = __ieee754_lgammal_r(x,
+ _LIB_VERSION != _ISOC_
+ /* ISO C99 does not define the
+ global variable. */
+ ? &signgam
+ : &local_signgam);
+ if(__builtin_expect(!__finitel(y), 0)
+ && __finitel(x) && _LIB_VERSION != _IEEE_)
+ return __kernel_standard(x, x,
+ __floorl(x)==x&&x<=0.0L
+ ? 215 /* lgamma pole */
+ : 214); /* lgamma overflow */
+
+ return y;
}
weak_alias (__lgammal, lgammal)
strong_alias (__lgammal, __gammal)
diff --git a/libc/math/w_lgammal_r.c b/libc/math/w_lgammal_r.c
index 2dfea8a46..ec3428486 100644
--- a/libc/math/w_lgammal_r.c
+++ b/libc/math/w_lgammal_r.c
@@ -14,39 +14,25 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: $";
-#endif
-
/*
* wrapper long double lgammal_r(long double x, int *signgamp)
*/
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- long double __lgammal_r(long double x, int *signgamp)
- /* wrapper lgamma_r */
-#else
- long double __lgammal_r(x,signgamp) /* wrapper lgamma_r */
- long double x; int *signgamp;
-#endif
+long double
+__lgammal_r(long double x, int *signgamp)
{
-#ifdef _IEEE_LIBM
- return __ieee754_lgammal_r(x,signgamp);
-#else
- long double y;
- y = __ieee754_lgammal_r(x,signgamp);
- if(_LIB_VERSION == _IEEE_) return y;
- if(!__finitel(y)&&__finitel(x)) {
- if(__floorl(x)==x&&x<=0.0)
- return __kernel_standard(x,x,215); /* lgamma pole */
- else
- return __kernel_standard(x,x,214); /* lgamma overflow */
- } else
- return y;
-#endif
+ long double y = __ieee754_lgammal_r(x,signgamp);
+ if(__builtin_expect(!__finitel(y), 0)
+ && __finitel(x) && _LIB_VERSION != _IEEE_)
+ return __kernel_standard(x, x,
+ __floorl(x)==x&&x<=0.0
+ ? 215 /* lgamma pole */
+ : 214); /* lgamma overflow */
+
+ return y;
}
weak_alias (__lgammal_r, lgammal_r)
diff --git a/libc/math/w_log.c b/libc/math/w_log.c
index 6f6f74fd1..b43af792c 100644
--- a/libc/math/w_log.c
+++ b/libc/math/w_log.c
@@ -1,45 +1,46 @@
-/* @(#)w_log.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_log.c,v 1.6 1995/05/10 20:49:33 jtc Exp $";
-#endif
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrapper log(x)
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- double __log(double x) /* wrapper log */
-#else
- double __log(x) /* wrapper log */
- double x;
-#endif
+/* wrapper log(x) */
+double
+__log (double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_log(x);
-#else
- double z;
- z = __ieee754_log(x);
- if(_LIB_VERSION == _IEEE_ || __isnan(x) || x > 0.0) return z;
- if(x==0.0)
- return __kernel_standard(x,x,16); /* log(0) */
- else
- return __kernel_standard(x,x,17); /* log(x<0) */
-#endif
+ if (__builtin_expect (x <= 0.0, 0) && _LIB_VERSION != _IEEE_)
+ {
+ if (x == 0.0)
+ {
+ feraiseexcept (FE_DIVBYZERO);
+ return __kernel_standard (x, x, 16); /* log(0) */
+ }
+ else
+ {
+ feraiseexcept (FE_INVALID);
+ return __kernel_standard (x, x, 17); /* log(x<0) */
+ }
+ }
+
+ return __ieee754_log (x);
}
weak_alias (__log, log)
#ifdef NO_LONG_DOUBLE
diff --git a/libc/math/w_log10.c b/libc/math/w_log10.c
index 9425db3dd..75ae580c9 100644
--- a/libc/math/w_log10.c
+++ b/libc/math/w_log10.c
@@ -1,48 +1,46 @@
-/* @(#)w_log10.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_log10.c,v 1.6 1995/05/10 20:49:35 jtc Exp $";
-#endif
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrapper log10(X)
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- double __log10(double x) /* wrapper log10 */
-#else
- double __log10(x) /* wrapper log10 */
- double x;
-#endif
+/* wrapper log10(x) */
+double
+__log10 (double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_log10(x);
-#else
- double z;
- z = __ieee754_log10(x);
- if(_LIB_VERSION == _IEEE_ || __isnan(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
+ if (__builtin_expect (x <= 0.0, 0) && _LIB_VERSION != _IEEE_)
+ {
+ if (x == 0.0)
+ {
+ feraiseexcept (FE_DIVBYZERO);
+ return __kernel_standard (x, x, 18); /* log10(0) */
+ }
+ else
+ {
+ feraiseexcept (FE_INVALID);
+ return __kernel_standard (x, x, 19); /* log10(x<0) */
+ }
+ }
+
+ return __ieee754_log10 (x);
}
weak_alias (__log10, log10)
#ifdef NO_LONG_DOUBLE
diff --git a/libc/math/w_log10f.c b/libc/math/w_log10f.c
index c63fcd1ec..3426e2d05 100644
--- a/libc/math/w_log10f.c
+++ b/libc/math/w_log10f.c
@@ -1,52 +1,45 @@
-/* w_log10f.c -- float version of w_log10.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_log10f.c,v 1.3 1995/05/10 20:49:37 jtc Exp $";
-#endif
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrapper log10f(X)
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- float __log10f(float x) /* wrapper log10f */
-#else
- float __log10f(x) /* wrapper log10f */
- float x;
-#endif
+/* wrapper log10f(x) */
+float
+__log10f (float x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_log10f(x);
-#else
- float z;
- z = __ieee754_log10f(x);
- if(_LIB_VERSION == _IEEE_ || __isnanf(x)) return z;
- if(x<=(float)0.0) {
- if(x==(float)0.0)
- /* log10(0) */
- return (float)__kernel_standard((double)x,(double)x,118);
- else
- /* log10(x<0) */
- return (float)__kernel_standard((double)x,(double)x,119);
- } else
- return z;
-#endif
+ if (__builtin_expect (x <= 0.0f, 0) && _LIB_VERSION != _IEEE_)
+ {
+ if (x == 0.0f)
+ {
+ feraiseexcept (FE_DIVBYZERO);
+ return __kernel_standard_f (x, x, 118); /* log10(0) */
+ }
+ else
+ {
+ feraiseexcept (FE_INVALID);
+ return __kernel_standard_f (x, x, 119); /* log10(x<0) */
+ }
+ }
+
+ return __ieee754_log10f (x);
}
weak_alias (__log10f, log10f)
diff --git a/libc/math/w_log10l.c b/libc/math/w_log10l.c
index 25c051d37..6f81f3961 100644
--- a/libc/math/w_log10l.c
+++ b/libc/math/w_log10l.c
@@ -1,51 +1,45 @@
-/* w_log10l.c -- long double version of w_log10.c.
- * Conversion to long double by Ulrich Drepper,
- * Cygnus Support, drepper@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: $";
-#endif
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrapper log10l(X)
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- long double __log10l(long double x) /* wrapper log10l */
-#else
- long double __log10l(x) /* wrapper log10l */
- long double x;
-#endif
+/* wrapper log10l(x) */
+long double
+__log10l (long double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_log10l(x);
-#else
- long double z;
- z = __ieee754_log10l(x);
- if(_LIB_VERSION == _IEEE_ || __isnanl(x)) return z;
- if(x<=0.0) {
- if(x==0.0)
- return __kernel_standard(x,x,218); /* log10(0) */
- else
- return __kernel_standard(x,x,219); /* log10(x<0) */
- } else
- return z;
-#endif
+ if (__builtin_expect (x <= 0.0L, 0) && _LIB_VERSION != _IEEE_)
+ {
+ if (x == 0.0L)
+ {
+ feraiseexcept (FE_DIVBYZERO);
+ return __kernel_standard (x, x, 218); /* log10(0) */
+ }
+ else
+ {
+ feraiseexcept (FE_INVALID);
+ return __kernel_standard (x, x, 219); /* log10(x<0) */
+ }
+ }
+
+ return __ieee754_log10l (x);
}
weak_alias (__log10l, log10l)
diff --git a/libc/math/w_log2.c b/libc/math/w_log2.c
index d56a6ee66..6d420438d 100644
--- a/libc/math/w_log2.c
+++ b/libc/math/w_log2.c
@@ -1,29 +1,46 @@
-/*
- * wrapper log2(X)
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
+
+/* wrapper log2(x) */
double
-__log2 (double x) /* wrapper log2 */
+__log2 (double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_log2 (x);
-#else
- double z;
- z = __ieee754_log2 (x);
- if (_LIB_VERSION == _IEEE_ || __isnan (x)) return z;
- if (x <= 0.0)
+ if (__builtin_expect (x <= 0.0, 0) && _LIB_VERSION != _IEEE_)
{
if (x == 0.0)
- return __kernel_standard (x, x, 48); /* log2 (0) */
+ {
+ feraiseexcept (FE_DIVBYZERO);
+ return __kernel_standard (x, x, 48); /* log2(0) */
+ }
else
- return __kernel_standard (x, x, 49); /* log2 (x < 0) */
+ {
+ feraiseexcept (FE_INVALID);
+ return __kernel_standard (x, x, 49); /* log2(x<0) */
+ }
}
- else
- return z;
-#endif
+
+ return __ieee754_log2 (x);
}
weak_alias (__log2, log2)
#ifdef NO_LONG_DOUBLE
diff --git a/libc/math/w_log2f.c b/libc/math/w_log2f.c
index ec8d29716..7c64ad8b8 100644
--- a/libc/math/w_log2f.c
+++ b/libc/math/w_log2f.c
@@ -1,30 +1,45 @@
-/*
- * wrapper log2(X)
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
+
+/* wrapper log2f(x) */
float
-__log2f (float x) /* wrapper log2f */
+__log2f (float x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_log2f (x);
-#else
- float z;
- z = __ieee754_log2f (x);
- if (_LIB_VERSION == _IEEE_ || __isnanf (x)) return z;
- if (x <= 0.0f)
+ if (__builtin_expect (x <= 0.0f, 0) && _LIB_VERSION != _IEEE_)
{
- if (x == 0.0f)
- /* log2f (0) */
- return __kernel_standard ((double) x, (double) x, 148);
+ if (x == 0.0)
+ {
+ feraiseexcept (FE_DIVBYZERO);
+ return __kernel_standard_f (x, x, 148); /* log2(0) */
+ }
else
- /* log2f (x < 0) */
- return __kernel_standard ((double) x, (double) x, 149);
+ {
+ feraiseexcept (FE_INVALID);
+ return __kernel_standard_f (x, x, 149); /* log2(x<0) */
+ }
}
- else
- return z;
-#endif
+
+ return __ieee754_log2f (x);
}
weak_alias (__log2f, log2f)
diff --git a/libc/math/w_log2l.c b/libc/math/w_log2l.c
index b1d8706f2..f589768b1 100644
--- a/libc/math/w_log2l.c
+++ b/libc/math/w_log2l.c
@@ -1,28 +1,45 @@
-/*
- * wrapper log2l(X)
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
+
+/* wrapper log2l(x) */
long double
-__log2l (long double x) /* wrapper log2l */
+__log2l (long double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_log2l (x);
-#else
- long double z;
- z = __ieee754_log2l (x);
- if (_LIB_VERSION == _IEEE_ || __isnanl (x)) return z;
- if (x <= 0.0)
+ if (__builtin_expect (x <= 0.0L, 0) && _LIB_VERSION != _IEEE_)
{
- if (x == 0.0)
- return __kernel_standard (x, x, 248); /* log2l (0) */
+ if (x == 0.0L)
+ {
+ feraiseexcept (FE_DIVBYZERO);
+ return __kernel_standard (x, x, 248); /* log2(0) */
+ }
else
- return __kernel_standard (x, x, 249); /* log2l (x < 0) */
+ {
+ feraiseexcept (FE_INVALID);
+ return __kernel_standard (x, x, 249); /* log2(x<0) */
+ }
}
- else
- return z;
-#endif
+
+ return __ieee754_log2l (x);
}
weak_alias (__log2l, log2l)
diff --git a/libc/math/w_logf.c b/libc/math/w_logf.c
index 46d974911..52b9befd1 100644
--- a/libc/math/w_logf.c
+++ b/libc/math/w_logf.c
@@ -1,49 +1,45 @@
-/* w_logf.c -- float version of w_log.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_logf.c,v 1.3 1995/05/10 20:49:40 jtc Exp $";
-#endif
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrapper logf(x)
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- float __logf(float x) /* wrapper logf */
-#else
- float __logf(x) /* wrapper logf */
- float x;
-#endif
+/* wrapper logf(x) */
+float
+__logf (float x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_logf(x);
-#else
- float z;
- z = __ieee754_logf(x);
- if(_LIB_VERSION == _IEEE_ || __isnanf(x) || x > (float)0.0) return z;
- if(x==(float)0.0)
- /* logf(0) */
- return (float)__kernel_standard((double)x,(double)x,116);
- else
- /* logf(x<0) */
- return (float)__kernel_standard((double)x,(double)x,117);
-#endif
+ if (__builtin_expect (x <= 0.0f, 0) && _LIB_VERSION != _IEEE_)
+ {
+ if (x == 0.0f)
+ {
+ feraiseexcept (FE_DIVBYZERO);
+ return __kernel_standard_f (x, x, 116); /* log(0) */
+ }
+ else
+ {
+ feraiseexcept (FE_INVALID);
+ return __kernel_standard_f (x, x, 117); /* log(x<0) */
+ }
+ }
+
+ return __ieee754_logf (x);
}
weak_alias (__logf, logf)
diff --git a/libc/math/w_logl.c b/libc/math/w_logl.c
index 5a38f2003..9f2bdf06c 100644
--- a/libc/math/w_logl.c
+++ b/libc/math/w_logl.c
@@ -1,48 +1,45 @@
-/* w_logl.c -- long double version of w_log.c.
- * Conversion to long double by Ulrich Drepper,
- * Cygnus Support, drepper@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: $";
-#endif
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrapper logl(x)
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+#include <fenv.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- long double __logl(long double x) /* wrapper logl */
-#else
- long double __logl(x) /* wrapper logl */
- long double x;
-#endif
+/* wrapper logl(x) */
+long double
+__logl (long double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_logl(x);
-#else
- long double z;
- z = __ieee754_logl(x);
- if(_LIB_VERSION == _IEEE_ || __isnanl(x) || x > 0.0) return z;
- if(x==0.0)
- return __kernel_standard(x,x,216); /* log(0) */
- else
- return __kernel_standard(x,x,217); /* log(x<0) */
-#endif
+ if (__builtin_expect (x <= 0.0L, 0) && _LIB_VERSION != _IEEE_)
+ {
+ if (x == 0.0L)
+ {
+ feraiseexcept (FE_DIVBYZERO);
+ return __kernel_standard (x, x, 216); /* log(0) */
+ }
+ else
+ {
+ feraiseexcept (FE_INVALID);
+ return __kernel_standard (x, x, 217); /* log(x<0) */
+ }
+ }
+
+ return __ieee754_logl (x);
}
weak_alias (__logl, logl)
diff --git a/libc/math/w_pow.c b/libc/math/w_pow.c
index 707cffcc4..4993c232a 100644
--- a/libc/math/w_pow.c
+++ b/libc/math/w_pow.c
@@ -1,67 +1,76 @@
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-/* @(#)w_pow.c 5.2 93/10/01 */
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrapper pow(x,y) return x**y
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- double __pow(double x, double y) /* wrapper pow */
-#else
- double __pow(x,y) /* wrapper pow */
- double x,y;
-#endif
+/* wrapper pow */
+double
+__pow (double x, double y)
{
-#ifdef _IEEE_LIBM
- return __ieee754_pow(x,y);
-#else
- double z;
- z=__ieee754_pow(x,y);
- if(_LIB_VERSION == _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(__finite(y)&&y<0.0) {
- if (signbit (x) && signbit (z))
- return __kernel_standard(x,y,23); /* pow(-0.0,negative) */
+ double z = __ieee754_pow (x, y);
+ if (__builtin_expect (!__finite (z), 0))
+ {
+ if (_LIB_VERSION != _IEEE_)
+ {
+ if (__isnan (x))
+ {
+ if (y == 0.0)
+ /* pow(NaN,0.0) */
+ return __kernel_standard (x, y, 42);
+ }
+ else if (__finite (x) && __finite (y))
+ {
+ if (__isnan (z))
+ /* pow neg**non-int */
+ return __kernel_standard (x, y, 24);
+ else if (x == 0.0 && y < 0.0)
+ {
+ if (signbit (x) && signbit (z))
+ /* pow(-0.0,negative) */
+ return __kernel_standard (x, y, 23);
+ else
+ /* pow(+0.0,negative) */
+ return __kernel_standard (x, y, 43);
+ }
else
- return __kernel_standard(x,y,43); /* pow(+0.0,negative) */
+ /* pow overflow */
+ return __kernel_standard (x, y, 21);
}
- return z;
}
- if(!__finite(z)) {
- if(__finite(x)&&__finite(y)) {
- if(__isnan(z))
- return __kernel_standard(x,y,24); /* pow neg**non-int */
- else
- return __kernel_standard(x,y,21); /* pow overflow */
- }
+ }
+ else if (__builtin_expect (z == 0.0, 0) && __finite (x) && __finite (y)
+ && _LIB_VERSION != _IEEE_)
+ {
+ if (x == 0.0)
+ {
+ if (y == 0.0)
+ /* pow(0.0,0.0) */
+ return __kernel_standard (x, y, 20);
}
- if(z==0.0&&__finite(x)&&__finite(y))
- return __kernel_standard(x,y,22); /* pow underflow */
- return z;
-#endif
+ else
+ /* pow underflow */
+ return __kernel_standard (x, y, 22);
+ }
+
+ return z;
}
weak_alias (__pow, pow)
#ifdef NO_LONG_DOUBLE
diff --git a/libc/math/w_powf.c b/libc/math/w_powf.c
index 2480fe559..c0406f4c1 100644
--- a/libc/math/w_powf.c
+++ b/libc/math/w_powf.c
@@ -1,77 +1,75 @@
-/* w_powf.c -- float version of w_pow.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_powf.c,v 1.3 1995/05/10 20:49:41 jtc Exp $";
-#endif
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrapper powf(x,y) return x**y
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- float __powf(float x, float y) /* wrapper powf */
-#else
- float __powf(x,y) /* wrapper powf */
- float x,y;
-#endif
+/* wrapper powf */
+float
+__powf (float x, float y)
{
-#ifdef _IEEE_LIBM
- return __ieee754_powf(x,y);
-#else
- float z;
- z=__ieee754_powf(x,y);
- if(_LIB_VERSION == _IEEE_|| __isnanf(y)) return z;
- if(__isnanf(x)) {
- if(y==(float)0.0)
- /* powf(NaN,0.0) */
- return (float)__kernel_standard((double)x,(double)y,142);
- else
- return z;
- }
- if(x==(float)0.0) {
- if(y==(float)0.0)
- /* powf(0.0,0.0) */
- return (float)__kernel_standard((double)x,(double)y,120);
- if(__finitef(y)&&y<(float)0.0) {
- if (signbit (x) && signbit (z))
- /* powf(0.0,negative) */
- return (float)__kernel_standard((double)x,(double)y,123);
+ float z = __ieee754_powf (x, y);
+ if (__builtin_expect (!__finitef (z), 0))
+ {
+ if (_LIB_VERSION != _IEEE_)
+ {
+ if (__isnanf (x))
+ {
+ if (y == 0.0f)
+ /* pow(NaN,0.0) */
+ return __kernel_standard_f (x, y, 142);
+ }
+ else if (__finitef (x) && __finitef (y))
+ {
+ if (__isnanf (z))
+ /* pow neg**non-int */
+ return __kernel_standard_f (x, y, 124);
+ else if (x == 0.0f && y < 0.0f)
+ {
+ if (signbit (x) && signbit (z))
+ /* pow(-0.0,negative) */
+ return __kernel_standard_f (x, y, 123);
+ else
+ /* pow(+0.0,negative) */
+ return __kernel_standard_f (x, y, 143);
+ }
else
- return (float)__kernel_standard((double)x,(double)y,143);
+ /* pow overflow */
+ return __kernel_standard_f (x, y, 121);
}
- return z;
}
- if(!__finitef(z)) {
- if(__finitef(x)&&__finitef(y)) {
- if(__isnanf(z))
- /* powf neg**non-int */
- return (float)__kernel_standard((double)x,(double)y,124);
- else
- /* powf overflow */
- return (float)__kernel_standard((double)x,(double)y,121);
- }
+ }
+ else if (__builtin_expect (z == 0.0f, 0) && __finitef (x) && __finitef (y)
+ && _LIB_VERSION != _IEEE_)
+ {
+ if (x == 0.0f)
+ {
+ if (y == 0.0f)
+ /* pow(0.0,0.0) */
+ return __kernel_standard_f (x, y, 120);
}
- if(z==(float)0.0&&__finitef(x)&&__finitef(y))
- /* powf underflow */
- return (float)__kernel_standard((double)x,(double)y,122);
- return z;
-#endif
+ else
+ /* pow underflow */
+ return __kernel_standard_f (x, y, 122);
+ }
+
+ return z;
}
weak_alias (__powf, powf)
diff --git a/libc/math/w_powl.c b/libc/math/w_powl.c
index d8be7b7b0..1ad581ad9 100644
--- a/libc/math/w_powl.c
+++ b/libc/math/w_powl.c
@@ -1,68 +1,75 @@
-/* w_powl.c -- long double version of w_pow.c.
- * Conversion to long double by Ulrich Drepper,
- * Cygnus Support, drepper@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-/*
- * wrapper powl(x,y) return x**y
- */
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- long double __powl(long double x, long double y)/* wrapper powl */
-#else
- long double __powl(x,y) /* wrapper powl */
- long double x,y;
-#endif
+/* wrapper powl */
+long double
+__powl (long double x, long double y)
{
-#ifdef _IEEE_LIBM
- return __ieee754_powl(x,y);
-#else
- long double z;
- z=__ieee754_powl(x,y);
- if(_LIB_VERSION == _IEEE_|| __isnanl(y)) return z;
- if(__isnanl(x)) {
- if(y==0.0)
- return __kernel_standard(x,y,242); /* pow(NaN,0.0) */
- else
- return z;
- }
- if(x==0.0) {
- if(y==0.0)
- return __kernel_standard(x,y,220); /* pow(0.0,0.0) */
- if(__finitel(y)&&y<0.0) {
- if (signbit (x) && signbit (z))
- return __kernel_standard(x,y,223); /* pow(-0.0,negative) */
+ long double z = __ieee754_powl (x, y);
+ if (__builtin_expect (!__finitel (z), 0))
+ {
+ if (_LIB_VERSION != _IEEE_)
+ {
+ if (__isnanl (x))
+ {
+ if (y == 0.0L)
+ /* pow(NaN,0.0) */
+ return __kernel_standard (x, y, 242);
+ }
+ else if (__finitel (x) && __finitel (y))
+ {
+ if (__isnanl (z))
+ /* pow neg**non-int */
+ return __kernel_standard (x, y, 224);
+ else if (x == 0.0L && y < 0.0L)
+ {
+ if (signbit (x) && signbit (z))
+ /* pow(-0.0,negative) */
+ return __kernel_standard (x, y, 223);
+ else
+ /* pow(+0.0,negative) */
+ return __kernel_standard (x, y, 243);
+ }
else
- return __kernel_standard(x,y,243); /* pow(+0.0,negative) */
+ /* pow overflow */
+ return __kernel_standard (x, y, 221);
}
- return z;
}
- if(!__finitel(z)) {
- if(__finitel(x)&&__finitel(y)) {
- if(__isnanl(z))
- return __kernel_standard(x,y,224); /* pow neg**non-int */
- else
- return __kernel_standard(x,y,221); /* pow overflow */
- }
+ }
+ else if (__builtin_expect (z == 0.0L, 0) && __finitel (x) && __finitel (y)
+ && _LIB_VERSION != _IEEE_)
+ {
+ if (x == 0.0L)
+ {
+ if (y == 0.0L)
+ /* pow(0.0,0.0) */
+ return __kernel_standard (x, y, 220);
}
- if(z==0.0&&__finitel(x)&&__finitel(y))
- return __kernel_standard(x,y,222); /* pow underflow */
- return z;
-#endif
+ else
+ /* pow underflow */
+ return __kernel_standard (x, y, 222);
+ }
+
+ return z;
}
weak_alias (__powl, powl)
diff --git a/libc/math/w_remainder.c b/libc/math/w_remainder.c
index 9d7a7c538..524cbf582 100644
--- a/libc/math/w_remainder.c
+++ b/libc/math/w_remainder.c
@@ -1,44 +1,36 @@
-/* @(#)w_remainder.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_remainder.c,v 1.6 1995/05/10 20:49:44 jtc Exp $";
-#endif
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrapper remainder(x,p)
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- double __remainder(double x, double y) /* wrapper remainder */
-#else
- double __remainder(x,y) /* wrapper remainder */
- double x,y;
-#endif
+
+/* wrapper remainder */
+double
+__remainder (double x, double y)
{
-#ifdef _IEEE_LIBM
- return __ieee754_remainder(x,y);
-#else
- double z;
- z = __ieee754_remainder(x,y);
- if(_LIB_VERSION == _IEEE_ || __isnan(y)) return z;
- if(y==0.0)
- return __kernel_standard(x,y,28); /* remainder(x,0) */
- else
- return z;
-#endif
+ if (((__builtin_expect (y == 0.0, 0) && ! __isnan (x))
+ || (__builtin_expect (__isinf_ns (x), 0) && ! __isnan (y)))
+ && _LIB_VERSION != _IEEE_)
+ return __kernel_standard (x, y, 28); /* remainder domain */
+
+ return __ieee754_remainder (x, y);
}
weak_alias (__remainder, remainder)
#ifdef NO_LONG_DOUBLE
diff --git a/libc/math/w_remainderf.c b/libc/math/w_remainderf.c
index 486e626c2..9bddf6f61 100644
--- a/libc/math/w_remainderf.c
+++ b/libc/math/w_remainderf.c
@@ -1,47 +1,35 @@
-/* w_remainderf.c -- float version of w_remainder.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_remainderf.c,v 1.3 1995/05/10 20:49:46 jtc Exp $";
-#endif
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrapper remainderf(x,p)
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- float __remainderf(float x, float y) /* wrapper remainder */
-#else
- float __remainderf(x,y) /* wrapper remainder */
- float x,y;
-#endif
+
+/* wrapper remainderf */
+float
+__remainderf (float x, float y)
{
-#ifdef _IEEE_LIBM
- return __ieee754_remainderf(x,y);
-#else
- float z;
- z = __ieee754_remainderf(x,y);
- if(_LIB_VERSION == _IEEE_ || __isnanf(y)) return z;
- if(y==(float)0.0)
- /* remainder(x,0) */
- return (float)__kernel_standard((double)x,(double)y,128);
- else
- return z;
-#endif
+ if (((__builtin_expect (y == 0.0f, 0) && ! __isnanf (x))
+ || (__builtin_expect (__isinf_nsf (x), 0) && ! __isnanf (y)))
+ && _LIB_VERSION != _IEEE_)
+ return __kernel_standard_f (x, y, 128); /* remainder domain */
+
+ return __ieee754_remainderf (x, y);
}
weak_alias (__remainderf, remainderf)
diff --git a/libc/math/w_remainderl.c b/libc/math/w_remainderl.c
index 7635fb936..66a141328 100644
--- a/libc/math/w_remainderl.c
+++ b/libc/math/w_remainderl.c
@@ -1,48 +1,35 @@
-/* w_remainderl.c -- long double version of w_remainder.c.
- * Conversion to long double by Ulrich Drepper,
- * Cygnus Support, drepper@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: $";
-#endif
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrapper remainderl(x,p)
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- long double __remainderl(long double x, long double y)
- /* wrapper remainderl */
-#else
- long double __remainderl(x,y) /* wrapper remainder */
- long double x,y;
-#endif
+
+/* wrapper remainderl */
+long double
+__remainderl (long double x, long double y)
{
-#ifdef _IEEE_LIBM
- return __ieee754_remainderl(x,y);
-#else
- long double z;
- z = __ieee754_remainderl(x,y);
- if(_LIB_VERSION == _IEEE_ || __isnanl(y)) return z;
- if(y==0.0)
- return __kernel_standard(x,y,228); /* remainder(x,0) */
- else
- return z;
-#endif
+ if (((__builtin_expect (y == 0.0L, 0) && ! __isnanl (x))
+ || (__builtin_expect (__isinf_nsl (x), 0) && ! __isnanl (y)))
+ && _LIB_VERSION != _IEEE_)
+ return __kernel_standard (x, y, 228); /* remainder domain */
+
+ return __ieee754_remainderl (x, y);
}
weak_alias (__remainderl, remainderl)
diff --git a/libc/math/w_scalb.c b/libc/math/w_scalb.c
index 0086c2adf..91f3658a6 100644
--- a/libc/math/w_scalb.c
+++ b/libc/math/w_scalb.c
@@ -1,62 +1,54 @@
-/* @(#)w_scalb.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_scalb.c,v 1.6 1995/05/10 20:49:48 jtc Exp $";
-#endif
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-/*
- * wrapper scalb(double x, double fn) is provide for
- * passing various standard test suite. One
- * should use scalbn() instead.
- */
+ The GNU C Library 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
+ Lesser General Public License for more details.
-#include <math.h>
-#include "math_private.h"
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
#include <errno.h>
+#include <math.h>
+#include <math_private.h>
-#ifdef __STDC__
-#ifdef _SCALB_INT
- double __scalb(double x, int fn) /* wrapper scalb */
-#else
- double __scalb(double x, double fn) /* wrapper scalb */
-#endif
-#else
- double __scalb(x,fn) /* wrapper scalb */
-#ifdef _SCALB_INT
- double x; int fn;
-#else
- double x,fn;
-#endif
-#endif
+
+static double
+__attribute__ ((noinline))
+sysv_scalb (double x, double fn)
{
-#ifdef _IEEE_LIBM
- return __ieee754_scalb(x,fn);
-#else
- double z;
- z = __ieee754_scalb(x,fn);
- if(_LIB_VERSION != _SVID_) return z;
- if(!(__finite(z)||__isnan(z))&&__finite(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 */
- }
-#ifndef _SCALB_INT
- if(!__finite(fn)) __set_errno (ERANGE);
-#endif
- return z;
-#endif
+ double z = __ieee754_scalb (x, fn);
+
+ if (__builtin_expect (__isinf (z), 0))
+ {
+ if (__finite (x))
+ return __kernel_standard (x, fn, 32); /* scalb overflow */
+ else
+ __set_errno (ERANGE);
+ }
+ else if (__builtin_expect (z == 0.0, 0) && z != x)
+ return __kernel_standard (x, fn, 33); /* scalb underflow */
+
+ return z;
+}
+
+
+/* Wrapper scalb */
+double
+__scalb (double x, double fn)
+{
+ return (__builtin_expect (_LIB_VERSION == _SVID_, 0)
+ ? sysv_scalb (x, fn)
+ : __ieee754_scalb (x, fn));
}
weak_alias (__scalb, scalb)
#ifdef NO_LONG_DOUBLE
diff --git a/libc/math/w_scalbf.c b/libc/math/w_scalbf.c
index 60cb5670e..b8ee3f1b4 100644
--- a/libc/math/w_scalbf.c
+++ b/libc/math/w_scalbf.c
@@ -1,66 +1,53 @@
-/* w_scalbf.c -- float version of w_scalb.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_scalbf.c,v 1.3 1995/05/10 20:49:50 jtc Exp $";
-#endif
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrapper scalbf(float x, float fn) is provide for
- * passing various standard test suite. One
- * should use scalbn() instead.
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+#include <errno.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
+
+
+static float
+__attribute__ ((noinline))
+sysv_scalbf (float x, float fn)
+{
+ float z = __ieee754_scalbf (x, fn);
+
+ if (__builtin_expect (__isinff (z), 0))
+ {
+ if (__finitef (x))
+ return __kernel_standard_f (x, fn, 132); /* scalb overflow */
+ else
+ __set_errno (ERANGE);
+ }
+ else if (__builtin_expect (z == 0.0f, 0) && z != x)
+ return __kernel_standard_f (x, fn, 133); /* scalb underflow */
+
+ return z;
+}
-#include <errno.h>
-#ifdef __STDC__
-#ifdef _SCALB_INT
- float __scalbf(float x, int fn) /* wrapper scalbf */
-#else
- float __scalbf(float x, float fn) /* wrapper scalbf */
-#endif
-#else
- float __scalbf(x,fn) /* wrapper scalbf */
-#ifdef _SCALB_INT
- float x; int fn;
-#else
- float x,fn;
-#endif
-#endif
+/* Wrapper scalbf */
+float
+__scalbf (float x, float fn)
{
-#ifdef _IEEE_LIBM
- return __ieee754_scalbf(x,fn);
-#else
- float z;
- z = __ieee754_scalbf(x,fn);
- if(_LIB_VERSION != _SVID_) return z;
- if(!(__finitef(z)||__isnanf(z))&&__finitef(x)) {
- /* scalbf overflow */
- return (float)__kernel_standard((double)x,(double)fn,132);
- }
- if(z==(float)0.0&&z!=x) {
- /* scalbf underflow */
- return (float)__kernel_standard((double)x,(double)fn,133);
- }
-#ifndef _SCALB_INT
- if(!__finitef(fn)) __set_errno (ERANGE);
-#endif
- return z;
-#endif
+ return (__builtin_expect (_LIB_VERSION == _SVID_, 0)
+ ? sysv_scalbf (x, fn)
+ : __ieee754_scalbf (x, fn));
}
weak_alias (__scalbf, scalbf)
diff --git a/libc/math/w_scalbl.c b/libc/math/w_scalbl.c
index c8a45d460..33fc725e5 100644
--- a/libc/math/w_scalbl.c
+++ b/libc/math/w_scalbl.c
@@ -1,65 +1,53 @@
-/* w_scalbl.c -- long double version of w_scalb.c.
- * Conversion to long double by Ulrich Drepper,
- * Cygnus Support, drepper@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: $";
-#endif
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrapper scalbl(long double x, long double fn) is provide for
- * passing various standard test suite. One
- * should use scalbnl() instead.
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+#include <errno.h>
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
+
+
+static long double
+__attribute__ ((noinline))
+sysv_scalbl (long double x, long double fn)
+{
+ long double z = __ieee754_scalbl (x, fn);
+
+ if (__builtin_expect (__isinfl (z), 0))
+ {
+ if (__finitel (x))
+ return __kernel_standard (x, fn, 232); /* scalb overflow */
+ else
+ __set_errno (ERANGE);
+ }
+ else if (__builtin_expect (z == 0.0L, 0) && z != x)
+ return __kernel_standard (x, fn, 233); /* scalb underflow */
+
+ return z;
+}
-#include <errno.h>
-#ifdef __STDC__
-#ifdef _SCALB_INT
- long double __scalbl(long double x, int fn) /* wrapper scalbl */
-#else
- long double __scalbl(long double x, long double fn)/* wrapper scalbl */
-#endif
-#else
- long double __scalbl(x,fn) /* wrapper scalbl */
-#ifdef _SCALB_INT
- long double x; int fn;
-#else
- long double x,fn;
-#endif
-#endif
+/* Wrapper scalbl */
+long double
+__scalbl (long double x, long double fn)
{
-#ifdef _IEEE_LIBM
- return __ieee754_scalbl(x,fn);
-#else
- long double z;
- z = __ieee754_scalbl(x,fn);
- if(_LIB_VERSION != _SVID_) return z;
- if(!(__finitel(z)||__isnanl(z))&&__finitel(x)) {
- return __kernel_standard(x,(double)fn,232); /* scalb overflow */
- }
- if(z==0.0&&z!=x) {
- return __kernel_standard(x,(double)fn,233); /* scalb underflow */
- }
-#ifndef _SCALB_INT
- if(!__finitel(fn)) __set_errno (ERANGE);
-#endif
- return z;
-#endif
+ return (__builtin_expect (_LIB_VERSION == _SVID_, 0)
+ ? sysv_scalbl (x, fn)
+ : __ieee754_scalbl (x, fn));
}
weak_alias (__scalbl, scalbl)
diff --git a/libc/math/w_sinh.c b/libc/math/w_sinh.c
index 5bde8a2dd..34ad2d862 100644
--- a/libc/math/w_sinh.c
+++ b/libc/math/w_sinh.c
@@ -10,35 +10,22 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_sinh.c,v 1.6 1995/05/10 20:49:51 jtc Exp $";
-#endif
-
/*
* wrapper sinh(x)
*/
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- double __sinh(double x) /* wrapper sinh */
-#else
- double __sinh(x) /* wrapper sinh */
- double x;
-#endif
+double
+__sinh (double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_sinh(x);
-#else
- double z;
- z = __ieee754_sinh(x);
- if(_LIB_VERSION == _IEEE_) return z;
- if(!__finite(z)&&__finite(x)) {
- return __kernel_standard(x,x,25); /* sinh overflow */
- } else
- return z;
-#endif
+ double z = __ieee754_sinh (x);
+ if (__builtin_expect (!__finite (z), 0) && __finite (x)
+ && _LIB_VERSION != _IEEE_)
+ return __kernel_standard (x, x, 25); /* sinh overflow */
+
+ return z;
}
weak_alias (__sinh, sinh)
#ifdef NO_LONG_DOUBLE
diff --git a/libc/math/w_sinhf.c b/libc/math/w_sinhf.c
index c29c46620..1347e9172 100644
--- a/libc/math/w_sinhf.c
+++ b/libc/math/w_sinhf.c
@@ -8,40 +8,26 @@
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_sinhf.c,v 1.3 1995/05/10 20:49:54 jtc Exp $";
-#endif
-
-/*
+/*
* wrapper sinhf(x)
*/
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- float __sinhf(float x) /* wrapper sinhf */
-#else
- float __sinhf(x) /* wrapper sinhf */
- float x;
-#endif
+float
+__sinhf (float x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_sinhf(x);
-#else
- float z;
- z = __ieee754_sinhf(x);
- if(_LIB_VERSION == _IEEE_) return z;
- if(!__finitef(z)&&__finitef(x)) {
- /* sinhf overflow */
- return (float)__kernel_standard((double)x,(double)x,125);
- } else
- return z;
-#endif
+ float z = __ieee754_sinhf (x);
+ if (__builtin_expect (!__finitef (z), 0) && __finitef (x)
+ && _LIB_VERSION != _IEEE_)
+ return __kernel_standard_f (x, x, 125); /* sinhf overflow */
+
+ return z;
}
weak_alias (__sinhf, sinhf)
diff --git a/libc/math/w_sinhl.c b/libc/math/w_sinhl.c
index 19eb774d6..5e65cf9b9 100644
--- a/libc/math/w_sinhl.c
+++ b/libc/math/w_sinhl.c
@@ -14,34 +14,21 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: $";
-#endif
-
/*
* wrapper sinhl(x)
*/
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- long double __sinhl(long double x) /* wrapper sinhl */
-#else
- long double __sinhl(x) /* wrapper sinhl */
- long double x;
-#endif
+long double
+__sinhl (long double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_sinhl(x);
-#else
- long double z;
- z = __ieee754_sinhl(x);
- if(_LIB_VERSION == _IEEE_) return z;
- if(!__finitel(z)&&__finitel(x)) {
- return __kernel_standard(x,x,225); /* sinh overflow */
- } else
- return z;
-#endif
+ long double z = __ieee754_sinhl (x);
+ if (__builtin_expect (!__finitel (z), 0) && __finitel (x)
+ && _LIB_VERSION != _IEEE_)
+ return __kernel_standard (x, x, 225); /* sinh overflow */
+
+ return z;
}
weak_alias (__sinhl, sinhl)
diff --git a/libc/math/w_sqrt.c b/libc/math/w_sqrt.c
index 41ab1d18b..8a435ef48 100644
--- a/libc/math/w_sqrt.c
+++ b/libc/math/w_sqrt.c
@@ -1,44 +1,34 @@
-/* @(#)w_sqrt.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_sqrt.c,v 1.6 1995/05/10 20:49:55 jtc Exp $";
-#endif
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrapper sqrt(x)
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- double __sqrt(double x) /* wrapper sqrt */
-#else
- double __sqrt(x) /* wrapper sqrt */
- double x;
-#endif
+
+/* wrapper sqrt */
+double
+__sqrt (double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_sqrt(x);
-#else
- double z;
- z = __ieee754_sqrt(x);
- if(_LIB_VERSION == _IEEE_ || __isnan(x)) return z;
- if(x<0.0) {
- return __kernel_standard(x,x,26); /* sqrt(negative) */
- } else
- return z;
-#endif
+ if (__builtin_expect (x < 0.0, 0) && _LIB_VERSION != _IEEE_)
+ return __kernel_standard (x, x, 26); /* sqrt(negative) */
+
+ return __ieee754_sqrt (x);
}
weak_alias (__sqrt, sqrt)
#ifdef NO_LONG_DOUBLE
diff --git a/libc/math/w_sqrtf.c b/libc/math/w_sqrtf.c
index 21beb550f..fc088b622 100644
--- a/libc/math/w_sqrtf.c
+++ b/libc/math/w_sqrtf.c
@@ -1,47 +1,33 @@
-/* w_sqrtf.c -- float version of w_sqrt.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_sqrtf.c,v 1.3 1995/05/10 20:49:59 jtc Exp $";
-#endif
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrapper sqrtf(x)
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- float __sqrtf(float x) /* wrapper sqrtf */
-#else
- float sqrt(x) /* wrapper sqrtf */
- float x;
-#endif
+
+/* wrapper sqrtf */
+float
+__sqrtf (float x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_sqrtf(x);
-#else
- float z;
- z = __ieee754_sqrtf(x);
- if(_LIB_VERSION == _IEEE_ || __isnanf(x)) return z;
- if(x<(float)0.0) {
- /* sqrtf(negative) */
- return (float)__kernel_standard((double)x,(double)x,126);
- } else
- return z;
-#endif
+ if (__builtin_expect (x < 0.0f, 0) && _LIB_VERSION != _IEEE_)
+ return __kernel_standard_f (x, x, 126); /* sqrt(negative) */
+
+ return __ieee754_sqrtf (x);
}
weak_alias (__sqrtf, sqrtf)
diff --git a/libc/math/w_sqrtl.c b/libc/math/w_sqrtl.c
index 0b03eebe1..0c446295c 100644
--- a/libc/math/w_sqrtl.c
+++ b/libc/math/w_sqrtl.c
@@ -1,47 +1,33 @@
-/* w_sqrtl.c -- long double version of w_sqrt.c.
- * Conversion to long double by Ulrich Drepper,
- * Cygnus Support, drepper@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: $";
-#endif
+ The GNU C Library 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
+ Lesser General Public License for more details.
-/*
- * wrapper sqrtl(x)
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- long double __sqrtl(long double x) /* wrapper sqrtl */
-#else
- long double __sqrtl(x) /* wrapper sqrtl */
- long double x;
-#endif
+
+/* wrapper sqrtl */
+long double
+__sqrtl (long double x)
{
-#ifdef _IEEE_LIBM
- return __ieee754_sqrtl(x);
-#else
- long double z;
- z = __ieee754_sqrtl(x);
- if(_LIB_VERSION == _IEEE_ || __isnanl(x)) return z;
- if(x<0.0) {
- return __kernel_standard(x,x,226); /* sqrt(negative) */
- } else
- return z;
-#endif
+ if (__builtin_expect (x < 0.0L, 0) && _LIB_VERSION != _IEEE_)
+ return __kernel_standard (x, x, 226); /* sqrt(negative) */
+
+ return __ieee754_sqrtl (x);
}
weak_alias (__sqrtl, sqrtl)
diff --git a/libc/math/w_tgamma.c b/libc/math/w_tgamma.c
index 3ce6e77b4..976b5fb95 100644
--- a/libc/math/w_tgamma.c
+++ b/libc/math/w_tgamma.c
@@ -10,35 +10,22 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_gamma.c,v 1.7 1995/11/20 22:06:43 jtc Exp $";
-#endif
-
/* double gamma(double x)
* Return the logarithm of the Gamma function of x or the Gamma function of x,
* depending on the library mode.
*/
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- double __tgamma(double x)
-#else
- double __tgamma(x)
- double x;
-#endif
+double
+__tgamma(double x)
{
- double y;
int local_signgam;
- y = __ieee754_gamma_r(x,&local_signgam);
- if (local_signgam < 0) y = -y;
-#ifdef _IEEE_LIBM
- return y;
-#else
- if(_LIB_VERSION == _IEEE_) return y;
+ double y = __ieee754_gamma_r(x,&local_signgam);
- if(!__finite(y)&&__finite(x)) {
+ if(__builtin_expect(!__finite(y), 0)&&__finite(x)
+ && _LIB_VERSION != _IEEE_) {
if (x == 0.0)
return __kernel_standard(x,x,50); /* tgamma pole */
else if(__floor(x)==x&&x<0.0)
@@ -46,8 +33,7 @@ static char rcsid[] = "$NetBSD: w_gamma.c,v 1.7 1995/11/20 22:06:43 jtc Exp $";
else
return __kernel_standard(x,x,40); /* tgamma overflow */
}
- return y;
-#endif
+ return local_signgam < 0 ? -y : y;
}
weak_alias (__tgamma, tgamma)
#ifdef NO_LONG_DOUBLE
diff --git a/libc/math/w_tgammaf.c b/libc/math/w_tgammaf.c
index d3698059e..48141354e 100644
--- a/libc/math/w_tgammaf.c
+++ b/libc/math/w_tgammaf.c
@@ -13,41 +13,27 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_gammaf.c,v 1.4 1995/11/20 22:06:48 jtc Exp $";
-#endif
-
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- float __tgammaf(float x)
-#else
- float __tgammaf(x)
- float x;
-#endif
+float
+__tgammaf(float x)
{
- float y;
int local_signgam;
- y = __ieee754_gammaf_r(x,&local_signgam);
- if (local_signgam < 0) y = -y;
-#ifdef _IEEE_LIBM
- return y;
-#else
- if(_LIB_VERSION == _IEEE_) return y;
+ float y = __ieee754_gammaf_r(x,&local_signgam);
- if(!__finitef(y)&&__finitef(x)) {
+ if(__builtin_expect(!__finitef(y), 0) && __finitef(x)
+ && _LIB_VERSION != _IEEE_) {
if (x == (float)0.0)
/* tgammaf pole */
- return (float)__kernel_standard((double)x,(double)x,150);
- else if(__floorf(x)==x&&x<(float)0.0)
+ return __kernel_standard_f(x, x, 150);
+ else if(__floorf(x)==x&&x<0.0f)
/* tgammaf domain */
- return (float)__kernel_standard((double)x,(double)x,141);
+ return __kernel_standard_f(x, x, 141);
else
/* tgammaf overflow */
- return (float)__kernel_standard((double)x,(double)x,140);
+ return __kernel_standard_f(x, x, 140);
}
- return y;
-#endif
+ return local_signgam < 0 ? - y : y;
}
weak_alias (__tgammaf, tgammaf)
diff --git a/libc/math/w_tgammal.c b/libc/math/w_tgammal.c
index 75970a34d..6910f923a 100644
--- a/libc/math/w_tgammal.c
+++ b/libc/math/w_tgammal.c
@@ -14,42 +14,28 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: $";
-#endif
-
/* long double gammal(double x)
* Return the Gamma function of x.
*/
#include <math.h>
-#include "math_private.h"
+#include <math_private.h>
-#ifdef __STDC__
- long double __tgammal(long double x)
-#else
- long double __tgammal(x)
- long double x;
-#endif
+long double
+__tgammal(long double x)
{
- long double y;
int local_signgam;
- y = __ieee754_gammal_r(x,&local_signgam);
- if (local_signgam < 0) y = -y;
-#ifdef _IEEE_LIBM
- return y;
-#else
- if(_LIB_VERSION == _IEEE_) return y;
+ long double y = __ieee754_gammal_r(x,&local_signgam);
- if(!__finitel(y)&&__finitel(x)) {
+ if(__builtin_expect(!__finitel(y), 0) && __finitel(x)
+ && _LIB_VERSION != _IEEE_) {
if(x==0.0)
return __kernel_standard(x,x,250); /* tgamma pole */
- else if(__floorl(x)==x&&x<0.0)
+ else if(__floorl(x)==x&&x<0.0L)
return __kernel_standard(x,x,241); /* tgamma domain */
else
return __kernel_standard(x,x,240); /* tgamma overflow */
}
- return y;
-#endif
+ return local_signgam < 0 ? - y : y;
}
weak_alias (__tgammal, tgammal)