Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Jul 2018 22:04:56 +0000 (UTC)
From:      Justin Hibbits <jhibbits@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r336688 - in head: lib/libc/powerpcspe/gen sys/powerpc/include
Message-ID:  <201807242204.w6OM4uxL006261@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhibbits
Date: Tue Jul 24 22:04:56 2018
New Revision: 336688
URL: https://svnweb.freebsd.org/changeset/base/336688

Log:
  Fix floating point exception definitions for powerpcspe
  
  These were incorrectly implemented in the original port.

Modified:
  head/lib/libc/powerpcspe/gen/fpgetmask.c
  head/lib/libc/powerpcspe/gen/fpsetmask.c
  head/sys/powerpc/include/ieeefp.h

Modified: head/lib/libc/powerpcspe/gen/fpgetmask.c
==============================================================================
--- head/lib/libc/powerpcspe/gen/fpgetmask.c	Tue Jul 24 21:10:17 2018	(r336687)
+++ head/lib/libc/powerpcspe/gen/fpgetmask.c	Tue Jul 24 22:04:56 2018	(r336688)
@@ -44,6 +44,6 @@ fpgetmask()
 	uint32_t fpscr;
 
 	__asm__ __volatile("mfspr %0, %1" : "=r"(fpscr) : "K"(SPR_SPEFSCR));
-	return ((fp_except_t)((fpscr >> 3) & 0x1f));
+	return ((fp_except_t)((fpscr >> 2) & 0x1f));
 }
 #endif

Modified: head/lib/libc/powerpcspe/gen/fpsetmask.c
==============================================================================
--- head/lib/libc/powerpcspe/gen/fpsetmask.c	Tue Jul 24 21:10:17 2018	(r336687)
+++ head/lib/libc/powerpcspe/gen/fpsetmask.c	Tue Jul 24 22:04:56 2018	(r336688)
@@ -45,8 +45,8 @@ fpsetmask(fp_except_t mask)
 	fp_rnd_t old;
 
 	__asm__ __volatile("mfspr %0, %1" : "=r"(fpscr) : "K"(SPR_SPEFSCR));
-	old = (fp_rnd_t)((fpscr >> 3) & 0x1f);
-	fpscr = (fpscr & 0xffffff07) | (mask << 3);
+	old = (fp_rnd_t)((fpscr >> 2) & 0x1f);
+	fpscr = (fpscr & 0xffffff83) | (mask << 2);
 	__asm__ __volatile("mtspr %1,%0" :: "r"(fpscr), "K"(SPR_SPEFSCR));
 	return (old);
 }

Modified: head/sys/powerpc/include/ieeefp.h
==============================================================================
--- head/sys/powerpc/include/ieeefp.h	Tue Jul 24 21:10:17 2018	(r336687)
+++ head/sys/powerpc/include/ieeefp.h	Tue Jul 24 22:04:56 2018	(r336688)
@@ -11,11 +11,19 @@
 /* Deprecated historical FPU control interface */
 
 typedef int fp_except_t;
+#ifdef __SPE__
+#define FP_X_OFL	0x01	/* overflow exception */
+#define FP_X_UFL	0x02	/* underflow exception */
+#define FP_X_DZ		0x04	/* divide-by-zero exception */
+#define FP_X_INV	0x08	/* invalid operation exception */
+#define FP_X_IMP	0x10	/* imprecise (loss of precision) */
+#else
 #define FP_X_IMP	0x01	/* imprecise (loss of precision) */
 #define FP_X_DZ		0x02	/* divide-by-zero exception */
 #define FP_X_UFL	0x04	/* underflow exception */
 #define FP_X_OFL	0x08	/* overflow exception */
 #define FP_X_INV	0x10	/* invalid operation exception */
+#endif
 
 typedef enum {
     FP_RN=0,			/* round to nearest representable number */



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