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

ruby-changes:41923

From: ko1 <ko1@a...>
Date: Fri, 4 Mar 2016 19:37:40 +0900 (JST)
Subject: [ruby-changes:41923] ko1:r53997 (trunk): * gc.c: use 2 bits with unsigned int for rb_objspace::flags::mode

ko1	2016-03-04 19:37:35 +0900 (Fri, 04 Mar 2016)

  New Revision: 53997

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53997

  Log:
    * gc.c: use 2 bits with unsigned int for rb_objspace::flags::mode
      because it always returns 0 to 2 (non-negative value).

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
Index: gc.c
===================================================================
--- gc.c	(revision 53996)
+++ gc.c	(revision 53997)
@@ -490,7 +490,7 @@ typedef struct rb_objspace { https://github.com/ruby/ruby/blob/trunk/gc.c#L490
     } malloc_params;
 
     struct {
-	enum gc_mode mode : 3;
+	unsigned int mode : 2;
 	unsigned int immediate_sweep : 1;
 	unsigned int dont_gc : 1;
 	unsigned int dont_incremental : 1;
@@ -747,8 +747,8 @@ gc_mode_verify(enum gc_mode mode) https://github.com/ruby/ruby/blob/trunk/gc.c#L747
     return mode;
 }
 
-#define gc_mode(objspace)                gc_mode_verify((objspace)->flags.mode)
-#define gc_mode_set(objspace, mode)      ((objspace)->flags.mode = gc_mode_verify(mode))
+#define gc_mode(objspace)                gc_mode_verify((enum gc_mode)(objspace)->flags.mode)
+#define gc_mode_set(objspace, mode)      ((objspace)->flags.mode = (unsigned int)gc_mode_verify(mode))
 
 #define is_marking(objspace)             (gc_mode(objspace) == gc_mode_marking)
 #define is_sweeping(objspace)            (gc_mode(objspace) == gc_mode_sweeping)
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 53996)
+++ ChangeLog	(revision 53997)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Mar  4 19:19:42 2016  Koichi Sasada  <ko1@a...>
+
+	* gc.c: use 2 bits with unsigned int for rb_objspace::flags::mode
+	  because it always returns 0 to 2 (non-negative value).
+
 Fri Mar  4 18:42:08 2016  Koichi Sasada  <ko1@a...>
 
 	* gc.c: rename "enum gc_stat" to "enum gc_mode"

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

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