Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 30 Mar 2010 19:15:57 +0000 (UTC)
From:      Marius Strobl <marius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r205906 - stable/7/lib/libc/sparc64/fpu
Message-ID:  <201003301915.o2UJFvrr069447@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marius
Date: Tue Mar 30 19:15:57 2010
New Revision: 205906
URL: http://svn.freebsd.org/changeset/base/205906

Log:
  MFC: r173859, r205410
  
  Avoid aliasing which leads to incorrect results when compiling with the
  default strict aliasing rules.
  
  PR:		144900
  Submitted by:	Peter Jeremy

Modified:
  stable/7/lib/libc/sparc64/fpu/fpu_explode.c
Directory Properties:
  stable/7/lib/libc/   (props changed)
  stable/7/lib/libc/stdtime/   (props changed)

Modified: stable/7/lib/libc/sparc64/fpu/fpu_explode.c
==============================================================================
--- stable/7/lib/libc/sparc64/fpu/fpu_explode.c	Tue Mar 30 19:13:37 2010	(r205905)
+++ stable/7/lib/libc/sparc64/fpu/fpu_explode.c	Tue Mar 30 19:15:57 2010	(r205906)
@@ -139,9 +139,9 @@ __fpu_xtof(fp, i)
 	 * a signed or unsigned entity.
 	 */
 	if (fp->fp_sign && (int64_t)i < 0)
-		*((int64_t*)fp->fp_mant) = -i;
+		*((int64_t *)fp->fp_mant) = -i;
 	else
-		*((int64_t*)fp->fp_mant) = i;
+		*((int64_t *)fp->fp_mant) = i;
 	fp->fp_mant[2] = 0;
 	fp->fp_mant[3] = 0;
 	__fpu_norm(fp);
@@ -262,13 +262,12 @@ __fpu_explode(fe, fp, type, reg)
 	struct fpn *fp;
 	int type, reg;
 {
-	u_int32_t s, *sp;
-	u_int64_t l[2];
+	u_int64_t l0, l1;
+	u_int32_t s;
 
 	if (type == FTYPE_LNG || type == FTYPE_DBL || type == FTYPE_EXT) {
-		l[0] = __fpu_getreg64(reg & ~1);
-		sp = (u_int32_t *)l;
-		fp->fp_sign = sp[0] >> 31;
+		l0 = __fpu_getreg64(reg & ~1);
+		fp->fp_sign = l0 >> 63;
 	} else {
 		s = __fpu_getreg(reg);
 		fp->fp_sign = s >> 31;
@@ -276,7 +275,7 @@ __fpu_explode(fe, fp, type, reg)
 	fp->fp_sticky = 0;
 	switch (type) {
 	case FTYPE_LNG:
-		s = __fpu_xtof(fp, l[0]);
+		s = __fpu_xtof(fp, l0);
 		break;
 
 	case FTYPE_INT:
@@ -288,12 +287,13 @@ __fpu_explode(fe, fp, type, reg)
 		break;
 
 	case FTYPE_DBL:
-		s = __fpu_dtof(fp, sp[0], sp[1]);
+		s = __fpu_dtof(fp, l0 >> 32, l0 & 0xffffffff);
 		break;
 
 	case FTYPE_EXT:
-		l[1] = __fpu_getreg64((reg & ~1) + 2);
-		s = __fpu_qtof(fp, sp[0], sp[1], sp[2], sp[3]);
+		l1 = __fpu_getreg64((reg & ~1) + 2);
+		s = __fpu_qtof(fp, l0 >> 32, l0 & 0xffffffff, l1 >> 32,
+		    l1 & 0xffffffff);
 		break;
 
 	default:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201003301915.o2UJFvrr069447>