aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Schultz <das@FreeBSD.org>2011-10-21 06:26:38 +0000
committerDavid Schultz <das@FreeBSD.org>2011-10-21 06:26:38 +0000
commitf2ea2b9d2796fcbe5d03775a35508e22fac4c7fd (patch)
treeefe324dcb8a65c88f3cfebddd083efe5239c4025 /lib
parentcd24d798437a57577a32dc033c53d32ed5100274 (diff)
downloadsrc-f2ea2b9d2796fcbe5d03775a35508e22fac4c7fd.tar.gz
src-f2ea2b9d2796fcbe5d03775a35508e22fac4c7fd.zip
Use STRICT_ASSIGN() to ensure that the compiler doesn't screw things
up by storing x in a wider type than it's supposed to. Submitted by: bde
Notes
Notes: svn path=/head/; revision=226596
Diffstat (limited to 'lib')
-rw-r--r--lib/msun/src/e_exp.c4
-rw-r--r--lib/msun/src/e_expf.c6
-rw-r--r--lib/msun/src/s_expm1.c4
-rw-r--r--lib/msun/src/s_expm1f.c4
4 files changed, 13 insertions, 5 deletions
diff --git a/lib/msun/src/e_exp.c b/lib/msun/src/e_exp.c
index 5b9a10c1a3d6..b47aef583c98 100644
--- a/lib/msun/src/e_exp.c
+++ b/lib/msun/src/e_exp.c
@@ -76,6 +76,8 @@ __FBSDID("$FreeBSD$");
* to produce the hexadecimal values shown.
*/
+#include <float.h>
+
#include "math.h"
#include "math_private.h"
@@ -133,7 +135,7 @@ __ieee754_exp(double x) /* default IEEE double exp */
hi = x - t*ln2HI[0]; /* t*ln2HI is exact here */
lo = t*ln2LO[0];
}
- x = hi - lo;
+ STRICT_ASSIGN(double, x, hi - lo);
}
else if(hx < 0x3e300000) { /* when |x|<2**-28 */
if(huge+x>one) return one+x;/* trigger inexact */
diff --git a/lib/msun/src/e_expf.c b/lib/msun/src/e_expf.c
index 502e42138d11..a4790765bcb5 100644
--- a/lib/msun/src/e_expf.c
+++ b/lib/msun/src/e_expf.c
@@ -16,6 +16,8 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <float.h>
+
#include "math.h"
#include "math_private.h"
@@ -40,7 +42,7 @@ P2 = -2.7667332906e-3; /* -0xb55215.0p-32 */
static volatile float twom100 = 7.8886090522e-31; /* 2**-100=0x0d800000 */
float
-__ieee754_expf(float x) /* default IEEE double exp */
+__ieee754_expf(float x)
{
float y,hi=0.0,lo=0.0,c,t,twopk;
int32_t k=0,xsb;
@@ -70,7 +72,7 @@ __ieee754_expf(float x) /* default IEEE double exp */
hi = x - t*ln2HI[0]; /* t*ln2HI is exact here */
lo = t*ln2LO[0];
}
- x = hi - lo;
+ STRICT_ASSIGN(float, x, hi - lo);
}
else if(hx < 0x39000000) { /* when |x|<2**-14 */
if(huge+x>one) return one+x;/* trigger inexact */
diff --git a/lib/msun/src/s_expm1.c b/lib/msun/src/s_expm1.c
index f41c7e3e99c6..5aa1917b5a4c 100644
--- a/lib/msun/src/s_expm1.c
+++ b/lib/msun/src/s_expm1.c
@@ -108,6 +108,8 @@ __FBSDID("$FreeBSD$");
* to produce the hexadecimal values shown.
*/
+#include <float.h>
+
#include "math.h"
#include "math_private.h"
@@ -168,7 +170,7 @@ expm1(double x)
hi = x - t*ln2_hi; /* t*ln2_hi is exact here */
lo = t*ln2_lo;
}
- x = hi - lo;
+ STRICT_ASSIGN(double, x, hi - lo);
c = (hi-x)-lo;
}
else if(hx < 0x3c900000) { /* when |x|<2**-54, return x */
diff --git a/lib/msun/src/s_expm1f.c b/lib/msun/src/s_expm1f.c
index d7dd1b90c464..fb374943000e 100644
--- a/lib/msun/src/s_expm1f.c
+++ b/lib/msun/src/s_expm1f.c
@@ -16,6 +16,8 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <float.h>
+
#include "math.h"
#include "math_private.h"
@@ -74,7 +76,7 @@ expm1f(float x)
hi = x - t*ln2_hi; /* t*ln2_hi is exact here */
lo = t*ln2_lo;
}
- x = hi - lo;
+ STRICT_ASSIGN(float, x, hi - lo);
c = (hi-x)-lo;
}
else if(hx < 0x33000000) { /* when |x|<2**-25, return x */