xref: /freebsd-src/lib/msun/man/feclearexcept.3 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
107235cc8SDavid Schultz.\" Copyright (c) 2004 David Schultz <das@FreeBSD.org>
207235cc8SDavid Schultz.\" All rights reserved.
307235cc8SDavid Schultz.\"
407235cc8SDavid Schultz.\" Redistribution and use in source and binary forms, with or without
507235cc8SDavid Schultz.\" modification, are permitted provided that the following conditions
607235cc8SDavid Schultz.\" are met:
707235cc8SDavid Schultz.\" 1. Redistributions of source code must retain the above copyright
807235cc8SDavid Schultz.\"    notice, this list of conditions and the following disclaimer.
907235cc8SDavid Schultz.\" 2. Redistributions in binary form must reproduce the above copyright
1007235cc8SDavid Schultz.\"    notice, this list of conditions and the following disclaimer in the
1107235cc8SDavid Schultz.\"    documentation and/or other materials provided with the distribution.
1207235cc8SDavid Schultz.\"
1307235cc8SDavid Schultz.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1407235cc8SDavid Schultz.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1507235cc8SDavid Schultz.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1607235cc8SDavid Schultz.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1707235cc8SDavid Schultz.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1807235cc8SDavid Schultz.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1907235cc8SDavid Schultz.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2007235cc8SDavid Schultz.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2107235cc8SDavid Schultz.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2207235cc8SDavid Schultz.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2307235cc8SDavid Schultz.\" SUCH DAMAGE.
2407235cc8SDavid Schultz.\"
2507235cc8SDavid Schultz.Dd May 8, 2004
2607235cc8SDavid Schultz.Dt FECLEAREXCEPT 3
2707235cc8SDavid Schultz.Os
2807235cc8SDavid Schultz.Sh NAME
2907235cc8SDavid Schultz.Nm feclearexcept ,
3007235cc8SDavid Schultz.Nm fegetexceptflag ,
3107235cc8SDavid Schultz.Nm feraiseexcept ,
3207235cc8SDavid Schultz.Nm fesetexceptflag ,
3307235cc8SDavid Schultz.Nm fetestexcept
3407235cc8SDavid Schultz.Nd floating-point exception flag manipulation
3507235cc8SDavid Schultz.Sh LIBRARY
3607235cc8SDavid Schultz.Lb libm
3707235cc8SDavid Schultz.Sh SYNOPSIS
3807235cc8SDavid Schultz.In fenv.h
3907235cc8SDavid Schultz.Fd "#pragma STDC FENV_ACCESS ON"
4007235cc8SDavid Schultz.Ft int
4107235cc8SDavid Schultz.Fn feclearexcept "int excepts"
4207235cc8SDavid Schultz.Ft int
4307235cc8SDavid Schultz.Fn fegetexceptflag "fexcept_t *flagp" "int excepts"
4407235cc8SDavid Schultz.Ft int
4507235cc8SDavid Schultz.Fn feraiseexcept "int excepts"
4607235cc8SDavid Schultz.Ft int
4707235cc8SDavid Schultz.Fn fesetexceptflag "const fexcept_t *flagp" "int excepts"
4807235cc8SDavid Schultz.Ft int
4907235cc8SDavid Schultz.Fn fetestexcept "int excepts"
5007235cc8SDavid Schultz.Sh DESCRIPTION
5107235cc8SDavid SchultzThe
5207235cc8SDavid Schultz.Fn feclearexcept
5307235cc8SDavid Schultzroutine clears the floating-point exception flags specified by
5407235cc8SDavid Schultz.Fa excepts ,
5507235cc8SDavid Schultzwhereas
5607235cc8SDavid Schultz.Fn feraiseexcept
5707235cc8SDavid Schultzraises the specified exceptions.
5807235cc8SDavid SchultzRaising an exception causes the corresponding flag to be set,
59*e880667bSRuslan Ermilovand a
60*e880667bSRuslan Ermilov.Dv SIGFPE
61*e880667bSRuslan Ermilovis delivered to the process if the exception is unmasked.
6207235cc8SDavid Schultz.Pp
6307235cc8SDavid SchultzThe
6407235cc8SDavid Schultz.Fn fetestexcept
6507235cc8SDavid Schultzfunction determines which flags are currently set, of those specified by
6607235cc8SDavid Schultz.Fa excepts .
6707235cc8SDavid Schultz.Pp
6807235cc8SDavid SchultzThe
6907235cc8SDavid Schultz.Fn fegetexceptflag
7007235cc8SDavid Schultzfunction stores the state of the exception flags specified in
7107235cc8SDavid Schultz.Fa excepts
7207235cc8SDavid Schultzin the opaque object pointed to by
7307235cc8SDavid Schultz.Fa flagp .
7407235cc8SDavid SchultzSimilarly,
7507235cc8SDavid Schultz.Fn fesetexceptflag
7607235cc8SDavid Schultzchanges the specified exception flags to reflect the state stored in
7707235cc8SDavid Schultzthe object pointed to by
7807235cc8SDavid Schultz.Fa flagp .
7907235cc8SDavid SchultzNote that the flags restored with
8007235cc8SDavid Schultz.Fn fesetexceptflag
8107235cc8SDavid Schultzmust be a (not necessarily proper) subset of the flags recorded by
8207235cc8SDavid Schultza prior call to
8307235cc8SDavid Schultz.Fn fegetexceptflag .
8407235cc8SDavid Schultz.Pp
8507235cc8SDavid SchultzFor all of these functions, the possible types of exceptions
8607235cc8SDavid Schultzinclude those described in
8707235cc8SDavid Schultz.Xr fenv 3 .
8807235cc8SDavid SchultzSome architectures may define other types of floating-point exceptions.
8907235cc8SDavid Schultz.Sh IMPLEMENTATION NOTES
9007235cc8SDavid SchultzOn some architectures, raising an overflow or underflow exception
9107235cc8SDavid Schultzalso causes an inexact exception to be raised.
9207235cc8SDavid SchultzIn these cases, the overflow or underflow will be raised first.
9307235cc8SDavid Schultz.Pp
9407235cc8SDavid SchultzThe
9507235cc8SDavid Schultz.Fn fegetexceptflag
9607235cc8SDavid Schultzand
9707235cc8SDavid Schultz.Fn fesetexceptflag
9807235cc8SDavid Schultzroutines are preferred to
9907235cc8SDavid Schultz.Fn fetestexcept
10007235cc8SDavid Schultzand
10107235cc8SDavid Schultz.Fn feraiseexcept ,
10207235cc8SDavid Schultzrespectively, for saving and restoring exception flags.
10307235cc8SDavid SchultzThe latter do not re-raise exceptions and may preserve
10407235cc8SDavid Schultzarchitecture-specific information such as addresses where
10507235cc8SDavid Schultzexceptions occurred.
10607235cc8SDavid Schultz.Sh RETURN VALUES
10707235cc8SDavid SchultzThe
10807235cc8SDavid Schultz.Fn feclearexcept ,
10907235cc8SDavid Schultz.Fn fegetexceptflag ,
11007235cc8SDavid Schultz.Fn feraiseexcept ,
11107235cc8SDavid Schultzand
11207235cc8SDavid Schultz.Fn fesetexceptflag
11307235cc8SDavid Schultzfunctions return 0 upon success, and non-zero otherwise.
11407235cc8SDavid SchultzThe
11507235cc8SDavid Schultz.Fn fetestexcept
11607235cc8SDavid Schultzfunction returns the bitwise OR of the values of the current exception
11707235cc8SDavid Schultzflags that were requested.
11807235cc8SDavid Schultz.Sh SEE ALSO
11907235cc8SDavid Schultz.Xr sigaction 2 ,
12007235cc8SDavid Schultz.Xr feholdexcept 3 ,
12107235cc8SDavid Schultz.Xr fenv 3 ,
12207235cc8SDavid Schultz.Xr feupdateenv 3 ,
12307235cc8SDavid Schultz.Xr fpgetsticky 3 ,
12407235cc8SDavid Schultz.Xr fpresetsticky 3
12507235cc8SDavid Schultz.Sh STANDARDS
12607235cc8SDavid SchultzThe
12707235cc8SDavid Schultz.Fn feclearexcept ,
12807235cc8SDavid Schultz.Fn fegetexceptflag ,
12907235cc8SDavid Schultz.Fn feraiseexcept ,
13007235cc8SDavid Schultz.Fn fesetexceptflag ,
13107235cc8SDavid Schultzand
13207235cc8SDavid Schultz.Fn fetestexcept
13307235cc8SDavid Schultzroutines conform to
13407235cc8SDavid Schultz.St -isoC-99 .
13507235cc8SDavid Schultz.Sh HISTORY
13607235cc8SDavid SchultzThese functions first appeared in
13707235cc8SDavid Schultz.Fx 5.3 .
138