root / fpu / softfloat-native.h @ e8ee3c72
History | View | Annotate | Download (11.9 kB)
1 | 158142c2 | bellard | /* Native implementation of soft float functions */
|
---|---|---|---|
2 | 158142c2 | bellard | #include <math.h> |
3 | 38cfa06c | bellard | |
4 | 38cfa06c | bellard | #if (defined(_BSD) && !defined(__APPLE__)) || defined(HOST_SOLARIS)
|
5 | 158142c2 | bellard | #include <ieeefp.h> |
6 | 38cfa06c | bellard | #define fabsf(f) ((float)fabs(f)) |
7 | 158142c2 | bellard | #else
|
8 | 158142c2 | bellard | #include <fenv.h> |
9 | 158142c2 | bellard | #endif
|
10 | 38cfa06c | bellard | |
11 | 38cfa06c | bellard | /*
|
12 | 38cfa06c | bellard | * Define some C99-7.12.3 classification macros and
|
13 | 38cfa06c | bellard | * some C99-.12.4 for Solaris systems OS less than 10,
|
14 | 38cfa06c | bellard | * or Solaris 10 systems running GCC 3.x or less.
|
15 | 38cfa06c | bellard | * Solaris 10 with GCC4 does not need these macros as they
|
16 | 38cfa06c | bellard | * are defined in <iso/math_c99.h> with a compiler directive
|
17 | 38cfa06c | bellard | */
|
18 | 128ab2ff | blueswir1 | #if defined(HOST_SOLARIS) && (( HOST_SOLARIS <= 9 ) || ((HOST_SOLARIS >= 10) \ |
19 | 128ab2ff | blueswir1 | && (__GNUC__ <= 4))) \
|
20 | 128ab2ff | blueswir1 | || defined(__OpenBSD__) |
21 | 38cfa06c | bellard | /*
|
22 | 38cfa06c | bellard | * C99 7.12.3 classification macros
|
23 | 38cfa06c | bellard | * and
|
24 | 38cfa06c | bellard | * C99 7.12.14 comparison macros
|
25 | 38cfa06c | bellard | *
|
26 | 38cfa06c | bellard | * ... do not work on Solaris 10 using GNU CC 3.4.x.
|
27 | 38cfa06c | bellard | * Try to workaround the missing / broken C99 math macros.
|
28 | 38cfa06c | bellard | */
|
29 | 128ab2ff | blueswir1 | #if defined(__OpenBSD__)
|
30 | 128ab2ff | blueswir1 | #define unordered(x, y) (isnan(x) || isnan(y))
|
31 | 128ab2ff | blueswir1 | #endif
|
32 | 38cfa06c | bellard | |
33 | 38cfa06c | bellard | #define isnormal(x) (fpclass(x) >= FP_NZERO)
|
34 | 38cfa06c | bellard | #define isgreater(x, y) ((!unordered(x, y)) && ((x) > (y)))
|
35 | 38cfa06c | bellard | #define isgreaterequal(x, y) ((!unordered(x, y)) && ((x) >= (y)))
|
36 | 38cfa06c | bellard | #define isless(x, y) ((!unordered(x, y)) && ((x) < (y)))
|
37 | 38cfa06c | bellard | #define islessequal(x, y) ((!unordered(x, y)) && ((x) <= (y)))
|
38 | 38cfa06c | bellard | #define isunordered(x,y) unordered(x, y)
|
39 | ec530c81 | bellard | #endif
|
40 | 158142c2 | bellard | |
41 | c94655b0 | ths | #if defined(__sun__) && !defined(NEED_LIBSUNMATH)
|
42 | c94655b0 | ths | |
43 | c94655b0 | ths | #ifndef isnan
|
44 | c94655b0 | ths | # define isnan(x) \
|
45 | c94655b0 | ths | (sizeof (x) == sizeof (long double) ? isnan_ld (x) \ |
46 | c94655b0 | ths | : sizeof (x) == sizeof (double) ? isnan_d (x) \ |
47 | c94655b0 | ths | : isnan_f (x)) |
48 | c94655b0 | ths | static inline int isnan_f (float x) { return x != x; } |
49 | c94655b0 | ths | static inline int isnan_d (double x) { return x != x; } |
50 | c94655b0 | ths | static inline int isnan_ld (long double x) { return x != x; } |
51 | c94655b0 | ths | #endif
|
52 | c94655b0 | ths | |
53 | c94655b0 | ths | #ifndef isinf
|
54 | c94655b0 | ths | # define isinf(x) \
|
55 | c94655b0 | ths | (sizeof (x) == sizeof (long double) ? isinf_ld (x) \ |
56 | c94655b0 | ths | : sizeof (x) == sizeof (double) ? isinf_d (x) \ |
57 | c94655b0 | ths | : isinf_f (x)) |
58 | c94655b0 | ths | static inline int isinf_f (float x) { return isnan (x - x); } |
59 | c94655b0 | ths | static inline int isinf_d (double x) { return isnan (x - x); } |
60 | c94655b0 | ths | static inline int isinf_ld (long double x) { return isnan (x - x); } |
61 | c94655b0 | ths | #endif
|
62 | c94655b0 | ths | #endif
|
63 | c94655b0 | ths | |
64 | 158142c2 | bellard | typedef float float32; |
65 | 158142c2 | bellard | typedef double float64; |
66 | 158142c2 | bellard | #ifdef FLOATX80
|
67 | 158142c2 | bellard | typedef long double floatx80; |
68 | 158142c2 | bellard | #endif
|
69 | 158142c2 | bellard | |
70 | 158142c2 | bellard | typedef union { |
71 | 158142c2 | bellard | float32 f; |
72 | 158142c2 | bellard | uint32_t i; |
73 | 158142c2 | bellard | } float32u; |
74 | 158142c2 | bellard | typedef union { |
75 | 158142c2 | bellard | float64 f; |
76 | 158142c2 | bellard | uint64_t i; |
77 | 158142c2 | bellard | } float64u; |
78 | 158142c2 | bellard | #ifdef FLOATX80
|
79 | 158142c2 | bellard | typedef union { |
80 | 158142c2 | bellard | floatx80 f; |
81 | 158142c2 | bellard | struct {
|
82 | 158142c2 | bellard | uint64_t low; |
83 | 158142c2 | bellard | uint16_t high; |
84 | 158142c2 | bellard | } i; |
85 | 158142c2 | bellard | } floatx80u; |
86 | 158142c2 | bellard | #endif
|
87 | 158142c2 | bellard | |
88 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
89 | 158142c2 | bellard | | Software IEC/IEEE floating-point rounding mode.
|
90 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
91 | 38cfa06c | bellard | #if (defined(_BSD) && !defined(__APPLE__)) || defined(HOST_SOLARIS)
|
92 | 128ab2ff | blueswir1 | #if defined(__OpenBSD__)
|
93 | 128ab2ff | blueswir1 | #define FE_RM FP_RM
|
94 | 128ab2ff | blueswir1 | #define FE_RP FP_RP
|
95 | 128ab2ff | blueswir1 | #define FE_RZ FP_RZ
|
96 | 128ab2ff | blueswir1 | #endif
|
97 | 158142c2 | bellard | enum {
|
98 | 158142c2 | bellard | float_round_nearest_even = FP_RN, |
99 | 7918bf47 | pbrook | float_round_down = FP_RM, |
100 | 7918bf47 | pbrook | float_round_up = FP_RP, |
101 | 7918bf47 | pbrook | float_round_to_zero = FP_RZ |
102 | 158142c2 | bellard | }; |
103 | 158142c2 | bellard | #elif defined(__arm__)
|
104 | 158142c2 | bellard | enum {
|
105 | 158142c2 | bellard | float_round_nearest_even = 0,
|
106 | 158142c2 | bellard | float_round_down = 1,
|
107 | 158142c2 | bellard | float_round_up = 2,
|
108 | 158142c2 | bellard | float_round_to_zero = 3
|
109 | 158142c2 | bellard | }; |
110 | 158142c2 | bellard | #else
|
111 | 158142c2 | bellard | enum {
|
112 | 158142c2 | bellard | float_round_nearest_even = FE_TONEAREST, |
113 | 158142c2 | bellard | float_round_down = FE_DOWNWARD, |
114 | 158142c2 | bellard | float_round_up = FE_UPWARD, |
115 | 158142c2 | bellard | float_round_to_zero = FE_TOWARDZERO |
116 | 158142c2 | bellard | }; |
117 | 158142c2 | bellard | #endif
|
118 | 158142c2 | bellard | |
119 | 158142c2 | bellard | typedef struct float_status { |
120 | 158142c2 | bellard | signed char float_rounding_mode; |
121 | 158142c2 | bellard | #ifdef FLOATX80
|
122 | 158142c2 | bellard | signed char floatx80_rounding_precision; |
123 | 158142c2 | bellard | #endif
|
124 | 158142c2 | bellard | } float_status; |
125 | 158142c2 | bellard | |
126 | 158142c2 | bellard | void set_float_rounding_mode(int val STATUS_PARAM); |
127 | 158142c2 | bellard | #ifdef FLOATX80
|
128 | 158142c2 | bellard | void set_floatx80_rounding_precision(int val STATUS_PARAM); |
129 | 158142c2 | bellard | #endif
|
130 | 158142c2 | bellard | |
131 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
132 | 158142c2 | bellard | | Software IEC/IEEE integer-to-floating-point conversion routines.
|
133 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
134 | 158142c2 | bellard | float32 int32_to_float32( int STATUS_PARAM);
|
135 | 75d62a58 | j_mayer | float32 uint32_to_float32( unsigned int STATUS_PARAM); |
136 | 158142c2 | bellard | float64 int32_to_float64( int STATUS_PARAM);
|
137 | 75d62a58 | j_mayer | float64 uint32_to_float64( unsigned int STATUS_PARAM); |
138 | 158142c2 | bellard | #ifdef FLOATX80
|
139 | 158142c2 | bellard | floatx80 int32_to_floatx80( int STATUS_PARAM);
|
140 | 158142c2 | bellard | #endif
|
141 | 158142c2 | bellard | #ifdef FLOAT128
|
142 | 158142c2 | bellard | float128 int32_to_float128( int STATUS_PARAM);
|
143 | 158142c2 | bellard | #endif
|
144 | 158142c2 | bellard | float32 int64_to_float32( int64_t STATUS_PARAM); |
145 | 75d62a58 | j_mayer | float32 uint64_to_float32( uint64_t STATUS_PARAM); |
146 | 158142c2 | bellard | float64 int64_to_float64( int64_t STATUS_PARAM); |
147 | 75d62a58 | j_mayer | float64 uint64_to_float64( uint64_t v STATUS_PARAM); |
148 | 158142c2 | bellard | #ifdef FLOATX80
|
149 | 158142c2 | bellard | floatx80 int64_to_floatx80( int64_t STATUS_PARAM); |
150 | 158142c2 | bellard | #endif
|
151 | 158142c2 | bellard | #ifdef FLOAT128
|
152 | 158142c2 | bellard | float128 int64_to_float128( int64_t STATUS_PARAM); |
153 | 158142c2 | bellard | #endif
|
154 | 158142c2 | bellard | |
155 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
156 | 158142c2 | bellard | | Software IEC/IEEE single-precision conversion routines.
|
157 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
158 | 158142c2 | bellard | int float32_to_int32( float32 STATUS_PARAM);
|
159 | 158142c2 | bellard | int float32_to_int32_round_to_zero( float32 STATUS_PARAM);
|
160 | 75d62a58 | j_mayer | unsigned int float32_to_uint32( float32 a STATUS_PARAM); |
161 | 75d62a58 | j_mayer | unsigned int float32_to_uint32_round_to_zero( float32 a STATUS_PARAM); |
162 | 158142c2 | bellard | int64_t float32_to_int64( float32 STATUS_PARAM); |
163 | 158142c2 | bellard | int64_t float32_to_int64_round_to_zero( float32 STATUS_PARAM); |
164 | 158142c2 | bellard | float64 float32_to_float64( float32 STATUS_PARAM); |
165 | 158142c2 | bellard | #ifdef FLOATX80
|
166 | 158142c2 | bellard | floatx80 float32_to_floatx80( float32 STATUS_PARAM); |
167 | 158142c2 | bellard | #endif
|
168 | 158142c2 | bellard | #ifdef FLOAT128
|
169 | 158142c2 | bellard | float128 float32_to_float128( float32 STATUS_PARAM); |
170 | 158142c2 | bellard | #endif
|
171 | 158142c2 | bellard | |
172 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
173 | 158142c2 | bellard | | Software IEC/IEEE single-precision operations.
|
174 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
175 | 158142c2 | bellard | float32 float32_round_to_int( float32 STATUS_PARAM); |
176 | 158142c2 | bellard | INLINE float32 float32_add( float32 a, float32 b STATUS_PARAM) |
177 | 158142c2 | bellard | { |
178 | 158142c2 | bellard | return a + b;
|
179 | 158142c2 | bellard | } |
180 | 158142c2 | bellard | INLINE float32 float32_sub( float32 a, float32 b STATUS_PARAM) |
181 | 158142c2 | bellard | { |
182 | 158142c2 | bellard | return a - b;
|
183 | 158142c2 | bellard | } |
184 | 158142c2 | bellard | INLINE float32 float32_mul( float32 a, float32 b STATUS_PARAM) |
185 | 158142c2 | bellard | { |
186 | 158142c2 | bellard | return a * b;
|
187 | 158142c2 | bellard | } |
188 | 158142c2 | bellard | INLINE float32 float32_div( float32 a, float32 b STATUS_PARAM) |
189 | 158142c2 | bellard | { |
190 | 158142c2 | bellard | return a / b;
|
191 | 158142c2 | bellard | } |
192 | 158142c2 | bellard | float32 float32_rem( float32, float32 STATUS_PARAM); |
193 | 158142c2 | bellard | float32 float32_sqrt( float32 STATUS_PARAM); |
194 | 750afe93 | bellard | INLINE int float32_eq( float32 a, float32 b STATUS_PARAM)
|
195 | 158142c2 | bellard | { |
196 | 158142c2 | bellard | return a == b;
|
197 | 158142c2 | bellard | } |
198 | 750afe93 | bellard | INLINE int float32_le( float32 a, float32 b STATUS_PARAM)
|
199 | 158142c2 | bellard | { |
200 | 158142c2 | bellard | return a <= b;
|
201 | 158142c2 | bellard | } |
202 | 750afe93 | bellard | INLINE int float32_lt( float32 a, float32 b STATUS_PARAM)
|
203 | 158142c2 | bellard | { |
204 | 158142c2 | bellard | return a < b;
|
205 | 158142c2 | bellard | } |
206 | 750afe93 | bellard | INLINE int float32_eq_signaling( float32 a, float32 b STATUS_PARAM)
|
207 | 158142c2 | bellard | { |
208 | b109f9f8 | bellard | return a <= b && a >= b;
|
209 | 158142c2 | bellard | } |
210 | 750afe93 | bellard | INLINE int float32_le_quiet( float32 a, float32 b STATUS_PARAM)
|
211 | 158142c2 | bellard | { |
212 | 158142c2 | bellard | return islessequal(a, b);
|
213 | 158142c2 | bellard | } |
214 | 750afe93 | bellard | INLINE int float32_lt_quiet( float32 a, float32 b STATUS_PARAM)
|
215 | 158142c2 | bellard | { |
216 | 158142c2 | bellard | return isless(a, b);
|
217 | 158142c2 | bellard | } |
218 | 750afe93 | bellard | INLINE int float32_unordered( float32 a, float32 b STATUS_PARAM)
|
219 | b109f9f8 | bellard | { |
220 | b109f9f8 | bellard | return isunordered(a, b);
|
221 | b109f9f8 | bellard | |
222 | b109f9f8 | bellard | } |
223 | 750afe93 | bellard | int float32_compare( float32, float32 STATUS_PARAM );
|
224 | 750afe93 | bellard | int float32_compare_quiet( float32, float32 STATUS_PARAM );
|
225 | 750afe93 | bellard | int float32_is_signaling_nan( float32 );
|
226 | 158142c2 | bellard | |
227 | 158142c2 | bellard | INLINE float32 float32_abs(float32 a) |
228 | 158142c2 | bellard | { |
229 | 158142c2 | bellard | return fabsf(a);
|
230 | 158142c2 | bellard | } |
231 | 158142c2 | bellard | |
232 | 158142c2 | bellard | INLINE float32 float32_chs(float32 a) |
233 | 158142c2 | bellard | { |
234 | 158142c2 | bellard | return -a;
|
235 | 158142c2 | bellard | } |
236 | 158142c2 | bellard | |
237 | 9ee6e8bb | pbrook | INLINE float32 float32_scalbn(float32 a, int n)
|
238 | 9ee6e8bb | pbrook | { |
239 | 9ee6e8bb | pbrook | return scalbnf(a, n);
|
240 | 9ee6e8bb | pbrook | } |
241 | 9ee6e8bb | pbrook | |
242 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
243 | 158142c2 | bellard | | Software IEC/IEEE double-precision conversion routines.
|
244 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
245 | 158142c2 | bellard | int float64_to_int32( float64 STATUS_PARAM );
|
246 | 158142c2 | bellard | int float64_to_int32_round_to_zero( float64 STATUS_PARAM );
|
247 | 75d62a58 | j_mayer | unsigned int float64_to_uint32( float64 STATUS_PARAM ); |
248 | 75d62a58 | j_mayer | unsigned int float64_to_uint32_round_to_zero( float64 STATUS_PARAM ); |
249 | 158142c2 | bellard | int64_t float64_to_int64( float64 STATUS_PARAM ); |
250 | 158142c2 | bellard | int64_t float64_to_int64_round_to_zero( float64 STATUS_PARAM ); |
251 | 75d62a58 | j_mayer | uint64_t float64_to_uint64( float64 STATUS_PARAM ); |
252 | 75d62a58 | j_mayer | uint64_t float64_to_uint64_round_to_zero( float64 STATUS_PARAM ); |
253 | 158142c2 | bellard | float32 float64_to_float32( float64 STATUS_PARAM ); |
254 | 158142c2 | bellard | #ifdef FLOATX80
|
255 | 158142c2 | bellard | floatx80 float64_to_floatx80( float64 STATUS_PARAM ); |
256 | 158142c2 | bellard | #endif
|
257 | 158142c2 | bellard | #ifdef FLOAT128
|
258 | 158142c2 | bellard | float128 float64_to_float128( float64 STATUS_PARAM ); |
259 | 158142c2 | bellard | #endif
|
260 | 158142c2 | bellard | |
261 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
262 | 158142c2 | bellard | | Software IEC/IEEE double-precision operations.
|
263 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
264 | 158142c2 | bellard | float64 float64_round_to_int( float64 STATUS_PARAM ); |
265 | e6e5906b | pbrook | float64 float64_trunc_to_int( float64 STATUS_PARAM ); |
266 | 158142c2 | bellard | INLINE float64 float64_add( float64 a, float64 b STATUS_PARAM) |
267 | 158142c2 | bellard | { |
268 | 158142c2 | bellard | return a + b;
|
269 | 158142c2 | bellard | } |
270 | 158142c2 | bellard | INLINE float64 float64_sub( float64 a, float64 b STATUS_PARAM) |
271 | 158142c2 | bellard | { |
272 | 158142c2 | bellard | return a - b;
|
273 | 158142c2 | bellard | } |
274 | 158142c2 | bellard | INLINE float64 float64_mul( float64 a, float64 b STATUS_PARAM) |
275 | 158142c2 | bellard | { |
276 | 158142c2 | bellard | return a * b;
|
277 | 158142c2 | bellard | } |
278 | 158142c2 | bellard | INLINE float64 float64_div( float64 a, float64 b STATUS_PARAM) |
279 | 158142c2 | bellard | { |
280 | 158142c2 | bellard | return a / b;
|
281 | 158142c2 | bellard | } |
282 | 158142c2 | bellard | float64 float64_rem( float64, float64 STATUS_PARAM ); |
283 | 158142c2 | bellard | float64 float64_sqrt( float64 STATUS_PARAM ); |
284 | 750afe93 | bellard | INLINE int float64_eq( float64 a, float64 b STATUS_PARAM)
|
285 | 158142c2 | bellard | { |
286 | 158142c2 | bellard | return a == b;
|
287 | 158142c2 | bellard | } |
288 | 750afe93 | bellard | INLINE int float64_le( float64 a, float64 b STATUS_PARAM)
|
289 | 158142c2 | bellard | { |
290 | 158142c2 | bellard | return a <= b;
|
291 | 158142c2 | bellard | } |
292 | 750afe93 | bellard | INLINE int float64_lt( float64 a, float64 b STATUS_PARAM)
|
293 | 158142c2 | bellard | { |
294 | 158142c2 | bellard | return a < b;
|
295 | 158142c2 | bellard | } |
296 | 750afe93 | bellard | INLINE int float64_eq_signaling( float64 a, float64 b STATUS_PARAM)
|
297 | 158142c2 | bellard | { |
298 | b109f9f8 | bellard | return a <= b && a >= b;
|
299 | 158142c2 | bellard | } |
300 | 750afe93 | bellard | INLINE int float64_le_quiet( float64 a, float64 b STATUS_PARAM)
|
301 | 158142c2 | bellard | { |
302 | 158142c2 | bellard | return islessequal(a, b);
|
303 | 158142c2 | bellard | } |
304 | 750afe93 | bellard | INLINE int float64_lt_quiet( float64 a, float64 b STATUS_PARAM)
|
305 | 158142c2 | bellard | { |
306 | 158142c2 | bellard | return isless(a, b);
|
307 | 158142c2 | bellard | |
308 | 158142c2 | bellard | } |
309 | 750afe93 | bellard | INLINE int float64_unordered( float64 a, float64 b STATUS_PARAM)
|
310 | b109f9f8 | bellard | { |
311 | b109f9f8 | bellard | return isunordered(a, b);
|
312 | b109f9f8 | bellard | |
313 | b109f9f8 | bellard | } |
314 | 750afe93 | bellard | int float64_compare( float64, float64 STATUS_PARAM );
|
315 | 750afe93 | bellard | int float64_compare_quiet( float64, float64 STATUS_PARAM );
|
316 | 750afe93 | bellard | int float64_is_signaling_nan( float64 );
|
317 | 750afe93 | bellard | int float64_is_nan( float64 );
|
318 | 158142c2 | bellard | |
319 | 158142c2 | bellard | INLINE float64 float64_abs(float64 a) |
320 | 158142c2 | bellard | { |
321 | 158142c2 | bellard | return fabs(a);
|
322 | 158142c2 | bellard | } |
323 | 158142c2 | bellard | |
324 | 158142c2 | bellard | INLINE float64 float64_chs(float64 a) |
325 | 158142c2 | bellard | { |
326 | 158142c2 | bellard | return -a;
|
327 | 158142c2 | bellard | } |
328 | 158142c2 | bellard | |
329 | 9ee6e8bb | pbrook | INLINE float64 float64_scalbn(float64 a, int n)
|
330 | 9ee6e8bb | pbrook | { |
331 | 9ee6e8bb | pbrook | return scalbn(a, n);
|
332 | 9ee6e8bb | pbrook | } |
333 | 9ee6e8bb | pbrook | |
334 | 158142c2 | bellard | #ifdef FLOATX80
|
335 | 158142c2 | bellard | |
336 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
337 | 158142c2 | bellard | | Software IEC/IEEE extended double-precision conversion routines.
|
338 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
339 | 158142c2 | bellard | int floatx80_to_int32( floatx80 STATUS_PARAM );
|
340 | 158142c2 | bellard | int floatx80_to_int32_round_to_zero( floatx80 STATUS_PARAM );
|
341 | 158142c2 | bellard | int64_t floatx80_to_int64( floatx80 STATUS_PARAM); |
342 | 158142c2 | bellard | int64_t floatx80_to_int64_round_to_zero( floatx80 STATUS_PARAM); |
343 | 158142c2 | bellard | float32 floatx80_to_float32( floatx80 STATUS_PARAM ); |
344 | 158142c2 | bellard | float64 floatx80_to_float64( floatx80 STATUS_PARAM ); |
345 | 158142c2 | bellard | #ifdef FLOAT128
|
346 | 158142c2 | bellard | float128 floatx80_to_float128( floatx80 STATUS_PARAM ); |
347 | 158142c2 | bellard | #endif
|
348 | 158142c2 | bellard | |
349 | 158142c2 | bellard | /*----------------------------------------------------------------------------
|
350 | 158142c2 | bellard | | Software IEC/IEEE extended double-precision operations.
|
351 | 158142c2 | bellard | *----------------------------------------------------------------------------*/
|
352 | 158142c2 | bellard | floatx80 floatx80_round_to_int( floatx80 STATUS_PARAM ); |
353 | 158142c2 | bellard | INLINE floatx80 floatx80_add( floatx80 a, floatx80 b STATUS_PARAM) |
354 | 158142c2 | bellard | { |
355 | 158142c2 | bellard | return a + b;
|
356 | 158142c2 | bellard | } |
357 | 158142c2 | bellard | INLINE floatx80 floatx80_sub( floatx80 a, floatx80 b STATUS_PARAM) |
358 | 158142c2 | bellard | { |
359 | 158142c2 | bellard | return a - b;
|
360 | 158142c2 | bellard | } |
361 | 158142c2 | bellard | INLINE floatx80 floatx80_mul( floatx80 a, floatx80 b STATUS_PARAM) |
362 | 158142c2 | bellard | { |
363 | 158142c2 | bellard | return a * b;
|
364 | 158142c2 | bellard | } |
365 | 158142c2 | bellard | INLINE floatx80 floatx80_div( floatx80 a, floatx80 b STATUS_PARAM) |
366 | 158142c2 | bellard | { |
367 | 158142c2 | bellard | return a / b;
|
368 | 158142c2 | bellard | } |
369 | 158142c2 | bellard | floatx80 floatx80_rem( floatx80, floatx80 STATUS_PARAM ); |
370 | 158142c2 | bellard | floatx80 floatx80_sqrt( floatx80 STATUS_PARAM ); |
371 | 750afe93 | bellard | INLINE int floatx80_eq( floatx80 a, floatx80 b STATUS_PARAM)
|
372 | 158142c2 | bellard | { |
373 | 158142c2 | bellard | return a == b;
|
374 | 158142c2 | bellard | } |
375 | 750afe93 | bellard | INLINE int floatx80_le( floatx80 a, floatx80 b STATUS_PARAM)
|
376 | 158142c2 | bellard | { |
377 | 158142c2 | bellard | return a <= b;
|
378 | 158142c2 | bellard | } |
379 | 750afe93 | bellard | INLINE int floatx80_lt( floatx80 a, floatx80 b STATUS_PARAM)
|
380 | 158142c2 | bellard | { |
381 | 158142c2 | bellard | return a < b;
|
382 | 158142c2 | bellard | } |
383 | 750afe93 | bellard | INLINE int floatx80_eq_signaling( floatx80 a, floatx80 b STATUS_PARAM)
|
384 | 158142c2 | bellard | { |
385 | b109f9f8 | bellard | return a <= b && a >= b;
|
386 | 158142c2 | bellard | } |
387 | 750afe93 | bellard | INLINE int floatx80_le_quiet( floatx80 a, floatx80 b STATUS_PARAM)
|
388 | 158142c2 | bellard | { |
389 | 158142c2 | bellard | return islessequal(a, b);
|
390 | 158142c2 | bellard | } |
391 | 750afe93 | bellard | INLINE int floatx80_lt_quiet( floatx80 a, floatx80 b STATUS_PARAM)
|
392 | 158142c2 | bellard | { |
393 | 158142c2 | bellard | return isless(a, b);
|
394 | 158142c2 | bellard | |
395 | 158142c2 | bellard | } |
396 | 750afe93 | bellard | INLINE int floatx80_unordered( floatx80 a, floatx80 b STATUS_PARAM)
|
397 | b109f9f8 | bellard | { |
398 | b109f9f8 | bellard | return isunordered(a, b);
|
399 | b109f9f8 | bellard | |
400 | b109f9f8 | bellard | } |
401 | 750afe93 | bellard | int floatx80_compare( floatx80, floatx80 STATUS_PARAM );
|
402 | 750afe93 | bellard | int floatx80_compare_quiet( floatx80, floatx80 STATUS_PARAM );
|
403 | 750afe93 | bellard | int floatx80_is_signaling_nan( floatx80 );
|
404 | 158142c2 | bellard | |
405 | 158142c2 | bellard | INLINE floatx80 floatx80_abs(floatx80 a) |
406 | 158142c2 | bellard | { |
407 | 158142c2 | bellard | return fabsl(a);
|
408 | 158142c2 | bellard | } |
409 | 158142c2 | bellard | |
410 | 158142c2 | bellard | INLINE floatx80 floatx80_chs(floatx80 a) |
411 | 158142c2 | bellard | { |
412 | 158142c2 | bellard | return -a;
|
413 | 158142c2 | bellard | } |
414 | 9ee6e8bb | pbrook | |
415 | 9ee6e8bb | pbrook | INLINE floatx80 floatx80_scalbn(floatx80 a, int n)
|
416 | 9ee6e8bb | pbrook | { |
417 | 9ee6e8bb | pbrook | return scalbnl(a, n);
|
418 | 9ee6e8bb | pbrook | } |
419 | 9ee6e8bb | pbrook | |
420 | 158142c2 | bellard | #endif |