diff options
author | 2011-05-25 21:28:43 +0000 | |
---|---|---|
committer | 2011-05-25 21:28:43 +0000 | |
commit | 939fdbfbefbedcc482706073c233c6a468ca2169 (patch) | |
tree | 3bd709d8b20f1a72bf52e3d4309828ff2a949f17 /lib/libm/man | |
parent | On PowerPC we cannot manipulate FPSCR[VX]--it's a summary of all (diff) | |
download | wireguard-openbsd-939fdbfbefbedcc482706073c233c6a468ca2169.tar.xz wireguard-openbsd-939fdbfbefbedcc482706073c233c6a468ca2169.zip |
Document C99 floating-point environment.
Diffstat (limited to 'lib/libm/man')
-rw-r--r-- | lib/libm/man/feclearexcept.3 | 170 | ||||
-rw-r--r-- | lib/libm/man/feenableexcept.3 | 87 | ||||
-rw-r--r-- | lib/libm/man/fegetenv.3 | 127 | ||||
-rw-r--r-- | lib/libm/man/fegetround.3 | 81 |
4 files changed, 465 insertions, 0 deletions
diff --git a/lib/libm/man/feclearexcept.3 b/lib/libm/man/feclearexcept.3 new file mode 100644 index 00000000000..9a6eaf6a500 --- /dev/null +++ b/lib/libm/man/feclearexcept.3 @@ -0,0 +1,170 @@ +.\" $OpenBSD: feclearexcept.3,v 1.1 2011/05/25 21:28:43 martynas Exp $ +.\" +.\" Copyright (c) 2011 Martynas Venckus <martynas@openbsd.org> +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: May 25 2011 $ +.Dt FECLEAREXCEPT 3 +.Os +.Sh NAME +.Nm feclearexcept , +.Nm fegetexceptflag , +.Nm feraiseexcept , +.Nm fesetexceptflag , +.Nm fetestexcept +.Nd access floating-point status flags +.Sh SYNOPSIS +.Fd #include <fenv.h> +.Ft int +.Fn feclearexcept "int excepts" +.Ft int +.Fn fegetexceptflag "fexcept_t *flagp" "int excepts" +.Ft int +.Fn feraiseexcept "int excepts" +.Ft int +.Fn fesetexceptflag "const fexcept_t *flagp" "int excepts" +.Ft int +.Fn fetestexcept "int excepts" +.Sh DESCRIPTION +These functions provide access to the floating-point status flags. +The +.Fa excepts +input argument is a bitmask specifying an exception type and +containing any of the values listed below. +.Bl -tag -width ".Dv FE_DIVBYZERO" +.It Dv FE_DIVBYZERO +A divide-by-zero exception occurs when the program attempts to +divide a finite non-zero number by zero. +.It Dv FE_INEXACT +An inexact exception is raised whenever there is a loss of precision +due to rounding. +.It Dv FE_INVALID +Invalid operation exceptions occur when a program attempts to +perform calculations for which there is no reasonable representable +answer. + +For instance, subtraction of infinities, division of zero by zero, +ordered comparison involving \*(Nas, and taking the square root of a +negative number are all invalid operations. +.It Dv FE_OVERFLOW +An overflow exception occurs when the magnitude of the result of a +computation is too large to fit in the destination type. +.It Dv FE_UNDERFLOW +Underflow occurs when the result of a computation is too close to zero +to be represented as a non-zero value in the destination type. +.It Dv FE_DENORMAL +Denormalization exception occurs when the result of a floating-point +expression is a denormalized number. + +This is available only on the floating-point implementations of +amd64 and i386 processors. +.El +.Pp +Additionally, the macro +.Dv FE_ALL_EXCEPT +is simply the bitwise OR of all floating-point exception macros +listed above. +.Pp +The +.Fn feclearexcept +function clears the floating-point exceptions represented by +.Fa excepts . +.Pp +The +.Fn fegetexceptflag +function stores representation of the states of the floating-point +flags indicated by +.Pa excepts +in the object pointed to by +.Pa flagp . +.Pp +The +.Fn feraiseexcept +funtion raises floating-point exceptions represented by +.Pa excepts . +.Pp +The +.Fn fesetexceptflag +function sets the floating-point status flags indicated by +.Pa excepts +to the states stored in the object pointed to by +.Pa flagp . +The value of +.Pa flagp +shall have been set by a previous call to +.Fn fegetexceptflag +whose second argument represented at least those floating-point +exceptions represented by +.Pa excepts . +This function does not raise floating-point exceptions, but only +sets the state of the flags. +.Pp +The +.Fn fetesteexcept +function determines which of a specified subset of the floating-point +exception flags are currently set. +The +.Pa excepts +specifies the floating-point status flags to be queried. +.Sh RETURN VALUES +The +.Fn feclearexcept , +.Fn fegetexceptflag , +.Fn feraiseexcept , +and +.Fn fesetexceptflag +functions return zero on success, and non-zero if an error occurred. +The +.Fn fetestexcept +function returns bitmask of a specified subset of the floating-point +exception flags are currently set. +.Sh SEE ALSO +.Xr fegetround 3 , +.Xr fegetenv 3 , +.Xr feenableexcept 3 +.Sh STANDARDS +The +.Fn feclearexcept , +.Fn fegetexceptflag , +.Fn feraiseexcept , +.Fn fesetexceptflag , +and +.Fn fetestexcept +functions conform to +.St -isoC-99 . +.Pp +The return types for +.Fn feclearexcept , +.Fn fegetexceptflag , +.Fn feraiseexcept , +and +.Fn fesetexceptflag +are +.Vt int +for alignment with +.St -isoC-99 +Defect Report #202. +.Sh HISTORY +These functions first appeared in +.Ox 5.0 . +.Sh CAVEATS +On some architectures, +.Fn feraiseexcept +function additionally raises the +.Dq inexact +floating-point exception whenever it raises the +.Dq overflow +or +.Dq underflow +floating-point exception. diff --git a/lib/libm/man/feenableexcept.3 b/lib/libm/man/feenableexcept.3 new file mode 100644 index 00000000000..d550c6575eb --- /dev/null +++ b/lib/libm/man/feenableexcept.3 @@ -0,0 +1,87 @@ +.\" $OpenBSD: feenableexcept.3,v 1.1 2011/05/25 21:28:43 martynas Exp $ +.\" +.\" Copyright (c) 2011 Martynas Venckus <martynas@openbsd.org> +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: May 25 2011 $ +.Dt FEENABLEEXCEPT 3 +.Os +.Sh NAME +.Nm feenableexcept , +.Nm fedisableexcept , +.Nm fegetexcept +.Nd control floating-point exception masks +.Sh SYNOPSIS +.Fd #include <fenv.h> +.Ft int +.Fn feenableexcept "int excepts" +.Ft int +.Fn fedisableexcept "int excepts" +.Ft int +.Fn fegetexcept void +.Sh DESCRIPTION +These functions provide control of the floating-point exception +masks. +The +.Fa excepts +input argument is a bitmask specifying an exception type and +containing any of the values listed in +.Xr feclearexcept 3 . +.El +.Pp +The +.Fn feenableexcept +function unmasks the floating-point exceptions represented by +.Fa excepts . +The future floating-point operations that produce +.Fa excepts +will trap, and a +.Dv SIGFPE +will be delivered to the process. +.Pp +The +.Fn fedisableexcept +function masks the floating-point exceptions represented by +.Fa excepts . +All exceptions are masked by default. +.Pp +The +.Fn fegetexcept +function returns the current exception mask. +.Sh RETURN VALUES +The +.Fn feenableexcept , +and +.Fn fedisableexcept +functions return the previous exception mask. +The +.Fn fegetexcept +function returns the current exception mask. +.Sh SEE ALSO +.Xr sigaction 2 , +.Xr feclearexcept 3 , +.Xr fegetround 3 , +.Xr fegetenv 3 +.Sh STANDARDS +The +.Fn feenableexcept , +.Fn fedisableexcept , +and +.Fn fegetexcept +functions are +.Ox +extensions. +.Sh HISTORY +These functions first appeared in +.Ox 5.0 . diff --git a/lib/libm/man/fegetenv.3 b/lib/libm/man/fegetenv.3 new file mode 100644 index 00000000000..cb6553e5c63 --- /dev/null +++ b/lib/libm/man/fegetenv.3 @@ -0,0 +1,127 @@ +.\" $OpenBSD: fegetenv.3,v 1.1 2011/05/25 21:28:43 martynas Exp $ +.\" +.\" Copyright (c) 2011 Martynas Venckus <martynas@openbsd.org> +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: May 25 2011 $ +.Dt FEGETENV 3 +.Os +.Sh NAME +.Nm fegetenv , +.Nm feholdexcept , +.Nm fesetenv , +.Nm feupdateenv +.Nd manage floating-point environment +.Sh SYNOPSIS +.Fd #include <fenv.h> +.Ft int +.Fn fegetenv "fenv_t *envp" +.Ft int +.Fn feholdexcept "fenv_t *envp" +.Ft int +.Fn fesetenv "const fenv_t *envp" +.Ft int +.Fn feupdateenv "const fenv_t *envp" +.Sh DESCRIPTION +These functions manage the floating-point environment -- status +flags, rounding direction modes and exception masks -- as one entity. +The +.Fa envp +input argument is an object representing floating-point environment. +The macro +.Dv FE_DFL_ENV +represents the default floating-point environment -- the one installed +at program startup. +.Pp +The +.Fn fegetenv +function stores the current floating-point environment in the object +pointed to by +.Pa envp . +.Pp +The +.Fn feholdexcept +function saves the current floating-point environment in the object +pointed to by +.Pa envp , +clears the floating-point status flags, and then installs a non-stop +(continue on floating-point exceptions) mode for all floating-point +exceptions. +.Pp +The +.Fn fesetenv +function establishes the floating-point environment represented by +the object pointed to by +.Pa envp . +The argument +.Pa envp +shall point to an object set by a call to +.Fn fegetenv +or +.Fn feholdexcept , +or equal the macro +.Dv FE_DFL_ENV . +Note that +.Fn fesetenv +merely installs the state of the floating-point status flags +represented through its argument, and does not raise these +floating-point exceptions. +.Pp +The +.Fn feupdateenv +function saves the currently raised floating-point exceptions in +its automatic storage, installs the floating-point environment +represented by the object pointed to by +.Pa envp , +and then raises the saved floating-point exceptions. +The argument +.Pa envp +shall point to an object set by a call to +.Fn feholdexcept +or +.Fn fegetenv , +or equal the macro +.Dv FE_DFL_ENV . +.Sh RETURN VALUES +The +.Fn fegetenv , +.Fn feholdexcept , +.Fn fesetenv , +and +.Fn feupdateenv +functions return zero on success, and non-zero if an error occurred. +.Sh SEE ALSO +.Xr feclearexcept 3 , +.Xr fegetround 3 , +.Xr feenableexcept 3 +.Sh STANDARDS +The +.Fn fegetenv , +.Fn feholdexcept , +.Fn fesetenv , +and +.Fn feupdateenv +functions conform to +.St -isoC-99 . +.Pp +The return types for +.Fn fegetenv , +.Fn fesetenv , +and +.Fn feupdateenv +are +.Vt int +for alignment with +.St -isoC-99 +Defect Report #202. diff --git a/lib/libm/man/fegetround.3 b/lib/libm/man/fegetround.3 new file mode 100644 index 00000000000..1f93010feef --- /dev/null +++ b/lib/libm/man/fegetround.3 @@ -0,0 +1,81 @@ +.\" $OpenBSD: fegetround.3,v 1.1 2011/05/25 21:28:43 martynas Exp $ +.\" +.\" Copyright (c) 2011 Martynas Venckus <martynas@openbsd.org> +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: May 25 2011 $ +.Dt FEGETROUND 3 +.Os +.Sh NAME +.Nm fegetround , +.Nm fesetround +.Nd control floating-point rounding direction modes +.Sh SYNOPSIS +.Fd #include <fenv.h> +.Ft int +.Fn fegetround void +.Ft int +.Fn fesetround "int round" +.Sh DESCRIPTION +These functions provide control of floating-point rounding direction +modes. +The +.Fa round +input argument is a value specifying a rounding direction mode and +containing any of the values listed below. +.Bl -tag -width ".Dv FE_TOWARDZERO" +.It Dv FE_TONEAREST +Results are rounded to the closest representable value. +If the exact result is exactly half way between two representable +values, the value whose last binary digit is even (zero) is chosen. +This is the default mode. +.It Dv FE_DOWNWARD +Results are rounded towards negative \*[If]. +.It Dv FE_UPWARD +Results are rounded towards positive \*[If]. +.It Dv FE_TOWARDZERO +Results are rounded towards zero. +.El +.Pp +The +.Fn fegetround +function gets the current rounding direction. +.Pp +The +.Fn fesetround +function establishes the rounding direction represented by +.Pa round . +If the argument is not equal to the value of a rounding direction +macro, the rounding direction is not changed. +.Sh RETURN VALUES +The +.Fn fegetround +function returns the current rounding direction. +The +.Fn fesetround +function return zero on success, and non-zero if an error occurred. +.Sh SEE ALSO +.Xr feclearexcept 3 , +.Xr fegetenv 3 , +.Xr feenableexcept 3 +.Sh STANDARDS +The +.Fn fegetround , +and +.Fn fesetround +functions conform to +.St -isoC-99 . +.Sh HISTORY +These functions first appeared in +.Ox 5.0 . |