Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 Mar 2014 12:28:22 +0000 (UTC)
From:      Andrew Turner <andrew@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r263631 - head/lib/libc/arm/gen
Message-ID:  <201403221228.s2MCSM4b096788@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: andrew
Date: Sat Mar 22 12:28:21 2014
New Revision: 263631
URL: http://svnweb.freebsd.org/changeset/base/263631

Log:
  Implement __flt_rounds for ARMv6 hard-float. The fpscr register stores the
  current rounding mode used by the VFP unit.

Modified:
  head/lib/libc/arm/gen/flt_rounds.c

Modified: head/lib/libc/arm/gen/flt_rounds.c
==============================================================================
--- head/lib/libc/arm/gen/flt_rounds.c	Sat Mar 22 11:49:44 2014	(r263630)
+++ head/lib/libc/arm/gen/flt_rounds.c	Sat Mar 22 12:28:21 2014	(r263631)
@@ -30,20 +30,32 @@ __FBSDID("$FreeBSD$");
 #include <fenv.h>
 #include <float.h>
 
+#ifndef __ARM_PCS_VFP
 #include "softfloat-for-gcc.h"
 #include "milieu.h"
 #include "softfloat.h"
+#endif
 
 int
 __flt_rounds(void)
 {
+	int mode;
 
-#ifndef ARM_HARD_FLOAT
+#ifndef __ARM_PCS_VFP
 	/*
 	 * Translate our rounding modes to the unnamed
 	 * manifest constants required by C99 et. al.
 	 */
-	switch (__softfloat_float_rounding_mode) {
+	mode = __softfloat_float_rounding_mode;
+#else /* __ARM_PCS_VFP */
+	/*
+	 * Read the floating-point status and control register
+	 */
+	__asm __volatile("vmrs %0, fpscr" : "=&r"(mode));
+	mode &= _ROUND_MASK;
+#endif /* __ARM_PCS_VFP */
+
+	switch (mode) {
 	case FE_TOWARDZERO:
 		return (0);
 	case FE_TONEAREST:
@@ -54,12 +66,4 @@ __flt_rounds(void)
 		return (3);
 	}
 	return (-1);
-#else /* ARM_HARD_FLOAT */
-	/*
-	 * Apparently, the rounding mode is specified as part of the
-	 * instruction format on ARM, so the dynamic rounding mode is
-	 * indeterminate.  Some FPUs may differ.
-	 */
-	return (-1);
-#endif /* ARM_HARD_FLOAT */
 }



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