Merge pull request #229 from t-b/recompile_openssh_against_current_openssl
[msysgit.git] / include / ieeefp.h
blob78bb5bf62ca4d6aef1254a05611428356d44a025
1 #ifndef _IEEE_FP_H_
2 #define _IEEE_FP_H_
4 #include "_ansi.h"
6 #include <machine/ieeefp.h>
8 /* FIXME FIXME FIXME:
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
12 they're needed. */
14 #ifdef __IEEE_BIG_ENDIAN
16 typedef union
18 double value;
19 struct
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;
28 } number;
29 struct
31 unsigned int sign : 1;
32 unsigned int exponent: 11;
33 unsigned int quiet:1;
34 unsigned int function0:3;
35 unsigned int function1:16;
36 unsigned int function2:16;
37 unsigned int function3:16;
38 } nan;
39 struct
41 unsigned long msw;
42 unsigned long lsw;
43 } parts;
44 long aslong[2];
45 } __ieee_double_shape_type;
47 #endif
49 #ifdef __IEEE_LITTLE_ENDIAN
51 typedef union
53 double value;
54 struct
56 #ifdef __SMALL_BITFIELDS
57 unsigned int fraction3:16;
58 unsigned int fraction2:16;
59 unsigned int fraction1:16;
60 unsigned int fraction0: 4;
61 #else
62 unsigned int fraction1:32;
63 unsigned int fraction0:20;
64 #endif
65 unsigned int exponent :11;
66 unsigned int sign : 1;
67 } number;
68 struct
70 #ifdef __SMALL_BITFIELDS
71 unsigned int function3:16;
72 unsigned int function2:16;
73 unsigned int function1:16;
74 unsigned int function0:3;
75 #else
76 unsigned int function1:32;
77 unsigned int function0:19;
78 #endif
79 unsigned int quiet:1;
80 unsigned int exponent: 11;
81 unsigned int sign : 1;
82 } nan;
83 struct
85 unsigned long lsw;
86 unsigned long msw;
87 } parts;
89 long aslong[2];
91 } __ieee_double_shape_type;
93 #endif
95 #ifdef __IEEE_BIG_ENDIAN
97 typedef union
99 float value;
100 struct
102 unsigned int sign : 1;
103 unsigned int exponent: 8;
104 unsigned int fraction0: 7;
105 unsigned int fraction1: 16;
106 } number;
107 struct
109 unsigned int sign:1;
110 unsigned int exponent:8;
111 unsigned int quiet:1;
112 unsigned int function0:6;
113 unsigned int function1:16;
114 } nan;
115 long p1;
117 } __ieee_float_shape_type;
119 #endif
121 #ifdef __IEEE_LITTLE_ENDIAN
123 typedef union
125 float value;
126 struct
128 unsigned int fraction0: 7;
129 unsigned int fraction1: 16;
130 unsigned int exponent: 8;
131 unsigned int sign : 1;
132 } number;
133 struct
135 unsigned int function1:16;
136 unsigned int function0:6;
137 unsigned int quiet:1;
138 unsigned int exponent:8;
139 unsigned int sign:1;
140 } nan;
141 long p1;
143 } __ieee_float_shape_type;
145 #endif
151 /* FLOATING ROUNDING */
153 typedef int fp_rnd;
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));
162 /* EXCEPTIONS */
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 */
178 typedef int fp_rdi;
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_ */