summaryrefslogtreecommitdiff
path: root/ext/bigdecimal/bigdecimal.c
diff options
context:
space:
mode:
authorKenta Murata <[email protected]>2019-10-09 10:50:59 +0900
committerNobuyoshi Nakada <[email protected]>2020-07-06 01:15:46 +0900
commit40b82afe6a20749a375d36ce17e941e890ef8b0e (patch)
treead4d44a808e4f30f9c1c17e99b50a00aca7d40d9 /ext/bigdecimal/bigdecimal.c
parent03a33603c66bf6eca6937d221f87daf3f5a489f7 (diff)
[ruby/bigdecimal] Support Ruby < 2.6
https://github.com/ruby/bigdecimal/commit/61ec452599
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3295
Diffstat (limited to 'ext/bigdecimal/bigdecimal.c')
-rw-r--r--ext/bigdecimal/bigdecimal.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 5d0fc85baa..380015248b 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -128,6 +128,30 @@ rb_rational_den(VALUE rat)
}
#endif
+#ifndef HAVE_RB_COMPLEX_REAL
+static inline VALUE
+rb_complex_real(VALUE cmp)
+{
+#ifdef HAVE_TYPE_STRUCT_RCOMPLEX
+ return RCOMPLEX(cmp)->real;
+#else
+ return rb_funcall(cmp, rb_intern("real"), 0);
+#endif
+}
+#endif
+
+#ifndef HAVE_RB_COMPLEX_IMAG
+static inline VALUE
+rb_complex_imag(VALUE cmp)
+{
+#ifdef HAVE_TYPE_STRUCT_RCOMPLEX
+ return RCOMPLEX(cmp)->imag;
+#else
+ return rb_funcall(cmp, rb_intern("imag"), 0);
+#endif
+}
+#endif
+
#define BIGDECIMAL_POSITIVE_P(bd) ((bd)->sign > 0)
#define BIGDECIMAL_NEGATIVE_P(bd) ((bd)->sign < 0)