[macruby-changes] [2157] MacRuby/branches/experimental/include/ruby/ruby.h

source_changes at macosforge.org source_changes at macosforge.org
Mon Aug 3 04:29:52 PDT 2009


Revision: 2157
          http://trac.macosforge.org/projects/ruby/changeset/2157
Author:   vincent.isambart at gmail.com
Date:     2009-08-03 04:29:49 -0700 (Mon, 03 Aug 2009)
Log Message:
-----------
started work to make 32 bits work again

Modified Paths:
--------------
    MacRuby/branches/experimental/include/ruby/ruby.h

Modified: MacRuby/branches/experimental/include/ruby/ruby.h
===================================================================
--- MacRuby/branches/experimental/include/ruby/ruby.h	2009-08-03 08:51:19 UTC (rev 2156)
+++ MacRuby/branches/experimental/include/ruby/ruby.h	2009-08-03 11:29:49 UTC (rev 2157)
@@ -234,8 +234,18 @@
 #define IMMEDIATE_P(x) ((VALUE)(x) & IMMEDIATE_MASK)
 
 
+#if __LP64__
 #define VOODOO_DOUBLE(d) (*(VALUE*)(&d))
 #define DBL2FIXFLOAT(d) (VOODOO_DOUBLE(d) | FIXFLOAT_FLAG)
+#else
+// voodoo_float must be a function
+// because the parameter must be converted to float
+static inline VALUE voodoo_float(float f)
+{
+    return *(VALUE *)(&f);
+}
+#define DBL2FIXFLOAT(d) (voodoo_float(d) | FIXFLOAT_FLAG)
+#endif
 #define FIXFLOAT_P(v)  (((VALUE)v & IMMEDIATE_MASK) == FIXFLOAT_FLAG)
 #define FIXFLOAT2DBL(v) coerce_ptr_to_double((VALUE)v)
 
@@ -269,7 +279,14 @@
 // and then extract its double member. Hacky, but effective.
 static inline double coerce_ptr_to_double(VALUE v)
 {
-    union {VALUE val; double d;} coerced_value;
+    union {
+	VALUE val;
+#if __LP64__
+	double d;
+#else
+	float d;
+#endif
+    } coerced_value;
     coerced_value.val = v & ~RUBY_FIXFLOAT_FLAG; // unset the last two bits.
     return coerced_value.d;
 }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090803/63cd48fe/attachment.html>


More information about the macruby-changes mailing list