MFC: r205410

Avoid aliasing which leads to incorrect results when compiling with the
default strict aliasing rules.

PR:		144900
Submitted by:	Peter Jeremy
This commit is contained in:
Marius Strobl 2010-03-30 19:13:37 +00:00
parent 1185606b8c
commit aa1750167b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/stable/8/; revision=205905

View File

@ -139,9 +139,9 @@ __fpu_xtof(fp, i)
* a signed or unsigned entity. * a signed or unsigned entity.
*/ */
if (fp->fp_sign && (int64_t)i < 0) if (fp->fp_sign && (int64_t)i < 0)
*((int64_t*)fp->fp_mant) = -i; *((int64_t *)fp->fp_mant) = -i;
else else
*((int64_t*)fp->fp_mant) = i; *((int64_t *)fp->fp_mant) = i;
fp->fp_mant[2] = 0; fp->fp_mant[2] = 0;
fp->fp_mant[3] = 0; fp->fp_mant[3] = 0;
__fpu_norm(fp); __fpu_norm(fp);
@ -262,14 +262,12 @@ __fpu_explode(fe, fp, type, reg)
struct fpn *fp; struct fpn *fp;
int type, reg; int type, reg;
{ {
u_int32_t s, *sp; u_int64_t l0, l1;
u_int64_t l[2]; u_int32_t s;
void *vl = l;
if (type == FTYPE_LNG || type == FTYPE_DBL || type == FTYPE_EXT) { if (type == FTYPE_LNG || type == FTYPE_DBL || type == FTYPE_EXT) {
l[0] = __fpu_getreg64(reg & ~1); l0 = __fpu_getreg64(reg & ~1);
sp = vl; fp->fp_sign = l0 >> 63;
fp->fp_sign = sp[0] >> 31;
} else { } else {
s = __fpu_getreg(reg); s = __fpu_getreg(reg);
fp->fp_sign = s >> 31; fp->fp_sign = s >> 31;
@ -277,7 +275,7 @@ __fpu_explode(fe, fp, type, reg)
fp->fp_sticky = 0; fp->fp_sticky = 0;
switch (type) { switch (type) {
case FTYPE_LNG: case FTYPE_LNG:
s = __fpu_xtof(fp, l[0]); s = __fpu_xtof(fp, l0);
break; break;
case FTYPE_INT: case FTYPE_INT:
@ -289,12 +287,13 @@ __fpu_explode(fe, fp, type, reg)
break; break;
case FTYPE_DBL: case FTYPE_DBL:
s = __fpu_dtof(fp, sp[0], sp[1]); s = __fpu_dtof(fp, l0 >> 32, l0 & 0xffffffff);
break; break;
case FTYPE_EXT: case FTYPE_EXT:
l[1] = __fpu_getreg64((reg & ~1) + 2); l1 = __fpu_getreg64((reg & ~1) + 2);
s = __fpu_qtof(fp, sp[0], sp[1], sp[2], sp[3]); s = __fpu_qtof(fp, l0 >> 32, l0 & 0xffffffff, l1 >> 32,
l1 & 0xffffffff);
break; break;
default: default: