~vcs-imports/qemu/git

« back to all changes in this revision

Viewing changes to fpu/softfloat-native.c

  • Committer: Blue Swirl
  • Date: 2009-08-31 15:14:40 UTC
  • Revision ID: git-v1:528e93a9787ccfc59582a44035f5f342caf5b84f
Fix breakage due to __thread

Thread-local storage is not supported on all hosts.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
   context is supported */
3
3
#include "softfloat.h"
4
4
#include <math.h>
 
5
#if defined(CONFIG_SOLARIS)
 
6
#include <fenv.h>
 
7
#endif
5
8
 
6
9
void set_float_rounding_mode(int val STATUS_PARAM)
7
10
{
8
11
    STATUS(float_rounding_mode) = val;
9
 
#if defined(_BSD) && !defined(__APPLE__) || (defined(HOST_SOLARIS) && HOST_SOLARIS < 10)
 
12
#if defined(CONFIG_BSD) && !defined(__APPLE__) ||         \
 
13
    (defined(CONFIG_SOLARIS) && CONFIG_SOLARIS_VERSION < 10)
10
14
    fpsetround(val);
11
15
#elif defined(__arm__)
12
16
    /* nothing to do */
22
26
}
23
27
#endif
24
28
 
25
 
#if defined(_BSD) || (defined(HOST_SOLARIS) && HOST_SOLARIS < 10)
 
29
#if defined(CONFIG_BSD) || \
 
30
    (defined(CONFIG_SOLARIS) && CONFIG_SOLARIS_VERSION < 10)
26
31
#define lrint(d)                ((int32_t)rint(d))
27
32
#define llrint(d)               ((int64_t)rint(d))
28
33
#define lrintf(f)               ((int32_t)rint(f))
30
35
#define sqrtf(f)                ((float)sqrt(f))
31
36
#define remainderf(fa, fb)      ((float)remainder(fa, fb))
32
37
#define rintf(f)                ((float)rint(f))
33
 
#if !defined(__sparc__) && defined(HOST_SOLARIS) && HOST_SOLARIS < 10
 
38
#if !defined(__sparc__) && \
 
39
    (defined(CONFIG_SOLARIS) && CONFIG_SOLARIS_VERSION < 10)
34
40
extern long double rintl(long double);
35
41
extern long double scalbnl(long double, int);
36
42
 
51
57
#endif
52
58
#endif
53
59
 
54
 
#if defined(__powerpc__)
 
60
#if defined(_ARCH_PPC)
55
61
 
56
62
/* correct (but slow) PowerPC rint() (glibc version is incorrect) */
57
 
double qemu_rint(double x)
 
63
static double qemu_rint(double x)
58
64
{
59
65
    double y = 4503599627370496.0;
60
66
    if (fabs(x) >= y)
220
226
int float32_compare( float32 a, float32 b STATUS_PARAM )
221
227
{
222
228
    if (a < b) {
223
 
        return -1;
 
229
        return float_relation_less;
224
230
    } else if (a == b) {
225
 
        return 0;
 
231
        return float_relation_equal;
226
232
    } else if (a > b) {
227
 
        return 1;
 
233
        return float_relation_greater;
228
234
    } else {
229
 
        return 2;
 
235
        return float_relation_unordered;
230
236
    }
231
237
}
232
238
int float32_compare_quiet( float32 a, float32 b STATUS_PARAM )
233
239
{
234
240
    if (isless(a, b)) {
235
 
        return -1;
 
241
        return float_relation_less;
236
242
    } else if (a == b) {
237
 
        return 0;
 
243
        return float_relation_equal;
238
244
    } else if (isgreater(a, b)) {
239
 
        return 1;
 
245
        return float_relation_greater;
240
246
    } else {
241
 
        return 2;
 
247
        return float_relation_unordered;
242
248
    }
243
249
}
244
250
int float32_is_signaling_nan( float32 a1)
250
256
    return ( ( ( a>>22 ) & 0x1FF ) == 0x1FE ) && ( a & 0x003FFFFF );
251
257
}
252
258
 
 
259
int float32_is_nan( float32 a1 )
 
