6 #include <machine/ieeefp.h>
9 Neither of __ieee_{float,double}_shape_tape seem to be used anywhere
10 except in libm/test. If that is the case, please delete these from here.
11 If that is not the case, please insert documentation here describing why
14 #ifdef __IEEE_BIG_ENDIAN
21 unsigned int sign
: 1;
22 unsigned int exponent
: 11;
23 unsigned int fraction0
:4;
24 unsigned int fraction1
:16;
25 unsigned int fraction2
:16;
26 unsigned int fraction3
:16;
31 unsigned int sign
: 1;
32 unsigned int exponent
: 11;
34 unsigned int function0
:3;
35 unsigned int function1
:16;
36 unsigned int function2
:16;
37 unsigned int function3
:16;
45 } __ieee_double_shape_type
;
49 #ifdef __IEEE_LITTLE_ENDIAN
56 #ifdef __SMALL_BITFIELDS
57 unsigned int fraction3
:16;
58 unsigned int fraction2
:16;
59 unsigned int fraction1
:16;
60 unsigned int fraction0
: 4;
62 unsigned int fraction1
:32;
63 unsigned int fraction0
:20;
65 unsigned int exponent
:11;
66 unsigned int sign
: 1;
70 #ifdef __SMALL_BITFIELDS
71 unsigned int function3
:16;
72 unsigned int function2
:16;
73 unsigned int function1
:16;
74 unsigned int function0
:3;
76 unsigned int function1
:32;
77 unsigned int function0
:19;
80 unsigned int exponent
: 11;
81 unsigned int sign
: 1;
91 } __ieee_double_shape_type
;
95 #ifdef __IEEE_BIG_ENDIAN
102 unsigned int sign
: 1;
103 unsigned int exponent
: 8;
104 unsigned int fraction0
: 7;
105 unsigned int fraction1
: 16;
110 unsigned int exponent
:8;
111 unsigned int quiet
:1;
112 unsigned int function0
:6;
113 unsigned int function1
:16;
117 } __ieee_float_shape_type
;
121 #ifdef __IEEE_LITTLE_ENDIAN
128 unsigned int fraction0
: 7;
129 unsigned int fraction1
: 16;
130 unsigned int exponent
: 8;
131 unsigned int sign
: 1;
135 unsigned int function1
:16;
136 unsigned int function0
:6;
137 unsigned int quiet
:1;
138 unsigned int exponent
:8;
143 } __ieee_float_shape_type
;
151 /* FLOATING ROUNDING */
154 #define FP_RN 0 /* Round to nearest */
155 #define FP_RM 1 /* Round down */
156 #define FP_RP 2 /* Round up */
157 #define FP_RZ 3 /* Round to zero (trunate) */
159 fp_rnd
_EXFUN(fpgetround
,(void));
160 fp_rnd
_EXFUN(fpsetround
, (fp_rnd
));
164 typedef int fp_except
;
165 #define FP_X_INV 0x10 /* Invalid operation */
166 #define FP_X_DX 0x80 /* Divide by zero */
167 #define FP_X_OFL 0x04 /* Overflow exception */
168 #define FP_X_UFL 0x02 /* Underflow exception */
169 #define FP_X_IMP 0x01 /* imprecise exception */
171 fp_except
_EXFUN(fpgetmask
,(void));
172 fp_except
_EXFUN(fpsetmask
,(fp_except
));
173 fp_except
_EXFUN(fpgetsticky
,(void));
174 fp_except
_EXFUN(fpsetsticky
, (fp_except
));
176 /* INTEGER ROUNDING */
179 #define FP_RDI_TOZ 0 /* Round to Zero */
180 #define FP_RDI_RD 1 /* Follow float mode */
182 fp_rdi
_EXFUN(fpgetroundtoi
,(void));
183 fp_rdi
_EXFUN(fpsetroundtoi
,(fp_rdi
));
185 int _EXFUN(isnan
, (double));
186 int _EXFUN(isinf
, (double));
187 int _EXFUN(finite
, (double));
191 int _EXFUN(isnanf
, (float));
192 int _EXFUN(isinff
, (float));
193 int _EXFUN(finitef
, (float));
195 #define __IEEE_DBL_EXPBIAS 1023
196 #define __IEEE_FLT_EXPBIAS 127
198 #define __IEEE_DBL_EXPLEN 11
199 #define __IEEE_FLT_EXPLEN 8
202 #define __IEEE_DBL_FRACLEN (64 - (__IEEE_DBL_EXPLEN + 1))
203 #define __IEEE_FLT_FRACLEN (32 - (__IEEE_FLT_EXPLEN + 1))
205 #define __IEEE_DBL_MAXPOWTWO ((double)(1L << 32 - 2) * (1L << (32-11) - 32 + 1))
206 #define __IEEE_FLT_MAXPOWTWO ((float)(1L << (32-8) - 1))
208 #define __IEEE_DBL_NAN_EXP 0x7ff
209 #define __IEEE_FLT_NAN_EXP 0xff
212 #define isnanf(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \
213 ((*(long *)&(x) & 0x007fffffL)!=0000000000L))
215 #define isinff(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \
216 ((*(long *)&(x) & 0x007fffffL)==0000000000L))
218 #define finitef(x) (((*(long *)&(x) & 0x7f800000L)!=0x7f800000L))
220 #ifdef _DOUBLE_IS_32BITS
221 #undef __IEEE_DBL_EXPBIAS
222 #define __IEEE_DBL_EXPBIAS __IEEE_FLT_EXPBIAS
224 #undef __IEEE_DBL_EXPLEN
225 #define __IEEE_DBL_EXPLEN __IEEE_FLT_EXPLEN
227 #undef __IEEE_DBL_FRACLEN
228 #define __IEEE_DBL_FRACLEN __IEEE_FLT_FRACLEN
230 #undef __IEEE_DBL_MAXPOWTWO
231 #define __IEEE_DBL_MAXPOWTWO __IEEE_FLT_MAXPOWTWO
233 #undef __IEEE_DBL_NAN_EXP
234 #define __IEEE_DBL_NAN_EXP __IEEE_FLT_NAN_EXP
236 #undef __ieee_double_shape_type
237 #define __ieee_double_shape_type __ieee_float_shape_type
239 #endif /* _DOUBLE_IS_32BITS */
241 #endif /* _IEEE_FP_H_ */