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

ruby-changes:29485

From: ko1 <ko1@a...>
Date: Fri, 21 Jun 2013 20:54:27 +0900 (JST)
Subject: [ruby-changes:29485] ko1:r41537 (trunk): * include/ruby/ruby.h: constify RArray::as::ary and RArray::heap::ptr.

ko1	2013-06-21 20:53:33 +0900 (Fri, 21 Jun 2013)

  New Revision: 41537

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

  Log:
    * include/ruby/ruby.h: constify RArray::as::ary and RArray::heap::ptr.
      Use RARRAY_ASET() or RARRAY_PTR_USE() to modify Array objects.
    * array.c, gc.c: catch up above changes.

  Modified files:
    trunk/ChangeLog
    trunk/array.c
    trunk/gc.c
    trunk/include/ruby/ruby.h

Index: array.c
===================================================================
--- array.c	(revision 41536)
+++ array.c	(revision 41537)
@@ -170,7 +170,7 @@ ary_resize_capa(VALUE ary, long capacity https://github.com/ruby/ruby/blob/trunk/array.c#L170
             long len = RARRAY_LEN(ary);
             VALUE *ptr = RARRAY_PTR(ary);
             if (len > capacity) len = capacity;
-            MEMCPY(RARRAY(ary)->as.ary, ptr, VALUE, len);
+            MEMCPY((VALUE *)RARRAY(ary)->as.ary, ptr, VALUE, len);
             FL_SET_EMBED(ary);
             ARY_SET_LEN(ary, len);
             xfree(ptr);
@@ -267,10 +267,10 @@ rb_ary_modify(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L267
         long len = RARRAY_LEN(ary);
 	VALUE shared = ARY_SHARED(ary);
         if (len <= RARRAY_EMBED_LEN_MAX) {
-            VALUE *ptr = ARY_HEAP_PTR(ary);
+	    const VALUE *ptr = ARY_HEAP_PTR(ary);
             FL_UNSET_SHARED(ary);
             FL_SET_EMBED(ary);
-            MEMCPY(ARY_EMBED_PTR(ary), ptr, VALUE, len);
+	    MEMCPY((VALUE *)ARY_EMBED_PTR(ary), ptr, VALUE, len);
             rb_ary_decrement_share(shared);
             ARY_SET_EMBED_LEN(ary, len);
         }
@@ -484,7 +484,7 @@ void https://github.com/ruby/ruby/blob/trunk/array.c#L484
 rb_ary_free(VALUE ary)
 {
     if (ARY_OWNS_HEAP_P(ary)) {
-	xfree(ARY_HEAP_PTR(ary));
+	xfree((void *)ARY_HEAP_PTR(ary));
     }
 }
 
@@ -545,7 +545,7 @@ ary_make_substitution(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L545
 {
     if (RARRAY_LEN(ary) <= RARRAY_EMBED_LEN_MAX) {
         VALUE subst = rb_ary_new2(RARRAY_LEN(ary));
-        MEMCPY(ARY_EMBED_PTR(subst), RARRAY_PTR(ary), VALUE, RARRAY_LEN(ary));
+	MEMCPY((VALUE *)ARY_EMBED_PTR(subst), RARRAY_PTR(ary), VALUE, RARRAY_LEN(ary));
         ARY_SET_EMBED_LEN(subst, RARRAY_LEN(ary));
         return subst;
     }
@@ -662,7 +662,7 @@ rb_ary_initialize(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/array.c#L662
     rb_ary_modify(ary);
     if (argc == 0) {
 	if (ARY_OWNS_HEAP_P(ary) && RARRAY_RAWPTR(ary) != 0) {
-	    xfree(RARRAY_RAWPTR(ary));
+	    xfree((void *)RARRAY_RAWPTR(ary));
 	}
         rb_ary_unshare_safe(ary);
         FL_SET_EMBED(ary);
@@ -703,7 +703,7 @@ rb_ary_initialize(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/array.c#L703
     }
     else {
 	RARRAY_PTR_USE(ary, ptr, {
-	    memfill(ptr, len, val);
+	    memfill((VALUE *)ptr, len, val);
 	});
 	OBJ_WRITTEN(ary, Qundef, val);
 	ARY_SET_LEN(ary, len);
@@ -769,7 +769,7 @@ ary_make_partial(VALUE ary, VALUE klass, https://github.com/ruby/ruby/blob/trunk/array.c#L769
 
     if (len <= RARRAY_EMBED_LEN_MAX) {
         VALUE result = ary_alloc(klass);
-        MEMCPY(ARY_EMBED_PTR(result), RARRAY_PTR(ary) + offset, VALUE, len);
+        MEMCPY((VALUE *)ARY_EMBED_PTR(result), RARRAY_PTR(ary) + offset, VALUE, len);
         ARY_SET_EMBED_LEN(result, len);
         return result;
     }
@@ -1551,7 +1551,7 @@ rb_ary_resize(VALUE ary, long len) https://github.com/ruby/ruby/blob/trunk/array.c#L1551
 	VALUE tmp[RARRAY_EMBED_LEN_MAX];
 	MEMCPY(tmp, ARY_HEAP_PTR(ary), VALUE, len);
 	ary_discard(ary);
-	MEMCPY(ARY_EMBED_PTR(ary), tmp, VALUE, len);
+	MEMCPY((VALUE *)ARY_EMBED_PTR(ary), tmp, VALUE, len);
         ARY_SET_EMBED_LEN(ary, len);
     }
     else {
@@ -2335,7 +2335,7 @@ rb_ary_sort_bang(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L2335
                     rb_ary_unshare(ary);
                 }
                 else {
-                    xfree(ARY_HEAP_PTR(ary));
+		    xfree((void *)ARY_HEAP_PTR(ary));
                 }
                 ARY_SET_PTR(ary, RARRAY_PTR(tmp));
                 ARY_SET_HEAP_LEN(ary, len);
Index: include/ruby/ruby.h
===================================================================
--- include/ruby/ruby.h	(revision 41536)
+++ include/ruby/ruby.h	(revision 41537)
@@ -933,9 +933,9 @@ struct RArray { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L933
 		long capa;
 		VALUE shared;
 	    } aux;
-	    VALUE *ptr;
+	    const VALUE *ptr;
 	} heap;
-	VALUE ary[RARRAY_EMBED_LEN_MAX];
+	const VALUE ary[RARRAY_EMBED_LEN_MAX];
     } as;
 };
 #define RARRAY_EMBED_FLAG FL_USER1
@@ -961,7 +961,7 @@ struct RArray { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L961
 
 #define RARRAY_PTR_USE(ary, ptr_name, expr) do { \
     const VALUE _ary = (ary); \
-    VALUE *ptr_name = RARRAY_PTR_USE_START(_ary); \
+    VALUE *ptr_name = (VALUE *)RARRAY_PTR_USE_START(_ary); \
     expr; \
     RARRAY_PTR_USE_END(_ary); \
 } while (0)
@@ -969,10 +969,10 @@ struct RArray { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L969
 #define RARRAY_AREF(a, i)    (RARRAY_RAWPTR(a)[i])
 #define RARRAY_ASET(a, i, v) do { \
     const VALUE _ary_ = (a); \
-    OBJ_WRITE(_ary_, &RARRAY_RAWPTR(_ary_)[i], (v)); \
+    OBJ_WRITE(_ary_, (VALUE *)&RARRAY_RAWPTR(_ary_)[i], (v)); \
 } while (0)
 
-#define RARRAY_PTR(a) RARRAY_RAWPTR(RGENGC_WB_PROTECTED_ARRAY ? OBJ_WB_GIVEUP((VALUE)a) : ((VALUE)a))
+#define RARRAY_PTR(a) ((VALUE *)RARRAY_RAWPTR(RGENGC_WB_PROTECTED_ARRAY ? OBJ_WB_GIVEUP((VALUE)a) : ((VALUE)a)))
 
 struct RRegexp {
     struct RBasic basic;
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41536)
+++ ChangeLog	(revision 41537)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Jun 21 20:50:32 2013  Koichi Sasada  <ko1@a...>
+
+	* include/ruby/ruby.h: constify RArray::as::ary and RArray::heap::ptr.
+	  Use RARRAY_ASET() or RARRAY_PTR_USE() to modify Array objects.
+
+	* array.c, gc.c: catch up above changes.
+
 Fri Jun 21 20:32:13 2013  Koichi Sasada  <ko1@a...>
 
 	* vm_eval.c (eval_string_with_cref): fix WB miss.
Index: gc.c
===================================================================
--- gc.c	(revision 41536)
+++ gc.c	(revision 41537)
@@ -3306,7 +3306,7 @@ gc_mark_children(rb_objspace_t *objspace https://github.com/ruby/ruby/blob/trunk/gc.c#L3306
 	}
 	else {
 	    long i, len = RARRAY_LEN(obj);
-	    VALUE *ptr = RARRAY_RAWPTR(obj);
+	    const VALUE *ptr = RARRAY_RAWPTR(obj);
 	    for (i=0; i < len; i++) {
 		gc_mark(objspace, *ptr++);
 	    }

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

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