ruby-changes:31577
From: nagachika <ko1@a...>
Date: Tue, 12 Nov 2013 23:55:45 +0900 (JST)
Subject: [ruby-changes:31577] nagachika:r43656 (ruby_2_0_0): merge revision(s) 43449, 43514, 43525: [Backport #8879] [Backport #8883]
nagachika 2013-11-12 23:55:40 +0900 (Tue, 12 Nov 2013) New Revision: 43656 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43656 Log: merge revision(s) 43449,43514,43525: [Backport #8879] [Backport #8883] * load.c (ruby_init_ext): share feature names between frame name and provided features. * load.c (rb_feature_p): deal with default loadable suffixes. * load.c (load_lock): initialize statically linked extensions. * load.c (search_required, rb_require_safe): deal with statically linked extensions. * load.c (ruby_init_ext): defer initalization of statically linked extensions until required actually. [Bug #8883] * load.c (ruby_init_ext): defer initialization of statically linked Modified directories: branches/ruby_2_0_0/ Modified files: branches/ruby_2_0_0/ChangeLog branches/ruby_2_0_0/load.c branches/ruby_2_0_0/version.h Index: ruby_2_0_0/ChangeLog =================================================================== --- ruby_2_0_0/ChangeLog (revision 43655) +++ ruby_2_0_0/ChangeLog (revision 43656) @@ -1,3 +1,20 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1 +Tue Nov 12 23:41:43 2013 Nobuyoshi Nakada <nobu@r...> + + * load.c (rb_feature_p): deal with default loadable suffixes. + + * load.c (load_lock): initialize statically linked extensions. + + * load.c (search_required, rb_require_safe): deal with statically + linked extensions. + + * load.c (ruby_init_ext): defer initialization of statically linked + extensions until required actually. [Bug #8883] + +Tue Nov 12 23:41:43 2013 Nobuyoshi Nakada <nobu@r...> + + * load.c (ruby_init_ext): share feature names between frame name and + provided features. + Tue Nov 12 23:33:08 2013 Nobuyoshi Nakada <nobu@r...> * tool/rbinstall.rb (Gem::Specification.load): obtain spec date from Index: ruby_2_0_0/load.c =================================================================== --- ruby_2_0_0/load.c (revision 43655) +++ ruby_2_0_0/load.c (revision 43656) @@ -8,6 +8,7 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/load.c#L8 #include "dln.h" #include "eval_intern.h" #include "probes.h" +#include "node.h" VALUE ruby_dln_librefs; @@ -482,6 +483,9 @@ rb_feature_p(const char *feature, const https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/load.c#L483 else { VALUE bufstr; char *buf; + static const char so_ext[][4] = { + ".so", ".o", + }; if (ext && *ext) return 0; bufstr = rb_str_tmp_new(len + DLEXT_MAXLEN); @@ -495,6 +499,14 @@ rb_feature_p(const char *feature, const https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/load.c#L499 return i ? 's' : 'r'; } } + for (i = 0; i < numberof(so_ext); i++) { + strlcpy(buf + len, so_ext[i], DLEXT_MAXLEN + 1); + if (st_get_key(loading_tbl, (st_data_t)buf, &data)) { + rb_str_resize(bufstr, 0); + if (fn) *fn = (const char*)data; + return 's'; + } + } rb_str_resize(bufstr, 0); } } @@ -705,6 +717,14 @@ load_lock(const char *ftptr) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/load.c#L717 st_insert(loading_tbl, (st_data_t)ftptr, data); return (char *)ftptr; } + else if (RB_TYPE_P((VALUE)data, T_NODE) && nd_type((VALUE)data) == NODE_MEMO) { + NODE *memo = RNODE(data); + void (*init)(void) = (void (*)(void))memo->nd_cfnc; + data = (st_data_t)rb_thread_shield_new(); + st_insert(loading_tbl, (st_data_t)ftptr, data); + (*init)(); + return (char *)""; + } if (RTEST(ruby_verbose)) { rb_warning("loading in progress, circular require considered harmful - %s", ftptr); /* TODO: display to $stderr, not stderr in C */ @@ -878,13 +898,16 @@ search_required(VALUE fname, volatile VA https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/load.c#L898 switch (type) { case 0: if (ft) - break; + goto statically_linked; ftptr = RSTRING_PTR(tmp); return rb_feature_p(ftptr, 0, FALSE, TRUE, 0); default: - if (ft) - break; + if (ft) { + statically_linked: + if (loading) *path = rb_filesystem_str_new_cstr(loading); + return ft; + } case 1: ext = strrchr(ftptr = RSTRING_PTR(tmp), '.'); if (rb_feature_p(ftptr, ext, !--type, TRUE, &loading) && !loading) @@ -953,6 +976,10 @@ rb_require_safe(VALUE fname, int safe) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/load.c#L976 if (!path || !(ftptr = load_lock(RSTRING_PTR(path)))) { result = Qfalse; } + else if (!*ftptr) { + rb_provide_feature(path); + result = Qtrue; + } else { switch (found) { case 'r': @@ -1001,24 +1028,30 @@ rb_require(const char *fname) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/load.c#L1028 return rb_require_safe(fn, rb_safe_level()); } -static VALUE -init_ext_call(VALUE arg) +static int +register_init_ext(st_data_t *key, st_data_t *value, st_data_t init, int existing) { - SCOPE_SET(NOEX_PUBLIC); - (*(void (*)(void))arg)(); - return Qnil; + const char *name = (char *)*key; + if (existing) { + /* already registered */ + rb_warn("%s is already registered", name); + } + else { + *value = (st_data_t)NEW_MEMO(init, 0, 0); + *key = (st_data_t)ruby_strdup(name); + } + return ST_CONTINUE; } RUBY_FUNC_EXPORTED void ruby_init_ext(const char *name, void (*init)(void)) { - char* const lock_key = load_lock(name); - if (lock_key) { - rb_vm_call_cfunc(rb_vm_top_self(), init_ext_call, (VALUE)init, - 0, rb_str_new2(name)); - rb_provide(name); - load_unlock(lock_key, 1); + st_table *loading_tbl = get_loading_table(); + + if (!loading_tbl) { + GET_VM()->loading_table = loading_tbl = st_init_strtable(); } + st_update(loading_tbl, (st_data_t)name, register_init_ext, (st_data_t)init); } /* Index: ruby_2_0_0/version.h =================================================================== --- ruby_2_0_0/version.h (revision 43655) +++ ruby_2_0_0/version.h (revision 43656) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1 #define RUBY_VERSION "2.0.0" #define RUBY_RELEASE_DATE "2013-11-12" -#define RUBY_PATCHLEVEL 348 +#define RUBY_PATCHLEVEL 349 #define RUBY_RELEASE_YEAR 2013 #define RUBY_RELEASE_MONTH 11 Property changes on: ruby_2_0_0 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r43449,43514,43525 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/