[m-rev.] diff: fix the second part of bug #228

Julien Fischer juliensf at csse.unimelb.edu.au
Fri Nov 11 19:40:28 AEDT 2011


Branches: main

Fix the other part of bug #228: the MR_float_word_bits macro does not
work with MSVC since it does not support casting to a union type.
Provide a function that does the same thing for use with MSVC.
(For GCC and clang we still use the macro version.)

runtime/mercury_float.h:
 	As above.

Julien.

Index: runtime/mercury_float.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_float.h,v
retrieving revision 1.24
diff -u -r1.24 mercury_float.h
--- runtime/mercury_float.h	17 Oct 2011 04:31:32 -0000	1.24
+++ runtime/mercury_float.h	11 Nov 2011 08:33:46 -0000
@@ -79,9 +79,22 @@
  	MR_Float f;
  	MR_Word	w[2];
    };
+ 
+  #if defined(MR_GNUC) || defined(MR_CLANG)
+    #define MR_float_word_bits(F, I)                                        \
+      (((union MR_Float_Dword) (MR_Float) (F)).w[(I)])
+  #else
+    MR_EXTERN_INLINE MR_Word
+    MR_float_word_bits(MR_Float f, MR_Integer n);

-  #define MR_float_word_bits(F, I)                                          \
-    (((union MR_Float_Dword) (MR_Float) (F)).w[(I)])
+    MR_EXTERN_INLINE MR_Word
+    MR_float_word_bits(MR_Float f, MR_Integer n)
+    {
+       union MR_Float_Dword __ffdw;
+       __ffdw.f = f;
+       return __ffdw.w[n];
+    }
+  #endif

    #define MR_float_from_dword_ptr(ptr)                                      \
      (((union MR_Float_Dword *) (ptr))->f)

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list