1.\" $NetBSD: fpgetmask.3,v 1.9 2004/04/04 23:41:23 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 4, 2004 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.In 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 92The 93.Fn fpsetmask 94function will set the current exception mask, i.e., it will cause 95future operations with the specified result status to raise the 96.Dv SIGFPE 97exception. 98The 99.Fn fpgetmask 100function will return the current exception mask. 101.Pp 102The 103.Fn fpsetround 104function will cause future operations to use the specified dynamic 105rounding mode. 106The 107.Fn fpgetround 108function will return the current rounding mode. 109.Bl -tag -width Note:x 110.It Em Note : 111On some architectures, instructions can optionally specify static 112rounding modes and exception enables that will supersede the specified 113dynamic mode. 114On other architectures, these features may not be fully supported. 115.El 116.Pp 117A 118.Dq sticky 119status word may be maintained in which a bit is set every time an 120exceptional floating point condition is encountered, whether or not a 121.Dv SIGFPE 122is generated. 123The 124.Fn fpsetsticky 125function will set or clear the specified exception history bits. 126The 127.Fn fpgetsticky 128function will return the exception history bits. 129.Sh RETURN VALUES 130The 131.Fn fpgetround 132and 133.Fn fpsetround 134functions return the 135.Pq previous 136rounding mode. 137The 138.Fn fpgetmask , 139.Fn fpsetmask , 140.Fn fpgetsticky , 141and 142.Fn fpsetsticky 143functions return the 144.Pq previous 145exception mask and exception history bits. 146.Sh SEE ALSO 147.Xr sigaction 2 148