260
{
 
261
    float32u u;
 
262
    uint64_t a;
 
263
    u.f = a1;
 
264
    a = u.i;
 
265
    return ( 0xFF800000 < ( a<<1 ) );
 
266
}
 
267
 
253
268
/*----------------------------------------------------------------------------
254
269
| Software IEC/IEEE double-precision conversion routines.
255
270
*----------------------------------------------------------------------------*/
336
351
/*----------------------------------------------------------------------------
337
352
| Software IEC/IEEE double-precision operations.
338
353
*----------------------------------------------------------------------------*/
339
 
#if defined(__sun__) && defined(HOST_SOLARIS) && HOST_SOLARIS < 10
 
354
#if defined(__sun__) && \
 
355
    (defined(CONFIG_SOLARIS) && CONFIG_SOLARIS_VERSION < 10)
340
356
static inline float64 trunc(float64 x)
341
357
{
342
358
    return x < 0 ? -floor(-x) : floor(x);
382
398
int float64_compare( float64 a, float64 b STATUS_PARAM )
383
399
{
384
400
    if (a < b) {
385
 
        return -1;
 
401
        return float_relation_less;
386
402
    } else if (a == b) {
387
 
        return 0;
 
403
        return float_relation_equal;
388
404
    } else if (a > b) {
389
 
        return 1;
 
405
        return float_relation_greater;
390
406
    } else {
391
 
        return 2;
 
407
        return float_relation_unordered;
392
408
    }
393
409
}
394
410
int float64_compare_quiet( float64 a, float64 b STATUS_PARAM )
395
411
{
396
412
    if (isless(a, b)) {
397
 
        return -1;
 
413
        return float_relation_less;
398
414
    } else if (a == b) {
399
 
        return 0;
 
415
        return float_relation_equal;
400
416
    } else if (isgreater(a, b)) {
401
 
        return 1;
 
417
        return float_relation_greater;
402
418
    } else {
403
 
        return 2;
 
419
        return float_relation_unordered;
404
420
    }
405
421
}
406
422
int float64_is_signaling_nan( float64 a1)
422
438
    u.f = a1;
423
439
    a = u.i;
424
440
 
425
 
    return ( LIT64( 0xFFE0000000000000 ) < (bits64) ( a<<1 ) );
 
441
    return ( LIT64( 0xFFF0000000000000 ) < (bits64) ( a<<1 ) );
426
442
 
427
443
}
428
444
 
474
490
int floatx80_compare( floatx80 a, floatx80 b STATUS_PARAM )
475
491
{
476
492
    if (a < b) {
477
 
        return -1;
 
493
        return float_relation_less;
478
494
    } else if (a == b) {
479
 
        return 0;
 
495
        return float_relation_equal;
480
496
    } else if (a > b) {
481
 
        return 1;
 
497
        return float_relation_greater;
482
498
    } else {
483
 
        return 2;
 
499
        return float_relation_unordered;
484
500
    }
485
501
}
486
502
int floatx80_compare_quiet( floatx80 a, floatx80 b STATUS_PARAM )
487
503
{
488
504
    if (isless(a, b)) {
489
 
        return -1;
 
505
        return float_relation_less;
490
506
    } else if (a == b) {
491
 
        return 0;
 
507
        return float_relation_equal;
492
508
    } else if (isgreater(a, b)) {
493
 
        return 1;
 
509
        return float_relation_greater;
494
510
    } else {
495
 
        return 2;
 
511
        return float_relation_unordered;
496
512
    }
497
513
}
498
514
int floatx80_is_signaling_nan( floatx80 a1)
499
515
{
500
516
    floatx80u u;
 
517
    uint64_t aLow;
 
518
    u.f = a1;
 
519
 
 
520
    aLow = u.i.low & ~ LIT64( 0x4000000000000000 );
 
521
    return
 
522
           ( ( u.i.high & 0x7FFF ) == 0x7FFF )
 
523
        && (bits64) ( aLow<<1 )
 
524
        && ( u.i.low == aLow );
 
525
}
 
526
 
 
527
int floatx80_is_nan( floatx80 a1 )
 
528
{
 
529
    floatx80u u;
501
530
    u.f = a1;
502
531
    return ( ( u.i.high & 0x7FFF ) == 0x7FFF ) && (bits64) ( u.i.low<<1 );
503
532
}