Floating point exceptions with -pthread

Marc Olzheim marcolz at stack.nl
Wed May 4 16:02:29 PDT 2005


On Thu, May 05, 2005 at 12:32:13AM +0200, Marc Olzheim wrote:
> That fixed it for me indeed. :-P

I've applied the attached patch on my systems.

Question remains why the truncf() doesn't trigger it and the ceilf() and
floorf() does.
And why it only triggers with threads (even a single thread is enough).

Marc
-------------- next part --------------
Index: lib/msun/i387/s_ceilf.S
--- lib/msun/i387/s_ceilf.S.orig	Thu Jan 13 19:58:25 2005
+++ lib/msun/i387/s_ceilf.S	Thu May  5 00:54:18 2005
@@ -13,17 +13,17 @@
 	movl	%esp,%ebp
 	subl	$8,%esp
 
-	fstcw	-12(%ebp)		/* store fpu control word */
-	movw	-12(%ebp),%dx
+	fstcw	-4(%ebp)		/* store fpu control word */
+	movw	-4(%ebp),%dx
 	orw	$0x0800,%dx		/* round towards +oo */
 	andw	$0xfbff,%dx
-	movw	%dx,-16(%ebp)
-	fldcw	-16(%ebp)		/* load modfied control word */
+	movw	%dx,-8(%ebp)
+	fldcw	-8(%ebp)		/* load modfied control word */
 
 	flds	8(%ebp);		/* round */
 	frndint
 
-	fldcw	-12(%ebp)		/* restore original control word */
+	fldcw	-4(%ebp)		/* restore original control word */
 
 	leave
 	ret
Index: lib/msun/i387/s_floorf.S
--- lib/msun/i387/s_floorf.S.orig	Thu Jan 13 19:58:25 2005
+++ lib/msun/i387/s_floorf.S	Thu May  5 00:54:29 2005
@@ -13,17 +13,17 @@
 	movl	%esp,%ebp
 	subl	$8,%esp
 
-	fstcw	-12(%ebp)		/* store fpu control word */
-	movw	-12(%ebp),%dx
+	fstcw	-4(%ebp)		/* store fpu control word */
+	movw	-4(%ebp),%dx
 	orw	$0x0400,%dx		/* round towards -oo */
 	andw	$0xf7ff,%dx
-	movw	%dx,-16(%ebp)
-	fldcw	-16(%ebp)		/* load modfied control word */
+	movw	%dx,-8(%ebp)
+	fldcw	-8(%ebp)		/* load modfied control word */
 
 	flds	8(%ebp);		/* round */
 	frndint
 
-	fldcw	-12(%ebp)		/* restore original control word */
+	fldcw	-4(%ebp)		/* restore original control word */
 
 	leave
 	ret
Index: lib/msun/i387/s_truncf.S
--- lib/msun/i387/s_truncf.S.orig	Sat Apr 16 23:12:55 2005
+++ lib/msun/i387/s_truncf.S	Thu May  5 00:54:35 2005
@@ -11,16 +11,16 @@
 	movl	%esp,%ebp
 	subl	$8,%esp
 
-	fstcw	-12(%ebp)		/* store fpu control word */
-	movw	-12(%ebp),%dx
+	fstcw	-4(%ebp)		/* store fpu control word */
+	movw	-4(%ebp),%dx
 	orw	$0x0c00,%dx		/* round towards -oo */
-	movw	%dx,-16(%ebp)
-	fldcw	-16(%ebp)		/* load modfied control word */
+	movw	%dx,-8(%ebp)
+	fldcw	-8(%ebp)		/* load modfied control word */
 
 	flds	8(%ebp)			/* round */
 	frndint
 
-	fldcw	-12(%ebp)		/* restore original control word */
+	fldcw	-4(%ebp)		/* restore original control word */
 
 	leave
 	ret
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-threads/attachments/20050505/dbba2446/attachment.bin


More information about the freebsd-threads mailing list