18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
23 */
24 /*
25 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
27 */
28
29 #ifndef _FENV_H
30 #define _FENV_H
31
32 #include <sys/feature_tests.h>
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 #ifndef __P
39 #ifdef __STDC__
40 #define __P(p) p
41 #else
42 #define __P(p) ()
43 #endif
44 #endif /* !defined(__P) */
45
46 /*
47 * Rounding modes
48 */
49 #if defined(__sparc)
50
51 #define FE_TONEAREST 0
52 #define FE_TOWARDZERO 1
53 #define FE_UPWARD 2
54 #define FE_DOWNWARD 3
55
56 #elif defined(__i386) || defined(__amd64)
57
58 #define FE_TONEAREST 0
59 #define FE_DOWNWARD 1
60 #define FE_UPWARD 2
61 #define FE_TOWARDZERO 3
62
63 #endif
64
65 extern int fegetround __P((void));
66 extern int fesetround __P((int));
67
68 #if (defined(__i386) || defined(__amd64)) && \
69 (!defined(_STRICT_STDC) || defined(__EXTENSIONS__))
70
71 #define FE_FLTPREC 0
72 #define FE_DBLPREC 2
73 #define FE_LDBLPREC 3
74
75 extern int fegetprec __P((void));
76 extern int fesetprec __P((int));
77
78 #endif
79
80 /*
81 * Exception flags
82 */
83 #if defined(__sparc)
84
85 #define FE_INEXACT 0x01
86 #define FE_DIVBYZERO 0x02
87 #define FE_UNDERFLOW 0x04
88 #define FE_OVERFLOW 0x08
89 #define FE_INVALID 0x10
90 #define FE_ALL_EXCEPT 0x1f
91
92 #elif defined(__i386) || defined(__amd64)
93
94 #define FE_INVALID 0x01
95 #define FE_DIVBYZERO 0x04
96 #define FE_OVERFLOW 0x08
97 #define FE_UNDERFLOW 0x10
98 #define FE_INEXACT 0x20
99 #define FE_ALL_EXCEPT 0x3d
100
101 #endif
102
103 typedef int fexcept_t;
104
105 extern int feclearexcept __P((int));
106 extern int feraiseexcept __P((int));
107 extern int fetestexcept __P((int));
108 extern int fegetexceptflag __P((fexcept_t *, int));
109 extern int fesetexceptflag __P((const fexcept_t *, int));
110
111 #if !defined(_STRICT_STDC) || defined(__EXTENSIONS__)
112
113 /*
114 * Exception handling extensions
115 */
116 #define FEX_NOHANDLER -1
117 #define FEX_NONSTOP 0
118 #define FEX_ABORT 1
119 #define FEX_SIGNAL 2
120 #define FEX_CUSTOM 3
121
122 #define FEX_INEXACT 0x001
123 #define FEX_DIVBYZERO 0x002
124 #define FEX_UNDERFLOW 0x004
125 #define FEX_OVERFLOW 0x008
126 #define FEX_INV_ZDZ 0x010
127 #define FEX_INV_IDI 0x020
128 #define FEX_INV_ISI 0x040
129 #define FEX_INV_ZMI 0x080
168 typedef struct {
169 enum fex_op {
170 fex_add = 0,
171 fex_sub = 1,
172 fex_mul = 2,
173 fex_div = 3,
174 fex_sqrt = 4,
175 fex_cnvt = 5,
176 fex_cmp = 6,
177 fex_other = 7
178 } op; /* operation that caused the exception */
179 int flags; /* flags to be set */
180 fex_numeric_t op1, op2, res; /* operands and result */
181 } fex_info_t;
182
183 typedef struct fex_handler_data {
184 int __mode;
185 void (*__handler)();
186 } fex_handler_t[FEX_NUM_EXC];
187
188 extern int fex_get_handling __P((int));
189 extern int fex_set_handling __P((int, int, void (*)()));
190
191 extern void fex_getexcepthandler __P((fex_handler_t *, int));
192 extern void fex_setexcepthandler __P((const fex_handler_t *, int));
193
194 #ifdef __STDC__
195 #include <stdio_tag.h>
196 #ifndef _FILEDEFED
197 #define _FILEDEFED
198 typedef __FILE FILE;
199 #endif
200 #endif
201 extern FILE *fex_get_log __P((void));
202 extern int fex_set_log __P((FILE *));
203 extern int fex_get_log_depth __P((void));
204 extern int fex_set_log_depth __P((int));
205 extern void fex_log_entry __P((const char *));
206
207 #define __fex_handler_t fex_handler_t
208
209 #else
210
211 typedef struct {
212 int __mode;
213 void (*__handler)();
214 } __fex_handler_t[12];
215
216 #endif /* !defined(_STRICT_STDC) || defined(__EXTENSIONS__) */
217
218 /*
219 * Environment as a whole
220 */
221 typedef struct {
222 __fex_handler_t __handlers;
223 unsigned long __fsr;
224 } fenv_t;
225
226 #ifdef __STDC__
227 extern const fenv_t __fenv_dfl_env;
228 #else
229 extern fenv_t __fenv_dfl_env;
230 #endif
231
232 #define FE_DFL_ENV (&__fenv_dfl_env)
233
234 extern int fegetenv __P((fenv_t *));
235 extern int fesetenv __P((const fenv_t *));
236 extern int feholdexcept __P((fenv_t *));
237 extern int feupdateenv __P((const fenv_t *));
238
239 #if !defined(_STRICT_STDC) || defined(__EXTENSIONS__)
240 extern void fex_merge_flags __P((const fenv_t *));
241 #endif
242
243 #ifdef __cplusplus
244 }
245 #endif
246
247 #endif /* _FENV_H */
|
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
23 */
24 /*
25 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
27 */
28
29 #ifndef _FENV_H
30 #define _FENV_H
31
32 #include <sys/feature_tests.h>
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 /*
39 * Rounding modes
40 */
41 #if defined(__sparc)
42
43 #define FE_TONEAREST 0
44 #define FE_TOWARDZERO 1
45 #define FE_UPWARD 2
46 #define FE_DOWNWARD 3
47
48 #elif defined(__i386) || defined(__amd64)
49
50 #define FE_TONEAREST 0
51 #define FE_DOWNWARD 1
52 #define FE_UPWARD 2
53 #define FE_TOWARDZERO 3
54
55 #endif
56
57 extern int fegetround(void);
58 extern int fesetround(int);
59
60 #if (defined(__i386) || defined(__amd64)) && \
61 (!defined(_STRICT_STDC) || defined(__EXTENSIONS__))
62
63 #define FE_FLTPREC 0
64 #define FE_DBLPREC 2
65 #define FE_LDBLPREC 3
66
67 extern int fegetprec(void);
68 extern int fesetprec(int);
69
70 #endif
71
72 /*
73 * Exception flags
74 */
75 #if defined(__sparc)
76
77 #define FE_INEXACT 0x01
78 #define FE_DIVBYZERO 0x02
79 #define FE_UNDERFLOW 0x04
80 #define FE_OVERFLOW 0x08
81 #define FE_INVALID 0x10
82 #define FE_ALL_EXCEPT 0x1f
83
84 #elif defined(__i386) || defined(__amd64)
85
86 #define FE_INVALID 0x01
87 #define FE_DIVBYZERO 0x04
88 #define FE_OVERFLOW 0x08
89 #define FE_UNDERFLOW 0x10
90 #define FE_INEXACT 0x20
91 #define FE_ALL_EXCEPT 0x3d
92
93 #endif
94
95 typedef int fexcept_t;
96
97 extern int feclearexcept(int);
98 extern int feraiseexcept(int);
99 extern int fetestexcept(int);
100 extern int fegetexceptflag(fexcept_t *, int);
101 extern int fesetexceptflag(const fexcept_t *, int);
102
103 #if !defined(_STRICT_STDC) || defined(__EXTENSIONS__)
104
105 /*
106 * Exception handling extensions
107 */
108 #define FEX_NOHANDLER -1
109 #define FEX_NONSTOP 0
110 #define FEX_ABORT 1
111 #define FEX_SIGNAL 2
112 #define FEX_CUSTOM 3
113
114 #define FEX_INEXACT 0x001
115 #define FEX_DIVBYZERO 0x002
116 #define FEX_UNDERFLOW 0x004
117 #define FEX_OVERFLOW 0x008
118 #define FEX_INV_ZDZ 0x010
119 #define FEX_INV_IDI 0x020
120 #define FEX_INV_ISI 0x040
121 #define FEX_INV_ZMI 0x080
160 typedef struct {
161 enum fex_op {
162 fex_add = 0,
163 fex_sub = 1,
164 fex_mul = 2,
165 fex_div = 3,
166 fex_sqrt = 4,
167 fex_cnvt = 5,
168 fex_cmp = 6,
169 fex_other = 7
170 } op; /* operation that caused the exception */
171 int flags; /* flags to be set */
172 fex_numeric_t op1, op2, res; /* operands and result */
173 } fex_info_t;
174
175 typedef struct fex_handler_data {
176 int __mode;
177 void (*__handler)();
178 } fex_handler_t[FEX_NUM_EXC];
179
180 extern int fex_get_handling(int);
181 extern int fex_set_handling(int, int, void (*)());
182
183 extern void fex_getexcepthandler(fex_handler_t *, int);
184 extern void fex_setexcepthandler(const fex_handler_t *, int);
185
186 #ifdef __STDC__
187 #include <stdio_tag.h>
188 #ifndef _FILEDEFED
189 #define _FILEDEFED
190 typedef __FILE FILE;
191 #endif
192 #endif
193 extern FILE *fex_get_log(void);
194 extern int fex_set_log(FILE *);
195 extern int fex_get_log_depth(void);
196 extern int fex_set_log_depth(int);
197 extern void fex_log_entry(const char *);
198
199 #define __fex_handler_t fex_handler_t
200
201 #else
202
203 typedef struct {
204 int __mode;
205 void (*__handler)();
206 } __fex_handler_t[12];
207
208 #endif /* !defined(_STRICT_STDC) || defined(__EXTENSIONS__) */
209
210 /*
211 * Environment as a whole
212 */
213 typedef struct {
214 __fex_handler_t __handlers;
215 unsigned long __fsr;
216 } fenv_t;
217
218 #ifdef __STDC__
219 extern const fenv_t __fenv_dfl_env;
220 #else
221 extern fenv_t __fenv_dfl_env;
222 #endif
223
224 #define FE_DFL_ENV (&__fenv_dfl_env)
225
226 extern int fegetenv(fenv_t *);
227 extern int fesetenv(const fenv_t *);
228 extern int feholdexcept(fenv_t *);
229 extern int feupdateenv(const fenv_t *);
230
231 #if !defined(_STRICT_STDC) || defined(__EXTENSIONS__)
232 extern void fex_merge_flags(const fenv_t *);
233 #endif
234
235 #ifdef __cplusplus
236 }
237 #endif
238
239 #endif /* _FENV_H */
|