[macruby-changes] [2525] MacRuby/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Wed Sep 9 00:11:24 PDT 2009
Revision: 2525
http://trac.macosforge.org/projects/ruby/changeset/2525
Author: lsansonetti at apple.com
Date: 2009-09-09 00:11:20 -0700 (Wed, 09 Sep 2009)
Log Message:
-----------
make sure the entry point of AOT compiled files is unique by using a dummy checksum
Modified Paths:
--------------
MacRuby/trunk/st.c
MacRuby/trunk/vm.cpp
Modified: MacRuby/trunk/st.c
===================================================================
--- MacRuby/trunk/st.c 2009-09-09 07:09:55 UTC (rev 2524)
+++ MacRuby/trunk/st.c 2009-09-09 07:11:20 UTC (rev 2525)
@@ -864,6 +864,12 @@
}
int
+rb_hash_string(const char *str)
+{
+ return strhash(str);
+}
+
+int
st_strcasecmp(const char *s1, const char *s2)
{
unsigned int c1, c2;
Modified: MacRuby/trunk/vm.cpp
===================================================================
--- MacRuby/trunk/vm.cpp 2009-09-09 07:09:55 UTC (rev 2524)
+++ MacRuby/trunk/vm.cpp 2009-09-09 07:11:20 UTC (rev 2525)
@@ -4745,7 +4745,8 @@
return val;
}
-#include <libgen.h>
+// in st.c
+extern "C" int rb_hash_string(const char *str);
extern "C"
void
@@ -4756,22 +4757,14 @@
const char *output = RSTRING_PTR(ruby_aot_compile);
// Generate the name of the init function.
- // TODO make it unique (checkum/hash?)
- char buf[PATH_MAX];
- strlcpy(buf, output, sizeof buf);
- std::string base(basename(buf));
- std::string init_function_name("MREP_");
- const size_t pos = base.rfind('.');
- if (pos != std::string::npos) {
- init_function_name.append(base, 0, pos);
- }
- else {
- init_function_name.append(base);
- }
+ char init_function_name[PATH_MAX];
+ const int hash = rb_hash_string(output);
+ snprintf(init_function_name, sizeof init_function_name,
+ "MREP_%d", hash >= 0 ? hash : -hash);
// Compile the program as IR.
Function *f = RoxorCompiler::shared->compile_main_function(node);
- f->setName(init_function_name.c_str());
+ f->setName(init_function_name);
GET_CORE()->optimize(f);
// Dump the bitcode.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090909/88164ba1/attachment-0001.html>
More information about the macruby-changes
mailing list