Module Name: src
Committed By: riastradh
Date: Wed May 29 02:27:39 UTC 2013
Modified Files:
src/lib/libm/arch/x86_64: fenv.c
Log Message:
Fix amd64 feraiseexcept so that it actually traps.
The call to fwait got lost somewhere along the line; the i387 code
has it.
XXX pullup to 6
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 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/x86_64/fenv.c
diff -u src/lib/libm/arch/x86_64/fenv.c:1.3 src/lib/libm/arch/x86_64/fenv.c:1.4
--- src/lib/libm/arch/x86_64/fenv.c:1.3 Wed May 29 00:53:19 2013
+++ src/lib/libm/arch/x86_64/fenv.c Wed May 29 02:27:39 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: fenv.c,v 1.3 2013/05/29 00:53:19 riastradh Exp $ */
+/* $NetBSD: fenv.c,v 1.4 2013/05/29 02:27:39 riastradh 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.3 2013/05/29 00:53:19 riastradh Exp $");
+__RCSID("$NetBSD: fenv.c,v 1.4 2013/05/29 02:27:39 riastradh Exp $");
#include <assert.h>
#include <fenv.h>
@@ -58,6 +58,10 @@ __RCSID("$NetBSD: fenv.c,v 1.3 2013/05/2
#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);