[macruby-changes] [2644] MacRuby/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Fri Sep 25 17:15:00 PDT 2009
Revision: 2644
http://trac.macosforge.org/projects/ruby/changeset/2644
Author: lsansonetti at apple.com
Date: 2009-09-25 17:14:56 -0700 (Fri, 25 Sep 2009)
Log Message:
-----------
.rbo files are now initialized using a gcc constructor instead of an Init_ function which was a bad idea (because the name is not unique)
Modified Paths:
--------------
MacRuby/trunk/bin/rubyc
MacRuby/trunk/dln.c
MacRuby/trunk/dln.h
MacRuby/trunk/load.c
Modified: MacRuby/trunk/bin/rubyc
===================================================================
--- MacRuby/trunk/bin/rubyc 2009-09-25 22:04:17 UTC (rev 2643)
+++ MacRuby/trunk/bin/rubyc 2009-09-26 00:14:56 UTC (rev 2644)
@@ -121,13 +121,11 @@
die "can't guess the init function of Ruby object file `#{obj}'"
end
- init_func = "Init_" + base.gsub(/-/, '_')
main_txt = <<EOS
extern "C" {
void *#{real_init_func}(void *, void *);
void *rb_vm_top_self(void);
- void
- #{init_func}(void) {
+ __attribute__((constructor)) static void __init__(void) {
#{real_init_func}(rb_vm_top_self(), 0);
}
}
Modified: MacRuby/trunk/dln.c
===================================================================
--- MacRuby/trunk/dln.c 2009-09-25 22:04:17 UTC (rev 2643)
+++ MacRuby/trunk/dln.c 2009-09-26 00:14:56 UTC (rev 2644)
@@ -74,7 +74,7 @@
bool ruby_is_miniruby = false;
void*
-dln_load(const char *file)
+dln_load(const char *file, bool call_init)
{
if (ruby_is_miniruby) {
rb_raise(rb_eLoadError,
@@ -90,7 +90,6 @@
{
void *handle;
- void (*init_fct)();
/* Load file */
if ((handle = (void*)dlopen(file, RTLD_LAZY|RTLD_GLOBAL)) == NULL) {
@@ -98,14 +97,17 @@
goto failed;
}
- init_fct = (void(*)())dlsym(handle, buf);
- if (init_fct == NULL) {
- error = DLN_ERROR();
- dlclose(handle);
- goto failed;
+ if (call_init) {
+ void (*init_fct)();
+ init_fct = (void(*)())dlsym(handle, buf);
+ if (init_fct == NULL) {
+ error = DLN_ERROR();
+ dlclose(handle);
+ goto failed;
+ }
+ /* Call the init code */
+ (*init_fct)();
}
- /* Call the init code */
- (*init_fct)();
return handle;
}
Modified: MacRuby/trunk/dln.h
===================================================================
--- MacRuby/trunk/dln.h 2009-09-25 22:04:17 UTC (rev 2643)
+++ MacRuby/trunk/dln.h 2009-09-26 00:14:56 UTC (rev 2644)
@@ -37,5 +37,5 @@
extern char *dln_argv0;
#endif
-void *dln_load(const char*);
+void *dln_load(const char*, bool);
#endif
Modified: MacRuby/trunk/load.c
===================================================================
--- MacRuby/trunk/load.c 2009-09-25 22:04:17 UTC (rev 2643)
+++ MacRuby/trunk/load.c 2009-09-26 00:14:56 UTC (rev 2644)
@@ -272,8 +272,11 @@
break;
case TYPE_RBO:
+ dln_load(RSTRING_PTR(path), false);
+ break;
+
case TYPE_BUNDLE:
- dln_load(RSTRING_PTR(path));
+ dln_load(RSTRING_PTR(path), true);
break;
default:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090925/949e04c1/attachment-0001.html>
More information about the macruby-changes
mailing list