Add a macro STRICT_ASSIGN() to help avoid the compiler bug that
assignments and casts don't clip extra precision, if any. The implementation is to assign to a temporary volatile variable and read the result back to assign to the original lvalue. lib/msun currently 2 different hard-coded hacks to avoid the problem in just a few places and needs it in a few more places. One variant uses volatile for the original lvalue. This works but is slower than necessary. Another temporarily casts the lvalue to volatile. This broke with gcc-4.2.1 or earlier (gcc now stores to the lvalue but doesn't load from it).
This commit is contained in:
parent
d2012f3333
commit
1880ccbd79
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=175403
@ -154,6 +154,22 @@ do { \
|
||||
(d) = sf_u.value; \
|
||||
} while (0)
|
||||
|
||||
#ifdef FLT_EVAL_METHOD
|
||||
/*
|
||||
* Attempt to get strict C99 semantics for assignment with non-C99 compilers.
|
||||
*/
|
||||
#if FLT_EVAL_METHOD == 0 || __GNUC__ == 0
|
||||
#define STRICT_ASSIGN(type, lval, rval) ((lval) = (rval))
|
||||
#else
|
||||
#define STRICT_ASSIGN(type, lval, rval) do { \
|
||||
volatile type __lval; \
|
||||
\
|
||||
__lval = (rval); \
|
||||
(lval) = __lval; \
|
||||
} while (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Common routine to process the arguments to nan(), nanf(), and nanl().
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user