Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/arch/i386/gen make rounding work
details: https://anonhg.NetBSD.org/src/rev/26f50a34a554
branches: trunk
changeset: 770026:26f50a34a554
user: christos <christos%NetBSD.org@localhost>
date: Fri Sep 30 23:42:00 2011 +0000
description:
make rounding work
diffstat:
lib/libc/arch/i386/gen/flt_rounds.S | 10 ++++++----
lib/libc/arch/i386/gen/fpgetround.S | 15 ++++++++-------
lib/libc/arch/i386/gen/fpsetround.S | 35 +++++++++++++++++------------------
3 files changed, 31 insertions(+), 29 deletions(-)
diffs (111 lines):
diff -r 12224e240681 -r 26f50a34a554 lib/libc/arch/i386/gen/flt_rounds.S
--- a/lib/libc/arch/i386/gen/flt_rounds.S Fri Sep 30 22:17:50 2011 +0000
+++ b/lib/libc/arch/i386/gen/flt_rounds.S Fri Sep 30 23:42:00 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: flt_rounds.S,v 1.8 2011/09/29 22:53:13 christos Exp $ */
+/* $NetBSD: flt_rounds.S,v 1.9 2011/09/30 23:42:00 christos Exp $ */
#include <machine/asm.h>
@@ -12,8 +12,10 @@
_ALIGN_TEXT
ENTRY(__flt_rounds)
fnstcw -4(%esp)
- movl -4(%esp), %eax
- shrl $10, %eax
+ movl -4(%esp), %ecx
+ shrl $9, %ecx
+ andl $6, %ecx
+ movl $0x2d, %eax /* 0x2d = 00.10.11.01 */
+ sarl %cl, %eax /* 0,1,2,3 -> 1,3,2,0 */
andl $3, %eax
- xorl $1, %eax /* map 0,1,2,3 -> 1,0,3,2 */
ret
diff -r 12224e240681 -r 26f50a34a554 lib/libc/arch/i386/gen/fpgetround.S
--- a/lib/libc/arch/i386/gen/fpgetround.S Fri Sep 30 22:17:50 2011 +0000
+++ b/lib/libc/arch/i386/gen/fpgetround.S Fri Sep 30 23:42:00 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fpgetround.S,v 1.5 2002/01/13 21:45:43 thorpej Exp $ */
+/* $NetBSD: fpgetround.S,v 1.6 2011/09/30 23:42:00 christos Exp $ */
/*
* Written by J.T. Conklin, Apr 4, 1995
@@ -7,16 +7,17 @@
#include <machine/asm.h>
+/*
+ * XXX load only x87 state.
+ */
+
#ifdef WEAK_ALIAS
WEAK_ALIAS(fpgetround, _fpgetround)
ENTRY(_fpgetround)
#else
ENTRY(fpgetround)
#endif
- subl $4,%esp
- fnstcw (%esp)
- movl (%esp),%eax
- rorl $10,%eax
- andl $3,%eax
- addl $4,%esp
+ fnstcw -4(%esp)
+ movl -4(%esp), %eax
+ andl $0x00000c00, %eax
ret
diff -r 12224e240681 -r 26f50a34a554 lib/libc/arch/i386/gen/fpsetround.S
--- a/lib/libc/arch/i386/gen/fpsetround.S Fri Sep 30 22:17:50 2011 +0000
+++ b/lib/libc/arch/i386/gen/fpsetround.S Fri Sep 30 23:42:00 2011 +0000
@@ -1,34 +1,33 @@
-/* $NetBSD: fpsetround.S,v 1.3 2002/01/13 21:45:43 thorpej Exp $ */
+/* $NetBSD: fpsetround.S,v 1.4 2011/09/30 23:42:00 christos Exp $ */
/*
- * Written by Charles M. Hannum, Apr 9, 1995
+ * Written by Frank van der Linden at Wasabi Systems for NetBSD.
* Public domain.
*/
#include <machine/asm.h>
+/*
+ * XXX set both the x87 control word
+ * Applications should only set exception and round flags
+ */
+
+
#ifdef WEAK_ALIAS
WEAK_ALIAS(fpsetround, _fpsetround)
ENTRY(_fpsetround)
#else
ENTRY(fpsetround)
#endif
- subl $4,%esp
-
- fnstcw (%esp)
- movl (%esp),%eax
-
- rorl $10,%eax
- movl %eax,%edx
- andl $3,%eax
- subl %eax,%edx
- movl 8(%esp),%ecx
- andl $3,%ecx
- orl %ecx,%edx
- roll $10,%edx
- movl %edx,(%esp)
- fldcw (%esp)
+ fnstcw -4(%esp)
+ movl -4(%esp), %edx
+ movl %edx, %eax
+ andl $0x00000c00, %eax
+ andl $0xfffff3ff, %edx
+ movl 4(%esp), %edi
+ orl %edi, %edx
+ movl %edx, -4(%esp)
+ fldcw -4(%esp)
- addl $4,%esp
ret
Home |
Main Index |
Thread Index |
Old Index