summaryrefslogtreecommitdiff
path: root/eval_load.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-06-18 08:02:30 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-06-18 08:02:30 +0000
commit1c03862049be55c911c1dfb2621c3be42d7c0d09 (patch)
treea0c0c5aa74e28b7d947f72a69ae9d9f46ec0eccd /eval_load.c
parent942a54302de5bfa4665960947c403e1c0b6831ad (diff)
* eval_load.c (rb_require_safe, ruby_init_ext): load with ruby level
cfp. [ruby-core:10779] * eval_intern.h, vm.c (rb_vm_call_cfunc): new function to call a function with ruby level cfp. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval_load.c')
-rw-r--r--eval_load.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/eval_load.c b/eval_load.c
index 871d2573ee..d95b438f63 100644
--- a/eval_load.c
+++ b/eval_load.c
@@ -408,6 +408,13 @@ load_failed(VALUE fname)
RSTRING_PTR(fname));
}
+static VALUE
+load_ext(VALUE arg)
+{
+ SCOPE_SET(NOEX_PUBLIC);
+ return (VALUE)dln_load((const char *)arg);
+}
+
VALUE
rb_require_safe(VALUE fname, int safe)
{
@@ -448,8 +455,8 @@ rb_require_safe(VALUE fname, int safe)
ruby_current_node = 0;
ruby_sourcefile = rb_source_filename(RSTRING_PTR(path));
ruby_sourceline = 0;
- /* SCOPE_SET(NOEX_PUBLIC); */
- handle = (long)dln_load(RSTRING_PTR(path));
+ handle = (long)rb_vm_call_cfunc(ruby_top_self, load_ext,
+ ruby_source_filename, 0, path);
rb_ary_push(ruby_dln_librefs, LONG2NUM(handle));
break;
}
@@ -484,18 +491,22 @@ rb_require(const char *fname)
return rb_require_safe(fn, rb_safe_level());
}
+static VALUE
+init_ext_call(VALUE arg)
+{
+ SCOPE_SET(NOEX_PUBLIC);
+ (*(void (*)(void))arg)();
+ return Qnil;
+}
+
void
ruby_init_ext(const char *name, void (*init)(void))
{
- rb_control_frame_t *frame = GET_THREAD()->cfp;
-
ruby_current_node = 0;
ruby_sourcefile = rb_source_filename(name);
ruby_sourceline = 0;
- frame->method_id = 0;
- SCOPE_SET(NOEX_PUBLIC);
if (load_lock(name)) {
- (*init)();
+ rb_vm_call_cfunc(ruby_top_self, init_ext_call, (VALUE)init, 0, rb_str_new2(name));
rb_provide(name);
load_unlock(name);
}