[m-rev.] diff: gcc back-end: handle new real.h interface

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Sep 20 02:40:40 AEST 2002


Estimated hours taken: 1
Branches: gcc_3_3

gcc/mercury/mercury-gcc.c:
	Update to handle the new version of real.h that was recently
	committed to the GCC CVS repository.

Workspace: /home/ceres/fjh/ws-gcc-basic-improvements-patched/mercury-gcc
Index: gcc/mercury/mercury-gcc.c
===================================================================
RCS file: /home/mercury1/repository/gcc/mercury/mercury-gcc.c,v
retrieving revision 1.31.2.3
diff -u -d -p -r1.31.2.3 mercury-gcc.c
--- gcc/mercury/mercury-gcc.c	16 Sep 2002 19:40:32 -0000	1.31.2.3
+++ gcc/mercury/mercury-gcc.c	18 Sep 2002 16:34:05 -0000
@@ -553,9 +553,39 @@ merc_build_real(type, value)
      double value;
 {
   /* XXX this won't work if cross-compiling */
+
+#ifdef REAL_VALUE_FROM_TARGET_DOUBLE /* for gcc < 3.3 */
+
   union { double dbl; HOST_WIDE_INT ints[20]; } u;
   u.dbl = value;
   return build_real(type, REAL_VALUE_FROM_TARGET_DOUBLE(u.ints));
+
+#else /* for gcc >= 3.3 */
+
+  /* We need a 32-bit (exactly) integer type.
+     Unfortunately we can't rely on C99 here.
+     The following should work on almost all systems, though.  */
+  /* XXX We can't use a typedef here, because gentype barfs on it. */
+  #if INT_MAX == 2147483647 
+    #define NUM_INT32S (sizeof(double) / sizeof(int) + 1)
+    union { double dbl; int int32s[NUM_INT32S]; } u;
+  #elif LONG_MAX == 2147483647 
+    #define NUM_INT32S (sizeof(double) / sizeof(long) + 1)
+    union { double dbl; long int32s[NUM_INT32S]; } u;
+  #else
+    #error "Need int32_t (neither int nor long is 32 bits)"
+  #endif
+
+  long longs[sizeof(double)];
+  int i;
+  REAL_VALUE_TYPE r;
+
+  u.dbl = value;
+  for (i = 0; i < (int) NUM_INT32S; i++)
+    longs[i] = u.int32s[i];
+  real_from_target(&r, longs, TYPE_MODE(double_type_node));
+  return build_real(type, r);
+#endif
 }
 
 /* Make an empty expression list.  */

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list