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

ruby-changes:36618

From: nobu <ko1@a...>
Date: Wed, 3 Dec 2014 16:47:42 +0900 (JST)
Subject: [ruby-changes:36618] nobu:r48699 (trunk): load.c: defer static linked init

nobu	2014-12-03 16:47:37 +0900 (Wed, 03 Dec 2014)

  New Revision: 48699

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

  Log:
    load.c: defer static linked init
    
    * enc/encinit.c.erb (Init_enc): initialize encdb and transdb
      directly.

  Modified files:
    trunk/ChangeLog
    trunk/enc/encinit.c.erb
    trunk/load.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48698)
+++ ChangeLog	(revision 48699)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Dec  3 16:47:35 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* enc/encinit.c.erb (Init_enc): initialize encdb and transdb
+	  directly.
+
 Wed Dec  3 14:51:26 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* load.c (ruby_require_internal): separate from rb_require_safe,
Index: enc/encinit.c.erb
===================================================================
--- enc/encinit.c.erb	(revision 48698)
+++ enc/encinit.c.erb	(revision 48699)
@@ -8,19 +8,30 @@ https://github.com/ruby/ruby/blob/trunk/enc/encinit.c.erb#L8
     ruby_init_ext(name, func);	\
 }
 
+#define init_enc(name) init(Init_##name, "enc/"#name".so")
+#define init_trans(name) init(Init_trans_##name, "enc/trans/"#name".so")
+#define provide(func, name) { \
+    extern void Init_##func(void); \
+    Init_##func(); \
+    rb_provide(name".so"); \
+}
+
 void ruby_init_ext(const char *name, void (*init)(void));
+void rb_provide(const char *feature);
 
 void
 Init_enc(void)
 {
+    provide(encdb, "encdb");
 % ENCS.each do |enc|
-    init(Init_<%= enc %>, "enc/<%= enc %>.so");
+%   next if enc == 'encdb'
+    init_enc(<%= enc %>);
 % end
 
-    init(Init_transdb, "enc/trans/transdb.so");
+    provide(transdb, "trans/transdb");
 % TRANS.each do |trans|
 %   next if trans == 'trans/transdb'
-    init(Init_trans_<%= File.basename trans %>, "enc/<%= trans %>.so");
+    init_trans(<%= File.basename trans %>);
 % end
 }
 <%# vim: set ft=eruby sw=2 : -%>
Index: load.c
===================================================================
--- load.c	(revision 48698)
+++ load.c	(revision 48699)
@@ -1077,7 +1077,6 @@ register_init_ext(st_data_t *key, st_dat https://github.com/ruby/ruby/blob/trunk/load.c#L1077
     else {
 	*value = (st_data_t)NEW_MEMO(init, 0, 0);
 	*key = (st_data_t)ruby_strdup(name);
-	(*(void (*)(void))init)();
     }
     return ST_CONTINUE;
 }
@@ -1093,7 +1092,6 @@ ruby_init_ext(const char *name, void (*i https://github.com/ruby/ruby/blob/trunk/load.c#L1092
 	GET_VM()->loading_table = loading_tbl = st_init_strtable();
     }
     st_update(loading_tbl, (st_data_t)name, register_init_ext, (st_data_t)init);
-    rb_provide(name);
 }
 
 /*

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

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