svn commit: r336665 - head/lib/msun/src

Bruce Evans bde at FreeBSD.org
Tue Jul 24 11:50:06 UTC 2018


Author: bde
Date: Tue Jul 24 11:50:05 2018
New Revision: 336665
URL: https://svnweb.freebsd.org/changeset/base/336665

Log:
  In C remquol() and thus also in C remainderl(), don't clobber the sign bit
  of NaNs before possible returning a NaN.
  
  The remquo*() and remainder*() functions should now give bitwise identical
  results across arches and implementations, and bitwise consistent results
  (with lower precisions having truncated mantissas) across precisions.  x86
  already had consistency across amd64 and i386 and precisions by using the
  i387 consistently and normally not using the C versions.  Inconsistencies
  for C reqmquol() were first detected on sparc64.
  
  Remove double second clearing of the sign bit and extra blank lines.

Modified:
  head/lib/msun/src/s_remquol.c

Modified: head/lib/msun/src/s_remquol.c
==============================================================================
--- head/lib/msun/src/s_remquol.c	Tue Jul 24 11:35:22 2018	(r336664)
+++ head/lib/msun/src/s_remquol.c	Tue Jul 24 11:50:05 2018	(r336665)
@@ -79,7 +79,6 @@ remquol(long double x, long double y, int *quo)
 	sxy = sx ^ uy.bits.sign;
 	ux.bits.sign = 0;	/* |x| */
 	uy.bits.sign = 0;	/* |y| */
-	x = ux.e;
 
     /* purge off exception values */
 	if((uy.bits.exp|uy.bits.manh|uy.bits.manl)==0 || /* y=0 */
@@ -126,7 +125,6 @@ remquol(long double x, long double y, int *quo)
     /* fix point fmod */
 	n = ix - iy;
 	q = 0;
-
 	while(n--) {
 	    hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1;
 	    if(hz<0){hx = hx+hx+(lx>>MANL_SHIFT); lx = lx+lx;}
@@ -154,9 +152,8 @@ remquol(long double x, long double y, int *quo)
 	} else {
 	    ux.bits.exp = iy + BIAS;
 	}
-	ux.bits.sign = 0;
-	x = ux.e;
 fixup:
+	x = ux.e;		/* |x| */
 	y = fabsl(y);
 	if (y < LDBL_MIN * 2) {
 	    if (x+x>y || (x+x==y && (q & 1))) {
@@ -167,11 +164,9 @@ fixup:
 	    q++;
 	    x-=y;
 	}
-
 	ux.e = x;
 	ux.bits.sign ^= sx;
 	x = ux.e;
-
 	q &= 0x7fffffff;
 	*quo = (sxy ? -q : q);
 	return x;


More information about the svn-src-all mailing list