Patchwork [v3,4/7] softfloat: Resolve type mismatches between declaration and implementation

login
register
mail settings
Submitter Andreas Färber
Date Dec. 18, 2010, 4:25 p.m.
Message ID <1292689531-18763-4-git-send-email-andreas.faerber@web.de>
Download mbox | patch
Permalink /patch/76080/
State New
Headers show

Comments

Andreas Färber - Dec. 18, 2010, 4:25 p.m.
The original SoftFloat 2.0b library avoided the use of custom integer types
in its public headers. This requires the definitions of int{8,16,32,64} to
match the assumptions in the declarations. This breaks on BeOS R5 and Haiku/x86,
where int32 is defined in {be,os}/support/SupportDefs.h in terms of a long
rather than an int. Spotted by Michael Lotz.

Since QEMU already breaks this distinction by defining those types just above,
do use them for consistency and to allow #ifndef'ing them out as done for
[u]int16 on AIX.

Note that the BeOS/Haiku types are exact-width types though.

v3:
* Split off as intermediate step.

v2:
* Rebased.

Cc: Michael Lotz <mmlr@mlotz.ch>
Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
 fpu/softfloat.h |   68 +++++++++++++++++++++++++++---------------------------
 1 files changed, 34 insertions(+), 34 deletions(-)
Blue Swirl - Dec. 19, 2010, 11:28 a.m.
On Sat, Dec 18, 2010 at 4:25 PM, Andreas Färber <andreas.faerber@web.de> wrote:
> The original SoftFloat 2.0b library avoided the use of custom integer types
> in its public headers. This requires the definitions of int{8,16,32,64} to
> match the assumptions in the declarations. This breaks on BeOS R5 and Haiku/x86,
> where int32 is defined in {be,os}/support/SupportDefs.h in terms of a long
> rather than an int. Spotted by Michael Lotz.
>
> Since QEMU already breaks this distinction by defining those types just above,
> do use them for consistency and to allow #ifndef'ing them out as done for
> [u]int16 on AIX.
>
> Note that the BeOS/Haiku types are exact-width types though.
>
> v3:
> * Split off as intermediate step.
>
> v2:
> * Rebased.
>
> Cc: Michael Lotz <mmlr@mlotz.ch>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Andreas Färber <andreas.faerber@web.de>
> ---
>  fpu/softfloat.h |   68 +++++++++++++++++++++++++++---------------------------
>  1 files changed, 34 insertions(+), 34 deletions(-)
>
> diff --git a/fpu/softfloat.h b/fpu/softfloat.h
> index 1c1004d..c62e769 100644
> --- a/fpu/softfloat.h
> +++ b/fpu/softfloat.h
> @@ -221,25 +221,25 @@ void float_raise( int8 flags STATUS_PARAM);
>  /*----------------------------------------------------------------------------
>  | Software IEC/IEEE integer-to-floating-point conversion routines.
>  *----------------------------------------------------------------------------*/
> -float32 int32_to_float32( int STATUS_PARAM );
> -float64 int32_to_float64( int STATUS_PARAM );
> +float32 int32_to_float32( int32 STATUS_PARAM );
> +float64 int32_to_float64( int32 STATUS_PARAM );
>  float32 uint32_to_float32( unsigned int STATUS_PARAM );
>  float64 uint32_to_float64( unsigned int STATUS_PARAM );

Shouldn't these use uint32 as well?
Andreas Färber - Dec. 19, 2010, 12:06 p.m.
Am 19.12.2010 um 12:28 schrieb Blue Swirl:

