summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-14 15:29:10 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-14 15:29:10 +0000
commitab9bc151e828843b9d9170754f4ba4d92ef85750 (patch)
tree83b20f332afc1f38ba0a0ad5f7319f07125ea022
parentd8633ac16c91cce0ecf83f089fb6fd89e04d0029 (diff)
* include/ruby/ruby.h,
internal.h, ext/-test-/bignum/bigzero.c: Hide a Bignum definition. [ruby-core:42891] [Feature #6083] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--ext/-test-/bignum/bigzero.c1
-rw-r--r--include/ruby/ruby.h43
-rw-r--r--internal.h45
4 files changed, 53 insertions, 43 deletions
diff --git a/ChangeLog b/ChangeLog
index ccf1119..21707e0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Sat Feb 15 00:27:46 2014 Tanaka Akira <akr@fsij.org>
+
+ * include/ruby/ruby.h,
+ internal.h,
+ ext/-test-/bignum/bigzero.c: Hide a Bignum definition.
+ [ruby-core:42891] [Feature #6083]
+
Sat Feb 15 00:13:14 2014 Tanaka Akira <akr@fsij.org>
* include/ruby/intern.h,
diff --git a/ext/-test-/bignum/bigzero.c b/ext/-test-/bignum/bigzero.c
index 2f7c272..21f8a33 100644
--- a/ext/-test-/bignum/bigzero.c
+++ b/ext/-test-/bignum/bigzero.c
@@ -1,4 +1,5 @@
#include "ruby.h"
+#include "internal.h"
static VALUE
bug_big_zero(VALUE self, VALUE length)
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h
index 53f5ecc..07477b0 100644
--- a/include/ruby/ruby.h
+++ b/include/ruby/ruby.h
@@ -1069,48 +1069,6 @@ struct RStruct {
#define RSTRUCT_SET(st, idx, v) RB_OBJ_WRITE(st, &RSTRUCT_CONST_PTR(st)[idx], (v))
#define RSTRUCT_GET(st, idx) (RSTRUCT_CONST_PTR(st)[idx])
-#define RBIGNUM_EMBED_LEN_NUMBITS 3
-#ifndef RBIGNUM_EMBED_LEN_MAX
-# if (SIZEOF_VALUE*3/SIZEOF_ACTUAL_BDIGIT) < (1 << RBIGNUM_EMBED_LEN_NUMBITS)-1
-# define RBIGNUM_EMBED_LEN_MAX (SIZEOF_VALUE*3/SIZEOF_ACTUAL_BDIGIT)
-# else
-# define RBIGNUM_EMBED_LEN_MAX ((1 << RBIGNUM_EMBED_LEN_NUMBITS)-1)
-# endif
-#endif
-struct RBignum {
- struct RBasic basic;
- union {
- struct {
- long len;
- BDIGIT *digits;
- } heap;
- BDIGIT ary[RBIGNUM_EMBED_LEN_MAX];
- } as;
-};
-#define RBIGNUM_SIGN_BIT FL_USER1
-/* sign: positive:1, negative:0 */
-#define RBIGNUM_SIGN(b) ((RBASIC(b)->flags & RBIGNUM_SIGN_BIT) != 0)
-#define RBIGNUM_SET_SIGN(b,sign) \
- ((sign) ? (RBASIC(b)->flags |= RBIGNUM_SIGN_BIT) \
- : (RBASIC(b)->flags &= ~RBIGNUM_SIGN_BIT))
-#define RBIGNUM_POSITIVE_P(b) RBIGNUM_SIGN(b)
-#define RBIGNUM_NEGATIVE_P(b) (!RBIGNUM_SIGN(b))
-
-#define RBIGNUM_EMBED_FLAG FL_USER2
-#define RBIGNUM_EMBED_LEN_MASK (FL_USER5|FL_USER4|FL_USER3)
-#define RBIGNUM_EMBED_LEN_SHIFT (FL_USHIFT+RBIGNUM_EMBED_LEN_NUMBITS)
-#define RBIGNUM_LEN(b) \
- ((RBASIC(b)->flags & RBIGNUM_EMBED_FLAG) ? \
- (long)((RBASIC(b)->flags >> RBIGNUM_EMBED_LEN_SHIFT) & \
- (RBIGNUM_EMBED_LEN_MASK >> RBIGNUM_EMBED_LEN_SHIFT)) : \
- RBIGNUM(b)->as.heap.len)
-/* LSB:RBIGNUM_DIGITS(b)[0], MSB:RBIGNUM_DIGITS(b)[RBIGNUM_LEN(b)-1] */
-#define RBIGNUM_DIGITS(b) \
- ((RBASIC(b)->flags & RBIGNUM_EMBED_FLAG) ? \
- RBIGNUM(b)->as.ary : \
- RBIGNUM(b)->as.heap.digits)
-#define RBIGNUM_LENINT(b) rb_long2int(RBIGNUM_LEN(b))
-
#define R_CAST(st) (struct st*)
#define RBASIC(obj) (R_CAST(RBasic)(obj))
#define ROBJECT(obj) (R_CAST(RObject)(obj))
@@ -1124,7 +1082,6 @@ struct RBignum {
#define RDATA(obj) (R_CAST(RData)(obj))
#define RTYPEDDATA(obj) (R_CAST(RTypedData)(obj))
#define RSTRUCT(obj) (R_CAST(RStruct)(obj))
-#define RBIGNUM(obj) (R_CAST(RBignum)(obj))
#define RFILE(obj) (R_CAST(RFile)(obj))
#define RRATIONAL(obj) (R_CAST(RRational)(obj))
#define RCOMPLEX(obj) (R_CAST(RComplex)(obj))
diff --git a/internal.h b/internal.h
index c27ebb7..a3b4045 100644
--- a/internal.h
+++ b/internal.h
@@ -305,6 +305,51 @@ struct method_table_wrapper {
size_t serial;
};
+#define RBIGNUM_EMBED_LEN_NUMBITS 3
+#ifndef RBIGNUM_EMBED_LEN_MAX
+# if (SIZEOF_VALUE*3/SIZEOF_ACTUAL_BDIGIT) < (1 << RBIGNUM_EMBED_LEN_NUMBITS)-1
+# define RBIGNUM_EMBED_LEN_MAX (SIZEOF_VALUE*3/SIZEOF_ACTUAL_BDIGIT)
+# else
+# define RBIGNUM_EMBED_LEN_MAX ((1 << RBIGNUM_EMBED_LEN_NUMBITS)-1)
+# endif
+#endif
+
+struct RBignum {
+ struct RBasic basic;
+ union {
+ struct {
+ long len;
+ BDIGIT *digits;
+ } heap;
+ BDIGIT ary[RBIGNUM_EMBED_LEN_MAX];
+ } as;
+};
+#define RBIGNUM_SIGN_BIT FL_USER1
+/* sign: positive:1, negative:0 */
+#define RBIGNUM_SIGN(b) ((RBASIC(b)->flags & RBIGNUM_SIGN_BIT) != 0)
+#define RBIGNUM_SET_SIGN(b,sign) \
+ ((sign) ? (RBASIC(b)->flags |= RBIGNUM_SIGN_BIT) \
+ : (RBASIC(b)->flags &= ~RBIGNUM_SIGN_BIT))
+#define RBIGNUM_POSITIVE_P(b) RBIGNUM_SIGN(b)
+#define RBIGNUM_NEGATIVE_P(b) (!RBIGNUM_SIGN(b))
+
+#define RBIGNUM_EMBED_FLAG FL_USER2
+#define RBIGNUM_EMBED_LEN_MASK (FL_USER5|FL_USER4|FL_USER3)
+#define RBIGNUM_EMBED_LEN_SHIFT (FL_USHIFT+RBIGNUM_EMBED_LEN_NUMBITS)
+#define RBIGNUM_LEN(b) \
+ ((RBASIC(b)->flags & RBIGNUM_EMBED_FLAG) ? \
+ (long)((RBASIC(b)->flags >> RBIGNUM_EMBED_LEN_SHIFT) & \
+ (RBIGNUM_EMBED_LEN_MASK >> RBIGNUM_EMBED_LEN_SHIFT)) : \
+ RBIGNUM(b)->as.heap.len)
+/* LSB:RBIGNUM_DIGITS(b)[0], MSB:RBIGNUM_DIGITS(b)[RBIGNUM_LEN(b)-1] */
+#define RBIGNUM_DIGITS(b) \
+ ((RBASIC(b)->flags & RBIGNUM_EMBED_FLAG) ? \
+ RBIGNUM(b)->as.ary : \
+ RBIGNUM(b)->as.heap.digits)
+#define RBIGNUM_LENINT(b) rb_long2int(RBIGNUM_LEN(b))
+
+#define RBIGNUM(obj) (R_CAST(RBignum)(obj))
+
/* class.c */
void rb_class_subclass_add(VALUE super, VALUE klass);
void rb_class_remove_from_super_subclasses(VALUE);