Skip to content

Commit af7420b

Browse files
committed
---
yaml --- r: 58213 b: refs/heads/auto c: b21f37c h: refs/heads/master i: 58211: d42513f v: v3
1 parent 7e9b824 commit af7420b

File tree

4 files changed

+20
-15
lines changed

4 files changed

+20
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 8f94ac6118a3ce97d3d1186b38217a6ca4803771
17+
refs/heads/auto: b21f37c81804293168424697518d306542cdd798
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/src/libcore/rt/mod.rs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,35 @@ mod local_heap;
3838
pub mod test;
3939

4040
pub fn start(main: *u8, _argc: int, _argv: **c_char, _crate_map: *u8) -> int {
41+
4142
use self::sched::{Scheduler, Task};
4243
use self::uvio::UvEventLoop;
44+
use sys::Closure;
45+
use ptr;
46+
use cast;
4347

4448
let loop_ = ~UvEventLoop::new();
4549
let mut sched = ~Scheduler::new(loop_);
50+
4651
let main_task = ~do Task::new(&mut sched.stack_pool) {
47-
// XXX: Can't call a C function pointer from Rust yet
48-
unsafe { rust_call_nullary_fn(main) };
52+
53+
unsafe {
54+
// `main` is an `fn() -> ()` that doesn't take an environment
55+
// XXX: Could also call this as an `extern "Rust" fn` once they work
56+
let main = Closure {
57+
code: main as *(),
58+
env: ptr::null(),
59+
};
60+
let mainfn: &fn() = cast::transmute(main);
61+
62+
mainfn();
63+
}
4964
};
65+
5066
sched.task_queue.push_back(main_task);
5167
sched.run();
52-
return 0;
5368

54-
extern {
55-
fn rust_call_nullary_fn(f: *u8);
56-
}
69+
return 0;
5770
}
5871

5972
/// Possible contexts in which Rust code may be executing.

branches/auto/src/rt/rust_builtin.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -829,13 +829,6 @@ rust_get_rt_env() {
829829
return task->kernel->env;
830830
}
831831

832-
typedef void *(*nullary_fn)();
833-
834-
extern "C" CDECL void
835-
rust_call_nullary_fn(nullary_fn f) {
836-
f();
837-
}
838-
839832
#ifndef _WIN32
840833
pthread_key_t sched_key;
841834
#else

branches/auto/src/rt/rustrt.def.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ rust_uv_ip4_addrp
222222
rust_uv_ip6_addrp
223223
rust_uv_free_ip4_addr
224224
rust_uv_free_ip6_addr
225-
rust_call_nullary_fn
226225
rust_initialize_global_state
227226
rust_dbg_next_port
228227
rust_new_memory_region

0 commit comments

Comments
 (0)