> On Sat, Dec 18, 2010 at 4:25 PM, Andreas Färber <andreas.faerber@web.de 
> > wrote:
>> The original SoftFloat 2.0b library avoided the use of custom  
>> integer types
>> in its public headers. This requires the definitions of  
>> int{8,16,32,64} to
>> match the assumptions in the declarations. This breaks on BeOS R5  
>> and Haiku/x86,
>> where int32 is defined in {be,os}/support/SupportDefs.h in terms of  
>> a long
>> rather than an int. Spotted by Michael Lotz.
>>
>> Since QEMU already breaks this distinction by defining those types  
>> just above,
>> do use them for consistency and to allow #ifndef'ing them out as  
>> done for
>> [u]int16 on AIX.
>>
>> Note that the BeOS/Haiku types are exact-width types though.
>>
>> v3:
>> * Split off as intermediate step.
>>
>> v2:
>> * Rebased.
>>
>> Cc: Michael Lotz <mmlr@mlotz.ch>
>> Cc: Peter Maydell <peter.maydell@linaro.org>
>> Signed-off-by: Andreas Färber <andreas.faerber@web.de>
>> ---
>>  fpu/softfloat.h |   68 ++++++++++++++++++++++++++ 
>> +---------------------------
>>  1 files changed, 34 insertions(+), 34 deletions(-)
>>
>> diff --git a/fpu/softfloat.h b/fpu/softfloat.h
>> index 1c1004d..c62e769 100644
>> --- a/fpu/softfloat.h
>> +++ b/fpu/softfloat.h
>> @@ -221,25 +221,25 @@ void float_raise( int8 flags STATUS_PARAM);
>>  / 
>> *----------------------------------------------------------------------------
>>  | Software IEC/IEEE integer-to-floating-point conversion routines.
>>   
>> *----------------------------------------------------------------------------*/
>> -float32 int32_to_float32( int STATUS_PARAM );
>> -float64 int32_to_float64( int STATUS_PARAM );
>> +float32 int32_to_float32( int32 STATUS_PARAM );
>> +float64 int32_to_float64( int32 STATUS_PARAM );
>>  float32 uint32_to_float32( unsigned int STATUS_PARAM );
>>  float64 uint32_to_float64( unsigned int STATUS_PARAM );
>
> Shouldn't these use uint32 as well?

As requested by Peter, I took this intermediate step to really just  
align declarations and implementations.
I manually compared the functions and some, including the recently  
added int16 stuff, do use unsigned int in the implementation as well.

I have not converted uint32 yet, awaiting feedback on this series, so  
that would go into a patch such as v3 7/7, doing the semantic change  
separately for bisection.

Andreas

Patch

diff --git a/fpu/softfloat.h b/fpu/softfloat.h
index 1c1004d..c62e769 100644
--- a/fpu/softfloat.h
+++ b/fpu/softfloat.h
@@ -221,25 +221,25 @@  void float_raise( int8 flags STATUS_PARAM);
 /*----------------------------------------------------------------------------
 | Software IEC/IEEE integer-to-floating-point conversion routines.
 *----------------------------------------------------------------------------*/
-float32 int32_to_float32( int STATUS_PARAM );
-float64 int32_to_float64( int STATUS_PARAM );
+float32 int32_to_float32( int32 STATUS_PARAM );
+float64 int32_to_float64( int32 STATUS_PARAM );
 float32 uint32_to_float32( unsigned int STATUS_PARAM );
 float64 uint32_to_float64( unsigned int STATUS_PARAM );
 #ifdef FLOATX80
-floatx80 int32_to_floatx80( int STATUS_PARAM );
+floatx80 int32_to_floatx80( int32 STATUS_PARAM );
 #endif
 #ifdef FLOAT128
-float128 int32_to_float128( int STATUS_PARAM );
+float128 int32_to_float128( int32 STATUS_PARAM );
 #endif
-float32 int64_to_float32( int64_t STATUS_PARAM );
-float32 uint64_to_float32( uint64_t STATUS_PARAM );
-float64 int64_to_float64( int64_t STATUS_PARAM );
-float64 uint64_to_float64( uint64_t STATUS_PARAM );
+float32 int64_to_float32( int64 STATUS_PARAM );
+float32 uint64_to_float32( uint64 STATUS_PARAM );
+float64 int64_to_float64( int64 STATUS_PARAM );
+float64 uint64_to_float64( uint64 STATUS_PARAM );
 #ifdef FLOATX80
-floatx80 int64_to_floatx80( int64_t STATUS_PARAM );
+floatx80 int64_to_floatx80( int64 STATUS_PARAM );
 #endif
 #ifdef FLOAT128
-float128 int64_to_float128( int64_t STATUS_PARAM );
+float128 int64_to_float128( int64 STATUS_PARAM );
 #endif
 
 /*----------------------------------------------------------------------------
@@ -251,14 +251,14 @@  float32 float16_to_float32( bits16, flag STATUS_PARAM );
 /*----------------------------------------------------------------------------
 | Software IEC/IEEE single-precision conversion routines.
 *----------------------------------------------------------------------------*/
-int float32_to_int16_round_to_zero( float32 STATUS_PARAM );
+int16 float32_to_int16_round_to_zero( float32 STATUS_PARAM );
 unsigned int float32_to_uint16_round_to_zero( float32 STATUS_PARAM );
