Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src add fpgetprec/fpsetprec



details:   https://anonhg.NetBSD.org/src/rev/a394dddf9f87
branches:  trunk
changeset: 763581:a394dddf9f87
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Mar 26 19:51:41 2011 +0000

description:
add fpgetprec/fpsetprec

diffstat:

 include/ieeefp.h                      |  23 +++++++---
 lib/libc/arch/i386/gen/Makefile.inc   |   5 +-
 lib/libc/arch/i386/gen/fpgetprec.S    |  22 +++++++++
 lib/libc/arch/i386/gen/fpsetprec.S    |  34 +++++++++++++++
 lib/libc/arch/x86_64/gen/Makefile.inc |   5 +-
 lib/libc/arch/x86_64/gen/fpgetprec.S  |  25 +++++++++++
 lib/libc/arch/x86_64/gen/fpsetprec.S  |  39 +++++++++++++++++
 lib/libc/gen/Makefile.inc             |   5 +-
 lib/libc/gen/fpgetmask.3              |  78 ++++++++++++++++++++++++----------
 lib/libc/include/namespace.h          |   4 +-
 10 files changed, 203 insertions(+), 37 deletions(-)

diffs (truncated from 377 to 300 lines):

diff -r 08ef90fca4ac -r a394dddf9f87 include/ieeefp.h
--- a/include/ieeefp.h  Sat Mar 26 17:55:05 2011 +0000
+++ b/include/ieeefp.h  Sat Mar 26 19:51:41 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ieeefp.h,v 1.7 2005/11/18 20:02:59 christos Exp $      */
+/*     $NetBSD: ieeefp.h,v 1.8 2011/03/26 19:51:59 christos Exp $      */
 
 /* 
  * Written by J.T. Conklin, Apr 6, 1995
@@ -12,12 +12,21 @@
 #include <machine/ieeefp.h>
 
 __BEGIN_DECLS
-fp_rnd    fpgetround(void);
-fp_rnd    fpsetround(fp_rnd);
-fp_except fpgetmask(void);
-fp_except fpsetmask(fp_except);
-fp_except fpgetsticky(void);
-fp_except fpsetsticky(fp_except);
+typedef fp_rnd fp_rnd_t;
+typedef fp_prec fp_prec_t;
+typedef fp_except fp_except_t;
+
+fp_rnd_t       fpgetround(void);
+fp_rnd_t       fpsetround(fp_rnd_t);
+#ifdef _X86_IEEEFP_H_  /* XXX */
+fp_prec_t      fpgetprec(void);
+fp_prec_t      fpsetprec(fp_prec_t);
+#endif
+fp_except_t    fpgetmask(void);
+fp_except_t    fpsetmask(fp_except_t);
+fp_except_t    fpgetsticky(void);
+fp_except_t    fpsetsticky(fp_except_t);
+fp_except_t    fpresetsticky(fp_except_t);
 __END_DECLS
 
 #endif /* _IEEEFP_H_ */
diff -r 08ef90fca4ac -r a394dddf9f87 lib/libc/arch/i386/gen/Makefile.inc
--- a/lib/libc/arch/i386/gen/Makefile.inc       Sat Mar 26 17:55:05 2011 +0000
+++ b/lib/libc/arch/i386/gen/Makefile.inc       Sat Mar 26 19:51:41 2011 +0000
@@ -1,9 +1,10 @@
-#      $NetBSD: Makefile.inc,v 1.26 2009/12/06 07:12:17 uebayasi Exp $
+#      $NetBSD: Makefile.inc,v 1.27 2011/03/26 19:51:41 christos Exp $
 
 # objects built from assembler sources (need lint stubs)
 SRCS+= alloca.S byte_swap_2.S byte_swap_4.S fabs.S \
        flt_rounds.S fpgetmask.S fpgetround.S fpgetsticky.S \
-       fpsetmask.S fpsetround.S fpsetsticky.S 
+       fpsetmask.S fpsetround.S fpsetsticky.S fpgetprec.S \
+       fpsetprec.S
 
 SRCS+= setjmp.S _setjmp.S sigsetjmp.S
 
