| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: softfloat.c,v 1.13 2013/11/22 17:04:24 martin Exp $ */ | | 1 | /* $NetBSD: softfloat.c,v 1.14 2016/03/29 18:42:29 martin Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * This version hacked for use with gcc -msoft-float by bjh21. | | 4 | * This version hacked for use with gcc -msoft-float by bjh21. |
5 | * (Mostly a case of #ifdefing out things GCC doesn't need or provides | | 5 | * (Mostly a case of #ifdefing out things GCC doesn't need or provides |
6 | * itself). | | 6 | * itself). |
7 | */ | | 7 | */ |
8 | | | 8 | |
9 | /* | | 9 | /* |
10 | * Things you may want to define: | | 10 | * Things you may want to define: |
11 | * | | 11 | * |
12 | * SOFTFLOAT_FOR_GCC - build only those functions necessary for GCC (with | | 12 | * SOFTFLOAT_FOR_GCC - build only those functions necessary for GCC (with |
13 | * -msoft-float) to work. Include "softfloat-for-gcc.h" to get them | | 13 | * -msoft-float) to work. Include "softfloat-for-gcc.h" to get them |
14 | * properly renamed. | | 14 | * properly renamed. |
| @@ -36,27 +36,27 @@ TIMES RESULT IN INCORRECT BEHAVIOR. USE | | | @@ -36,27 +36,27 @@ TIMES RESULT IN INCORRECT BEHAVIOR. USE |
36 | PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY | | 36 | PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY |
37 | AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. | | 37 | AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. |
38 | | | 38 | |
39 | Derivative works are acceptable, even for commercial purposes, so long as | | 39 | Derivative works are acceptable, even for commercial purposes, so long as |
40 | (1) they include prominent notice that the work is derivative, and (2) they | | 40 | (1) they include prominent notice that the work is derivative, and (2) they |
41 | include prominent notice akin to these four paragraphs for those parts of | | 41 | include prominent notice akin to these four paragraphs for those parts of |
42 | this code that are retained. | | 42 | this code that are retained. |
43 | | | 43 | |
44 | =============================================================================== | | 44 | =============================================================================== |
45 | */ | | 45 | */ |
46 | | | 46 | |
47 | #include <sys/cdefs.h> | | 47 | #include <sys/cdefs.h> |
48 | #if defined(LIBC_SCCS) && !defined(lint) | | 48 | #if defined(LIBC_SCCS) && !defined(lint) |
49 | __RCSID("$NetBSD: softfloat.c,v 1.13 2013/11/22 17:04:24 martin Exp $"); | | 49 | __RCSID("$NetBSD: softfloat.c,v 1.14 2016/03/29 18:42:29 martin Exp $"); |
50 | #endif /* LIBC_SCCS and not lint */ | | 50 | #endif /* LIBC_SCCS and not lint */ |
51 | | | 51 | |
52 | #ifdef SOFTFLOAT_FOR_GCC | | 52 | #ifdef SOFTFLOAT_FOR_GCC |
53 | #include "softfloat-for-gcc.h" | | 53 | #include "softfloat-for-gcc.h" |
54 | #endif | | 54 | #endif |
55 | | | 55 | |
56 | #include "milieu.h" | | 56 | #include "milieu.h" |
57 | #include "softfloat.h" | | 57 | #include "softfloat.h" |
58 | | | 58 | |
59 | /* | | 59 | /* |
60 | * Conversions between floats as stored in memory and floats as | | 60 | * Conversions between floats as stored in memory and floats as |
61 | * SoftFloat uses them | | 61 | * SoftFloat uses them |
62 | */ | | 62 | */ |
| @@ -651,27 +651,27 @@ format. | | | @@ -651,27 +651,27 @@ format. |
651 | significand is not normalized, `zExp' must be 0; in that case, the result | | 651 | significand is not normalized, `zExp' must be 0; in that case, the result |
652 | returned is a subnormal number, and it must not require rounding. The | | 652 | returned is a subnormal number, and it must not require rounding. The |
653 | handling of underflow and overflow follows the IEC/IEEE Standard for Binary | | 653 | handling of underflow and overflow follows the IEC/IEEE Standard for Binary |
654 | Floating-Point Arithmetic. | | 654 | Floating-Point Arithmetic. |
655 | ------------------------------------------------------------------------------- | | 655 | ------------------------------------------------------------------------------- |
656 | */ | | 656 | */ |
657 | static floatx80 | | 657 | static floatx80 |
658 | roundAndPackFloatx80( | | 658 | roundAndPackFloatx80( |
659 | int8 roundingPrecision, flag zSign, int32 zExp, bits64 zSig0, bits64 zSig1 | | 659 | int8 roundingPrecision, flag zSign, int32 zExp, bits64 zSig0, bits64 zSig1 |
660 | ) | | 660 | ) |
661 | { | | 661 | { |
662 | int8 roundingMode; | | 662 | int8 roundingMode; |
663 | flag roundNearestEven, increment, isTiny; | | 663 | flag roundNearestEven, increment, isTiny; |
664 | int64 roundIncrement, roundMask, roundBits; | | 664 | uint64 roundIncrement, roundMask, roundBits; |
665 | | | 665 | |
666 | roundingMode = float_rounding_mode; | | 666 | roundingMode = float_rounding_mode; |
667 | roundNearestEven = ( roundingMode == float_round_nearest_even ); | | 667 | roundNearestEven = ( roundingMode == float_round_nearest_even ); |
668 | if ( roundingPrecision == 80 ) goto precision80; | | 668 | if ( roundingPrecision == 80 ) goto precision80; |
669 | if ( roundingPrecision == 64 ) { | | 669 | if ( roundingPrecision == 64 ) { |
670 | roundIncrement = LIT64( 0x0000000000000400 ); | | 670 | roundIncrement = LIT64( 0x0000000000000400 ); |
671 | roundMask = LIT64( 0x00000000000007FF ); | | 671 | roundMask = LIT64( 0x00000000000007FF ); |
672 | } | | 672 | } |
673 | else if ( roundingPrecision == 32 ) { | | 673 | else if ( roundingPrecision == 32 ) { |
674 | roundIncrement = LIT64( 0x0000008000000000 ); | | 674 | roundIncrement = LIT64( 0x0000008000000000 ); |
675 | roundMask = LIT64( 0x000000FFFFFFFFFF ); | | 675 | roundMask = LIT64( 0x000000FFFFFFFFFF ); |
676 | } | | 676 | } |
677 | else { | | 677 | else { |
| @@ -3928,38 +3928,38 @@ floatx80 floatx80_div( floatx80 a, float | | | @@ -3928,38 +3928,38 @@ floatx80 floatx80_div( floatx80 a, float |
3928 | floatx80_rounding_precision, zSign, zExp, zSig0, zSig1 ); | | 3928 | floatx80_rounding_precision, zSign, zExp, zSig0, zSig1 ); |
3929 | | | 3929 | |
3930 | } | | 3930 | } |
3931 | | | 3931 | |
3932 | /* | | 3932 | /* |
3933 | ------------------------------------------------------------------------------- | | 3933 | ------------------------------------------------------------------------------- |
3934 | Returns the remainder of the extended double-precision floating-point value | | 3934 | Returns the remainder of the extended double-precision floating-point value |
3935 | `a' with respect to the corresponding value `b'. The operation is performed | | 3935 | `a' with respect to the corresponding value `b'. The operation is performed |
3936 | according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. | | 3936 | according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. |
3937 | ------------------------------------------------------------------------------- | | 3937 | ------------------------------------------------------------------------------- |
3938 | */ | | 3938 | */ |
3939 | floatx80 floatx80_rem( floatx80 a, floatx80 b ) | | 3939 | floatx80 floatx80_rem( floatx80 a, floatx80 b ) |
3940 | { | | 3940 | { |
3941 | flag aSign, bSign, zSign; | | 3941 | flag aSign, zSign; |
3942 | int32 aExp, bExp, expDiff; | | 3942 | int32 aExp, bExp, expDiff; |
3943 | bits64 aSig0, aSig1, bSig; | | 3943 | bits64 aSig0, aSig1, bSig; |
3944 | bits64 q, term0, term1, alternateASig0, alternateASig1; | | 3944 | bits64 q, term0, term1, alternateASig0, alternateASig1; |
3945 | floatx80 z; | | 3945 | floatx80 z; |
3946 | | | 3946 | |
3947 | aSig0 = extractFloatx80Frac( a ); | | 3947 | aSig0 = extractFloatx80Frac( a ); |
3948 | aExp = extractFloatx80Exp( a ); | | 3948 | aExp = extractFloatx80Exp( a ); |
3949 | aSign = extractFloatx80Sign( a ); | | 3949 | aSign = extractFloatx80Sign( a ); |
3950 | bSig = extractFloatx80Frac( b ); | | 3950 | bSig = extractFloatx80Frac( b ); |
3951 | bExp = extractFloatx80Exp( b ); | | 3951 | bExp = extractFloatx80Exp( b ); |
3952 | bSign = extractFloatx80Sign( b ); | | 3952 | |
3953 | if ( aExp == 0x7FFF ) { | | 3953 | if ( aExp == 0x7FFF ) { |
3954 | if ( (bits64) ( aSig0<<1 ) | | 3954 | if ( (bits64) ( aSig0<<1 ) |
3955 | || ( ( bExp == 0x7FFF ) && (bits64) ( bSig<<1 ) ) ) { | | 3955 | || ( ( bExp == 0x7FFF ) && (bits64) ( bSig<<1 ) ) ) { |
3956 | return propagateFloatx80NaN( a, b ); | | 3956 | return propagateFloatx80NaN( a, b ); |
3957 | } | | 3957 | } |
3958 | goto invalid; | | 3958 | goto invalid; |
3959 | } | | 3959 | } |
3960 | if ( bExp == 0x7FFF ) { | | 3960 | if ( bExp == 0x7FFF ) { |
3961 | if ( (bits64) ( bSig<<1 ) ) return propagateFloatx80NaN( a, b ); | | 3961 | if ( (bits64) ( bSig<<1 ) ) return propagateFloatx80NaN( a, b ); |
3962 | return a; | | 3962 | return a; |
3963 | } | | 3963 | } |
3964 | if ( bExp == 0 ) { | | 3964 | if ( bExp == 0 ) { |
3965 | if ( bSig == 0 ) { | | 3965 | if ( bSig == 0 ) { |