1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
|
/*
File: fenv.h
Contains: Floating-Point environment for PowerPC and 68K
Version: QuickTime 7.3
Copyright: (c) 2007 (c) 1987-2001 by Apple Computer, Inc., all rights reserved.
Bugs?: For bug reports, consult the following page on
the World Wide Web:
http://developer.apple.com/bugreporter/
*/
#ifndef __FENV__
#define __FENV__
#ifndef __CONDITIONALMACROS__
#include <ConditionalMacros.h>
#endif
#if PRAGMA_ONCE
#pragma once
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if PRAGMA_IMPORT
#pragma import on
#endif
#if PRAGMA_STRUCT_ALIGN
#pragma options align=mac68k
#elif PRAGMA_STRUCT_PACKPUSH
#pragma pack(push, 2)
#elif PRAGMA_STRUCT_PACK
#pragma pack(2)
#endif
#if TARGET_RT_MAC_MACHO && defined(__MATH__)
/* these types were already defined in math.h */
#else
#if TARGET_OS_MAC
/*
A collection of functions designed to provide access to the floating
point environment for numerical programming. It is modeled after
the floating-point requirements in C9X.
The file <fenv.h> declares many functions in support of numerical
programming. It provides a set of environmental controls similar to
the ones found in <SANE.h>. Programs that test flags or run under
non-default modes must do so under the effect of an enabling
"fenv_access" pragma.
*/
/********************************************************************************
* *
* fenv_t is a type for representing the entire floating-point *
* environment in a single object. *
* *
* fexcept_t is a type for representing the floating-point *
* exception flag state collectively. *
* *
********************************************************************************/
#if TARGET_CPU_PPC
typedef long fenv_t;
typedef long fexcept_t;
/* Definitions of floating-point exception macros */
enum {
FE_INEXACT = 0x02000000,
FE_DIVBYZERO = 0x04000000,
FE_UNDERFLOW = 0x08000000,
FE_OVERFLOW = 0x10000000,
FE_INVALID = 0x20000000,
FE_ALL_EXCEPT = 0x3E000000 /* FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID*/
};
/* Definitions of rounding direction macros */
enum {
FE_TONEAREST = 0x00000000,
FE_TOWARDZERO = 0x00000001,
FE_UPWARD = 0x00000002,
FE_DOWNWARD = 0x00000003
};
#endif /* TARGET_CPU_PPC */
#if TARGET_CPU_68K
#if TARGET_RT_MAC_68881
typedef long fexcept_t;
struct fenv_t {
long FPCR;
long FPSR;
};
typedef struct fenv_t fenv_t;
enum {
FE_INEXACT = 0x00000008, /* ((long)(8)) */
FE_DIVBYZERO = 0x00000010, /* ((long)(16)) */
FE_UNDERFLOW = 0x00000020, /* ((long)(32)) */
FE_OVERFLOW = 0x00000040, /* ((long)(64)) */
FE_INVALID = 0x00000080, /* ((long)(128)) */
FE_ALL_EXCEPT = 0x000000F8 /* FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID*/
};
#else
typedef short fexcept_t;
typedef short fenv_t;
enum {
FE_INVALID = 0x0001, /* ((short)(1)) */
FE_UNDERFLOW = 0x0002, /* ((short)(2)) */
FE_OVERFLOW = 0x0004, /* ((short)(4)) */
FE_DIVBYZERO = 0x0008, /* ((short)(8)) */
FE_INEXACT = 0x0010, /* ((short)(16)) */
FE_ALL_EXCEPT = 0x001F /* FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID*/
};
#endif /* TARGET_RT_MAC_68881 */
enum {
FE_TONEAREST = 0x0000, /* ((short)(0)) */
FE_UPWARD = 0x0001, /* ((short)(1)) */
FE_DOWNWARD = 0x0002, /* ((short)(2)) */
FE_TOWARDZERO = 0x0003 /* ((short)(3)) */
};
/* Definitions of rounding precision macros (68K only) */
enum {
FE_LDBLPREC = 0x0000, /* ((short)(0)) */
FE_DBLPREC = 0x0001, /* ((short)(1)) */
FE_FLTPREC = 0x0002 /* ((short)(2)) */
};
#endif /* TARGET_CPU_68K */
/* default environment object */
/*
* _FE_DFL_ENV
*
* Availability:
* Non-Carbon CFM: in MathLib 1.0 and later
* CarbonLib: in CarbonLib 1.3 and later
* Mac OS X: in version 10.1 and later
*/
extern fenv_t _FE_DFL_ENV;
#define FE_DFL_ENV &_FE_DFL_ENV /* pointer to default environment */
/*******************************************************************************
* The following functions provide access to the exception flags. The *
* "int" input argument can be constructed by bitwise ORs of the exception *
* macros: for example: FE_OVERFLOW | FE_INEXACT. *
*******************************************************************************/
/*******************************************************************************
* The function "feclearexcept" clears the supported exceptions represented *
* by its argument. *
*******************************************************************************/
/*
* feclearexcept()
*
* Availability:
* Non-Carbon CFM: in MathLib 1.0 and later
* CarbonLib: in CarbonLib 1.0 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API_C( void ) feclearexcept(int excepts);
/*******************************************************************************
* The function "fegetexcept" stores a representation of the exception *
* flags indicated by the argument "excepts" through the pointer argument *
* "flagp". *
*******************************************************************************/
/*
* fegetexcept()
*
* Availability:
* Non-Carbon CFM: in MathLib 1.0 and later
* CarbonLib: in CarbonLib 1.0 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API_C( void ) fegetexcept(fexcept_t *flagp, int excepts);
/*******************************************************************************
* The function "feraiseexcept" raises the supported exceptions *
* represented by its argument. *
*******************************************************************************/
/*
* feraiseexcept()
*
* Availability:
* Non-Carbon CFM: in MathLib 1.0 and later
* CarbonLib: in CarbonLib 1.0 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API_C( void ) feraiseexcept(int excepts);
/*******************************************************************************
* The function "fesetexcept" sets or clears the exception flags indicated *
* by the int argument "excepts" according to the representation in the *
* object pointed to by the pointer argument "flagp". The value of *
* "*flagp" must have been set by a previous call to "fegetexcept". *
* This function does not raise exceptions; it just sets the state of *
* the flags. *
*******************************************************************************/
/*
* fesetexcept()
*
* Availability:
* Non-Carbon CFM: in MathLib 1.0 and later
* CarbonLib: in CarbonLib 1.0 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API_C( void ) fesetexcept(const fexcept_t *flagp, int excepts);
/*******************************************************************************
* The function "fetestexcept" determines which of the specified subset of *
* the exception flags are currently set. The argument "excepts" specifies *
* the exception flags to be queried as a bitwise OR of the exception *
* macros. This function returns the bitwise OR of the exception macros *
* corresponding to the currently set exceptions included in "excepts". *
*******************************************************************************/
/*
* fetestexcept()
*
* Availability:
* Non-Carbon CFM: in MathLib 1.0 and later
* CarbonLib: in CarbonLib 1.0 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API_C( int ) fetestexcept(int excepts);
/*******************************************************************************
* The following functions provide control of rounding direction modes. *
*******************************************************************************/
/*******************************************************************************
* The function "fegetround" returns the value of the rounding direction *
* macro which represents the current rounding direction. *
*******************************************************************************/
/*
* fegetround()
*
* Availability:
* Non-Carbon CFM: in MathLib 1.0 and later
* CarbonLib: in CarbonLib 1.0 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API_C( int ) fegetround(void);
/*******************************************************************************
* The function "fesetround" establishes the rounding direction represented *
* by its argument. It returns nonzero if and only if the argument matches *
* a rounding direction macro. If not, the rounding direction is not *
* changed. *
*******************************************************************************/
/*
* fesetround()
*
* Availability:
* Non-Carbon CFM: in MathLib 1.0 and later
* CarbonLib: in CarbonLib 1.0 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API_C( int ) fesetround(int round);
/*******************************************************************************
* The following functions manage the floating-point environment, exception *
* flags and dynamic modes, as one entity. *
*******************************************************************************/
/*******************************************************************************
* The function "fegetenv" stores the current floating-point environment *
* in the object pointed to by its pointer argument "envp". *
*******************************************************************************/
/*
* fegetenv()
*
* Availability:
* Non-Carbon CFM: in MathLib 1.0 and later
* CarbonLib: in CarbonLib 1.0 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API_C( void ) fegetenv(fenv_t * envp);
/*******************************************************************************
* The function "feholdexcept" saves the current environment in the object *
* pointed to by its pointer argument "envp", clears the exception flags, *
* and clears floating-point exception enables. This function supersedes *
* the SANE function "procentry", but it does not change the current *
* rounding direction mode. *
*******************************************************************************/
/*
* feholdexcept()
*
* Availability:
* Non-Carbon CFM: in MathLib 1.0 and later
* CarbonLib: in CarbonLib 1.0 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API_C( int ) feholdexcept(fenv_t * envp);
/*******************************************************************************
* The function "fesetenv" installs the floating-point environment *
* environment represented by the object pointed to by its argument *
* "envp". The value of "*envp" must be set by a call to "fegetenv" or *
* "feholdexcept", by an implementation-defined macro of type "fenv_t", *
* or by the use of the pointer macro FE_DFL_ENV as the argument. *
*******************************************************************************/
/*
* fesetenv()
*
* Availability:
* Non-Carbon CFM: in MathLib 1.0 and later
* CarbonLib: in CarbonLib 1.0 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API_C( void ) fesetenv(const fenv_t * envp);
/*******************************************************************************
* The function "feupdateenv" saves the current exceptions into its *
* automatic storage, installs the environment represented through its *
* pointer argument "envp", and then re-raises the saved exceptions. *
* This function, which supersedes the SANE function "procexit", can be *
* used in conjunction with "feholdexcept" to write routines which hide *
* spurious exceptions from their callers. *
*******************************************************************************/
/*
* feupdateenv()
*
* Availability:
* Non-Carbon CFM: in MathLib 1.0 and later
* CarbonLib: in CarbonLib 1.0 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API_C( void ) feupdateenv(const fenv_t * envp);
#if TARGET_CPU_68K
/*******************************************************************************
* The following functions provide control of rounding precision. *
* Because the PowerPC does not provide this capability, these functions *
* are available only for the 68K Macintosh. Rounding precision values *
* are defined by the rounding precision macros. These functions are *
* equivalent to the SANE functions getprecision and setprecision. *
*******************************************************************************/
#if CALL_NOT_IN_CARBON
/*
* fegetprec()
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: not available
* Mac OS X: not available
*/
EXTERN_API_C( int ) fegetprec(void);
/*
* fesetprec()
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: not available
* Mac OS X: not available
*/
EXTERN_API_C( int ) fesetprec(int precision);
#endif /* CALL_NOT_IN_CARBON */
#endif /* TARGET_CPU_68K */
#endif /* TARGET_OS_MAC */
#endif /* TARGET_RT_MAC_MACHO && defined(__MATH__) */
#if PRAGMA_STRUCT_ALIGN
#pragma options align=reset
#elif PRAGMA_STRUCT_PACKPUSH
#pragma pack(pop)
#elif PRAGMA_STRUCT_PACK
#pragma pack()
#endif
#ifdef PRAGMA_IMPORT_OFF
#pragma import off
#elif PRAGMA_IMPORT
#pragma import reset
#endif
#ifdef __cplusplus
}
#endif
#endif /* __FENV__ */
|