svn commit: r326342 - head/lib/libc/mips/gen

Alex Richardson arichardson at FreeBSD.org
Tue Nov 28 20:37:28 UTC 2017


Author: arichardson
Date: Tue Nov 28 20:37:27 2017
New Revision: 326342
URL: https://svnweb.freebsd.org/changeset/base/326342

Log:
  Fix fabs() for MIPS when used on -0.0
  
  It would previously return negative zero for -0.0 since -0.0 does not
  compare less than 0. The issue was discovered when running the libc++
  test suite on softfloat MIPS64.
  
  I have verified that both clang and GCC generate sensible code for the
  builtin. For soft float they clear the sign bit using integer operations
  and in hard float mode they use abs.d.
  
  Reviewed by:	#mips, jhb, brooks, imp, emaste
  Approved by:	jhb (mentor)
  Differential Revision: https://reviews.freebsd.org/D13135

Modified:
  head/lib/libc/mips/gen/fabs.c

Modified: head/lib/libc/mips/gen/fabs.c
==============================================================================
--- head/lib/libc/mips/gen/fabs.c	Tue Nov 28 19:57:16 2017	(r326341)
+++ head/lib/libc/mips/gen/fabs.c	Tue Nov 28 20:37:27 2017	(r326342)
@@ -42,7 +42,6 @@ __FBSDID("$FreeBSD$");
 double
 fabs(double x)
 {
-	if (x < 0)
-		x = -x;
-	return(x);
+
+	return (__builtin_fabs(x));
 }


More information about the svn-src-head mailing list