Use volatile hacks to make sure these functions generate an underflow

exception when they're supposed to. Previously, gcc -O2 was optimizing
away the statement that generated it.
This commit is contained in:
David Schultz 2008-01-18 22:19:04 +00:00
parent 007d5445df
commit 86c2e0c047
3 changed files with 6 additions and 3 deletions

View File

@ -24,7 +24,6 @@ static const float
one = 1.0,
halF[2] = {0.5,-0.5,},
huge = 1.0e+30,
twom100 = 7.8886090522e-31, /* 2**-100=0x0d800000 */
o_threshold= 8.8721679688e+01, /* 0x42b17180 */
u_threshold= -1.0397208405e+02, /* 0xc2cff1b5 */
ln2HI[2] ={ 6.9314575195e-01, /* 0x3f317200 */
@ -38,6 +37,8 @@ P3 = 6.6137559770e-05, /* 0x388ab355 */
P4 = -1.6533901999e-06, /* 0xb5ddea0e */
P5 = 4.1381369442e-08; /* 0x3331bb4c */
static volatile float twom100 = 7.8886090522e-31; /* 2**-100=0x0d800000 */
float
__ieee754_expf(float x) /* default IEEE double exp */
{

View File

@ -37,7 +37,6 @@ __FBSDID("$FreeBSD$");
static const double
huge = 0x1p1000,
twom1000 = 0x1p-1000,
redux = 0x1.8p52 / TBLSIZE,
P1 = 0x1.62e42fefa39efp-1,
P2 = 0x1.ebfbdff82c575p-3,
@ -45,6 +44,8 @@ static const double
P4 = 0x1.3b2ab88f70400p-7,
P5 = 0x1.5d88003875c74p-10;
static volatile double twom1000 = 0x1p-1000;
static const double tbl[TBLSIZE * 2] = {
/* exp2(z + eps) eps */
0x1.6a09e667f3d5dp-1, 0x1.9880p-44,

View File

@ -35,13 +35,14 @@ __FBSDID("$FreeBSD$");
static const float
huge = 0x1p100f,
twom100 = 0x1p-100f,
redux = 0x1.8p23f / TBLSIZE,
P1 = 0x1.62e430p-1f,
P2 = 0x1.ebfbe0p-3f,
P3 = 0x1.c6b348p-5f,
P4 = 0x1.3b2c9cp-7f;
static volatile float twom100 = 0x1p-100f;
static const double exp2ft[TBLSIZE] = {
0x1.6a09e667f3bcdp-1,
0x1.7a11473eb0187p-1,