[前][次][番号順一覧][スレッド一覧]

ruby-changes:32878

From: akr <ko1@a...>
Date: Sat, 15 Feb 2014 00:29:16 +0900 (JST)
Subject: [ruby-changes:32878] akr:r44957 (trunk): * include/ruby/ruby.h,

akr	2014-02-15 00:29:10 +0900 (Sat, 15 Feb 2014)

  New Revision: 44957

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44957

  Log:
    * include/ruby/ruby.h,
      internal.h,
      ext/-test-/bignum/bigzero.c: Hide a Bignum definition.
      [ruby-core:42891] [Feature #6083]

  Modified files:
    trunk/ChangeLog
    trunk/ext/-test-/bignum/bigzero.c
    trunk/include/ruby/ruby.h
    trunk/internal.h
Index: include/ruby/ruby.h
===================================================================
--- include/ruby/ruby.h	(revision 44956)
+++ include/ruby/ruby.h	(revision 44957)
@@ -1069,48 +1069,6 @@ struct RStruct { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1069
 #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 { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1082
 #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))
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 44956)
+++ ChangeLog	(revision 44957)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Feb 15 00:27:46 2014  Tanaka Akira  <akr@f...>
+
+	* 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@f...>
 
 	* include/ruby/intern.h,
Index: ext/-test-/bignum/bigzero.c
===================================================================
--- ext/-test-/bignum/bigzero.c	(revision 44956)
+++ ext/-test-/bignum/bigzero.c	(revision 44957)
@@ -1,4 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ext/-test-/bignum/bigzero.c#L1
 #include "ruby.h"
+#include "internal.h"
 
 static VALUE
 bug_big_zero(VALUE self, VALUE length)
Index: internal.h
===================================================================
--- internal.h	(revision 44956)
+++ internal.h	(revision 44957)
@@ -305,6 +305,51 @@ struct method_table_wrapper { https://github.com/ruby/ruby/blob/trunk/internal.h#L305
     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);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]