Subject: lib/12352: gcc-3.0 requires new floating point support function in libc
To: None <gnats-bugs@gnats.netbsd.org>
From: Richard Earnshaw <rearnsha@buzzard.freeserve.co.uk>
List: netbsd-bugs
Date: 03/07/2001 23:07:22
>Number:         12352
>Category:       lib
>Synopsis:       gcc-3.0 requires new floating point support function in libc
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 07 15:08:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Richard Earnshaw
>Release:        NetBSD-current<NetBSD-current source date>
>Organization:
ARM
	
>Environment:
	
System: NetBSD buzzard.buzzard.freeserve.co.uk 1.5S NetBSD 1.5S (BUZZARD) #231: Wed Mar 7 02:09:39 GMT 2001 rearnsha@buzzard.buzzard.freeserve.co.uk:/usr/src/sys/arch/arm32/compile/BUZZARD arm32


>Description:
	GCC 3.0 intruduces a new basic support call for handling software 
	floating point comparisons: __unord<m>2 where m is sf, df etc.  This
	routine returns true if the comparison of the two arguments passed
	has an unordered result.

	
>How-To-Repeat:
	run the gcc 3.0 test suite; in particular the test 
	gcc.c-torture/execute/ieee/fp-cmp4.c
	
>Fix:
	Patch attached for libc/arch/arm32/fplib, but this may need installing
	elsewhere as well, particularly since arch/arm32 is likely to be 
	obsolete soon.
	

Index: softfloat.c
===================================================================
RCS file: /cvsroot/basesrc/lib/libc/arch/arm32/fplib/softfloat.c,v
retrieving revision 1.4
diff -p -p -r1.4 softfloat.c
*** softfloat.c	1999/05/06 13:56:28	1.4
--- softfloat.c	2001/03/07 22:59:04
*************** flag float32_eq( float32 a, float32 b )
*** 1428,1433 ****
--- 1432,1455 ----
  
  /*
  -------------------------------------------------------------------------------
+ Returns true if the single-precision floating-point value `a' is unordered
+ relative to the corresponding value `b', and false otherwise.  The
+ comparison is performed according to the IEC/IEEE Standard for Binary
+ Floating-point Arithmetic.
+ -------------------------------------------------------------------------------
+ */
+ flag float32_un( float32 a, float32 b )
+ {
+     if (    ( ( extractFloat32Exp( a ) == 0xFF ) && extractFloat32Frac( a ) )
+          || ( ( extractFloat32Exp( b ) == 0xFF ) && extractFloat32Frac( b ) )
+        ) {
+         return 1;
+     }
+     return 0;
+ }
+ 
+ /*
+ -------------------------------------------------------------------------------
  Returns true if the single-precision floating-point value `a' is less
  than or equal to the corresponding value `b', and false otherwise.  The
  comparison is performed according to the IEC/IEEE Standard for Binary
*************** flag float64_eq( float64 a, float64 b )
*** 2229,2234 ****
--- 2251,2277 ----
             ( a.low == b.low )
          && ( ( a.high == b.high ) || bothZeroFloat64( a, b ) );
  
+ }
+ 
+ /*
+ -------------------------------------------------------------------------------
+ Returns true if the double-precision floating-point value `a' is unordered
+ relative to the corresponding value `b', and false otherwise.  The 
+ comparison is performed according to the IEC/IEEE Standard for Binary 
+ Floating-point Arithmetic.
+ -------------------------------------------------------------------------------
+ */
+ flag float64_un( float64 a, float64 b )
+ {
+ 
+     if (    (    ( extractFloat64Exp( a ) == 0x7FF )
+               && ( extractFloat64Frac0( a ) | extractFloat64Frac1( a ) ) )
+          || (    ( extractFloat64Exp( b ) == 0x7FF )
+               && ( extractFloat64Frac0( b ) | extractFloat64Frac1( b ) ) )
+        ) {
+         return 1;
+     }
+     return 0;
  }
  
  /*
Index: softfloat.h
===================================================================
RCS file: /cvsroot/basesrc/lib/libc/arch/arm32/fplib/softfloat.h,v
retrieving revision 1.4
diff -p -p -r1.4 softfloat.h
*** softfloat.h	1999/05/06 13:56:28	1.4
--- softfloat.h	2001/03/07 22:59:38
*************** static float32 float32_rem( float32, flo
*** 132,137 ****
--- 132,138 ----
  static float32 float32_sqrt( float32 );
  #endif
  char float32_eq( float32, float32 );
+ char float32_un( float32, float32 );
  char float32_le( float32, float32 );
  char float32_lt( float32, float32 );
  #if 0 /* unused */
*************** static float64 float64_rem( float64, flo
*** 157,162 ****
--- 158,164 ----
  static float64 float64_sqrt( float64 );
  #endif
  char float64_eq( float64, float64 );
+ char float64_un( float64, float64 );
  char float64_le( float64, float64 );
  char float64_lt( float64, float64 );
  #if 0 /* unused */
Index: arm-gcc.h
===================================================================
RCS file: /cvsroot/basesrc/lib/libc/arch/arm32/fplib/arm-gcc.h,v
retrieving revision 1.2
diff -p -p -r1.2 arm-gcc.h
*** arm-gcc.h	1998/01/06 00:06:10	1.2
--- arm-gcc.h	2001/03/07 22:59:41
*************** typedef signed long long int int64;
*** 77,79 ****
--- 77,81 ----
  #define float64_to_uint32_round_to_zero	__fixunsdfsi
  #define float32_to_float64		__extendsfdf2
  #define float64_to_float32		__truncdfsf2
+ #define float32_un			__unordsf2
+ #define float64_un			__unorddf2
>Release-Note:
>Audit-Trail:
>Unformatted: