summaryrefslogtreecommitdiff
path: root/include/ruby/missing.h
diff options
context:
space:
mode:
authorngoto <ngoto@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-10-21 17:34:58 +0000
committerngoto <ngoto@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-10-21 17:34:58 +0000
commit971769cd7632cd13be53c9c2e777b7f6810bfd4b (patch)
tree66f3a154e3e15244f8807c27fd409fdaec014456 /include/ruby/missing.h
parentcb2a69d883469d8929892facb6c48059bdfac3dd (diff)
* numeric.c (rb_infinity, rb_nan): use union to prevent bus error
caused by misalignment. [Bug #5469] [ruby-dev:44657] * include/ruby/missing.h (INFINITY, NAN): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33502 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'include/ruby/missing.h')
-rw-r--r--include/ruby/missing.h15
1 files changed, 11 insertions, 4 deletions
diff --git a/include/ruby/missing.h b/include/ruby/missing.h
index 91a65402995..0edb1ec6c0a 100644
--- a/include/ruby/missing.h
+++ b/include/ruby/missing.h
@@ -124,20 +124,27 @@ RUBY_EXTERN double lgamma_r(double, int *);
RUBY_EXTERN double cbrt(double);
#endif
+#if !defined(INFINITY) || !defined(NAN)
+union bytesequence4_or_float {
+ unsigned char bytesequence[4];
+ float float_value;
+};
+#endif
+
#ifdef INFINITY
# define HAVE_INFINITY
#else
/** @internal */
-RUBY_EXTERN const unsigned char rb_infinity[];
-# define INFINITY (*(float *)rb_infinity)
+RUBY_EXTERN const union bytesequence4_or_float rb_infinity;
+# define INFINITY (rb_infinity.float_value)
#endif
#ifdef NAN
# define HAVE_NAN
#else
/** @internal */
-RUBY_EXTERN const unsigned char rb_nan[];
-# define NAN (*(float *)rb_nan)
+RUBY_EXTERN const union bytesequence4_or_float rb_nan;
+# define NAN (rb_nan.float_value)
#endif
#ifndef isinf