Correct type signature for start lang item.

This commit is contained in:
Luqman Aden 2013-03-30 19:59:21 -07:00
parent 8e30d3fc0b
commit eadd358b2a
3 changed files with 47 additions and 1 deletions

View File

@ -48,6 +48,7 @@ macro_rules! rtdebug (
mod thread;
pub mod env;
#[cfg(stage0)]
pub fn start(main: *u8, _argc: int, _argv: *c_char, _crate_map: *u8) -> int {
use self::sched::{Scheduler, Task};
use self::uvio::UvEventLoop;
@ -67,3 +68,22 @@ pub fn start(main: *u8, _argc: int, _argv: *c_char, _crate_map: *u8) -> int {
}
}
#[cfg(not(stage0))]
pub fn start(main: *u8, _argc: int, _argv: **c_char, _crate_map: *u8) -> int {
use self::sched::{Scheduler, Task};
use self::uvio::UvEventLoop;
let loop_ = ~UvEventLoop::new();
let mut sched = ~Scheduler::new(loop_);
let main_task = ~do Task::new(&mut sched.stack_pool) {
// XXX: Can't call a C function pointer from Rust yet
unsafe { rust_call_nullary_fn(main) };
};
sched.task_queue.push_back(main_task);
sched.run();
return 0;
extern {
fn rust_call_nullary_fn(f: *u8);
}
}

View File

@ -127,6 +127,7 @@ pub unsafe fn strdup_uniq(ptr: *c_uchar, len: uint) -> ~str {
}
#[lang="start"]
#[cfg(stage0)]
pub fn start(main: *u8, argc: int, argv: *c_char,
crate_map: *u8) -> int {
use libc::getenv;
@ -150,6 +151,31 @@ fn rust_start(main: *c_void, argc: c_int, argv: *c_char,
}
}
#[lang="start"]
#[cfg(not(stage0))]
pub fn start(main: *u8, argc: int, argv: **c_char,
crate_map: *u8) -> int {
use libc::getenv;
use rt::start;
unsafe {
let use_new_rt = do str::as_c_str("RUST_NEWRT") |s| {
getenv(s).is_null()
};
if use_new_rt {
return rust_start(main as *c_void, argc as c_int, argv,
crate_map as *c_void) as int;
} else {
return start(main, argc, argv, crate_map);
}
}
extern {
fn rust_start(main: *c_void, argc: c_int, argv: **c_char,
crate_map: *c_void) -> c_int;
}
}
// Local Variables:
// mode: rust;
// fill-column: 78;

View File

@ -2247,7 +2247,7 @@ fn create_entry_fn(ccx: @CrateContext, rust_main: ValueRef) {
fn main_name() -> ~str { return ~"WinMain@16"; }
#[cfg(unix)]
fn main_name() -> ~str { return ~"main"; }
let llfty = T_fn(~[ccx.int_type, T_ptr(T_i8())], ccx.int_type);
let llfty = T_fn(~[ccx.int_type, T_ptr(T_ptr(T_i8()))], ccx.int_type);
// FIXME #4404 android JNI hacks
let llfn = if *ccx.sess.building_library {