Root/
Source at commit 1270 created 12 years 11 months ago. By meklort, Add arm headers. update makefiles | |
---|---|
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 | /* We require VFP for this set of interfaces to work */␊ |
35 | #if !defined(__VFP_FP__) || defined(__SOFTFP__)␊ |
36 | ␉#warning The <fenv.h> functions are not supported on platforms that do not have hardware floating-point.␊ |
37 | #else␊ |
38 | ␊ |
39 | #ifdef __cplusplus␊ |
40 | extern "C" {␊ |
41 | #endif␊ |
42 | ␊ |
43 | /*␊ |
44 | A collection of functions designed to provide access to the floating␊ |
45 | point environment for numerical programming. It is compliant with␊ |
46 | the floating-point requirements in C99.␊ |
47 | ␊ |
48 | The file <fenv.h> declares many functions in support of numerical␊ |
49 | programming. Programs that test flags or run under␊ |
50 | non-default modes must do so under the effect of an enabling␊ |
51 | "fenv_access" pragma:␊ |
52 | ␊ |
53 | #pragma STDC FENV_ACCESS on␊ |
54 | ␊ |
55 | Note that prior to iPhone OS 2.0, these interfaces did nothing.␊ |
56 | */␊ |
57 | ␊ |
58 | /********************************************************************************␊ |
59 | * *␊ |
60 | * fenv_t is a type for representing the entire floating-point *␊ |
61 | * environment in a single object. *␊ |
62 | * *␊ |
63 | * fexcept_t is a type for representing the floating-point *␊ |
64 | * exception flag state collectively. *␊ |
65 | * *␊ |
66 | ********************************************************************************/␊ |
67 | ␊ |
68 | ␊ |
69 | ␊ |
70 | typedef struct {␊ |
71 | union␊ |
72 | {␊ |
73 | struct␊ |
74 | {␊ |
75 | unsigned int __fpscr; ␊ |
76 | unsigned int __reserved0;␊ |
77 | unsigned int __reserved1;␊ |
78 | unsigned int __reserved2;␊ |
79 | };␊ |
80 | #if defined( __GNUC__ )␊ |
81 | struct␊ |
82 | {␊ |
83 | unsigned int __fpscr_cmp_n : 1;␊ |
84 | unsigned int __fpscr_cmp_z : 1;␊ |
85 | unsigned int __fpscr_cmp_c : 1;␊ |
86 | unsigned int __fpscr_cmp_v : 1;␊ |
87 | unsigned int __fpscr_do_not_modify_1 : 2; /* Should be zero */␊ |
88 | unsigned int __fpscr_default_nan_mode : 1;␊ |
89 | unsigned int __fpscr_flush_to_zero : 1;␊ |
90 | unsigned int __fpscr_rounding_mode : 2;␊ |
91 | unsigned int __fpscr_stride : 2;␊ |
92 | unsigned int __fpscr_do_not_modify_2 : 1; /* Should be zero */␊ |
93 | unsigned int __fpscr_len : 3 ;␊ |
94 | unsigned int __fpscr_trap_enable_subnormal : 1 ; /* Note: we run under "Run Fast Mode". Setting this bit has undefined results. */␊ |
95 | unsigned int __fpscr_do_not_modfify_3 : 2; /* Should be zero */␊ |
96 | unsigned int __fpscr_trap_enable_inexact : 1; /* Note: we run under "Run Fast Mode". Setting this bit has undefined results. */␊ |
97 | unsigned int __fpscr_trap_enable_underflow : 1; /* Note: we run under "Run Fast Mode". Setting this bit has undefined results. */␊ |
98 | unsigned int __fpscr_trap_enable_overflow : 1; /* Note: we run under "Run Fast Mode". Setting this bit has undefined results. */␊ |
99 | unsigned int __fpscr_trap_enable_div_by_zero : 1; /* Note: we run under "Run Fast Mode". Setting this bit has undefined results. */␊ |
100 | unsigned int __fpscr_trap_enable_invalid : 1; /* Note: we run under "Run Fast Mode". Setting this bit has undefined results. */␊ |
101 | unsigned int __fpscr_fp_state_flag_subnormal : 1;␊ |
102 | unsigned int __fpscr_do_not_modify_4 : 2; /* Should be zero */␊ |
103 | unsigned int __fpscr_fp_state_flag_inexact : 1;␊ |
104 | unsigned int __fpscr_fp_state_flag_underflow : 1;␊ |
105 | unsigned int __fpscr_fp_state_flag_overflow : 1;␊ |
106 | unsigned int __fpscr_fp_state_flag_div_by_zero : 1;␊ |
107 | unsigned int __fpscr_fp_state_flag_invalid : 1;␊ |
108 | } __attribute((packed));␊ |
109 | #endif␊ |
110 | };␊ |
111 | } fenv_t;␊ |
112 | ␊ |
113 | typedef unsigned short fexcept_t;␊ |
114 | ␊ |
115 | /* Definitions of floating-point exception macros */␊ |
116 | #define FE_INEXACT 0x0010␊ |
117 | #define FE_UNDERFLOW 0x0008␊ |
118 | #define FE_OVERFLOW 0x0004␊ |
119 | #define FE_DIVBYZERO 0x0002␊ |
120 | #define FE_INVALID 0x0001␊ |
121 | #define FE_ALL_EXCEPT 0x001F␊ |
122 | ␊ |
123 | /* Definitions of rounding direction macros */␊ |
124 | #define FE_TONEAREST 0x00000000␊ |
125 | #define FE_UPWARD 0x00400000␊ |
126 | #define FE_DOWNWARD 0x00800000␊ |
127 | #define FE_TOWARDZERO 0x00C00000␊ |
128 | ␊ |
129 | /* default environment object */␊ |
130 | extern const fenv_t _FE_DFL_ENV;␊ |
131 | #define FE_DFL_ENV &_FE_DFL_ENV /* pointer to default environment */␊ |
132 | ␊ |
133 | ␊ |
134 | /*******************************************************************************␊ |
135 | * The following functions provide high level access to the exception flags.* ␊ |
136 | * The "int" input argument can be constructed by bitwise ORs of the *␊ |
137 | * exception macros: for example: FE_OVERFLOW | FE_INEXACT. *␊ |
138 | *******************************************************************************/␊ |
139 | ␊ |
140 | /*******************************************************************************␊ |
141 | * The function "feclearexcept" clears the supported floating point *␊ |
142 | * exceptions represented by its argument. *␊ |
143 | *******************************************************************************/␊ |
144 | ␊ |
145 | extern int feclearexcept(int /*excepts*/);␊ |
146 | ␊ |
147 | ␊ |
148 | /*******************************************************************************␊ |
149 | * The function "fegetexceptflag" stores a implementation-defined *␊ |
150 | * representation of the states of the floating-point status flags indicated *␊ |
151 | * by its integer argument excepts in the object pointed to by the argument, * ␊ |
152 | * flagp. *␊ |
153 | *******************************************************************************/␊ |
154 | ␊ |
155 | extern int fegetexceptflag(fexcept_t * /*flagp*/, int /*excepts*/);␊ |
156 | ␊ |
157 | ␊ |
158 | /*******************************************************************************␊ |
159 | * The function "feraiseexcept" raises the supported floating-point *␊ |
160 | * exceptions represented by its argument. The order in which these *␊ |
161 | * floating-point exceptions are raised is unspecified. *␊ |
162 | *******************************************************************************/␊ |
163 | ␊ |
164 | extern int feraiseexcept(int /*excepts*/);␊ |
165 | ␊ |
166 | ␊ |
167 | /*******************************************************************************␊ |
168 | * The function "fesetexceptflag" sets or clears the floating point status *␊ |
169 | * flags indicated by the argument excepts to the states stored in the *␊ |
170 | * object pointed to by flagp. The value of the *flagp shall have been set *␊ |
171 | * by a previous call to fegetexceptflag whose second argument represented *␊ |
172 | * at least those floating-point exceptions represented by the argument *␊ |
173 | * excepts. This function does not raise floating-point exceptions; it just *␊ |
174 | * sets the state of the flags. *␊ |
175 | *******************************************************************************/␊ |
176 | ␊ |
177 | extern int fesetexceptflag(const fexcept_t * /*flagp*/, int /*excepts*/);␊ |
178 | ␊ |
179 | ␊ |
180 | /*******************************************************************************␊ |
181 | * The function "fetestexcept" determines which of the specified subset of *␊ |
182 | * the floating-point exception flags are currently set. The excepts *␊ |
183 | * argument specifies the floating-point status flags to be queried. This *␊ |
184 | * function returns the value of the bitwise OR of the floating-point *␊ |
185 | * exception macros corresponding to the currently set floating-point *␊ |
186 | * exceptions included in excepts. *␊ |
187 | * *␊ |
188 | *******************************************************************************/␊ |
189 | ␊ |
190 | extern int fetestexcept(int /*excepts*/);␊ |
191 | ␊ |
192 | ␊ |
193 | /*******************************************************************************␊ |
194 | * The following functions provide control of rounding direction modes. *␊ |
195 | *******************************************************************************/␊ |
196 | ␊ |
197 | /*******************************************************************************␊ |
198 | * The function "fegetround" returns the value of the rounding direction *␊ |
199 | * macro which represents the current rounding direction, or a negative *␊ |
200 | * if there is no such rounding direction macro or the current rounding *␊ |
201 | * direction is not determinable. *␊ |
202 | *******************************************************************************/␊ |
203 | ␊ |
204 | extern int fegetround(void);␊ |
205 | ␊ |
206 | ␊ |
207 | /*******************************************************************************␊ |
208 | * The function "fesetround" establishes the rounding direction represented *␊ |
209 | * by its argument "round". If the argument is not equal to the value of a *␊ |
210 | * rounding direction macro, the rounding direction is not changed. It *␊ |
211 | * returns zero if and only if the argument is equal to a rounding *␊ |
212 | * direction macro. *␊ |
213 | *******************************************************************************/␊ |
214 | ␊ |
215 | extern int fesetround(int /*round*/);␊ |
216 | ␊ |
217 | ␊ |
218 | /*******************************************************************************␊ |
219 | * The following functions manage the floating-point environment, exception *␊ |
220 | * flags and dynamic modes, as one entity. *␊ |
221 | *******************************************************************************/␊ |
222 | ␊ |
223 | /*******************************************************************************␊ |
224 | * The fegetenv function stores the current floating-point enviornment in *␊ |
225 | * the object pointed to by envp. *␊ |
226 | *******************************************************************************/␊ |
227 | extern int fegetenv(fenv_t * /*envp*/);␊ |
228 | ␊ |
229 | /*******************************************************************************␊ |
230 | * The feholdexcept function saves the current floating-point environment in *␊ |
231 | * the object pointed to by envp, clears the floating-point status flags, *␊ |
232 | * and then installs a non-stop (continue on floating-point exceptions) *␊ |
233 | * mode, if available, for all floating-point exceptions. The feholdexcept *␊ |
234 | * function returns zero if and only if non-stop floating-point exceptions *␊ |
235 | * handling was successfully installed. *␊ |
236 | *******************************************************************************/␊ |
237 | extern int feholdexcept(fenv_t * /*envp*/);␊ |
238 | ␊ |
239 | /*******************************************************************************␊ |
240 | * The fesetnv function establishes the floating-point environment *␊ |
241 | * represented by the object pointed to by envp. The argument envp shall *␊ |
242 | * point to an object set by a call to fegetenv or feholdexcept, or equal to *␊ |
243 | * a floating-point environment macro -- we define only *FE_DFL_ENV and *␊ |
244 | * FE_DISABLE_SSE_DENORMS_ENV -- to be C99 standard compliant and portable *␊ |
245 | * to other architectures. Note that fesetnv merely installs the state of *␊ |
246 | * the floating-point status flags represented through its argument, and *␊ |
247 | * does not raise these floating-point exceptions. *␊ |
248 | *******************************************************************************/␊ |
249 | extern int fesetenv(const fenv_t * /*envp*/);␊ |
250 | ␊ |
251 | /*******************************************************************************␊ |
252 | * The feupdateenv function saves the currently raised floating-point *␊ |
253 | * exceptions in its automatic storage, installs the floating-point *␊ |
254 | * environment represented by the object pointed to by envp, and then raises *␊ |
255 | * the saved floating-point exceptions. The argument envp shall point to an *␊ |
256 | * object set by a call to feholdexcept or fegetenv or equal a *␊ |
257 | * floating-point environment macro. *␊ |
258 | *******************************************************************************/␊ |
259 | extern int feupdateenv(const fenv_t * /*envp*/);␊ |
260 | ␊ |
261 | #ifdef __cplusplus␊ |
262 | }␊ |
263 | #endif␊ |
264 | ␊ |
265 | #endif // HARDWARE FP␊ |
266 | ␊ |
267 | #endif /* __FENV__ */␊ |
268 | ␊ |
269 |