Date: Fri, 21 Oct 2011 06:26:38 +0000 (UTC) From: David Schultz <das@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r226596 - head/lib/msun/src Message-ID: <201110210626.p9L6QcEG009703@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: das Date: Fri Oct 21 06:26:38 2011 New Revision: 226596 URL: http://svn.freebsd.org/changeset/base/226596 Log: 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 Modified: head/lib/msun/src/e_exp.c head/lib/msun/src/e_expf.c head/lib/msun/src/s_expm1.c head/lib/msun/src/s_expm1f.c Modified: head/lib/msun/src/e_exp.c ============================================================================== --- head/lib/msun/src/e_exp.c Fri Oct 21 06:26:07 2011 (r226595) +++ head/lib/msun/src/e_exp.c Fri Oct 21 06:26:38 2011 (r226596) @@ -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 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 */ Modified: head/lib/msun/src/e_expf.c ============================================================================== --- head/lib/msun/src/e_expf.c Fri Oct 21 06:26:07 2011 (r226595) +++ head/lib/msun/src/e_expf.c Fri Oct 21 06:26:38 2011 (r226596) @@ -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- 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 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 */ Modified: head/lib/msun/src/s_expm1.c ============================================================================== --- head/lib/msun/src/s_expm1.c Fri Oct 21 06:26:07 2011 (r226595) +++ head/lib/msun/src/s_expm1.c Fri Oct 21 06:26:38 2011 (r226596) @@ -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 */ Modified: head/lib/msun/src/s_expm1f.c ============================================================================== --- head/lib/msun/src/s_expm1f.c Fri Oct 21 06:26:07 2011 (r226595) +++ head/lib/msun/src/s_expm1f.c Fri Oct 21 06:26:38 2011 (r226596) @@ -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 */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201110210626.p9L6QcEG009703>