diff -r 08ef90fca4ac -r a394dddf9f87 lib/libc/arch/i386/gen/fpgetprec.S
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/arch/i386/gen/fpgetprec.S        Sat Mar 26 19:51:41 2011 +0000
@@ -0,0 +1,22 @@
+/*     $NetBSD: fpgetprec.S,v 1.1 2011/03/26 19:51:41 christos Exp $   */
+
+/*
+ * Written by J.T. Conklin, Apr 4, 1995
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#ifdef WEAK_ALIAS
+WEAK_ALIAS(fpgetprec, _fpgetprec)
+ENTRY(_fpgetprec)
+#else
+ENTRY(fpgetprec)
+#endif
+       subl $4,%esp
+       fnstcw (%esp)
+       movl (%esp),%eax
+       rorl $8,%eax
+       andl $3,%eax
+       addl $4,%esp
+       ret
diff -r 08ef90fca4ac -r a394dddf9f87 lib/libc/arch/i386/gen/fpsetprec.S
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/arch/i386/gen/fpsetprec.S        Sat Mar 26 19:51:41 2011 +0000
@@ -0,0 +1,34 @@
+/*     $NetBSD: fpsetprec.S,v 1.1 2011/03/26 19:51:41 christos Exp $   */
+
+/*
+ * Written by Charles M. Hannum, Apr 9, 1995
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#ifdef WEAK_ALIAS
+WEAK_ALIAS(fpsetprec, _fpsetprec)
+ENTRY(_fpsetprec)
+#else
+ENTRY(fpsetprec)
+#endif
+       subl $4,%esp
+
+       fnstcw (%esp)
+       movl (%esp),%eax
+
+       rorl $8,%eax
+       movl %eax,%edx
+       andl $3,%eax
+
+       subl %eax,%edx
+       movl 8(%esp),%ecx
+       andl $3,%ecx
+       orl %ecx,%edx
+       roll $8,%edx
+       movl %edx,(%esp)
+       fldcw (%esp)
+
+       addl $4,%esp
+       ret
diff -r 08ef90fca4ac -r a394dddf9f87 lib/libc/arch/x86_64/gen/Makefile.inc
--- a/lib/libc/arch/x86_64/gen/Makefile.inc     Sat Mar 26 17:55:05 2011 +0000
+++ b/lib/libc/arch/x86_64/gen/Makefile.inc     Sat Mar 26 19:51:41 2011 +0000
@@ -1,9 +1,10 @@
-#      $NetBSD: Makefile.inc,v 1.15 2010/01/14 02:09:46 joerg Exp $
+#      $NetBSD: Makefile.inc,v 1.16 2011/03/26 19:51:42 christos Exp $
 
 # objects built from assembler sources (need lint stubs)
 SRCS+= alloca.S byte_swap_2.S byte_swap_4.S byte_swap_8.S fabs.S \
        flt_rounds.S fpgetmask.S fpgetround.S fpgetsticky.S \
-       fpsetmask.S fpsetround.S fpsetsticky.S 
+       fpsetmask.S fpsetround.S fpsetsticky.S fpgetprec.S \
+       fpsetprec.S
 
 SRCS+= __setjmp14.S
 SRCS+= _setjmp.S
diff -r 08ef90fca4ac -r a394dddf9f87 lib/libc/arch/x86_64/gen/fpgetprec.S
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/arch/x86_64/gen/fpgetprec.S      Sat Mar 26 19:51:41 2011 +0000
@@ -0,0 +1,25 @@
+/*     $NetBSD: fpgetprec.S,v 1.1 2011/03/26 19:51:42 christos Exp $   */
+
+/*
+ * Written by J.T. Conklin, Apr 4, 1995
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+/*
+ * XXX store only x87 state. If an application only uses the fp*
+ * interface, this should be in sync with the SSE mxcsr register.
+ */
+
+#ifdef WEAK_ALIAS
+WEAK_ALIAS(fpgetprec, _fpgetprec)
+ENTRY(_fpgetprec)
+#else
+ENTRY(fpgetprec)
+#endif
+       fnstcw -4(%rsp)
+       movl -4(%rsp),%eax
+       rorl $8,%eax
+       andl $3,%eax
+       ret
diff -r 08ef90fca4ac -r a394dddf9f87 lib/libc/arch/x86_64/gen/fpsetprec.S
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/arch/x86_64/gen/fpsetprec.S      Sat Mar 26 19:51:41 2011 +0000
@@ -0,0 +1,39 @@
+/*     $NetBSD: fpsetprec.S,v 1.1 2011/03/26 19:51:42 christos Exp $   */
+
+/*
+ * Written by Frank van der Linden at Wasabi Systems for NetBSD.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+/*
+ * XXX set both the x87 control word and the SSE mxcsr register.
+ * Applications should only set exception and round flags
+ * via the fp*() interface, otherwise the status words
+ * will get our of sync.
+ */ 
+
+
+#ifdef WEAK_ALIAS
+WEAK_ALIAS(fpsetprec, _fpsetprec)
+ENTRY(_fpsetprec)
+#else
+ENTRY(fpsetprec)
+#endif
+       fnstcw  -4(%rsp)
+
+       andl    $3,%edi
+
+       movl    -4(%rsp),%edx
+       rorl    $8,%edx
+       movl    %edx,%eax
+       andl    $3,%eax
+
+       andl    $~3,%edx
+       orl     %edi,%edx
+       roll    $8,%edx
+       movl    %edx,-4(%rsp)
+
+       fldcw   -4(%rsp)
+       ret
diff -r 08ef90fca4ac -r a394dddf9f87 lib/libc/gen/Makefile.inc
--- a/lib/libc/gen/Makefile.inc Sat Mar 26 17:55:05 2011 +0000
+++ b/lib/libc/gen/Makefile.inc Sat Mar 26 19:51:41 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.inc,v 1.177 2011/03/16 01:30:24 erh Exp $
+#      $NetBSD: Makefile.inc,v 1.178 2011/03/26 19:51:42 christos Exp $
 #      from: @(#)Makefile.inc  8.6 (Berkeley) 5/4/95
 
 # gen sources
