Statistics
| Branch: | Revision:

root / fpu / softfloat-native.h @ b53d44e5

History | View | Annotate | Download (13.3 kB)

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