-int float32_to_int32( float32 STATUS_PARAM );
-int float32_to_int32_round_to_zero( float32 STATUS_PARAM );
-unsigned int float32_to_uint32( float32 STATUS_PARAM );
-unsigned int float32_to_uint32_round_to_zero( float32 STATUS_PARAM );
-int64_t float32_to_int64( float32 STATUS_PARAM );
-int64_t float32_to_int64_round_to_zero( float32 STATUS_PARAM );
+int32 float32_to_int32( float32 STATUS_PARAM );
+int32 float32_to_int32_round_to_zero( float32 STATUS_PARAM );
+uint32 float32_to_uint32( float32 STATUS_PARAM );
+uint32 float32_to_uint32_round_to_zero( float32 STATUS_PARAM );
+int64 float32_to_int64( float32 STATUS_PARAM );
+int64 float32_to_int64_round_to_zero( float32 STATUS_PARAM );
 float64 float32_to_float64( float32 STATUS_PARAM );
 #ifdef FLOATX80
 floatx80 float32_to_floatx80( float32 STATUS_PARAM );
@@ -329,16 +329,16 @@  INLINE int float32_is_any_nan(float32 a)
 /*----------------------------------------------------------------------------
 | Software IEC/IEEE double-precision conversion routines.
 *----------------------------------------------------------------------------*/
-int float64_to_int16_round_to_zero( float64 STATUS_PARAM );
+int16 float64_to_int16_round_to_zero( float64 STATUS_PARAM );
 unsigned int float64_to_uint16_round_to_zero( float64 STATUS_PARAM );
-int float64_to_int32( float64 STATUS_PARAM );
-int float64_to_int32_round_to_zero( float64 STATUS_PARAM );
-unsigned int float64_to_uint32( float64 STATUS_PARAM );
-unsigned int float64_to_uint32_round_to_zero( float64 STATUS_PARAM );
-int64_t float64_to_int64( float64 STATUS_PARAM );
-int64_t float64_to_int64_round_to_zero( float64 STATUS_PARAM );
-uint64_t float64_to_uint64 (float64 a STATUS_PARAM);
-uint64_t float64_to_uint64_round_to_zero (float64 a STATUS_PARAM);
+int32 float64_to_int32( float64 STATUS_PARAM );
+int32 float64_to_int32_round_to_zero( float64 STATUS_PARAM );
+uint32 float64_to_uint32( float64 STATUS_PARAM );
+uint32 float64_to_uint32_round_to_zero( float64 STATUS_PARAM );
+int64 float64_to_int64( float64 STATUS_PARAM );
+int64 float64_to_int64_round_to_zero( float64 STATUS_PARAM );
+uint64 float64_to_uint64 (float64 a STATUS_PARAM);
+uint64 float64_to_uint64_round_to_zero (float64 a STATUS_PARAM);
 float32 float64_to_float32( float64 STATUS_PARAM );
 #ifdef FLOATX80
 floatx80 float64_to_floatx80( float64 STATUS_PARAM );
@@ -411,10 +411,10 @@  INLINE int float64_is_any_nan(float64 a)
 /*----------------------------------------------------------------------------
 | Software IEC/IEEE extended double-precision conversion routines.
 *----------------------------------------------------------------------------*/
-int floatx80_to_int32( floatx80 STATUS_PARAM );
-int floatx80_to_int32_round_to_zero( floatx80 STATUS_PARAM );
-int64_t floatx80_to_int64( floatx80 STATUS_PARAM );
-int64_t floatx80_to_int64_round_to_zero( floatx80 STATUS_PARAM );
+int32 floatx80_to_int32( floatx80 STATUS_PARAM );
+int32 floatx80_to_int32_round_to_zero( floatx80 STATUS_PARAM );
+int64 floatx80_to_int64( floatx80 STATUS_PARAM );
+int64 floatx80_to_int64_round_to_zero( floatx80 STATUS_PARAM );
 float32 floatx80_to_float32( floatx80 STATUS_PARAM );
 float64 floatx80_to_float64( floatx80 STATUS_PARAM );
 #ifdef FLOAT128
@@ -475,10 +475,10 @@  INLINE int floatx80_is_zero(floatx80 a)
 /*----------------------------------------------------------------------------
 | Software IEC/IEEE quadruple-precision conversion routines.
 *----------------------------------------------------------------------------*/
-int float128_to_int32( float128 STATUS_PARAM );
-int float128_to_int32_round_to_zero( float128 STATUS_PARAM );
-int64_t float128_to_int64( float128 STATUS_PARAM );
-int64_t float128_to_int64_round_to_zero( float128 STATUS_PARAM );
+int32 float128_to_int32( float128 STATUS_PARAM );
+int32 float128_to_int32_round_to_zero( float128 STATUS_PARAM );
+int64 float128_to_int64( float128 STATUS_PARAM );
+int64 float128_to_int64_round_to_zero( float128 STATUS_PARAM );
 float32 float128_to_float32( float128 STATUS_PARAM );
 float64 float128_to_float64( float128 STATUS_PARAM );
 #ifdef FLOATX80