xref: /netbsd-src/lib/libc/gen/fpgetmask.3 (revision b1c86f5f087524e68db12794ee9c3e3da1ab17a0)
1.\"	$NetBSD: fpgetmask.3,v 1.10 2008/04/30 13:10:50 martin 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.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28.\" POSSIBILITY OF SUCH DAMAGE.
29.\"
30.Dd April 4, 2004
31.Dt FPGETMASK 3
32.Os
33.Sh NAME
34.Nm fpgetmask ,
35.Nm fpgetround ,
36.Nm fpgetsticky ,
37.Nm fpsetmask ,
38.Nm fpsetround ,
39.Nm fpsetsticky
40.Nd IEEE FP mode control
41.Sh LIBRARY
42.Lb libc
43.Sh SYNOPSIS
44.In ieeefp.h
45.Ft fp_except
46.Fn fpgetmask void
47.Ft fp_rnd
48.Fn fpgetround void
49.Ft fp_except
50.Fn fpgetsticky void
51.Ft fp_except
52.Fn fpsetmask fp_except\ mask
53.Ft fp_rnd
54.Fn fpsetround fp_rnd\ rnd_dir
55.Ft fp_except
56.Fn fpsetsticky fp_except\ sticky
57.Sh DESCRIPTION
58A rounding mode is one of
59.Dv FP_RZ , FP_RM , FP_RN ,
60or
61.Dv FP_RP ,
62for rounding towards zero, rounding
63.Pq Em Minus infinity
64down, rounding to
65.Em nearest ,
66and rounding
67.Pq Em Plus infinity
68up.
69The default mode is
70.Dv FP_RN .
71.Pp
72An
73.Ft fp_except
74value is a bitmask specifying an exception type and containing any of
75the values listed below.
76.Bl -column -offset indent FP_X_UFLxx
77.It Dv FP_X_INV Ta Invalid\ Operation
78.It Dv FP_X_DZ Ta Division\ by\ zero
79.It Dv FP_X_OFL Ta Overflow
80.It Dv FP_X_UFL Ta Underflow
81.It Dv FP_X_IMP Ta Imprecision (inexact)
82.It Dv FP_X_IOV Ta Integer\ Overflow
83.El
84.Pp
85The
86.Fn fpsetmask
87function will set the current exception mask, i.e., it will cause
88future operations with the specified result status to raise the
89.Dv SIGFPE
90exception.
91The
92.Fn fpgetmask
93function will return the current exception mask.
94.Pp
95The
96.Fn fpsetround
97function will cause future operations to use the specified dynamic
98rounding mode.
99The
100.Fn fpgetround
101function will return the current rounding 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.
107On other architectures, these features may not be fully supported.
108.El
109.Pp
110A
111.Dq sticky
112status word may be maintained in which a bit is set every time an
113exceptional floating point condition is encountered, whether or not a
114.Dv SIGFPE
115is generated.
116The
117.Fn fpsetsticky
118function will set or clear the specified exception history bits.
119The
120.Fn fpgetsticky
121function will return the exception history bits.
122.Sh RETURN VALUES
123The
124.Fn fpgetround
125and
126.Fn fpsetround
127functions return the
128.Pq previous
129rounding mode.
130The
131.Fn fpgetmask ,
132.Fn fpsetmask ,
133.Fn fpgetsticky ,
134and
135.Fn fpsetsticky
136functions return the
137.Pq previous
138exception mask and exception history bits.
139.Sh SEE ALSO
140.Xr sigaction 2
141