this repo has no description
1/*
2 * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22
23/*******************************************************************************
24* *
25* File: fenv.h *
26* *
27* Contains: typedefs and prototypes for C99 floating point environment. *
28* *
29*******************************************************************************/
30
31#ifndef __FENV__
32#define __FENV__
33
34#if defined( __i386__ ) || defined( __x86_64__ )
35 #error Wrong arch. This is PowerPC only.
36#endif
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42/*
43 A collection of functions designed to provide access to the floating
44 point environment for numerical programming. It is modeled after
45 the floating-point requirements in C9X.
46
47 The file <fenv.h> declares many functions in support of numerical
48 programming. Programs that test flags or run under
49 non-default modes must do so under the effect of an enabling
50 "fenv_access" pragma.
51*/
52
53/********************************************************************************
54* *
55* fenv_t is a type for representing the entire floating-point *
56* environment in a single object. *
57* *
58* fexcept_t is a type for representing the floating-point *
59* exception flag state collectively. *
60* *
61********************************************************************************/
62typedef unsigned int fenv_t;
63typedef unsigned int fexcept_t;
64
65/* Definitions of floating-point exception macros */
66#define FE_INEXACT 0x02000000
67#define FE_DIVBYZERO 0x04000000
68#define FE_UNDERFLOW 0x08000000
69#define FE_OVERFLOW 0x10000000
70#define FE_INVALID 0x20000000
71#define FE_ALL_EXCEPT 0x3E000000
72
73/* Definitions of rounding direction macros */
74#define FE_TONEAREST 0x00000000
75#define FE_TOWARDZERO 0x00000001
76#define FE_UPWARD 0x00000002
77#define FE_DOWNWARD 0x00000003
78
79/* default environment object */
80extern const fenv_t _FE_DFL_ENV;
81#define FE_DFL_ENV &_FE_DFL_ENV /* pointer to default environment */
82
83/*******************************************************************************
84* The following functions provide access to the exception flags. The *
85* "int" input argument can be constructed by bitwise ORs of the exception *
86* macros: for example: FE_OVERFLOW | FE_INEXACT. *
87*******************************************************************************/
88
89/*******************************************************************************
90* The function "feclearexcept" clears the supported exceptions represented *
91* by its argument. *
92*******************************************************************************/
93
94extern int feclearexcept(int);
95
96
97/*******************************************************************************
98* The function "fegetexceptflag" stores a representation of the exception *
99* flags indicated by its integer argument through the fexcept_t pointer *
100* argument. *
101*******************************************************************************/
102
103extern int fegetexceptflag(fexcept_t *, int);
104
105
106/*******************************************************************************
107* The function "feraiseexcept" raises the supported exceptions *
108* represented by its argument. *
109*******************************************************************************/
110
111extern int feraiseexcept(int);
112
113
114/*******************************************************************************
115* The function "fesetexceptflag" sets or clears the exception flags indicated *
116* by the its integer argument according to the representation in the *
117* object pointed to by the fexcept_t pointer argument. The value of the *
118* object must have been set by a previous call to "fegetexceptflag". *
119* This function does not raise exceptions; it just sets the state of *
120* the flags. *
121*******************************************************************************/
122
123extern int fesetexceptflag(const fexcept_t *, int);
124
125
126/*******************************************************************************
127* The function "fetestexcept" determines which of the specified subset of *
128* the exception flags are currently set. The integer argument specifies *
129* the exception flags to be queried as a bitwise OR of the exception *
130* macros. This function returns the bitwise OR of the exception macros *
131* corresponding to the currently set exceptions included in "excepts". *
132*******************************************************************************/
133
134extern int fetestexcept(int);
135
136
137/*******************************************************************************
138* The following functions provide control of rounding direction modes. *
139*******************************************************************************/
140
141/*******************************************************************************
142* The function "fegetround" returns the value of the rounding direction *
143* macro which represents the current rounding direction. *
144*******************************************************************************/
145
146extern int fegetround(void);
147
148
149/*******************************************************************************
150* The function "fesetround" establishes the rounding direction represented *
151* by its argument. It returns zero if and only if the argument matches *
152* a rounding direction macro. If not, the rounding direction is not *
153* changed. *
154*******************************************************************************/
155
156extern int fesetround(int);
157
158
159/*******************************************************************************
160* The following functions manage the floating-point environment, exception *
161* flags and dynamic modes, as one entity. *
162*******************************************************************************/
163
164extern int fegetenv(fenv_t *);
165extern int feholdexcept(fenv_t *);
166extern int fesetenv(const fenv_t *);
167extern int feupdateenv(const fenv_t *);
168
169
170#ifdef __cplusplus
171}
172#endif
173
174#endif /* __FENV__ */
175