Mac OS 9
fenv.h
Go to the documentation of this file.
1 
19 #ifndef __FENV__
20 #define __FENV__
21 
22 #ifndef __CONDITIONALMACROS__
23 #include <ConditionalMacros.h>
24 #endif
25 
26 #if PRAGMA_ONCE
27 #pragma once
28 #endif
29 
30 #ifdef __cplusplus
31 extern "C"
32 {
33 #endif
34 
35 #if PRAGMA_IMPORT
36 #pragma import on
37 #endif
38 
39 #if PRAGMA_STRUCT_ALIGN
40 #pragma options align = mac68k
41 #elif PRAGMA_STRUCT_PACKPUSH
42 #pragma pack(push, 2)
43 #elif PRAGMA_STRUCT_PACK
44 #pragma pack(2)
45 #endif
46 
47 #if TARGET_OS_MAC
60 /********************************************************************************
61  * *
62  * fenv_t is a type for representing the entire floating-point *
63  * environment in a single object. *
64  * *
65  * fexcept_t is a type for representing the floating-point * exception
66  *flag state collectively. *
67  * *
68  ********************************************************************************/
69 #if TARGET_CPU_PPC
70  typedef long fenv_t;
71  typedef long fexcept_t;
72  /* Definitions of floating-point exception macros */
73  enum
74  {
75  FE_INEXACT = 0x02000000,
76  FE_DIVBYZERO = 0x04000000,
77  FE_UNDERFLOW = 0x08000000,
78  FE_OVERFLOW = 0x10000000,
79  FE_INVALID = 0x20000000,
80  FE_ALL_EXCEPT = 0x3E000000 /* FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW |
81  FE_OVERFLOW | FE_INVALID*/
82  };
83 
84  /* Definitions of rounding direction macros */
85  enum
86  {
87  FE_TONEAREST = 0x00000000,
88  FE_TOWARDZERO = 0x00000001,
89  FE_UPWARD = 0x00000002,
90  FE_DOWNWARD = 0x00000003
91  };
92 
93 #endif /* TARGET_CPU_PPC */
94 
95 #if TARGET_CPU_68K
96 #if TARGET_RT_MAC_68881
97  typedef long fexcept_t;
98  struct fenv_t
99  {
100  long FPCR;
101  long FPSR;
102  };
103  typedef struct fenv_t fenv_t;
104  enum
105  {
106  FE_INEXACT = 0x00000008, /* ((long)(8)) */
107  FE_DIVBYZERO = 0x00000010, /* ((long)(16)) */
108  FE_UNDERFLOW = 0x00000020, /* ((long)(32)) */
109  FE_OVERFLOW = 0x00000040, /* ((long)(64)) */
110  FE_INVALID = 0x00000080, /* ((long)(128)) */
111  FE_ALL_EXCEPT = 0x000000F8 /* FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW |
112  FE_OVERFLOW | FE_INVALID*/
113  };
114 
115 #else
116 
117  typedef short fexcept_t;
118  typedef short fenv_t;
119  enum
120  {
121  FE_INVALID = 0x0001, /* ((short)(1)) */
122  FE_UNDERFLOW = 0x0002, /* ((short)(2)) */
123  FE_OVERFLOW = 0x0004, /* ((short)(4)) */
124  FE_DIVBYZERO = 0x0008, /* ((short)(8)) */
125  FE_INEXACT = 0x0010, /* ((short)(16)) */
126  FE_ALL_EXCEPT = 0x001F /* FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW |
127  FE_OVERFLOW | FE_INVALID*/
128  };
129 
130 #endif /* TARGET_RT_MAC_68881 */
131 
132  enum
133  {
134  FE_TONEAREST = 0x0000, /* ((short)(0)) */
135  FE_UPWARD = 0x0001, /* ((short)(1)) */
136  FE_DOWNWARD = 0x0002, /* ((short)(2)) */
137  FE_TOWARDZERO = 0x0003 /* ((short)(3)) */
138  };
139 
140  /* Definitions of rounding precision macros (68K only) */
141  enum
142  {
143  FE_LDBLPREC = 0x0000, /* ((short)(0)) */
144  FE_DBLPREC = 0x0001, /* ((short)(1)) */
145  FE_FLTPREC = 0x0002 /* ((short)(2)) */
146  };
147 
148 #endif /* TARGET_CPU_68K */
149 
150  /* default environment object */
159  extern fenv_t _FE_DFL_ENV;
160 #define FE_DFL_ENV &_FE_DFL_ENV /* pointer to default environment */
161  /*******************************************************************************
162  * The following functions provide access to the exception flags. The *
163  * "int" input argument can be constructed by bitwise ORs of the exception *
164  * macros: for example: FE_OVERFLOW | FE_INEXACT. *
165  *******************************************************************************/
166  /*******************************************************************************
167  * The function "feclearexcept" clears the supported exceptions represented
168  ** by its argument. *
169  *******************************************************************************/
178  void feclearexcept(int excepts);
179 
180  /*******************************************************************************
181  * The function "fegetexcept" stores a representation of the exception *
182  * flags indicated by the argument "excepts" through the pointer argument *
183  * "flagp". *
184  *******************************************************************************/
193  void fegetexcept(fexcept_t *flagp, int excepts);
194 
195  /*******************************************************************************
196  * The function "feraiseexcept" raises the supported exceptions *
197  * represented by its argument. *
198  *******************************************************************************/
207  void feraiseexcept(int excepts);
208 
209  /*******************************************************************************
210  * The function "fesetexcept" sets or clears the exception flags indicated *
211  * by the int argument "excepts" according to the representation in the *
212  * object pointed to by the pointer argument "flagp". The value of *
213  * "*flagp" must have been set by a previous call to "fegetexcept". * This
214  *function does not raise exceptions; it just sets the state of * the
215  *flags. *
216  *******************************************************************************/
225  void fesetexcept(const fexcept_t *flagp, int excepts);
226 
227  /*******************************************************************************
228  * The function "fetestexcept" determines which of the specified subset of *
229  * the exception flags are currently set. The argument "excepts" specifies
230  ** the exception flags to be queried as a bitwise OR of the exception *
231  * macros. This function returns the bitwise OR of the exception macros *
232  * corresponding to the currently set exceptions included in "excepts". *
233  *******************************************************************************/
242  int fetestexcept(int excepts);
243 
244  /*******************************************************************************
245  * The following functions provide control of rounding direction modes. *
246  *******************************************************************************/
247  /*******************************************************************************
248  * The function "fegetround" returns the value of the rounding direction *
249  * macro which represents the current rounding direction. *
250  *******************************************************************************/
259  int fegetround(void);
260 
261  /*******************************************************************************
262  * The function "fesetround" establishes the rounding direction represented
263  ** by its argument. It returns nonzero if and only if the argument matches *
264  * a rounding direction macro. If not, the rounding direction is not *
265  * changed. *
266  *******************************************************************************/
275  int fesetround(int round);
276 
277  /*******************************************************************************
278  * The following functions manage the floating-point environment, exception *
279  * flags and dynamic modes, as one entity. *
280  *******************************************************************************/
281  /*******************************************************************************
282  * The function "fegetenv" stores the current floating-point environment *
283  * in the object pointed to by its pointer argument "envp". *
284  *******************************************************************************/
293  void fegetenv(fenv_t *envp);
294 
295  /*******************************************************************************
296  * The function "feholdexcept" saves the current environment in the object *
297  * pointed to by its pointer argument "envp", clears the exception flags, *
298  * and clears floating-point exception enables. This function supersedes *
299  * the SANE function "procentry", but it does not change the current *
300  * rounding direction mode. *
301  *******************************************************************************/
310  int feholdexcept(fenv_t *envp);
311 
312  /*******************************************************************************
313  * The function "fesetenv" installs the floating-point environment *
314  * environment represented by the object pointed to by its argument *
315  * "envp". The value of "*envp" must be set by a call to "fegetenv" or *
316  * "feholdexcept", by an implementation-defined macro of type "fenv_t", * or
317  *by the use of the pointer macro FE_DFL_ENV as the argument. *
318  *******************************************************************************/
327  void fesetenv(const fenv_t *envp);
328 
329  /*******************************************************************************
330  * The function "feupdateenv" saves the current exceptions into its *
331  * automatic storage, installs the environment represented through its *
332  * pointer argument "envp", and then re-raises the saved exceptions. * This
333  *function, which supersedes the SANE function "procexit", can be * used in
334  *conjunction with "feholdexcept" to write routines which hide * spurious
335  *exceptions from their callers. *
336  *******************************************************************************/
345  void feupdateenv(const fenv_t *envp);
346 
347 #if TARGET_CPU_68K
348 /*******************************************************************************
349  * The following functions provide control of rounding precision. * Because
350  *the PowerPC does not provide this capability, these functions * are
351  *available only for the 68K Macintosh. Rounding precision values * are
352  *defined by the rounding precision macros. These functions are *
353  * equivalent to the SANE functions getprecision and setprecision. *
354  *******************************************************************************/
355 #if CALL_NOT_IN_CARBON
364  int fegetprec(void);
365 
374  int fesetprec(int precision);
375 
376 #endif /* CALL_NOT_IN_CARBON */
377 
378 #endif /* TARGET_CPU_68K */
379 
380 #endif /* TARGET_OS_MAC */
381 
382 #if PRAGMA_STRUCT_ALIGN
383 #pragma options align = reset
384 #elif PRAGMA_STRUCT_PACKPUSH
385 #pragma pack(pop)
386 #elif PRAGMA_STRUCT_PACK
387 #pragma pack()
388 #endif
389 
390 #ifdef PRAGMA_IMPORT_OFF
391 #pragma import off
392 #elif PRAGMA_IMPORT
393 #pragma import reset
394 #endif
395 
396 #ifdef __cplusplus
397 }
398 #endif
399 
400 #endif /* __FENV__ */
Set up for compiler independent conditionals.