@@ -96,7 +96,8 @@
        extattr.3 extattr_string_to_namespace.3
 MLINKS+=fpgetmask.3 fpgetround.3 fpgetmask.3 fpgetsticky.3 \
        fpgetmask.3 fpsetmask.3  fpgetmask.3 fpsetround.3 \
-       fpgetmask.3 fpsetsticky.3
+       fpgetmask.3 fpsetsticky.3 fpgetmask.3 fpgetprec.3 \
+       fpgetmask.3 fpsetprec.3
 MLINKS+=fts.3 fts_open.3 fts.3 fts_read.3 fts.3 fts_children.3 \
        fts.3 fts_set.3 fts.3 fts_close.3
 MLINKS+=ftw.3 nftw.3
diff -r 08ef90fca4ac -r a394dddf9f87 lib/libc/gen/fpgetmask.3
--- a/lib/libc/gen/fpgetmask.3  Sat Mar 26 17:55:05 2011 +0000
+++ b/lib/libc/gen/fpgetmask.3  Sat Mar 26 19:51:41 2011 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: fpgetmask.3,v 1.10 2008/04/30 13:10:50 martin Exp $
+.\"    $NetBSD: fpgetmask.3,v 1.11 2011/03/26 19:51:42 christos Exp $
 .\"
 .\" Copyright (c) 1999 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,14 +27,16 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd April 4, 2004
+.Dd March 26, 2011
 .Dt FPGETMASK 3
 .Os
 .Sh NAME
 .Nm fpgetmask ,
+.Nm fpgetprec ,
 .Nm fpgetround ,
 .Nm fpgetsticky ,
 .Nm fpsetmask ,
+.Nm fpsetprec ,
 .Nm fpsetround ,
 .Nm fpsetsticky
 .Nd IEEE FP mode control
@@ -42,35 +44,37 @@
 .Lb libc
 .Sh SYNOPSIS
 .In ieeefp.h
-.Ft fp_except
+.Ft fp_except_t
 .Fn fpgetmask void
-.Ft fp_rnd
+.Ft fp_prec_t
+.Fn fpgetprec void
+.Ft fp_rnd_t
 .Fn fpgetround void
-.Ft fp_except
+.Ft fp_except_t
 .Fn fpgetsticky void
-.Ft fp_except
-.Fn fpsetmask fp_except\ mask
-.Ft fp_rnd
-.Fn fpsetround fp_rnd\ rnd_dir
-.Ft fp_except
-.Fn fpsetsticky fp_except\ sticky
+.Ft fp_except_t
+.Fn fpsetmask "fp_except_t mask"
+.Ft fp_prec_t
+.Fn fpsetprec "fp_prec_t prec"
+.Ft fp_rnd_t
+.Fn fpsetround "fp_rnd_t rnd_dir"
+.Ft fp_except_t
+.Fn fpsetsticky "fp_except_t sticky"
 .Sh DESCRIPTION
-A rounding mode is one of
-.Dv FP_RZ , FP_RM , FP_RN ,
-or
-.Dv FP_RP ,
-for rounding towards zero, rounding
-.Pq Em Minus infinity
-down, rounding to
-.Em nearest ,
-and rounding
-.Pq Em Plus infinity
-up.
+A rounding mode 
+.Ft fp_rnd_t
+is one of:
+.Bl -column -offset indent FP_RZ
+.It Dv FP_RZ Ta rounding towards Em zero
+.It Dv FP_RM Ta rounding down to Pq Em Minus infinity
+.It Dv FP_RN Ta rounding to Em nearest
+.It Dv FP_RP Ta rounding down to Pq Em Plus infinity



Home | Main Index | Thread Index | Old Index