rt: Remove rust_call_nullary_fn
There's no need to delegate to C to call the Rust main function.
This commit is contained in:
@@ -38,22 +38,35 @@ mod local_heap;
|
|||||||
pub mod test;
|
pub mod test;
|
||||||
|
|
||||||
pub fn start(main: *u8, _argc: int, _argv: **c_char, _crate_map: *u8) -> int {
|
pub fn start(main: *u8, _argc: int, _argv: **c_char, _crate_map: *u8) -> int {
|
||||||
|
|
||||||
use self::sched::{Scheduler, Task};
|
use self::sched::{Scheduler, Task};
|
||||||
use self::uvio::UvEventLoop;
|
use self::uvio::UvEventLoop;
|
||||||
|
use sys::Closure;
|
||||||
|
use ptr;
|
||||||
|
use cast;
|
||||||
|
|
||||||
let loop_ = ~UvEventLoop::new();
|
let loop_ = ~UvEventLoop::new();
|
||||||
let mut sched = ~Scheduler::new(loop_);
|
let mut sched = ~Scheduler::new(loop_);
|
||||||
|
|
||||||
let main_task = ~do Task::new(&mut sched.stack_pool) {
|
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) };
|
unsafe {
|
||||||
|
// `main` is an `fn() -> ()` that doesn't take an environment
|
||||||
|
// XXX: Could also call this as an `extern "Rust" fn` once they work
|
||||||
|
let main = Closure {
|
||||||
|
code: main as *(),
|
||||||
|
env: ptr::null(),
|
||||||
|
};
|
||||||
|
let mainfn: &fn() = cast::transmute(main);
|
||||||
|
|
||||||
|
mainfn();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
sched.task_queue.push_back(main_task);
|
sched.task_queue.push_back(main_task);
|
||||||
sched.run();
|
sched.run();
|
||||||
return 0;
|
|
||||||
|
|
||||||
extern {
|
return 0;
|
||||||
fn rust_call_nullary_fn(f: *u8);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Possible contexts in which Rust code may be executing.
|
/// Possible contexts in which Rust code may be executing.
|
||||||
|
|||||||
@@ -830,13 +830,6 @@ rust_get_rt_env() {
|
|||||||
return task->kernel->env;
|
return task->kernel->env;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef void *(*nullary_fn)();
|
|
||||||
|
|
||||||
extern "C" CDECL void
|
|
||||||
rust_call_nullary_fn(nullary_fn f) {
|
|
||||||
f();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
pthread_key_t sched_key;
|
pthread_key_t sched_key;
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -222,7 +222,6 @@ rust_uv_ip4_addrp
|
|||||||
rust_uv_ip6_addrp
|
rust_uv_ip6_addrp
|
||||||
rust_uv_free_ip4_addr
|
rust_uv_free_ip4_addr
|
||||||
rust_uv_free_ip6_addr
|
rust_uv_free_ip6_addr
|
||||||
rust_call_nullary_fn
|
|
||||||
rust_initialize_global_state
|
rust_initialize_global_state
|
||||||
rust_dbg_next_port
|
rust_dbg_next_port
|
||||||
rust_new_memory_region
|
rust_new_memory_region
|
||||||
|
|||||||
Reference in New Issue
Block a user