зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1438599 - Part 2: Import fdlibm from FreeBSD (revision b21ccf63f28a3a4692d8a31419e0a725a1b1a800). r=jwalden
This commit is contained in:
Родитель
cacb9bf19b
Коммит
dc9e1f8ab9
|
@ -11,7 +11,7 @@ The in-tree copy is updated by running
|
|||
sh update.sh
|
||||
from within the modules/fdlibm directory.
|
||||
|
||||
Current version: [commit f2287da07ac7a26ac08745cac66eec82ab9ba384 (2016-09-04T12:01:32Z)].
|
||||
Current version: [commit b21ccf63f28a3a4692d8a31419e0a725a1b1a800 (2018-02-14T07:59:30Z)].
|
||||
|
||||
patches 01-14 fixes files to be usable within mozilla-central tree.
|
||||
See https://bugzilla.mozilla.org/show_bug.cgi?id=933257
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*
|
||||
* Developed at SunSoft, a Sun Microsystems, Inc. business.
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software is freely granted, provided that this notice
|
||||
* software is freely granted, provided that this notice
|
||||
* is preserved.
|
||||
* ====================================================
|
||||
*/
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
* ====================================================
|
||||
*/
|
||||
|
@ -19,7 +19,7 @@
|
|||
* 1. Compute and return log2(x) in two pieces:
|
||||
* log2(x) = w1 + w2,
|
||||
* where w1 has 53-24 = 29 bit trailing zeros.
|
||||
* 2. Perform y*log2(x) = n+y' by simulating multi-precision
|
||||
* 2. Perform y*log2(x) = n+y' by simulating multi-precision
|
||||
* arithmetic, where |y'|<=0.5.
|
||||
* 3. Return x**y = 2**n*exp(y'*log2)
|
||||
*
|
||||
|
@ -47,13 +47,13 @@
|
|||
* Accuracy:
|
||||
* pow(x,y) returns x**y nearly rounded. In particular
|
||||
* pow(integer,integer)
|
||||
* always returns the correct integer provided it is
|
||||
* always returns the correct integer provided it is
|
||||
* representable.
|
||||
*
|
||||
* Constants :
|
||||
* The hexadecimal values are the intended ones for the following
|
||||
* constants. The decimal values may be used, provided that the
|
||||
* compiler will convert from decimal to binary accurately enough
|
||||
* The hexadecimal values are the intended ones for the following
|
||||
* constants. The decimal values may be used, provided that the
|
||||
* compiler will convert from decimal to binary accurately enough
|
||||
* to produce the hexadecimal values shown.
|
||||
*/
|
||||
|
||||
|
@ -106,14 +106,14 @@ __ieee754_pow(double x, double y)
|
|||
ix = hx&0x7fffffff; iy = hy&0x7fffffff;
|
||||
|
||||
/* y==zero: x**0 = 1 */
|
||||
if((iy|ly)==0) return one;
|
||||
if((iy|ly)==0) return one;
|
||||
|
||||
/* x==1: 1**y = 1, even if y is NaN */
|
||||
if (hx==0x3ff00000 && lx == 0) return one;
|
||||
|
||||
/* y!=zero: result is NaN if either arg is NaN */
|
||||
if(ix > 0x7ff00000 || ((ix==0x7ff00000)&&(lx!=0)) ||
|
||||
iy > 0x7ff00000 || ((iy==0x7ff00000)&&(ly!=0)))
|
||||
iy > 0x7ff00000 || ((iy==0x7ff00000)&&(ly!=0)))
|
||||
return (x+0.0)+(y+0.0);
|
||||
|
||||
/* determine if y is an odd int when x < 0
|
||||
|
@ -122,7 +122,7 @@ __ieee754_pow(double x, double y)
|
|||
* yisint = 2 ... y is an even int
|
||||
*/
|
||||
yisint = 0;
|
||||
if(hx<0) {
|
||||
if(hx<0) {
|
||||
if(iy>=0x43400000) yisint = 2; /* even integer y */
|
||||
else if(iy>=0x3ff00000) {
|
||||
k = (iy>>20)-0x3ff; /* exponent */
|
||||
|
@ -133,11 +133,11 @@ __ieee754_pow(double x, double y)
|
|||
j = iy>>(20-k);
|
||||
if((j<<(20-k))==iy) yisint = 2-(j&1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* special value of y */
|
||||
if(ly==0) {
|
||||
if(ly==0) {
|
||||
if (iy==0x7ff00000) { /* y is +-inf */
|
||||
if(((ix-0x3ff00000)|lx)==0)
|
||||
return one; /* (-1)**+-inf is 1 */
|
||||
|
@ -145,14 +145,14 @@ __ieee754_pow(double x, double y)
|
|||
return (hy>=0)? y: zero;
|
||||
else /* (|x|<1)**-,+inf = inf,0 */
|
||||
return (hy<0)?-y: zero;
|
||||
}
|
||||
}
|
||||
if(iy==0x3ff00000) { /* y is +-1 */
|
||||
if(hy<0) return one/x; else return x;
|
||||
}
|
||||
if(hy==0x40000000) return x*x; /* y is 2 */
|
||||
if(hy==0x3fe00000) { /* y is 0.5 */
|
||||
if(hx>=0) /* x >= +0 */
|
||||
return sqrt(x);
|
||||
return sqrt(x);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,13 +165,13 @@ __ieee754_pow(double x, double y)
|
|||
if(hx<0) {
|
||||
if(((ix-0x3ff00000)|yisint)==0) {
|
||||
z = (z-z)/(z-z); /* (-1)**non-int is NaN */
|
||||
} else if(yisint==1)
|
||||
} else if(yisint==1)
|
||||
z = -z; /* (x<0)**odd = -(|x|**odd) */
|
||||
}
|
||||
return z;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* CYGNUS LOCAL + fdlibm-5.3 fix: This used to be
|
||||
n = (hx>>31)+1;
|
||||
but ANSI C says a right shift of a signed negative quantity is
|
||||
|
@ -193,7 +193,7 @@ __ieee754_pow(double x, double y)
|
|||
/* over/underflow if x is not close to one */
|
||||
if(ix<0x3fefffff) return (hy<0)? s*huge*huge:s*tiny*tiny;
|
||||
if(ix>0x3ff00000) return (hy>0)? s*huge*huge:s*tiny*tiny;
|
||||
/* now |1-x| is tiny <= 2**-20, suffice to compute
|
||||
/* now |1-x| is tiny <= 2**-20, suffice to compute
|
||||
log(x) by x-x^2/2+x^3/3-x^4/4 */
|
||||
t = ax-one; /* t has 20 trailing zeros */
|
||||
w = (t*t)*(0.5-t*(0.3333333333333333333333-t*0.25));
|
||||
|
@ -286,7 +286,7 @@ __ieee754_pow(double x, double y)
|
|||
n = ((n&0x000fffff)|0x00100000)>>(20-k);
|
||||
if(j<0) n = -n;
|
||||
p_h -= t;
|
||||
}
|
||||
}
|
||||
t = p_l+p_h;
|
||||
SET_LOW_WORD(t,0);
|
||||
u = t*lg2_h;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||
*
|
||||
* Copyright (c) 2011 David Schultz <das@FreeBSD.ORG>
|
||||
* All rights reserved.
|
||||
*
|
||||
|
|
|
@ -319,9 +319,21 @@ do { \
|
|||
fpsetprec(__oprec); \
|
||||
RETURNF(__retval); \
|
||||
} while (0)
|
||||
#define ENTERV() \
|
||||
fp_prec_t __oprec; \
|
||||
\
|
||||
if ((__oprec = fpgetprec()) != FP_PE) \
|
||||
fpsetprec(FP_PE)
|
||||
#define RETURNV() do { \
|
||||
if (__oprec != FP_PE) \
|
||||
fpsetprec(__oprec); \
|
||||
return; \
|
||||
} while (0)
|
||||
#else
|
||||
#define ENTERI(x)
|
||||
#define ENTERI()
|
||||
#define RETURNI(x) RETURNF(x)
|
||||
#define ENTERV()
|
||||
#define RETURNV() return
|
||||
#endif
|
||||
|
||||
/* Default return statement if hack*_t() is not used. */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* @(#)s_fabs.c 5.1 93/09/24 */
|
||||
/* @(#)s_fabs.c 5.1 93/09/24 */
|
||||
/*
|
||||
* ====================================================
|
||||
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
||||
|
@ -10,9 +10,8 @@
|
|||
* ====================================================
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
//static char rcsid[] = "$FreeBSD$";
|
||||
#endif
|
||||
//#include <sys/cdefs.h>
|
||||
//__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* fabs(x) returns the absolute value of x.
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||
*
|
||||
* Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
|
||||
* All rights reserved.
|
||||
*
|
||||
|
|
|
@ -10,9 +10,8 @@
|
|||
* ====================================================
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
//static char rcsid[] = "$FreeBSD$";
|
||||
#endif
|
||||
//#include <sys/cdefs.h>
|
||||
//__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* scalbn (double x, int n)
|
||||
|
@ -21,7 +20,6 @@
|
|||
* exponentiation or a multiplication.
|
||||
*/
|
||||
|
||||
//#include <sys/cdefs.h>
|
||||
#include <float.h>
|
||||
|
||||
#include "math_private.h"
|
||||
|
@ -50,10 +48,12 @@ scalbn (double x, int n)
|
|||
if (k > 0x7fe) return huge*copysign(huge,x); /* overflow */
|
||||
if (k > 0) /* normal result */
|
||||
{SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); return x;}
|
||||
if (k <= -54)
|
||||
if (k <= -54) {
|
||||
if (n > 50000) /* in case integer overflow in n+k */
|
||||
return huge*copysign(huge,x); /*overflow*/
|
||||
else return tiny*copysign(tiny,x); /*underflow*/
|
||||
else
|
||||
return tiny*copysign(tiny,x); /*underflow*/
|
||||
}
|
||||
k += 54; /* subnormal result */
|
||||
SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20));
|
||||
return x*twom54;
|
||||
|
|
Загрузка…
Ссылка в новой задаче