about summary refs log tree commit diff
path: root/src/libnative/lib.rs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-03-11 13:38:36 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-03-21 12:03:13 -0700
commitab1dd09d736fd443883ea4c1d8ec73ff285f6308 (patch)
treeb26f7fca7415e216cf61a92a8ac444d8ba5d257d /src/libnative/lib.rs
parent7b957a879bd5065005327b0d9912695e8750cefa (diff)
downloadrust-ab1dd09d736fd443883ea4c1d8ec73ff285f6308.tar.gz
rust-ab1dd09d736fd443883ea4c1d8ec73ff285f6308.zip
rustc: Switch defaults from libgreen to libnative
The compiler will no longer inject libgreen as the default runtime for rust
programs, this commit switches it over to libnative by default. Now that
libnative has baked for some time, it is ready enough to start getting more
serious usage as the default runtime for rustc generated binaries.

We've found that there isn't really a correct decision in choosing a 1:1 or M:N
runtime as a default for all applications, but it seems that a larger number of
programs today would work more reasonable with a native default rather than a
green default.

With this commit come a number of bugfixes:

* The main native task is now named "<main>"
* The main native task has the stack bounds set up properly
* #[no_uv] was renamed to #[no_start]
* The core-run-destroy test was rewritten for both libnative and libgreen and
  one of the tests was modified to be more robust.
* The process-detach test was locked to libgreen because it uses signal handling
Diffstat (limited to 'src/libnative/lib.rs')
-rw-r--r--src/libnative/lib.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/libnative/lib.rs b/src/libnative/lib.rs
index f50cf727864..afe440cc1e0 100644
--- a/src/libnative/lib.rs
+++ b/src/libnative/lib.rs
@@ -58,6 +58,7 @@
 
 use std::os;
 use std::rt;
+use std::str;
 
 pub mod io;
 pub mod task;
@@ -68,6 +69,16 @@ static OS_DEFAULT_STACK_ESTIMATE: uint = 1 << 20;
 #[cfg(unix, not(android))]
 static OS_DEFAULT_STACK_ESTIMATE: uint = 2 * (1 << 20);
 
+#[lang = "start"]
+#[cfg(not(test), not(stage0))]
+pub fn lang_start(main: *u8, argc: int, argv: **u8) -> int {
+    use std::cast;
+    start(argc, argv, proc() {
+        let main: extern "Rust" fn() = unsafe { cast::transmute(main) };
+        main();
+    })
+}
+
 /// Executes the given procedure after initializing the runtime with the given
 /// argc/argv.
 ///
@@ -90,7 +101,12 @@ pub fn start(argc: int, argv: **u8, main: proc()) -> int {
     rt::init(argc, argv);
     let mut exit_code = None;
     let mut main = Some(main);
-    let t = task::new((my_stack_bottom, my_stack_top)).run(|| {
+    let mut task = task::new((my_stack_bottom, my_stack_top));
+    task.name = Some(str::Slice("<main>"));
+    let t = task.run(|| {
+        unsafe {
+            rt::stack::record_stack_bounds(my_stack_bottom, my_stack_top);
+        }
         exit_code = Some(run(main.take_unwrap()));
     });
     drop(t);