about summary refs log tree commit diff
path: root/src/rt/rust.cpp
diff options
context:
space:
mode:
authorEric Holk <eholk@mozilla.com>2011-06-14 17:41:45 -0700
committerEric Holk <eholk@mozilla.com>2011-06-15 12:10:15 -0700
commit01ea27b205817ee952f7132b2663701622aa6c69 (patch)
tree26339935bc03aea21b196bfd170774e937bbc278 /src/rt/rust.cpp
parent766d54df9378b6e8d13f577af6c1f8a2995635e1 (diff)
downloadrust-01ea27b205817ee952f7132b2663701622aa6c69.tar.gz
rust-01ea27b205817ee952f7132b2663701622aa6c69.zip
Step 1 of moving task startup to always be cdecl.
Diffstat (limited to 'src/rt/rust.cpp')
-rw-r--r--src/rt/rust.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/rt/rust.cpp b/src/rt/rust.cpp
index ae150acab17..a8ac7c7ef9c 100644
--- a/src/rt/rust.cpp
+++ b/src/rt/rust.cpp
@@ -71,13 +71,24 @@ command_line_args : public dom_owned<command_line_args>
     }
 };
 
+// THIS IS AN UGLY HACK TO MAKE rust_start STILL WORK WITH STAGE0 WHILE WE
+// TRANSITION TO ALL-CDECL TASK STARTUP FUNCTIONS.
+void FASTCALL
+(*real_main)(uintptr_t a, uintptr_t b, uintptr_t c, uintptr_t d) = NULL;
+
+void CDECL fake_main(uintptr_t a, uintptr_t b, uintptr_t c, uintptr_t d)
+{
+    real_main(a, b, c, d);
+}
+
 /**
  * Main entry point into the Rust runtime. Here we create a Rust service,
  * initialize the kernel, create the root domain and run it.
  */
 
 extern "C" CDECL int
-rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
+rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map,
+           uintptr_t main_fn_cdecl) {
 
     update_log_settings(crate_map, getenv("RUST_LOG"));
     rust_srv *srv = new rust_srv();
@@ -93,12 +104,9 @@ rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
         DLOG(dom, dom, "startup: arg[%d] = '%s'", i, args->argv[i]);
     }
 
-    /*
-    uintptr_t main_args[4] = {0, 0, 0, (uintptr_t)args->args};
-    dom->root_task->start(main_fn,
-                          (uintptr_t)&main_args, sizeof(main_args));
-    */
-    dom->root_task->start(main_fn,
+    real_main = (typeof(real_main))main_fn;
+    if(main_fn) { printf("using fastcall main\n"); }
+    dom->root_task->start(main_fn ? (uintptr_t)fake_main : main_fn_cdecl,
                           (uintptr_t)args->args, sizeof(args->args));
 
     int ret = dom->start_main_loop();