diff options
author | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2012-02-08 16:44:31 +0000 |
---|---|---|
committer | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2012-02-08 16:44:31 +0000 |
commit | 78be84cd747c2e3965bf6c2fd5f702d6ff2f5525 (patch) | |
tree | c070a60ef7c5371bef8b7a559442a6920b394c8e /libc/sysdeps/ieee754/dbl-64 | |
parent | de06548e980675e65a1e6d850bb8c3a3f7ec638d (diff) |
Merge changes between r16568 and r17050 from /fsf/trunk.
git-svn-id: svn://svn.eglibc.org/trunk@17051 7b3dc134-2b1b-0410-93df-9e9f96275f8d
Diffstat (limited to 'libc/sysdeps/ieee754/dbl-64')
22 files changed, 251 insertions, 215 deletions
diff --git a/libc/sysdeps/ieee754/dbl-64/k_rem_pio2.c b/libc/sysdeps/ieee754/dbl-64/k_rem_pio2.c index 911ff1fe3..53be066e0 100644 --- a/libc/sysdeps/ieee754/dbl-64/k_rem_pio2.c +++ b/libc/sysdeps/ieee754/dbl-64/k_rem_pio2.c @@ -133,17 +133,9 @@ static char rcsid[] = "$NetBSD: k_rem_pio2.c,v 1.7 1995/05/10 20:46:25 jtc Exp $ #include "math.h" #include "math_private.h" -#ifdef __STDC__ static const int init_jk[] = {2,3,4,6}; /* initial value for jk */ -#else -static int init_jk[] = {2,3,4,6}; -#endif -#ifdef __STDC__ static const double PIo2[] = { -#else -static double PIo2[] = { -#endif 1.57079625129699707031e+00, /* 0x3FF921FB, 0x40000000 */ 7.54978941586159635335e-08, /* 0x3E74442D, 0x00000000 */ 5.39030252995776476554e-15, /* 0x3CF84698, 0x80000000 */ @@ -154,22 +146,13 @@ static double PIo2[] = { 2.16741683877804819444e-51, /* 0x3569F31D, 0x00000000 */ }; -#ifdef __STDC__ static const double -#else -static double -#endif zero = 0.0, one = 1.0, two24 = 1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */ twon24 = 5.96046447753906250000e-08; /* 0x3E700000, 0x00000000 */ -#ifdef __STDC__ - int __kernel_rem_pio2(double *x, double *y, int e0, int nx, int prec, const int32_t *ipio2) -#else - int __kernel_rem_pio2(x,y,e0,nx,prec,ipio2) - double x[], y[]; int e0,nx,prec; int32_t ipio2[]; -#endif +int __kernel_rem_pio2(double *x, double *y, int e0, int nx, int prec, const int32_t *ipio2) { int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih; double z,fw,f[20],fq[20],q[20]; diff --git a/libc/sysdeps/ieee754/dbl-64/k_tan.c b/libc/sysdeps/ieee754/dbl-64/k_tan.c index 55dafb8eb..7ef4103bc 100644 --- a/libc/sysdeps/ieee754/dbl-64/k_tan.c +++ b/libc/sysdeps/ieee754/dbl-64/k_tan.c @@ -53,11 +53,7 @@ static char rcsid[] = "$NetBSD: k_tan.c,v 1.8 1995/05/10 20:46:37 jtc Exp $"; #include "math.h" #include "math_private.h" -#ifdef __STDC__ static const double -#else -static double -#endif one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ pio4 = 7.85398163397448278999e-01, /* 0x3FE921FB, 0x54442D18 */ pio4lo= 3.06161699786838301793e-17, /* 0x3C81A626, 0x33145C07 */ @@ -77,12 +73,7 @@ T[] = { 2.59073051863633712884e-05, /* 0x3EFB2A70, 0x74BF7AD4 */ }; -#ifdef __STDC__ - double __kernel_tan(double x, double y, int iy) -#else - double __kernel_tan(x, y, iy) - double x,y; int iy; -#endif +double __kernel_tan(double x, double y, int iy) { double z,r,v,w,s,r1,r2,r3,v1,v2,v3,w2,w4; int32_t ix,hx; diff --git a/libc/sysdeps/ieee754/dbl-64/s_copysign.c b/libc/sysdeps/ieee754/dbl-64/s_copysign.c index 5e35e6943..63f3bd3cc 100644 --- a/libc/sysdeps/ieee754/dbl-64/s_copysign.c +++ b/libc/sysdeps/ieee754/dbl-64/s_copysign.c @@ -23,12 +23,7 @@ static char rcsid[] = "$NetBSD: s_copysign.c,v 1.8 1995/05/10 20:46:57 jtc Exp $ #include "math.h" #include "math_private.h" -#ifdef __STDC__ - double __copysign(double x, double y) -#else - double __copysign(x,y) - double x,y; -#endif +double __copysign(double x, double y) { u_int32_t hx,hy; GET_HIGH_WORD(hx,x); diff --git a/libc/sysdeps/ieee754/dbl-64/s_erf.c b/libc/sysdeps/ieee754/dbl-64/s_erf.c index 94fb5c964..97d7e34ff 100644 --- a/libc/sysdeps/ieee754/dbl-64/s_erf.c +++ b/libc/sysdeps/ieee754/dbl-64/s_erf.c @@ -115,11 +115,7 @@ static char rcsid[] = "$NetBSD: s_erf.c,v 1.8 1995/05/10 20:47:05 jtc Exp $"; #include "math.h" #include "math_private.h" -#ifdef __STDC__ static const double -#else -static double -#endif tiny = 1e-300, half= 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */ one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ @@ -194,12 +190,7 @@ sb[] = {0.0,3.03380607434824582924e+01, /* 0x403E568B, 0x261D5190 */ 4.74528541206955367215e+02, /* 0x407DA874, 0xE79FE763 */ -2.24409524465858183362e+01}; /* 0xC03670E2, 0x42712D62 */ -#ifdef __STDC__ - double __erf(double x) -#else - double __erf(x) - double x; -#endif +double __erf(double x) { int32_t hx,ix,i; double R,S,P,Q,s,y,z,r; @@ -307,12 +298,7 @@ strong_alias (__erf, __erfl) weak_alias (__erf, erfl) #endif -#ifdef __STDC__ - double __erfc(double x) -#else - double __erfc(x) - double x; -#endif +double __erfc(double x) { int32_t hx,ix; double R,S,P,Q,s,y,z,r; diff --git a/libc/sysdeps/ieee754/dbl-64/s_fabs.c b/libc/sysdeps/ieee754/dbl-64/s_fabs.c index 1abe9432a..6dca1dec0 100644 --- a/libc/sysdeps/ieee754/dbl-64/s_fabs.c +++ b/libc/sysdeps/ieee754/dbl-64/s_fabs.c @@ -21,12 +21,7 @@ static char rcsid[] = "$NetBSD: s_fabs.c,v 1.7 1995/05/10 20:47:13 jtc Exp $"; #include "math.h" #include "math_private.h" -#ifdef __STDC__ - double __fabs(double x) -#else - double __fabs(x) - double x; -#endif +double __fabs(double x) { u_int32_t high; GET_HIGH_WORD(high,x); diff --git a/libc/sysdeps/ieee754/dbl-64/s_finite.c b/libc/sysdeps/ieee754/dbl-64/s_finite.c index 2ca3bf245..cf3d8d891 100644 --- a/libc/sysdeps/ieee754/dbl-64/s_finite.c +++ b/libc/sysdeps/ieee754/dbl-64/s_finite.c @@ -23,12 +23,7 @@ static char rcsid[] = "$NetBSD: s_finite.c,v 1.8 1995/05/10 20:47:17 jtc Exp $"; #include "math_private.h" #undef __finite -#ifdef __STDC__ - int __finite(double x) -#else - int __finite(x) - double x; -#endif +int __finite(double x) { int32_t hx; GET_HIGH_WORD(hx,x); diff --git a/libc/sysdeps/ieee754/dbl-64/s_floor.c b/libc/sysdeps/ieee754/dbl-64/s_floor.c index 8b2038e69..139e2f5cb 100644 --- a/libc/sysdeps/ieee754/dbl-64/s_floor.c +++ b/libc/sysdeps/ieee754/dbl-64/s_floor.c @@ -22,18 +22,9 @@ #include "math.h" #include "math_private.h" -#ifdef __STDC__ static const double huge = 1.0e300; -#else -static double huge = 1.0e300; -#endif -#ifdef __STDC__ - double __floor(double x) -#else - double __floor(x) - double x; -#endif +double __floor(double x) { int32_t i0,i1,j0; u_int32_t i,j; diff --git a/libc/sysdeps/ieee754/dbl-64/s_frexp.c b/libc/sysdeps/ieee754/dbl-64/s_frexp.c index 7dbddfde0..e92727417 100644 --- a/libc/sysdeps/ieee754/dbl-64/s_frexp.c +++ b/libc/sysdeps/ieee754/dbl-64/s_frexp.c @@ -27,19 +27,10 @@ static char rcsid[] = "$NetBSD: s_frexp.c,v 1.9 1995/05/10 20:47:24 jtc Exp $"; #include "math.h" #include "math_private.h" -#ifdef __STDC__ static const double -#else -static double -#endif two54 = 1.80143985094819840000e+16; /* 0x43500000, 0x00000000 */ -#ifdef __STDC__ - double __frexp(double x, int *eptr) -#else - double __frexp(x, eptr) - double x; int *eptr; -#endif +double __frexp(double x, int *eptr) { int32_t hx, ix, lx; EXTRACT_WORDS(hx,lx,x); diff --git a/libc/sysdeps/ieee754/dbl-64/s_ilogb.c b/libc/sysdeps/ieee754/dbl-64/s_ilogb.c index 89a833781..a2395a10a 100644 --- a/libc/sysdeps/ieee754/dbl-64/s_ilogb.c +++ b/libc/sysdeps/ieee754/dbl-64/s_ilogb.c @@ -25,12 +25,7 @@ static char rcsid[] = "$NetBSD: s_ilogb.c,v 1.9 1995/05/10 20:47:28 jtc Exp $"; #include "math.h" #include "math_private.h" -#ifdef __STDC__ - int __ilogb(double x) -#else - int __ilogb(x) - double x; -#endif +int __ilogb(double x) { int32_t hx,lx,ix; diff --git a/libc/sysdeps/ieee754/dbl-64/s_isnan.c b/libc/sysdeps/ieee754/dbl-64/s_isnan.c index 74e829160..c87eb69b1 100644 --- a/libc/sysdeps/ieee754/dbl-64/s_isnan.c +++ b/libc/sysdeps/ieee754/dbl-64/s_isnan.c @@ -23,12 +23,7 @@ static char rcsid[] = "$NetBSD: s_isnan.c,v 1.8 1995/05/10 20:47:36 jtc Exp $"; #include "math_private.h" #undef __isnan -#ifdef __STDC__ - int __isnan(double x) -#else - int __isnan(x) - double x; -#endif +int __isnan(double x) { int32_t hx,lx; EXTRACT_WORDS(hx,lx,x); diff --git a/libc/sysdeps/ieee754/dbl-64/s_log1p.c b/libc/sysdeps/ieee754/dbl-64/s_log1p.c index dc79a02bb..f82048f20 100644 --- a/libc/sysdeps/ieee754/dbl-64/s_log1p.c +++ b/libc/sysdeps/ieee754/dbl-64/s_log1p.c @@ -106,11 +106,11 @@ __log1p(double x) k = 1; if (hx < 0x3FDA827A) { /* x < 0.41422 */ - if(ax>=0x3ff00000) { /* x <= -1.0 */ + if(__builtin_expect(ax>=0x3ff00000, 0)) { /* x <= -1.0 */ if(x==-1.0) return -two54/(x-x);/* log1p(-1)=+inf */ else return (x-x)/(x-x); /* log1p(x<-1)=NaN */ } - if(ax<0x3e200000) { /* |x| < 2**-29 */ + if(__builtin_expect(ax<0x3e200000, 0)) { /* |x| < 2**-29 */ math_force_eval(two54+x); /* raise inexact */ if (ax<0x3c900000) /* |x| < 2**-54 */ return x; @@ -120,7 +120,7 @@ __log1p(double x) if(hx>0||hx<=((int32_t)0xbfd2bec3)) { k=0;f=x;hu=1;} /* -0.2929<x<0.41422 */ } - if (hx >= 0x7ff00000) return x+x; + else if (__builtin_expect(hx >= 0x7ff00000, 0)) return x+x; if(k!=0) { if(hx<0x43400000) { u = 1.0+x; diff --git a/libc/sysdeps/ieee754/dbl-64/s_logb.c b/libc/sysdeps/ieee754/dbl-64/s_logb.c index 4668cf78f..46743c0cb 100644 --- a/libc/sysdeps/ieee754/dbl-64/s_logb.c +++ b/libc/sysdeps/ieee754/dbl-64/s_logb.c @@ -23,12 +23,7 @@ static char rcsid[] = "$NetBSD: s_logb.c,v 1.8 1995/05/10 20:47:50 jtc Exp $"; #include "math.h" #include "math_private.h" -#ifdef __STDC__ - double __logb(double x) -#else - double __logb(x) - double x; -#endif +double __logb(double x) { int32_t lx,ix; EXTRACT_WORDS(ix,lx,x); diff --git a/libc/sysdeps/ieee754/dbl-64/s_modf.c b/libc/sysdeps/ieee754/dbl-64/s_modf.c index 7851f675a..a884de5d5 100644 --- a/libc/sysdeps/ieee754/dbl-64/s_modf.c +++ b/libc/sysdeps/ieee754/dbl-64/s_modf.c @@ -1,4 +1,3 @@ -/* @(#)s_modf.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: s_modf.c,v 1.8 1995/05/10 20:47:55 jtc Exp $"; -#endif - /* * modf(double x, double *iptr) * return fraction part of x, and return x's integral part in *iptr. @@ -27,18 +22,10 @@ static char rcsid[] = "$NetBSD: s_modf.c,v 1.8 1995/05/10 20:47:55 jtc Exp $"; #include "math.h" #include "math_private.h" -#ifdef __STDC__ static const double one = 1.0; -#else -static double one = 1.0; -#endif -#ifdef __STDC__ - double __modf(double x, double *iptr) -#else - double __modf(x, iptr) - double x,*iptr; -#endif +double +__modf(double x, double *iptr) { int32_t i0,i1,j0; u_int32_t i; @@ -46,7 +33,7 @@ static double one = 1.0; j0 = ((i0>>20)&0x7ff)-0x3ff; /* exponent of x */ if(j0<20) { /* integer part in high x */ if(j0<0) { /* |x|<1 */ - INSERT_WORDS(*iptr,i0&0x80000000,0); /* *iptr = +-0 */ + INSERT_WORDS(*iptr,i0&0x80000000,0); /* *iptr = +-0 */ return x; } else { i = (0x000fffff)>>j0; @@ -59,7 +46,7 @@ static double one = 1.0; return x - *iptr; } } - } else if (j0>51) { /* no fraction part */ + } else if (__builtin_expect(j0>51, 0)) { /* no fraction part */ *iptr = x*one; /* We must handle NaNs separately. */ if (j0 == 0x400 && ((i0 & 0xfffff) | i1)) @@ -73,7 +60,7 @@ static double one = 1.0; INSERT_WORDS(x,i0&0x80000000,0); /* return +-0 */ return x; } else { - INSERT_WORDS(*iptr,i0,i1&(~i)); + INSERT_WORDS(*iptr,i0,i1&(~i)); return x - *iptr; } } diff --git a/libc/sysdeps/ieee754/dbl-64/s_nearbyint.c b/libc/sysdeps/ieee754/dbl-64/s_nearbyint.c index 71e14cfb6..184fa7017 100644 --- a/libc/sysdeps/ieee754/dbl-64/s_nearbyint.c +++ b/libc/sysdeps/ieee754/dbl-64/s_nearbyint.c @@ -28,22 +28,13 @@ static char rcsid[] = "$NetBSD: s_rint.c,v 1.8 1995/05/10 20:48:04 jtc Exp $"; #include "math.h" #include "math_private.h" -#ifdef __STDC__ static const double -#else -static double -#endif TWO52[2]={ 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */ -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */ }; -#ifdef __STDC__ - double __nearbyint(double x) -#else - double __nearbyint(x) - double x; -#endif +double __nearbyint(double x) { fenv_t env; int32_t i0,j0,sx; diff --git a/libc/sysdeps/ieee754/dbl-64/s_scalbln.c b/libc/sysdeps/ieee754/dbl-64/s_scalbln.c index aa6134f09..89174b47f 100644 --- a/libc/sysdeps/ieee754/dbl-64/s_scalbln.c +++ b/libc/sysdeps/ieee754/dbl-64/s_scalbln.c @@ -1,4 +1,3 @@ -/* @(#)s_scalbn.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: s_scalbn.c,v 1.8 1995/05/10 20:48:08 jtc Exp $"; -#endif - /* * scalbn (double x, int n) * scalbn(x,n) returns x* 2**n computed by exponent @@ -24,44 +19,37 @@ static char rcsid[] = "$NetBSD: s_scalbn.c,v 1.8 1995/05/10 20:48:08 jtc Exp $"; #include "math.h" #include "math_private.h" -#ifdef __STDC__ static const double -#else -static double -#endif two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */ twom54 = 5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */ huge = 1.0e+300, tiny = 1.0e-300; -#ifdef __STDC__ - double __scalbln (double x, long int n) -#else - double __scalbln (x,n) - double x; long int n; -#endif +double +__scalbln (double x, long int n) { int32_t k,hx,lx; EXTRACT_WORDS(hx,lx,x); - k = (hx&0x7ff00000)>>20; /* extract exponent */ - if (k==0) { /* 0 or subnormal x */ - if ((lx|(hx&0x7fffffff))==0) return x; /* +-0 */ + k = (hx&0x7ff00000)>>20; /* extract exponent */ + if (__builtin_expect(k==0, 0)) { /* 0 or subnormal x */ + if ((lx|(hx&0x7fffffff))==0) return x; /* +-0 */ x *= two54; GET_HIGH_WORD(hx,x); k = ((hx&0x7ff00000)>>20) - 54; } - if (k==0x7ff) return x+x; /* NaN or Inf */ - k = k+n; - if (n> 50000 || k > 0x7fe) + if (__builtin_expect(k==0x7ff, 0)) return x+x; /* NaN or Inf */ + k = k+n; + if (__builtin_expect(n> 50000 || k > 0x7fe, 0)) return huge*__copysign(huge,x); /* overflow */ - if (n< -50000) return tiny*__copysign(tiny,x); /*underflow*/ - if (k > 0) /* normal result */ + if (__builtin_expect(n< -50000, 0)) + return tiny*__copysign(tiny,x); /*underflow*/ + if (__builtin_expect(k > 0, 1)) /* normal result */ {SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); return x;} - if (k <= -54) + if (k <= -54) return tiny*__copysign(tiny,x); /*underflow*/ - k += 54; /* subnormal result */ + k += 54; /* subnormal result */ SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); - return x*twom54; + return x*twom54; } weak_alias (__scalbln, scalbln) #ifdef NO_LONG_DOUBLE diff --git a/libc/sysdeps/ieee754/dbl-64/s_scalbn.c b/libc/sysdeps/ieee754/dbl-64/s_scalbn.c index 3dbfe8fef..1e67dbe5e 100644 --- a/libc/sysdeps/ieee754/dbl-64/s_scalbn.c +++ b/libc/sysdeps/ieee754/dbl-64/s_scalbn.c @@ -1,4 +1,3 @@ -/* @(#)s_scalbn.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: s_scalbn.c,v 1.8 1995/05/10 20:48:08 jtc Exp $"; -#endif - /* * scalbn (double x, int n) * scalbn(x,n) returns x* 2**n computed by exponent @@ -24,44 +19,37 @@ static char rcsid[] = "$NetBSD: s_scalbn.c,v 1.8 1995/05/10 20:48:08 jtc Exp $"; #include "math.h" #include "math_private.h" -#ifdef __STDC__ static const double -#else -static double -#endif two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */ twom54 = 5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */ huge = 1.0e+300, tiny = 1.0e-300; -#ifdef __STDC__ - double __scalbn (double x, int n) -#else - double __scalbn (x,n) - double x; int n; -#endif +double +__scalbn (double x, int n) { int32_t k,hx,lx; EXTRACT_WORDS(hx,lx,x); - k = (hx&0x7ff00000)>>20; /* extract exponent */ - if (k==0) { /* 0 or subnormal x */ - if ((lx|(hx&0x7fffffff))==0) return x; /* +-0 */ + k = (hx&0x7ff00000)>>20; /* extract exponent */ + if (__builtin_expect(k==0, 0)) { /* 0 or subnormal x */ + if ((lx|(hx&0x7fffffff))==0) return x; /* +-0 */ x *= two54; GET_HIGH_WORD(hx,x); k = ((hx&0x7ff00000)>>20) - 54; } - if (k==0x7ff) return x+x; /* NaN or Inf */ - k = k+n; - if (n> 50000 || k > 0x7fe) + if (__builtin_expect(k==0x7ff, 0)) return x+x; /* NaN or Inf */ + k = k+n; + if (__builtin_expect(n> 50000 || k > 0x7fe, 0)) return huge*__copysign(huge,x); /* overflow */ - if (n< -50000) return tiny*__copysign(tiny,x); /*underflow*/ - if (k > 0) /* normal result */ + if (__builtin_expect(n< -50000, 0)) + return tiny*__copysign(tiny,x); /*underflow*/ + if (__builtin_expect(k > 0, 1)) /* normal result */ {SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); return x;} - if (k <= -54) + if (k <= -54) return tiny*__copysign(tiny,x); /*underflow*/ - k += 54; /* subnormal result */ + k += 54; /* subnormal result */ SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); - return x*twom54; + return x*twom54; } weak_alias (__scalbn, scalbn) #ifdef NO_LONG_DOUBLE diff --git a/libc/sysdeps/ieee754/dbl-64/s_tanh.c b/libc/sysdeps/ieee754/dbl-64/s_tanh.c index 944f96386..63ef4b88a 100644 --- a/libc/sysdeps/ieee754/dbl-64/s_tanh.c +++ b/libc/sysdeps/ieee754/dbl-64/s_tanh.c @@ -41,18 +41,9 @@ static char rcsid[] = "$NetBSD: s_tanh.c,v 1.7 1995/05/10 20:48:22 jtc Exp $"; #include "math.h" #include "math_private.h" -#ifdef __STDC__ static const double one=1.0, two=2.0, tiny = 1.0e-300; -#else -static double one=1.0, two=2.0, tiny = 1.0e-300; -#endif -#ifdef __STDC__ - double __tanh(double x) -#else - double __tanh(x) - double x; -#endif +double __tanh(double x) { double t,z; int32_t jx,ix,lx; diff --git a/libc/sysdeps/ieee754/dbl-64/wordsize-64/e_acosh.c b/libc/sysdeps/ieee754/dbl-64/wordsize-64/e_acosh.c new file mode 100644 index 000000000..83c28479d --- /dev/null +++ b/libc/sysdeps/ieee754/dbl-64/wordsize-64/e_acosh.c @@ -0,0 +1,67 @@ +/* Optimized for 64-bit by Ulrich Drepper <drepper@gmail.com>, 2012 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* __ieee754_acosh(x) + * Method : + * Based on + * acosh(x) = log [ x + sqrt(x*x-1) ] + * we have + * acosh(x) := log(x)+ln2, if x is large; else + * acosh(x) := log(2x-1/(sqrt(x*x-1)+x)) if x>2; else + * acosh(x) := log1p(t+sqrt(2.0*t+t*t)); where t=x-1. + * + * Special cases: + * acosh(x) is NaN with signal if x<1. + * acosh(NaN) is NaN without signal. + */ + +#include "math.h" +#include "math_private.h" + +static const double +one = 1.0, +ln2 = 6.93147180559945286227e-01; /* 0x3FE62E42, 0xFEFA39EF */ + +double +__ieee754_acosh (double x) +{ + int64_t hx; + EXTRACT_WORDS64 (hx, x); + + if (hx > INT64_C (0x4000000000000000)) + { + if (__builtin_expect (hx >= INT64_C (0x41b0000000000000), 0)) + { + /* x > 2**28 */ + if (hx >= INT64_C (0x7ff0000000000000)) + /* x is inf of NaN */ + return x + x; + else + return __ieee754_log (x) + ln2;/* acosh(huge)=log(2x) */ + } + + /* 2**28 > x > 2 */ + double t = x * x; + return __ieee754_log (2.0 * x - one / (x + __ieee754_sqrt (t - one))); + } + else if (__builtin_expect (hx > INT64_C (0x3ff0000000000000), 1)) + { + /* 1<x<2 */ + double t = x - one; + return __log1p (t + __ieee754_sqrt (2.0 * t + t * t)); + } + else if (__builtin_expect (hx == INT64_C (0x3ff0000000000000), 1)) + return 0.0; /* acosh(1) = 0 */ + else /* x < 1 */ + return (x - x) / (x - x); +} +strong_alias (__ieee754_acosh, __acosh_finite) diff --git a/libc/sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c b/libc/sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c index 65dc8934f..86d0ac8bb 100644 --- a/libc/sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c +++ b/libc/sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c @@ -19,12 +19,7 @@ #include "math_private.h" #undef __isnan -#ifdef __STDC__ - int __isnan(double x) -#else - int __isnan(x) - double x; -#endif +int __isnan(double x) { int64_t hx; EXTRACT_WORDS64(hx,x); diff --git a/libc/sysdeps/ieee754/dbl-64/wordsize-64/s_modf.c b/libc/sysdeps/ieee754/dbl-64/wordsize-64/s_modf.c new file mode 100644 index 000000000..0cba548ab --- /dev/null +++ b/libc/sysdeps/ieee754/dbl-64/wordsize-64/s_modf.c @@ -0,0 +1,65 @@ +/* Rewritten for 64-bit machines by Ulrich Drepper <drepper@gmail.com>. */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * modf(double x, double *iptr) + * return fraction part of x, and return x's integral part in *iptr. + * Method: + * Bit twiddling. + * + * Exception: + * No exception. + */ + +#include "math.h" +#include "math_private.h" + +static const double one = 1.0; + +double +__modf(double x, double *iptr) +{ + int64_t i0; + int32_t j0; + EXTRACT_WORDS64(i0,x); + j0 = ((i0>>52)&0x7ff)-0x3ff; /* exponent of x */ + if(j0<52) { /* integer part in x */ + if(j0<0) { /* |x|<1 */ + /* *iptr = +-0 */ + INSERT_WORDS64(*iptr,i0&UINT64_C(0x8000000000000000)); + return x; + } else { + uint64_t i = UINT64_C(0x000fffffffffffff)>>j0; + if((i0&i)==0) { /* x is integral */ + *iptr = x; + /* return +-0 */ + INSERT_WORDS64(x,i0&UINT64_C(0x8000000000000000)); + return x; + } else { + INSERT_WORDS64(*iptr,i0&(~i)); + return x - *iptr; + } + } + } else { /* no fraction part */ + *iptr = x*one; + /* We must handle NaNs separately. */ + if (j0 == 0x400 && (i0 & UINT64_C(0xfffffffffffff))) + return x*one; + INSERT_WORDS64(x,i0&UINT64_C(0x8000000000000000)); /* return +-0 */ + return x; + } +} +weak_alias (__modf, modf) +#ifdef NO_LONG_DOUBLE +strong_alias (__modf, __modfl) +weak_alias (__modf, modfl) +#endif diff --git a/libc/sysdeps/ieee754/dbl-64/wordsize-64/s_scalbln.c b/libc/sysdeps/ieee754/dbl-64/wordsize-64/s_scalbln.c new file mode 100644 index 000000000..d6b97b548 --- /dev/null +++ b/libc/sysdeps/ieee754/dbl-64/wordsize-64/s_scalbln.c @@ -0,0 +1,60 @@ +/* + * ==================================================== + * 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. + * ==================================================== + */ + +/* + * scalbn (double x, int n) + * scalbn(x,n) returns x* 2**n computed by exponent + * manipulation rather than by actually performing an + * exponentiation or a multiplication. + */ + +#include "math.h" +#include "math_private.h" + +static const double +two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */ +twom54 = 5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */ +huge = 1.0e+300, +tiny = 1.0e-300; + +double +__scalbln (double x, long int n) +{ + int64_t ix; + int64_t k; + EXTRACT_WORDS64(ix,x); + k = (ix >> 52) & 0x7ff; /* extract exponent */ + if (__builtin_expect(k==0, 0)) { /* 0 or subnormal x */ + if ((ix & UINT64_C(0xfffffffffffff))==0) return x; /* +-0 */ + x *= two54; + EXTRACT_WORDS64(ix,x); + k = ((ix >> 52) & 0x7ff) - 54; + } + if (__builtin_expect(k==0x7ff, 0)) return x+x; /* NaN or Inf */ + k = k+n; + if (__builtin_expect(n> 50000 || k > 0x7fe, 0)) + return huge*__copysign(huge,x); /* overflow */ + if (__builtin_expect(n< -50000, 0)) + return tiny*__copysign(tiny,x); /*underflow*/ + if (__builtin_expect(k > 0, 1)) /* normal result */ + {INSERT_WORDS64(x,(ix&UINT64_C(0x800fffffffffffff))|(k<<52)); + return x;} + if (k <= -54) + return tiny*__copysign(tiny,x); /*underflow*/ + k += 54; /* subnormal result */ + INSERT_WORDS64(x,(ix&INT64_C(0x800fffffffffffff))|(k<<52)); + return x*twom54; +} +weak_alias (__scalbln, scalbln) +#ifdef NO_LONG_DOUBLE +strong_alias (__scalbln, __scalblnl) +weak_alias (__scalbln, scalblnl) +#endif diff --git a/libc/sysdeps/ieee754/dbl-64/wordsize-64/s_scalbn.c b/libc/sysdeps/ieee754/dbl-64/wordsize-64/s_scalbn.c index 25cf3b169..7f0e21f64 100644 --- a/libc/sysdeps/ieee754/dbl-64/wordsize-64/s_scalbn.c +++ b/libc/sysdeps/ieee754/dbl-64/wordsize-64/s_scalbn.c @@ -1,4 +1,3 @@ -/* @(#)s_scalbn.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -20,39 +19,32 @@ #include "math.h" #include "math_private.h" -#ifdef __STDC__ static const double -#else -static double -#endif two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */ twom54 = 5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */ huge = 1.0e+300, tiny = 1.0e-300; -#ifdef __STDC__ - double __scalbn (double x, int n) -#else - double __scalbn (x,n) - double x; int n; -#endif +double +__scalbn (double x, int n) { int64_t ix; int64_t k; EXTRACT_WORDS64(ix,x); k = (ix >> 52) & 0x7ff; /* extract exponent */ - if (k==0) { /* 0 or subnormal x */ + if (__builtin_expect(k==0, 0)) { /* 0 or subnormal x */ if ((ix & UINT64_C(0xfffffffffffff))==0) return x; /* +-0 */ x *= two54; EXTRACT_WORDS64(ix,x); k = ((ix >> 52) & 0x7ff) - 54; } - if (k==0x7ff) return x+x; /* NaN or Inf */ + if (__builtin_expect(k==0x7ff, 0)) return x+x; /* NaN or Inf */ k = k+n; - if (n> 50000 || k > 0x7fe) + if (__builtin_expect(n> 50000 || k > 0x7fe, 0)) return huge*__copysign(huge,x); /* overflow */ - if (n< -50000) return tiny*__copysign(tiny,x); /*underflow*/ - if (k > 0) /* normal result */ + if (__builtin_expect(n< -50000, 0)) + return tiny*__copysign(tiny,x); /*underflow*/ + if (__builtin_expect(k > 0, 1)) /* normal result */ {INSERT_WORDS64(x,(ix&UINT64_C(0x800fffffffffffff))|(k<<52)); return x;} if (k <= -54) |