xref: /netbsd-src/lib/libc/gen/fpgetmask.3 (revision 3b01aba77a7a698587faaae455bbfe740923c1f5)
1.\"	$NetBSD: fpgetmask.3,v 1.1 1999/04/30 00:58:31 ross Exp $
2.\"
3.\" Copyright (c) 1999 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Ross Harvey.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\" 3. All advertising materials mentioning features or use of this software
18.\"    must display the following acknowledgement:
19.\"        This product includes software developed by the NetBSD
20.\"        Foundation, Inc. and its contributors.
21.\" 4. Neither the name of The NetBSD Foundation nor the names of its
22.\"    contributors may be used to endorse or promote products derived
23.\"    from this software without specific prior written permission.
24.\"
25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35.\" POSSIBILITY OF SUCH DAMAGE.
36.\"
37.Dd April 29, 1999
38.Dt FPGETMASK 3
39.Os
40.Sh NAME
41.Nm fpgetmask ,
42.Nm fpgetround ,
43.Nm fpgetsticky ,
44.Nm fpsetmask ,
45.Nm fpsetround ,
46.Nm fpsetsticky
47.Nd IEEE FP mode control
48.Sh LIBRARY
49.Lb libc
50.Sh SYNOPSIS
51.Fd #include <ieeefp.h>
52.Ft fp_except
53.Fn fpgetmask void
54.Ft fp_rnd
55.Fn fpgetround void
56.Ft fp_except
57.Fn fpgetsticky void
58.Ft fp_except
59.Fn fpsetmask fp_except\ mask
60.Ft fp_rnd
61.Fn fpsetround fp_rnd\ rnd_dir
62.Ft fp_except
63.Fn fpsetsticky fp_except\ sticky
64.Sh DESCRIPTION
65A rounding mode is one of
66.Dv FP_RZ , FP_RM , FP_RN ,
67or
68.Dv FP_RP ,
69for rounding towards zero, rounding
70.Pq Em Minus infinity
71down, rounding to
72.Em nearest ,
73and rounding
74.Pq Em Plus infinity
75up.
76The default mode is
77.Dv FP_RN .
78.Pp
79An
80.Ft fp_except
81value is a bitmask specifying an exception type and containing any of
82the values listed below.
83.Bl -column -offset indent FP_X_UFLxx
84.It Dv FP_X_INV Ta Invalid\ Operation
85.It Dv FP_X_DZ Ta Division\ by\ zero
86.It Dv FP_X_OFL Ta Overflow
87.It Dv FP_X_UFL Ta Underflow
88.It Dv FP_X_IMP Ta Imprecision (inexact)
89.It Dv FP_X_IOV Ta Integer\ Overflow
90.El
91.Pp
92.Pp
93The
94.Fn fpsetmask
95function will cause future operations with the specified result status to
96raise the
97.Dv SIGFPE
98exception.
99The
100.Fn fpsetround
101function will cause future operations to use the specified dynamic mode.
102.Bl -tag -width Note:x
103.It Em Note:
104On some architectures, instructions can optionally specify static
105rounding modes and exception enables that will supersede the specified
106dynamic mode. On other architectures, these features may not be fully
107supported.
108.El
109.Pp
110The
111.Fn fpsetsticky
112function will set or clear the specified exception history bits.
113.Sh RETURN VALUES
114The
115.Fn fpgetround
116and
117.Fn fpsetround
118functions return the
119.Pq previous
120rounding mode.
121The
122.Fn fpgetmask ,
123.Fn fpsetmask ,
124.Fn fpgetsticky ,
125and
126.Fn fpsetsticky
127functions return the
128.Pq previous
129exception mask and exception history bits.
130.Sh SEE ALSO
131.Xr sigaction 2
132