Module Name:    src
Committed By:   msaitoh
Date:           Fri Jun 14 02:43:36 UTC 2013

Modified Files:
        src/lib/libm/arch/i387 [netbsd-6-1]: fenv.c
        src/lib/libm/arch/x86_64 [netbsd-6-1]: fenv.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #899):
        lib/libm/arch/i387/fenv.c: revision 1.5
        lib/libm/arch/x86_64/fenv.c: revision 1.3-1.4
Fix amd64 feraiseexcept so that it actually traps.
The call to fwait got lost somewhere along the line; the i387 code has it.
Fix sense of fegetexcept on x86.
Somehow I overlooked this when I fixed feenableexcept and fedisableexcept
last summer.


To generate a diff of this commit:
cvs rdiff -u -r1.3.8.1 -r1.3.8.1.6.1 src/lib/libm/arch/i387/fenv.c
cvs rdiff -u -r1.1.8.1 -r1.1.8.1.6.1 src/lib/libm/arch/x86_64/fenv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libm/arch/i387/fenv.c
diff -u src/lib/libm/arch/i387/fenv.c:1.3.8.1 src/lib/libm/arch/i387/fenv.c:1.3.8.1.6.1
--- src/lib/libm/arch/i387/fenv.c:1.3.8.1	Sun Aug 12 18:53:11 2012
+++ src/lib/libm/arch/i387/fenv.c	Fri Jun 14 02:43:36 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: fenv.c,v 1.3.8.1 2012/08/12 18:53:11 martin Exp $ */
+/* $NetBSD: fenv.c,v 1.3.8.1.6.1 2013/06/14 02:43:36 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 2004-2005 David Schultz <[email protected]>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: fenv.c,v 1.3.8.1 2012/08/12 18:53:11 martin Exp $");
+__RCSID("$NetBSD: fenv.c,v 1.3.8.1.6.1 2013/06/14 02:43:36 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/sysctl.h>
@@ -510,5 +510,5 @@ fegetexcept(void)
 	 */
 	__fnstcw(&control);
 
-	return (control & FE_ALL_EXCEPT);
+	return (~control & FE_ALL_EXCEPT);
 }

Index: src/lib/libm/arch/x86_64/fenv.c
diff -u src/lib/libm/arch/x86_64/fenv.c:1.1.8.1 src/lib/libm/arch/x86_64/fenv.c:1.1.8.1.6.1
--- src/lib/libm/arch/x86_64/fenv.c:1.1.8.1	Sun Aug 12 18:53:11 2012
+++ src/lib/libm/arch/x86_64/fenv.c	Fri Jun 14 02:43:36 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: fenv.c,v 1.1.8.1 2012/08/12 18:53:11 martin Exp $ */
+/* $NetBSD: fenv.c,v 1.1.8.1.6.1 2013/06/14 02:43:36 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 2004-2005 David Schultz <das (at) FreeBSD.ORG>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: fenv.c,v 1.1.8.1 2012/08/12 18:53:11 martin Exp $");
+__RCSID("$NetBSD: fenv.c,v 1.1.8.1.6.1 2013/06/14 02:43:36 msaitoh Exp $");
 
 #include <assert.h>
 #include <fenv.h>
@@ -58,6 +58,10 @@ __RCSID("$NetBSD: fenv.c,v 1.1.8.1 2012/
 #define	__fnstenv(__env)	__asm__ __volatile__ \
 	("fnstenv %0" : "=m" (*(__env)))
 
+/* Check for and handle pending unmasked x87 pending FPU exceptions */
+#define	__fwait(__env)		__asm__	__volatile__	\
+	("fwait")
+
 /* Load the MXCSR register */
 #define	__ldmxcsr(__mxcsr)	__asm__ __volatile__ \
 	("ldmxcsr %0" : : "m" (__mxcsr))
@@ -178,6 +182,7 @@ feraiseexcept(int excepts)
 
 	ex = excepts & FE_ALL_EXCEPT;
 	fesetexceptflag((unsigned int *)&excepts, excepts);
+	__fwait();
 
 	/* Success */
 	return (0);
@@ -519,6 +524,6 @@ fegetexcept(void)
 	 */
 	__fnstcw(&control);
 
-	return (control & FE_ALL_EXCEPT);
+	return (~control & FE_ALL_EXCEPT);
 }
 

Reply via email to