Module Name: src Committed By: thorpej Date: Wed Sep 2 03:41:56 UTC 2020
Modified Files: src/sys/lib/libkern: softfloat-specialize.h softfloat.h Log Message: Update to the SoftFloat-2c version of softfloat-specialize.h and softfloat.h. This includes a simplification of the license and updates the comments. NFC. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/lib/libkern/softfloat-specialize.h cvs rdiff -u -r1.5 -r1.6 src/sys/lib/libkern/softfloat.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/lib/libkern/softfloat-specialize.h diff -u src/sys/lib/libkern/softfloat-specialize.h:1.2 src/sys/lib/libkern/softfloat-specialize.h:1.3 --- src/sys/lib/libkern/softfloat-specialize.h:1.2 Mon Apr 28 20:24:06 2008 +++ src/sys/lib/libkern/softfloat-specialize.h Wed Sep 2 03:41:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: softfloat-specialize.h,v 1.2 2008/04/28 20:24:06 martin Exp $ */ +/* $NetBSD: softfloat-specialize.h,v 1.3 2020/09/02 03:41:56 thorpej Exp $ */ /* This is a derivative work. */ @@ -31,68 +31,55 @@ * POSSIBILITY OF SUCH DAMAGE. */ -/* -=============================================================================== - -This C source fragment is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2a. - -Written by John R. Hauser. This work was made possible in part by the -International Computer Science Institute, located at Suite 600, 1947 Center -Street, Berkeley, California 94704. Funding was partially provided by the -National Science Foundation under grant MIP-9311980. The original version -of this code was written as part of a project to build a fixed-point vector -processor in collaboration with the University of California at Berkeley, -overseen by Profs. Nelson Morgan and John Wawrzynek. More information -is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ -arithmetic/SoftFloat.html'. - -THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort -has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT -TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO -PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY -AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. - -Derivative works are acceptable, even for commercial purposes, so long as -(1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these four paragraphs for those parts of -this code that are retained. +/*============================================================================ -=============================================================================== -*/ - -/* -------------------------------------------------------------------------------- -Underflow tininess-detection mode, statically initialized to default value. -------------------------------------------------------------------------------- -*/ +This C source fragment is part of the Berkeley SoftFloat IEEE Floating-Point +Arithmetic Package, Release 2c, by John R. Hauser. +THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort has +been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT TIMES +RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO PERSONS +AND ORGANIZATIONS WHO CAN AND WILL TOLERATE ALL LOSSES, COSTS, OR OTHER +PROBLEMS THEY INCUR DUE TO THE SOFTWARE WITHOUT RECOMPENSE FROM JOHN HAUSER OR +THE INTERNATIONAL COMPUTER SCIENCE INSTITUTE, AND WHO FURTHERMORE EFFECTIVELY +INDEMNIFY JOHN HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE INSTITUTE +(possibly via similar legal notice) AGAINST ALL LOSSES, COSTS, OR OTHER +PROBLEMS INCURRED BY THEIR CUSTOMERS AND CLIENTS DUE TO THE SOFTWARE, OR +INCURRED BY ANYONE DUE TO A DERIVATIVE WORK THEY CREATE USING ANY PART OF THE +SOFTWARE. + +Derivative works require also that (1) the source code for the derivative work +includes prominent notice that the work is derivative, and (2) the source code +includes prominent notice of these three paragraphs for those parts of this +code that are retained. + +=============================================================================*/ + +/*---------------------------------------------------------------------------- +| Underflow tininess-detection mode, statically initialized to default value. +| (The declaration in `softfloat.h' must match the `int8' type here.) +*----------------------------------------------------------------------------*/ /* [ MP safe, does not change dynamically ] */ int float_detect_tininess = float_tininess_after_rounding; -/* -------------------------------------------------------------------------------- -Internal canonical NaN format. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| Internal canonical NaN format. +*----------------------------------------------------------------------------*/ typedef struct { flag sign; bits64 high, low; } commonNaNT; -/* -------------------------------------------------------------------------------- -The pattern for a default generated single-precision NaN. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| The pattern for a default generated single-precision NaN. +*----------------------------------------------------------------------------*/ #define float32_default_nan 0xFFC00000 -/* -------------------------------------------------------------------------------- -Returns 1 if the single-precision floating-point value `a' is a NaN; -otherwise returns 0. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| Returns 1 if the single-precision floating-point value `a' is a NaN; +| otherwise returns 0. +*----------------------------------------------------------------------------*/ + static flag float32_is_nan( float32 a ) { @@ -100,12 +87,11 @@ static flag float32_is_nan( float32 a ) } -/* -------------------------------------------------------------------------------- -Returns 1 if the single-precision floating-point value `a' is a signaling -NaN; otherwise returns 0. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| Returns 1 if the single-precision floating-point value `a' is a signaling +| NaN; otherwise returns 0. +*----------------------------------------------------------------------------*/ + flag float32_is_signaling_nan( float32 a ) { @@ -113,13 +99,12 @@ flag float32_is_signaling_nan( float32 a } -/* -------------------------------------------------------------------------------- -Returns the result of converting the single-precision floating-point NaN -`a' to the canonical NaN format. If `a' is a signaling NaN, the invalid -exception is raised. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| Returns the result of converting the single-precision floating-point NaN +| `a' to the canonical NaN format. If `a' is a signaling NaN, the invalid +| exception is raised. +*----------------------------------------------------------------------------*/ + static commonNaNT float32ToCommonNaN( float32 a ) { commonNaNT z; @@ -132,12 +117,11 @@ static commonNaNT float32ToCommonNaN( fl } -/* -------------------------------------------------------------------------------- -Returns the result of converting the canonical NaN `a' to the single- -precision floating-point format. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| Returns the result of converting the canonical NaN `a' to the single- +| precision floating-point format. +*----------------------------------------------------------------------------*/ + static float32 commonNaNToFloat32( commonNaNT a ) { @@ -145,13 +129,12 @@ static float32 commonNaNToFloat32( commo } -/* -------------------------------------------------------------------------------- -Takes two single-precision floating-point values `a' and `b', one of which -is a NaN, and returns the appropriate NaN result. If either `a' or `b' is a -signaling NaN, the invalid exception is raised. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| Takes two single-precision floating-point values `a' and `b', one of which +| is a NaN, and returns the appropriate NaN result. If either `a' or `b' is a +| signaling NaN, the invalid exception is raised. +*----------------------------------------------------------------------------*/ + static float32 propagateFloat32NaN( float32 a, float32 b ) { flag aIsNaN, aIsSignalingNaN, bIsNaN, bIsSignalingNaN; @@ -180,14 +163,17 @@ static float32 propagateFloat32NaN( floa } - /* -------------------------------------------------------------------------------- -Returns the result of converting the double-precision floating-point NaN -`a' to the canonical NaN format. If `a' is a signaling NaN, the invalid -exception is raised. -------------------------------------------------------------------------------- -*/ + * float64_default_nan, float64_is_nan(), float64_is_signaling_nan() + * have moved to softfloat.h. + */ + +/*---------------------------------------------------------------------------- +| Returns the result of converting the double-precision floating-point NaN +| `a' to the canonical NaN format. If `a' is a signaling NaN, the invalid +| exception is raised. +*----------------------------------------------------------------------------*/ + static commonNaNT float64ToCommonNaN( float64 a ) { commonNaNT z; @@ -200,12 +186,11 @@ static commonNaNT float64ToCommonNaN( fl } -/* -------------------------------------------------------------------------------- -Returns the result of converting the canonical NaN `a' to the double- -precision floating-point format. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| Returns the result of converting the canonical NaN `a' to the double- +| precision floating-point format. +*----------------------------------------------------------------------------*/ + static float64 commonNaNToFloat64( commonNaNT a ) { @@ -216,13 +201,12 @@ static float64 commonNaNToFloat64( commo } -/* -------------------------------------------------------------------------------- -Takes two double-precision floating-point values `a' and `b', one of which -is a NaN, and returns the appropriate NaN result. If either `a' or `b' is a -signaling NaN, the invalid exception is raised. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| Takes two double-precision floating-point values `a' and `b', one of which +| is a NaN, and returns the appropriate NaN result. If either `a' or `b' is a +| signaling NaN, the invalid exception is raised. +*----------------------------------------------------------------------------*/ + static float64 propagateFloat64NaN( float64 a, float64 b ) { flag aIsNaN, aIsSignalingNaN, bIsNaN, bIsSignalingNaN; @@ -253,22 +237,19 @@ static float64 propagateFloat64NaN( floa #ifdef FLOATX80 -/* -------------------------------------------------------------------------------- -The pattern for a default generated extended double-precision NaN. The -`high' and `low' values hold the most- and least-significant bits, -respectively. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| The pattern for a default generated double-extended-precision NaN. +| The `high' and `low' values hold the most- and least-significant bits, +| respectively. +*----------------------------------------------------------------------------*/ #define floatx80_default_nan_high 0xFFFF #define floatx80_default_nan_low LIT64( 0xC000000000000000 ) -/* -------------------------------------------------------------------------------- -Returns 1 if the extended double-precision floating-point value `a' is a -NaN; otherwise returns 0. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| Returns 1 if the double-extended-precision floating-point value `a' is a +| NaN; otherwise returns 0. +*----------------------------------------------------------------------------*/ + static flag floatx80_is_nan( floatx80 a ) { @@ -276,12 +257,11 @@ static flag floatx80_is_nan( floatx80 a } -/* -------------------------------------------------------------------------------- -Returns 1 if the extended double-precision floating-point value `a' is a -signaling NaN; otherwise returns 0. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| Returns 1 if the double-extended-precision floating-point value `a' is a +| signaling NaN; otherwise returns 0. +*----------------------------------------------------------------------------*/ + flag floatx80_is_signaling_nan( floatx80 a ) { bits64 aLow; @@ -294,13 +274,12 @@ flag floatx80_is_signaling_nan( floatx80 } -/* -------------------------------------------------------------------------------- -Returns the result of converting the extended double-precision floating- -point NaN `a' to the canonical NaN format. If `a' is a signaling NaN, the -invalid exception is raised. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| Returns the result of converting the double-extended-precision floating- +| point NaN `a' to the canonical NaN format. If `a' is a signaling NaN, the +| invalid exception is raised. +*----------------------------------------------------------------------------*/ + static commonNaNT floatx80ToCommonNaN( floatx80 a ) { commonNaNT z; @@ -313,12 +292,11 @@ static commonNaNT floatx80ToCommonNaN( f } -/* -------------------------------------------------------------------------------- -Returns the result of converting the canonical NaN `a' to the extended -double-precision floating-point format. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| Returns the result of converting the canonical NaN `a' to the double- +| extended-precision floating-point format. +*----------------------------------------------------------------------------*/ + static floatx80 commonNaNToFloatx80( commonNaNT a ) { floatx80 z; @@ -329,13 +307,12 @@ static floatx80 commonNaNToFloatx80( com } -/* -------------------------------------------------------------------------------- -Takes two extended double-precision floating-point values `a' and `b', one -of which is a NaN, and returns the appropriate NaN result. If either `a' or -`b' is a signaling NaN, the invalid exception is raised. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| Takes two double-extended-precision floating-point values `a' and `b', one +| of which is a NaN, and returns the appropriate NaN result. If either `a' or +| `b' is a signaling NaN, the invalid exception is raised. +*----------------------------------------------------------------------------*/ + static floatx80 propagateFloatx80NaN( floatx80 a, floatx80 b ) { flag aIsNaN, aIsSignalingNaN, bIsNaN, bIsSignalingNaN; @@ -368,21 +345,18 @@ static floatx80 propagateFloatx80NaN( fl #ifdef FLOAT128 -/* -------------------------------------------------------------------------------- -The pattern for a default generated quadruple-precision NaN. The `high' and -`low' values hold the most- and least-significant bits, respectively. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| The pattern for a default generated quadruple-precision NaN. The `high' and +| `low' values hold the most- and least-significant bits, respectively. +*----------------------------------------------------------------------------*/ #define float128_default_nan_high LIT64( 0xFFFF800000000000 ) #define float128_default_nan_low LIT64( 0x0000000000000000 ) -/* -------------------------------------------------------------------------------- -Returns 1 if the quadruple-precision floating-point value `a' is a NaN; -otherwise returns 0. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| Returns 1 if the quadruple-precision floating-point value `a' is a NaN; +| otherwise returns 0. +*----------------------------------------------------------------------------*/ + flag float128_is_nan( float128 a ) { @@ -392,12 +366,11 @@ flag float128_is_nan( float128 a ) } -/* -------------------------------------------------------------------------------- -Returns 1 if the quadruple-precision floating-point value `a' is a -signaling NaN; otherwise returns 0. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| Returns 1 if the quadruple-precision floating-point value `a' is a +| signaling NaN; otherwise returns 0. +*----------------------------------------------------------------------------*/ + flag float128_is_signaling_nan( float128 a ) { @@ -407,13 +380,12 @@ flag float128_is_signaling_nan( float128 } -/* -------------------------------------------------------------------------------- -Returns the result of converting the quadruple-precision floating-point NaN -`a' to the canonical NaN format. If `a' is a signaling NaN, the invalid -exception is raised. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| Returns the result of converting the quadruple-precision floating-point NaN +| `a' to the canonical NaN format. If `a' is a signaling NaN, the invalid +| exception is raised. +*----------------------------------------------------------------------------*/ + static commonNaNT float128ToCommonNaN( float128 a ) { commonNaNT z; @@ -425,12 +397,11 @@ static commonNaNT float128ToCommonNaN( f } -/* -------------------------------------------------------------------------------- -Returns the result of converting the canonical NaN `a' to the quadruple- -precision floating-point format. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| Returns the result of converting the canonical NaN `a' to the quadruple- +| precision floating-point format. +*----------------------------------------------------------------------------*/ + static float128 commonNaNToFloat128( commonNaNT a ) { float128 z; @@ -441,13 +412,12 @@ static float128 commonNaNToFloat128( com } -/* -------------------------------------------------------------------------------- -Takes two quadruple-precision floating-point values `a' and `b', one of -which is a NaN, and returns the appropriate NaN result. If either `a' or -`b' is a signaling NaN, the invalid exception is raised. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| Takes two quadruple-precision floating-point values `a' and `b', one of +| which is a NaN, and returns the appropriate NaN result. If either `a' or +| `b' is a signaling NaN, the invalid exception is raised. +*----------------------------------------------------------------------------*/ + static float128 propagateFloat128NaN( float128 a, float128 b ) { flag aIsNaN, aIsSignalingNaN, bIsNaN, bIsSignalingNaN; Index: src/sys/lib/libkern/softfloat.h diff -u src/sys/lib/libkern/softfloat.h:1.5 src/sys/lib/libkern/softfloat.h:1.6 --- src/sys/lib/libkern/softfloat.h:1.5 Sun Dec 31 11:43:42 2017 +++ src/sys/lib/libkern/softfloat.h Wed Sep 2 03:41:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: softfloat.h,v 1.5 2017/12/31 11:43:42 martin Exp $ */ +/* $NetBSD: softfloat.h,v 1.6 2020/09/02 03:41:56 thorpej Exp $ */ /* This is a derivative work. */ @@ -31,35 +31,29 @@ * POSSIBILITY OF SUCH DAMAGE. */ -/* -=============================================================================== +/*============================================================================ -This C header file is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2a. +This C header file template is part of the Berkeley SoftFloat IEEE Floating- +Point Arithmetic Package, Release 2c, by John R. Hauser. -Written by John R. Hauser. This work was made possible in part by the -International Computer Science Institute, located at Suite 600, 1947 Center -Street, Berkeley, California 94704. Funding was partially provided by the -National Science Foundation under grant MIP-9311980. The original version -of this code was written as part of a project to build a fixed-point vector -processor in collaboration with the University of California at Berkeley, -overseen by Profs. Nelson Morgan and John Wawrzynek. More information -is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ -arithmetic/SoftFloat.html'. - -THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort -has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT -TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO -PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY -AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. - -Derivative works are acceptable, even for commercial purposes, so long as -(1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these four paragraphs for those parts of -this code that are retained. +THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort has +been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT TIMES +RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO PERSONS +AND ORGANIZATIONS WHO CAN AND WILL TOLERATE ALL LOSSES, COSTS, OR OTHER +PROBLEMS THEY INCUR DUE TO THE SOFTWARE WITHOUT RECOMPENSE FROM JOHN HAUSER OR +THE INTERNATIONAL COMPUTER SCIENCE INSTITUTE, AND WHO FURTHERMORE EFFECTIVELY +INDEMNIFY JOHN HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE INSTITUTE +(possibly via similar legal notice) AGAINST ALL LOSSES, COSTS, OR OTHER +PROBLEMS INCURRED BY THEIR CUSTOMERS AND CLIENTS DUE TO THE SOFTWARE, OR +INCURRED BY ANYONE DUE TO A DERIVATIVE WORK THEY CREATE USING ANY PART OF THE +SOFTWARE. + +Derivative works require also that (1) the source code for the derivative work +includes prominent notice that the work is derivative, and (2) the source code +includes prominent notice of these three paragraphs for those parts of this +code that are retained. -=============================================================================== -*/ +=============================================================================*/ #include <sys/types.h> @@ -72,23 +66,19 @@ this code that are retained. #endif #include <sys/endian.h> -/* -------------------------------------------------------------------------------- -The macro `FLOATX80' must be defined to enable the extended double-precision -floating-point format `floatx80'. If this macro is not defined, the -`floatx80' type will not be defined, and none of the functions that either -input or output the `floatx80' type will be defined. The same applies to -the `FLOAT128' macro and the quadruple-precision format `float128'. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| The macro `FLOATX80' must be defined to enable the double-extended-precision +| floating-point format `floatx80'. If this macro is not defined, the +| `floatx80' type will not be defined, and none of the functions that either +| input or output the `floatx80' type will be defined. The same applies to +| the `FLOAT128' macro and the quadruple-precision format `float128'. +*----------------------------------------------------------------------------*/ /* #define FLOATX80 */ /* #define FLOAT128 */ -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point types. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| Software IEEE floating-point types. +*----------------------------------------------------------------------------*/ typedef u_int32_t float32; typedef u_int64_t float64; #ifdef FLOATX80 @@ -116,24 +106,18 @@ typedef struct { #define float_rounding_mode() fpgetround() -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point underflow tininess-detection mode. -------------------------------------------------------------------------------- -*/ - +/*---------------------------------------------------------------------------- +| Software IEEE floating-point underflow tininess-detection mode. +*----------------------------------------------------------------------------*/ extern int float_detect_tininess; enum { float_tininess_after_rounding = 1, float_tininess_before_rounding = 0 }; -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point rounding mode. -------------------------------------------------------------------------------- -*/ - +/*---------------------------------------------------------------------------- +| Software IEEE floating-point rounding mode. +*----------------------------------------------------------------------------*/ enum { float_round_nearest_even = FP_RN, float_round_to_zero = FP_RZ, @@ -141,12 +125,9 @@ enum { float_round_up = FP_RP }; -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point exception flags. -------------------------------------------------------------------------------- -*/ - +/*---------------------------------------------------------------------------- +| Software IEEE floating-point exception flags. +*----------------------------------------------------------------------------*/ enum { float_flag_inexact = FP_X_IMP, float_flag_underflow = FP_X_UFL, @@ -155,11 +136,21 @@ enum { float_flag_invalid = FP_X_INV }; +/*---------------------------------------------------------------------------- +| Routine to raise any or all of the software IEEE floating-point exception +| flags. +*----------------------------------------------------------------------------*/ /* -------------------------------------------------------------------------------- -Software IEC/IEEE integer-to-floating-point conversion routines. -------------------------------------------------------------------------------- -*/ + * Routines provided by <machine/ieeefp.h>: + * + * float_raise() + * float_set_inexact() + * float_set_invalid() + */ + +/*---------------------------------------------------------------------------- +| Software IEEE integer-to-floating-point conversion routines. +*----------------------------------------------------------------------------*/ float32 int32_to_float32( int ); float64 int32_to_float64( int ); #ifdef FLOATX80 @@ -179,11 +170,9 @@ float128 int64_to_float128( int64_t ); #endif #endif -/* -------------------------------------------------------------------------------- -Software IEC/IEEE single-precision conversion routines. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| Software IEEE single-precision conversion routines. +*----------------------------------------------------------------------------*/ int float32_to_int32( float32 ); int float32_to_int32_round_to_zero( float32 ); #ifndef SOFTFLOAT_FOR_GCC /* __fix?fdi provided by libgcc2.c */ @@ -198,11 +187,9 @@ floatx80 float32_to_floatx80( float32 ); float128 float32_to_float128( float32 ); #endif -/* -------------------------------------------------------------------------------- -Software IEC/IEEE single-precision operations. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| Software IEEE single-precision operations. +*----------------------------------------------------------------------------*/ float32 float32_round_to_int( float32 ); float32 float32_add( float32, float32 ); float32 float32_sub( float32, float32 ); @@ -220,11 +207,9 @@ int float32_lt_quiet( float32, float32 ) int float32_is_signaling_nan( float32 ); #endif -/* -------------------------------------------------------------------------------- -Software IEC/IEEE double-precision conversion routines. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| Software IEEE double-precision conversion routines. +*----------------------------------------------------------------------------*/ int float64_to_int32( float64 ); int float64_to_int32_round_to_zero( float64 ); #ifndef SOFTFLOAT_FOR_GCC /* __fix?fdi provided by libgcc2.c */ @@ -240,19 +225,31 @@ floatx80 float64_to_floatx80( float64 ); float128 float64_to_float128( float64 ); #endif -/* -------------------------------------------------------------------------------- -Software IEC/IEEE double-precision operations. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| Software IEEE double-precision operations. +*----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +| The pattern for a default generated double-precision NaN. +*----------------------------------------------------------------------------*/ #define float64_default_nan 0xFFF8000000000000LL +/*---------------------------------------------------------------------------- +| Returns 1 if the double-precision floating-point value `a' is a NaN; +| otherwise returns 0. +*----------------------------------------------------------------------------*/ + static __inline int float64_is_nan(float64 a) { return 0xFFE0000000000000LL < a << 1; } +/*---------------------------------------------------------------------------- +| Returns 1 if the double-precision floating-point value `a' is a signaling +| NaN; otherwise returns 0. +*----------------------------------------------------------------------------*/ + static __inline int float64_is_signaling_nan(float64 a) { @@ -278,11 +275,9 @@ int float64_is_signaling_nan( float64 ); #ifdef FLOATX80 -/* -------------------------------------------------------------------------------- -Software IEC/IEEE extended double-precision conversion routines. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| Software IEEE double-extended-precision conversion routines. +*----------------------------------------------------------------------------*/ int floatx80_to_int32( floatx80 ); int floatx80_to_int32_round_to_zero( floatx80 ); int64_t floatx80_to_int64( floatx80 ); @@ -293,19 +288,15 @@ float64 floatx80_to_float64( floatx80 ); float128 floatx80_to_float128( floatx80 ); #endif -/* -------------------------------------------------------------------------------- -Software IEC/IEEE extended double-precision rounding precision. Valid -values are 32, 64, and 80. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| Software IEEE double-extended-precision rounding precision. Valid values +| are 32, 64, and 80. +*----------------------------------------------------------------------------*/ extern int floatx80_rounding_precision; -/* -------------------------------------------------------------------------------- -Software IEC/IEEE extended double-precision operations. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| Software IEEE double-extended-precision operations. +*----------------------------------------------------------------------------*/ floatx80 floatx80_round_to_int( floatx80 ); floatx80 floatx80_add( floatx80, floatx80 ); floatx80 floatx80_sub( floatx80, floatx80 ); @@ -325,11 +316,9 @@ int floatx80_is_signaling_nan( floatx80 #ifdef FLOAT128 -/* -------------------------------------------------------------------------------- -Software IEC/IEEE quadruple-precision conversion routines. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| Software IEEE quadruple-precision conversion routines. +*----------------------------------------------------------------------------*/ int float128_to_int32( float128 ); int float128_to_int32_round_to_zero( float128 ); int64_t float128_to_int64( float128 ); @@ -340,11 +329,9 @@ float64 float128_to_float64( float128 ); floatx80 float128_to_floatx80( float128 ); #endif -/* -------------------------------------------------------------------------------- -Software IEC/IEEE quadruple-precision operations. -------------------------------------------------------------------------------- -*/ +/*---------------------------------------------------------------------------- +| Software IEEE quadruple-precision operations. +*----------------------------------------------------------------------------*/ float128 float128_round_to_int( float128 ); float128 float128_add( float128, float128 ); float128 float128_sub( float128, float128 );