about summary refs log tree commit diff
path: root/src/rt/rust.cpp
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-08-17 20:31:55 -0700
committerBrian Anderson <banderson@mozilla.com>2011-08-18 13:09:49 -0700
commit0a8bffceb3ba25b12926bbd42ed3d282f573c9a0 (patch)
tree049632f6bf5475751688f571ee3c7d79eda9769a /src/rt/rust.cpp
parentc2d8a4df35a0a22d64d7d15ccd5fe25a495a2bc1 (diff)
downloadrust-0a8bffceb3ba25b12926bbd42ed3d282f573c9a0.tar.gz
rust-0a8bffceb3ba25b12926bbd42ed3d282f573c9a0.zip
Simplify the _rust_main/rust_start interface
rust_start will always call _rust_main with the command line args, and it is
_rust_main's responsibility to free the args ivec heap. _rust_main will be
generated slightly differently depending on whether main takes an ivec or not:
if so then it's just passed through to main, otherwise it frees the ivec
directly.
Diffstat (limited to 'src/rt/rust.cpp')
-rw-r--r--src/rt/rust.cpp25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/rt/rust.cpp b/src/rt/rust.cpp
index 908d3dca80b..a34738b8411 100644
--- a/src/rt/rust.cpp
+++ b/src/rt/rust.cpp
@@ -14,8 +14,7 @@ command_line_args : public kernel_owned<command_line_args>
 
     command_line_args(rust_task *task,
                       int sys_argc,
-                      char **sys_argv,
-                      bool main_is_ivec)
+                      char **sys_argv)
         : kernel(task->kernel),
           task(task),
           argc(sys_argc),
@@ -67,15 +66,13 @@ command_line_args : public kernel_owned<command_line_args>
         args_ivec->fill = 0;
         size_t ivec_exterior_sz = sizeof(rust_str *) * argc;
         args_ivec->alloc = ivec_exterior_sz;
-        if (main_is_ivec) {
-            // NB: This is freed by some ivec machinery, probably the drop
-            // glue in main, so we don't free it ourselves
-            args_ivec->payload.ptr = (rust_ivec_heap *)
-                kernel->malloc(ivec_exterior_sz + sizeof(size_t),
-                               "command line arg exterior");
-            args_ivec->payload.ptr->fill = ivec_exterior_sz;
-            memcpy(&args_ivec->payload.ptr->data, strs, ivec_exterior_sz);
-        }
+        // NB: This is freed by some ivec machinery, probably the drop
+        // glue in main, so we don't free it ourselves
+        args_ivec->payload.ptr = (rust_ivec_heap *)
+            kernel->malloc(ivec_exterior_sz + sizeof(size_t),
+                           "command line arg exterior");
+        args_ivec->payload.ptr->fill = ivec_exterior_sz;
+        memcpy(&args_ivec->payload.ptr->data, strs, ivec_exterior_sz);
     }
 
     ~command_line_args() {
@@ -107,7 +104,7 @@ int check_claims = 0;
 
 extern "C" CDECL int
 rust_start(uintptr_t main_fn, int argc, char **argv,
-           void* crate_map, int main_takes_ivec) {
+           void* crate_map) {
 
     rust_env *env = load_env();
 
@@ -122,7 +119,7 @@ rust_start(uintptr_t main_fn, int argc, char **argv,
     rust_scheduler *sched = root_task->sched;
     command_line_args *args
         = new (kernel, "main command line args")
-        command_line_args(root_task, argc, argv, main_takes_ivec);
+        command_line_args(root_task, argc, argv);
 
     DLOG(sched, dom, "startup: %d args in 0x%" PRIxPTR,
              args->argc, (uintptr_t)args->args);
@@ -154,7 +151,7 @@ rust_start(uintptr_t main_fn, int argc, char **argv,
 extern "C" CDECL int
 rust_start_ivec(uintptr_t main_fn, int argc, char **argv,
                 void* crate_map, int main_takes_ivec) {
-    return rust_start(main_fn, argc, argv, crate_map, main_takes_ivec);
+    return rust_start(main_fn, argc, argv, crate_map);
 }