xref: /netbsd/lib/libc/gen/fpgetmask.3 (revision c4a72b64)
1.\"	$NetBSD: fpgetmask.3,v 1.6 2002/10/01 16:48:34 wiz 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 \*[Lt]ieeefp.h\*[Gt]
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
92The
93.Fn fpsetmask
94function will cause future operations with the specified result status to
95raise the
96.Dv SIGFPE
97exception.
98The
99.Fn fpsetround
100function will cause future operations to use the specified dynamic mode.
101.Bl -tag -width Note:x
102.It Em Note :
103On some architectures, instructions can optionally specify static
104rounding modes and exception enables that will supersede the specified
105dynamic mode.
106On other architectures, these features may not be fully supported.
107.El
108.Pp
109The
110.Fn fpsetsticky
111function will set or clear the specified exception history bits.
112.Sh RETURN VALUES
113The
114.Fn fpgetround
115and
116.Fn fpsetround
117functions return the
118.Pq previous
119rounding mode.
120The
121.Fn fpgetmask ,
122.Fn fpsetmask ,
123.Fn fpgetsticky ,
124and
125.Fn fpsetsticky
126functions return the
127.Pq previous
128exception mask and exception history bits.
129.Sh SEE ALSO
130.Xr sigaction 2
131