Module Name: src
Committed By: christos
Date: Sat Mar 26 19:51:42 UTC 2011
Modified Files:
src/lib/libc/arch/i386/gen: Makefile.inc
src/lib/libc/arch/x86_64/gen: Makefile.inc
src/lib/libc/gen: Makefile.inc fpgetmask.3
src/lib/libc/include: namespace.h
Added Files:
src/lib/libc/arch/i386/gen: fpgetprec.S fpsetprec.S
src/lib/libc/arch/x86_64/gen: fpgetprec.S fpsetprec.S
Log Message:
add fpgetprec/fpsetprec
To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/lib/libc/arch/i386/gen/Makefile.inc
cvs rdiff -u -r0 -r1.1 src/lib/libc/arch/i386/gen/fpgetprec.S \
src/lib/libc/arch/i386/gen/fpsetprec.S
cvs rdiff -u -r1.15 -r1.16 src/lib/libc/arch/x86_64/gen/Makefile.inc
cvs rdiff -u -r0 -r1.1 src/lib/libc/arch/x86_64/gen/fpgetprec.S \
src/lib/libc/arch/x86_64/gen/fpsetprec.S
cvs rdiff -u -r1.177 -r1.178 src/lib/libc/gen/Makefile.inc
cvs rdiff -u -r1.10 -r1.11 src/lib/libc/gen/fpgetmask.3
cvs rdiff -u -r1.147 -r1.148 src/lib/libc/include/namespace.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libc/arch/i386/gen/Makefile.inc
diff -u src/lib/libc/arch/i386/gen/Makefile.inc:1.26 src/lib/libc/arch/i386/gen/Makefile.inc:1.27
--- src/lib/libc/arch/i386/gen/Makefile.inc:1.26 Sun Dec 6 02:12:17 2009
+++ src/lib/libc/arch/i386/gen/Makefile.inc Sat Mar 26 15:51:41 2011
@@ -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
Index: src/lib/libc/arch/x86_64/gen/Makefile.inc
diff -u src/lib/libc/arch/x86_64/gen/Makefile.inc:1.15 src/lib/libc/arch/x86_64/gen/Makefile.inc:1.16
--- src/lib/libc/arch/x86_64/gen/Makefile.inc:1.15 Wed Jan 13 21:09:46 2010
+++ src/lib/libc/arch/x86_64/gen/Makefile.inc Sat Mar 26 15:51:42 2011
@@ -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
Index: src/lib/libc/gen/Makefile.inc
diff -u src/lib/libc/gen/Makefile.inc:1.177 src/lib/libc/gen/Makefile.inc:1.178
--- src/lib/libc/gen/Makefile.inc:1.177 Tue Mar 15 21:30:24 2011
+++ src/lib/libc/gen/Makefile.inc Sat Mar 26 15:51:42 2011
@@ -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
Index: src/lib/libc/gen/fpgetmask.3
diff -u src/lib/libc/gen/fpgetmask.3:1.10 src/lib/libc/gen/fpgetmask.3:1.11
--- src/lib/libc/gen/fpgetmask.3:1.10 Wed Apr 30 09:10:50 2008
+++ src/lib/libc/gen/fpgetmask.3 Sat Mar 26 15:51:42 2011
@@ -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
+.El
The default mode is
.Dv FP_RN .
.Pp
An
-.Ft fp_except
+.Ft fp_except_t
value is a bitmask specifying an exception type and containing any of
the values listed below.
.Bl -column -offset indent FP_X_UFLxx
@@ -82,6 +86,16 @@
.It Dv FP_X_IOV Ta Integer\ Overflow
.El
.Pp
+An
+.Ft fp_prec_t
+specifies the precision of the floating point operations listed below.
+.Bl -column -offset indent FP_RPS
+.It Dv FP_PS Ta Dv 24 bit (single-precision)
+.It Dv FP_PRS Ta reserved
+.It Dv FP_PD Ta Dv 53 bit (double-precision)
+.It Dv FP_PE Ta Dv 64 bit (extended-precision)
+.El
+.Pp
The
.Fn fpsetmask
function will set the current exception mask, i.e., it will cause
@@ -92,6 +106,14 @@
.Fn fpgetmask
function will return the current exception mask.
.Pp
+The
+.Fn fpgetprec
+function will return the current floating point precision.
+The
+.Fn fpsetprec
+function will set the floating point precision and will return
+the previous precision.
+.Pp
The
.Fn fpsetround
function will cause future operations to use the specified dynamic
@@ -138,3 +160,13 @@
exception mask and exception history bits.
.Sh SEE ALSO
.Xr sigaction 2
+.Xr fenv 3
+.Sh BUGS
+There is no way to return an unsupported value.
+Not all processors support all the modes.
+These interfaces are deprecated and the ones
+in
+.Xr fenv 3
+should be used, although the interfaces in
+.Xr fenv 3
+don't support getting or setting the precision.
Index: src/lib/libc/include/namespace.h
diff -u src/lib/libc/include/namespace.h:1.147 src/lib/libc/include/namespace.h:1.148
--- src/lib/libc/include/namespace.h:1.147 Sat Mar 12 14:52:48 2011
+++ src/lib/libc/include/namespace.h Sat Mar 26 15:51:42 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: namespace.h,v 1.147 2011/03/12 19:52:48 christos Exp $ */
+/* $NetBSD: namespace.h,v 1.148 2011/03/26 19:51:42 christos Exp $ */
/*-
* Copyright (c) 1997-2004 The NetBSD Foundation, Inc.
@@ -265,9 +265,11 @@
#define fnmatch _fnmatch
#define fparseln _fparseln
#define fpgetmask _fpgetmask
+#define fpgetprec _fpgetprec
#define fpgetround _fpgetround
#define fpgetsticky _fpgetsticky
#define fpsetmask _fpsetmask
+#define fpsetprec _fpsetprec
#define fpsetround _fpsetround
#define fpsetsticky _fpsetsticky
#define freenetconfigent _freenetconfigent
Added files:
Index: src/lib/libc/arch/i386/gen/fpgetprec.S
diff -u /dev/null src/lib/libc/arch/i386/gen/fpgetprec.S:1.1
--- /dev/null Sat Mar 26 15:51:43 2011
+++ src/lib/libc/arch/i386/gen/fpgetprec.S Sat Mar 26 15:51:41 2011
@@ -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
Index: src/lib/libc/arch/i386/gen/fpsetprec.S
diff -u /dev/null src/lib/libc/arch/i386/gen/fpsetprec.S:1.1
--- /dev/null Sat Mar 26 15:51:43 2011
+++ src/lib/libc/arch/i386/gen/fpsetprec.S Sat Mar 26 15:51:41 2011
@@ -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
Index: src/lib/libc/arch/x86_64/gen/fpgetprec.S
diff -u /dev/null src/lib/libc/arch/x86_64/gen/fpgetprec.S:1.1
--- /dev/null Sat Mar 26 15:51:43 2011
+++ src/lib/libc/arch/x86_64/gen/fpgetprec.S Sat Mar 26 15:51:42 2011
@@ -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
Index: src/lib/libc/arch/x86_64/gen/fpsetprec.S
diff -u /dev/null src/lib/libc/arch/x86_64/gen/fpsetprec.S:1.1
--- /dev/null Sat Mar 26 15:51:43 2011
+++ src/lib/libc/arch/x86_64/gen/fpsetprec.S Sat Mar 26 15:51:42 2011
@@ -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