]> git.ipfire.org Git - thirdparty/glibc.git/blame - math/fenv.h
Update.
[thirdparty/glibc.git] / math / fenv.h
CommitLineData
4d3a563f 1/* Copyright (C) 1997, 1999 Free Software Foundation, Inc.
63551311
UD
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
18
19/*
63ae7b63 20 * ISO C99 7.6: Floating-point environment <fenv.h>
63551311
UD
21 */
22
23#ifndef _FENV_H
779ae82e 24#define _FENV_H 1
5107cf1d 25
63551311
UD
26#include <features.h>
27
28/* Get the architecture dependend definitions. The following definitions
29 are expected to be done:
30
31 fenv_t type for object representing an entire floating-point
32 environment
33
34 FE_DFL_ENV macro of type pointer to fenv_t to be used as the argument
35 to functions taking an argument of type fenv_t; in this
36 case the default environment will be used
37
38 fexcept_t type for object representing the floating-point exception
39 flags including status associated with the flags
40
41 The following macros are defined iff the implementation supports this
42 kind of exception.
779ae82e 43 FE_INEXACT inexact result
63551311
UD
44 FE_DIVBYZERO devision by zero
45 FE_UNDERFLOW result not representable due to underflow
46 FE_OVERFLOW result not representable due to overflow
47 FE_INVALID invalid operation
48
49 FE_ALL_EXCEPT bitwise OR of all supported exceptions
50
51 The next macros are defined iff the appropriate rounding mode is
52 supported by the implementation.
53 FE_TONEAREST round to nearest
54 FE_UPWARD round toward +Inf
55 FE_DOWNWARD round toward -Inf
56 FE_TOWARDZERO round toward 0
57*/
5107cf1d 58#include <bits/fenv.h>
63551311
UD
59
60__BEGIN_DECLS
61
62/* Floating-point exception handling. */
63
64/* Clear the supported exceptions represented by EXCEPTS. */
63ae7b63 65extern int feclearexcept (int __excepts) __THROW;
63551311
UD
66
67/* Store implementation-defined representation of the exception flags
68 indicated by EXCEPTS in the object pointed to by FLAGP. */
63ae7b63 69extern int fegetexceptflag (fexcept_t *__flagp, int __excepts) __THROW;
63551311
UD
70
71/* Raise the supported exceptions represented by EXCEPTS. */
63ae7b63 72extern int feraiseexcept (int __excepts) __THROW;
63551311 73
1f205a47 74/* Set complete status for exceptions indicated by EXCEPTS according to
63551311 75 the representation in the object pointed to by FLAGP. */
63ae7b63 76extern int fesetexceptflag (__const fexcept_t *__flagp, int __excepts) __THROW;
63551311
UD
77
78/* Determine which of subset of the exceptions specified by EXCEPTS are
79 currently set. */
4d3a563f 80extern int fetestexcept (int __excepts) __THROW;
63551311
UD
81
82
83/* Rounding control. */
84
85/* Get current rounding direction. */
4d3a563f 86extern int fegetround (void) __THROW;
63551311
UD
87
88/* Establish the rounding direction represented by ROUND. */
4d3a563f 89extern int fesetround (int __rounding_direction) __THROW;
63551311
UD
90
91
92/* Floating-point environment. */
93
94/* Store the current floating-point environment in the object pointed
95 to by ENVP. */
63ae7b63 96extern int fegetenv (fenv_t *__envp) __THROW;
63551311
UD
97
98/* Save the current environment in the object pointed to by ENVP, clear
99 exception flags and install a non-stop mode (if available) for all
100 exceptions. */
4d3a563f 101extern int feholdexcept (fenv_t *__envp) __THROW;
63551311
UD
102
103/* Establish the floating-point environment represented by the object
104 pointed to by ENVP. */
63ae7b63 105extern int fesetenv (__const fenv_t *__envp) __THROW;
63551311
UD
106
107/* Save current exceptions in temporary storage, install environment
108 represented by object pointed to by ENVP and raise exceptions
109 according to saved exceptions. */
63ae7b63 110extern int feupdateenv (__const fenv_t *__envp) __THROW;
63551311 111
7ad6d73d
UD
112
113/* Include optimization. */
114#ifdef __OPTIMIZE__
115# include <bits/fenvinline.h>
116#endif
117
05ef7ce9
UD
118#ifdef __USE_GNU
119
120/* Enable individual exceptions. Will not enable more exceptions than
121 EXCEPTS specifies. Returns the previous enabled exceptions if all
122 exceptions are successfull set, otherwise returns -1. */
123extern int feenableexcept (int __excepts) __THROW;
124
125/* Disable individual exceptions. Will not disable more exceptions than
126 EXCEPTS specifies. Returns the previous enabled exceptions if all
127 exceptions are successfull disabled, otherwise returns -1. */
128extern int fedisableexcept (int __excepts) __THROW;
129
130/* Return enabled exceptions. */
131extern int fegetexcept (void) __THROW;
132#endif
133
63551311
UD
134__END_DECLS
135
136#endif /* fenv.h */