提交 be2c9207 编写于 作者: G Graydon Hoare

Change crust -> extern.

上级 dc981654
......@@ -612,7 +612,7 @@ fn new_task_in_new_sched(opts: sched_opts) -> *rust_task {
// Has to be a pointer at outermost layer; the foreign call returns void *.
type task_local_map = @dvec::dvec<option<task_local_element>>;
crust fn cleanup_task_local_map(map_ptr: *libc::c_void) unsafe {
extern fn cleanup_task_local_map(map_ptr: *libc::c_void) unsafe {
assert !map_ptr.is_null();
// Get and keep the single reference that was created at the beginning.
let map: task_local_map = unsafe::reinterpret_cast(map_ptr);
......@@ -1250,7 +1250,7 @@ fn my_key(+_x: @str) { }
#[test]
fn test_tls_crust_automorestack_memorial_bug() unsafe {
// This might result in a stack-canary clobber if the runtime fails to set
// sp_limit to 0 when calling the cleanup crust - it might automatically
// sp_limit to 0 when calling the cleanup extern - it might automatically
// jump over to the rust stack, which causes next_c_sp to get recorded as
// something within a rust stack segment. Then a subsequent upcall (esp.
// for logging, think vsnprintf) would run on a stack smaller than 1 MB.
......
......@@ -257,7 +257,7 @@ fn try_parse_addr(ip: str) -> result::result<ip_addr,parse_addr_err> {
output_ch: comm::chan<result::result<[ip_addr]/~,ip_get_addr_err>>
};
crust fn get_addr_cb(handle: *uv_getaddrinfo_t, status: libc::c_int,
extern fn get_addr_cb(handle: *uv_getaddrinfo_t, status: libc::c_int,
res: *addrinfo) unsafe {
log(debug, "in get_addr_cb");
let handle_data = get_data_for_req(handle) as
......
......@@ -1031,13 +1031,13 @@ enum tcp_new_connection {
mut active: bool
};
crust fn tcp_lfc_close_cb(handle: *uv::ll::uv_tcp_t) unsafe {
extern fn tcp_lfc_close_cb(handle: *uv::ll::uv_tcp_t) unsafe {
let server_data_ptr = uv::ll::get_data_for_uv_handle(
handle) as *tcp_listen_fc_data;
comm::send((*server_data_ptr).stream_closed_ch, ());
}
crust fn tcp_lfc_on_connection_cb(handle: *uv::ll::uv_tcp_t,
extern fn tcp_lfc_on_connection_cb(handle: *uv::ll::uv_tcp_t,
status: libc::c_int) unsafe {
let server_data_ptr = uv::ll::get_data_for_uv_handle(handle)
as *tcp_listen_fc_data;
......@@ -1094,7 +1094,7 @@ fn to_tcp_err() -> tcp_err_data {
}
}
crust fn on_tcp_read_cb(stream: *uv::ll::uv_stream_t,
extern fn on_tcp_read_cb(stream: *uv::ll::uv_stream_t,
nread: libc::ssize_t,
++buf: uv::ll::uv_buf_t) unsafe {
log(debug, #fmt("entering on_tcp_read_cb stream: %? nread: %?",
......@@ -1128,7 +1128,7 @@ fn to_tcp_err() -> tcp_err_data {
log(debug, "exiting on_tcp_read_cb");
}
crust fn on_alloc_cb(handle: *libc::c_void,
extern fn on_alloc_cb(handle: *libc::c_void,
++suggested_size: size_t)
-> uv::ll::uv_buf_t unsafe {
log(debug, "tcp read on_alloc_cb!");
......@@ -1144,7 +1144,7 @@ fn to_tcp_err() -> tcp_err_data {
closed_ch: comm::chan<()>
};
crust fn tcp_socket_dtor_close_cb(handle: *uv::ll::uv_tcp_t) unsafe {
extern fn tcp_socket_dtor_close_cb(handle: *uv::ll::uv_tcp_t) unsafe {
let data = uv::ll::get_data_for_uv_handle(handle)
as *tcp_socket_close_data;
let closed_ch = (*data).closed_ch;
......@@ -1152,7 +1152,7 @@ fn to_tcp_err() -> tcp_err_data {
log(debug, "tcp_socket_dtor_close_cb exiting..");
}
crust fn tcp_write_complete_cb(write_req: *uv::ll::uv_write_t,
extern fn tcp_write_complete_cb(write_req: *uv::ll::uv_write_t,
status: libc::c_int) unsafe {
let write_data_ptr = uv::ll::get_data_for_req(write_req)
as *write_req_data;
......@@ -1178,18 +1178,18 @@ fn to_tcp_err() -> tcp_err_data {
closed_signal_ch: comm::chan<()>
};
crust fn stream_error_close_cb(handle: *uv::ll::uv_tcp_t) unsafe {
extern fn stream_error_close_cb(handle: *uv::ll::uv_tcp_t) unsafe {
let data = uv::ll::get_data_for_uv_handle(handle) as
*connect_req_data;
comm::send((*data).closed_signal_ch, ());
log(debug, #fmt("exiting steam_error_close_cb for %?", handle));
}
crust fn tcp_connect_close_cb(handle: *uv::ll::uv_tcp_t) unsafe {
extern fn tcp_connect_close_cb(handle: *uv::ll::uv_tcp_t) unsafe {
log(debug, #fmt("closed client tcp handle %?", handle));
}
crust fn tcp_connect_on_connect_cb(connect_req_ptr: *uv::ll::uv_connect_t,
extern fn tcp_connect_on_connect_cb(connect_req_ptr: *uv::ll::uv_connect_t,
status: libc::c_int) unsafe {
let conn_data_ptr = (uv::ll::get_data_for_req(connect_req_ptr)
as *connect_req_data);
......
......@@ -116,7 +116,7 @@ fn recv_timeout<T: copy send>(iotask: iotask,
}
// INTERNAL API
crust fn delayed_send_cb(handle: *uv::ll::uv_timer_t,
extern fn delayed_send_cb(handle: *uv::ll::uv_timer_t,
status: libc::c_int) unsafe {
log(debug, #fmt("delayed_send_cb handle %? status %?", handle, status));
let timer_done_ch =
......@@ -133,7 +133,7 @@ fn recv_timeout<T: copy send>(iotask: iotask,
}
}
crust fn delayed_send_close_cb(handle: *uv::ll::uv_timer_t) unsafe {
extern fn delayed_send_close_cb(handle: *uv::ll::uv_timer_t) unsafe {
log(debug, #fmt("delayed_send_close_cb handle %?", handle));
let timer_done_ch =
*(uv::ll::get_data_for_uv_handle(handle) as *comm::chan<()>);
......
......@@ -116,7 +116,7 @@ fn spawn_loop() -> iotask unsafe {
#[cfg(test)]
mod test {
crust fn simple_timer_close_cb(timer_ptr: *ll::uv_timer_t) unsafe {
extern fn simple_timer_close_cb(timer_ptr: *ll::uv_timer_t) unsafe {
let exit_ch_ptr = ll::get_data_for_uv_handle(
timer_ptr as *libc::c_void) as *comm::chan<bool>;
let exit_ch = *exit_ch_ptr;
......@@ -124,7 +124,7 @@ mod test {
log(debug, #fmt("EXIT_CH_PTR simple_timer_close_cb exit_ch_ptr: %?",
exit_ch_ptr));
}
crust fn simple_timer_cb(timer_ptr: *ll::uv_timer_t,
extern fn simple_timer_cb(timer_ptr: *ll::uv_timer_t,
_status: libc::c_int) unsafe {
log(debug, "in simple timer cb");
ll::timer_stop(timer_ptr);
......
......@@ -148,10 +148,10 @@ fn send_msg(iotask: iotask,
}
#[doc ="Dispatch all pending messages"]
crust fn wake_up_cb(async_handle: *ll::uv_async_t,
extern fn wake_up_cb(async_handle: *ll::uv_async_t,
status: int) unsafe {
log(debug, #fmt("wake_up_cb crust.. handle: %? status: %?",
log(debug, #fmt("wake_up_cb extern.. handle: %? status: %?",
async_handle, status));
let loop_ptr = ll::get_loop_for_uv_handle(async_handle);
......@@ -176,7 +176,7 @@ fn begin_teardown(data: *iotask_loop_data) unsafe {
ll::close(async_handle as *c_void, tear_down_close_cb);
}
crust fn tear_down_close_cb(handle: *ll::uv_async_t) unsafe {
extern fn tear_down_close_cb(handle: *ll::uv_async_t) unsafe {
let loop_ptr = ll::get_loop_for_uv_handle(handle);
let loop_refs = ll::loop_refcount(loop_ptr);
log(debug, #fmt("tear_down_close_cb called, closing handle at %? refs %?",
......@@ -186,13 +186,13 @@ fn begin_teardown(data: *iotask_loop_data) unsafe {
#[cfg(test)]
mod test {
crust fn async_close_cb(handle: *ll::uv_async_t) unsafe {
extern fn async_close_cb(handle: *ll::uv_async_t) unsafe {
log(debug, #fmt("async_close_cb handle %?", handle));
let exit_ch = (*(ll::get_data_for_uv_handle(handle)
as *ah_data)).exit_ch;
comm::send(exit_ch, ());
}
crust fn async_handle_cb(handle: *ll::uv_async_t, status: libc::c_int)
extern fn async_handle_cb(handle: *ll::uv_async_t, status: libc::c_int)
unsafe {
log(debug, #fmt("async_handle_cb handle %? status %?",handle,status));
ll::close(handle, async_close_cb);
......@@ -231,11 +231,11 @@ unsafe fn spawn_test_loop(exit_ch: comm::chan<()>) -> iotask {
ret comm::recv(iotask_port);
}
crust fn lifetime_handle_close(handle: *libc::c_void) unsafe {
extern fn lifetime_handle_close(handle: *libc::c_void) unsafe {
log(debug, #fmt("lifetime_handle_close ptr %?", handle));
}
crust fn lifetime_async_callback(handle: *libc::c_void,
extern fn lifetime_async_callback(handle: *libc::c_void,
status: libc::c_int) {
log(debug, #fmt("lifetime_handle_close ptr %? status %?",
handle, status));
......
......@@ -1016,12 +1016,12 @@ enum tcp_read_data {
read_chan: *comm::chan<str>
};
crust fn after_close_cb(handle: *libc::c_void) {
extern fn after_close_cb(handle: *libc::c_void) {
log(debug, #fmt("after uv_close! handle ptr: %?",
handle));
}
crust fn on_alloc_cb(handle: *libc::c_void,
extern fn on_alloc_cb(handle: *libc::c_void,
++suggested_size: libc::size_t)
-> uv_buf_t unsafe {
log(debug, "on_alloc_cb!");
......@@ -1033,7 +1033,7 @@ enum tcp_read_data {
ret buf_init(char_ptr, suggested_size as uint);
}
crust fn on_read_cb(stream: *uv_stream_t,
extern fn on_read_cb(stream: *uv_stream_t,
nread: libc::ssize_t,
++buf: uv_buf_t) unsafe {
let nread = nread as int;
......@@ -1067,7 +1067,7 @@ enum tcp_read_data {
log(debug, "CLIENT exiting on_read_cb");
}
crust fn on_write_complete_cb(write_req: *uv_write_t,
extern fn on_write_complete_cb(write_req: *uv_write_t,
status: libc::c_int) unsafe {
log(debug, #fmt("CLIENT beginning on_write_complete_cb status: %d",
status as int));
......@@ -1079,7 +1079,7 @@ enum tcp_read_data {
result as int));
}
crust fn on_connect_cb(connect_req_ptr: *uv_connect_t,
extern fn on_connect_cb(connect_req_ptr: *uv_connect_t,
status: libc::c_int) unsafe {
log(debug, #fmt("beginning on_connect_cb .. status: %d",
status as int));
......@@ -1184,12 +1184,12 @@ fn impl_uv_tcp_request(ip: str, port: int, req_str: str,
}
crust fn server_after_close_cb(handle: *libc::c_void) unsafe {
extern fn server_after_close_cb(handle: *libc::c_void) unsafe {
log(debug, #fmt("SERVER server stream closed, should exit.. h: %?",
handle));
}
crust fn client_stream_after_close_cb(handle: *libc::c_void)
extern fn client_stream_after_close_cb(handle: *libc::c_void)
unsafe {
log(debug, "SERVER: closed client stream, now closing server stream");
let client_data = get_data_for_uv_handle(
......@@ -1199,7 +1199,7 @@ fn impl_uv_tcp_request(ip: str, port: int, req_str: str,
server_after_close_cb);
}
crust fn after_server_resp_write(req: *uv_write_t) unsafe {
extern fn after_server_resp_write(req: *uv_write_t) unsafe {
let client_stream_ptr =
get_stream_handle_from_write_req(req);
log(debug, "SERVER: resp sent... closing client stream");
......@@ -1207,7 +1207,7 @@ fn impl_uv_tcp_request(ip: str, port: int, req_str: str,
client_stream_after_close_cb)
}
crust fn on_server_read_cb(client_stream_ptr: *uv_stream_t,
extern fn on_server_read_cb(client_stream_ptr: *uv_stream_t,
nread: libc::ssize_t,
++buf: uv_buf_t) unsafe {
let nread = nread as int;
......@@ -1268,7 +1268,7 @@ fn impl_uv_tcp_request(ip: str, port: int, req_str: str,
log(debug, "SERVER exiting on_read_cb");
}
crust fn server_connection_cb(server_stream_ptr:
extern fn server_connection_cb(server_stream_ptr:
*uv_stream_t,
status: libc::c_int) unsafe {
log(debug, "client connecting!");
......@@ -1335,12 +1335,12 @@ fn impl_uv_tcp_request(ip: str, port: int, req_str: str,
continue_chan: *comm::chan<bool>
};
crust fn async_close_cb(handle: *libc::c_void) {
extern fn async_close_cb(handle: *libc::c_void) {
log(debug, #fmt("SERVER: closing async cb... h: %?",
handle));
}
crust fn continue_async_cb(async_handle: *uv_async_t,
extern fn continue_async_cb(async_handle: *uv_async_t,
status: libc::c_int) unsafe {
// once we're in the body of this callback,
// the tcp server's loop is set up, so we
......
......@@ -563,7 +563,7 @@ enum purity {
pure_fn, // declared with "pure fn"
unsafe_fn, // declared with "unsafe fn"
impure_fn, // declared with "fn"
extern_fn, // declared with "crust fn"
extern_fn, // declared with "extern fn"
}
#[auto_serialize]
......
......@@ -1009,7 +1009,7 @@ fn build_shim_fn(ccx: @crate_ctxt, path: ast_map::path,
fn build_args(bcx: block, tys: @c_stack_tys,
llargbundle: ValueRef) -> ~[ValueRef] {
let _icx = bcx.insn_ctxt("foreign::crust::shim::build_args");
let _icx = bcx.insn_ctxt("foreign::extern::shim::build_args");
let mut llargvals = ~[];
let mut i = 0u;
let n = vec::len(tys.arg_tys);
......
......@@ -2031,7 +2031,7 @@ fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) ->
}
}
ast::def_fn(id, ast::extern_fn) {
// Crust functions are just u8 pointers
// extern functions are just u8 pointers
ret {
bounds: @~[],
rp: ast::rp_none,
......
// error-pattern:expected function or foreign function but found *u8
crust fn f() {
extern fn f() {
}
fn main() {
......
// error-pattern:expected `fn()` but found `*u8`
crust fn f() {
extern fn f() {
}
fn main() {
// Crust functions are *u8 types
// extern functions are *u8 types
let _x: fn() = f;
}
\ No newline at end of file
......@@ -7,7 +7,7 @@ fn rust_dbg_call(cb: *u8,
data: libc::uintptr_t) -> libc::uintptr_t;
}
crust fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
if data == 1u {
data
} else {
......
......@@ -3,7 +3,7 @@ fn rust_dbg_call(cb: *u8,
data: libc::uintptr_t) -> libc::uintptr_t;
}
crust fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
if data == 1u {
data
} else {
......
......@@ -3,7 +3,7 @@ fn rust_dbg_call(cb: *u8,
data: libc::uintptr_t) -> libc::uintptr_t;
}
crust fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
if data == 1u {
data
} else {
......
......@@ -7,7 +7,7 @@ fn rust_dbg_call(cb: *u8,
data: libc::uintptr_t) -> libc::uintptr_t;
}
crust fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
if data == 1u {
data
} else {
......
......@@ -3,7 +3,7 @@ fn rust_dbg_call(cb: *u8,
data: libc::uintptr_t) -> libc::uintptr_t;
}
crust fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
if data == 1u {
data
} else {
......
......@@ -6,7 +6,7 @@ fn rust_dbg_call(cb: *u8,
data: libc::uintptr_t) -> libc::uintptr_t;
}
crust fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
if data == 1u {
data
} else {
......
crust fn f() {
extern fn f() {
}
crust fn g() {
extern fn g() {
}
fn main() {
// Crust functions are *u8 types
// extern functions are *u8 types
let a: *u8 = f;
let b: *u8 = f;
let c: *u8 = g;
......
......@@ -3,7 +3,7 @@ fn rust_dbg_call(cb: *u8,
data: libc::uintptr_t) -> libc::uintptr_t;
}
crust fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
if data == 1u {
data
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册