1
Fork 0

librustc: Remove "extern mod { ... }" from librustc, librustdoc, and tests. rs=deexterning

This commit is contained in:
Patrick Walton 2013-03-05 14:42:58 -08:00
parent 87e44af2f2
commit 6b5d1afeec
62 changed files with 1594 additions and 1338 deletions

View file

@ -1139,8 +1139,8 @@ pub mod funcs {
unsafe fn strxfrm(s: *c_char, ct: *c_char, n: size_t) unsafe fn strxfrm(s: *c_char, ct: *c_char, n: size_t)
-> size_t; -> size_t;
// These are fine to execute on the Rust stack. They must be, in // These are fine to execute on the Rust stack. They must be,
// fact, because LLVM generates calls to them! // in fact, because LLVM generates calls to them!
#[rust_stack] #[rust_stack]
#[inline(always)] #[inline(always)]
unsafe fn memcpy(s: *c_void, ct: *c_void, n: size_t) unsafe fn memcpy(s: *c_void, ct: *c_void, n: size_t)

View file

@ -94,10 +94,12 @@ pub mod jit {
use core::ptr; use core::ptr;
use core::str; use core::str;
#[nolink] pub mod rusti {
#[abi = "rust-intrinsic"] #[nolink]
pub extern mod rusti { #[abi = "rust-intrinsic"]
pub fn morestack_addr() -> *(); pub extern {
pub fn morestack_addr() -> *();
}
} }
pub struct Closure { pub struct Closure {

View file

@ -122,9 +122,13 @@ pub mod intrinsic {
fn visit_closure_ptr(&self, ck: uint) -> bool; fn visit_closure_ptr(&self, ck: uint) -> bool;
} }
#[abi = "rust-intrinsic"] pub mod rusti {
pub extern mod rusti { use super::{TyDesc, TyVisitor};
pub fn get_tydesc<T>() -> *();
pub fn visit_tydesc(++td: *TyDesc, &&tv: TyVisitor); #[abi = "rust-intrinsic"]
pub extern {
pub fn get_tydesc<T>() -> *();
pub fn visit_tydesc(++td: *TyDesc, &&tv: TyVisitor);
}
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -135,15 +135,9 @@ fn should_extract_top_mod_attributes() {
assert doc.cratemod().desc() == Some(~"test"); assert doc.cratemod().desc() == Some(~"test");
} }
#[test]
fn should_extract_foreign_mod_attributes() {
let doc = test::mk_doc(~"#[doc = \"test\"] extern mod a { }");
assert doc.cratemod().nmods()[0].desc() == Some(~"test");
}
#[test] #[test]
fn should_extract_foreign_fn_attributes() { fn should_extract_foreign_fn_attributes() {
let doc = test::mk_doc(~"extern mod a { #[doc = \"test\"] fn a(); }"); let doc = test::mk_doc(~"extern { #[doc = \"test\"] fn a(); }");
assert doc.cratemod().nmods()[0].fns[0].desc() == Some(~"test"); assert doc.cratemod().nmods()[0].fns[0].desc() == Some(~"test");
} }

View file

@ -371,15 +371,9 @@ mod test {
assert doc.cratemod().mods()[0].mods()[1].name() == ~"c"; assert doc.cratemod().mods()[0].mods()[1].name() == ~"c";
} }
#[test]
pub fn extract_foreign_mods() {
let doc = mk_doc(~"extern mod a { }");
assert doc.cratemod().nmods()[0].name() == ~"a";
}
#[test] #[test]
pub fn extract_fns_from_foreign_mods() { pub fn extract_fns_from_foreign_mods() {
let doc = mk_doc(~"extern mod a { fn a(); }"); let doc = mk_doc(~"extern { fn a(); }");
assert doc.cratemod().nmods()[0].fns[0].name() == ~"a"; assert doc.cratemod().nmods()[0].fns[0].name() == ~"a";
} }

View file

@ -169,18 +169,6 @@ fn should_remove_mods_from_containing_mods() {
assert vec::is_empty(doc.cratemod().mods()); assert vec::is_empty(doc.cratemod().mods());
} }
#[test]
fn should_make_a_page_for_every_foreign_mod() {
let doc = test::mk_doc(~"extern mod a { }");
assert doc.pages.nmods()[0].name() == ~"a";
}
#[test]
fn should_remove_foreign_mods_from_containing_mods() {
let doc = test::mk_doc(~"extern mod a { }");
assert vec::is_empty(doc.cratemod().nmods());
}
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use astsrv; use astsrv;

View file

@ -115,22 +115,3 @@ fn should_record_fn_paths() {
} }
} }
#[test]
fn should_record_foreign_mod_paths() {
let source = ~"mod a { extern mod b { } }";
do astsrv::from_str(source) |srv| {
let doc = extract::from_srv(srv.clone(), ~"");
let doc = run(srv.clone(), doc);
assert doc.cratemod().mods()[0].nmods()[0].path() == ~[~"a"];
}
}
#[test]
fn should_record_foreign_fn_paths() {
let source = ~"extern mod a { fn b(); }";
do astsrv::from_str(source) |srv| {
let doc = extract::from_srv(srv.clone(), ~"");
let doc = run(srv.clone(), doc);
assert doc.cratemod().nmods()[0].fns[0].path() == ~[~"a"];
}
}

View file

@ -786,9 +786,11 @@ pub mod rustrt {
unsafe fn rust_uv_tcp_bind6(tcp_server: *uv_tcp_t, unsafe fn rust_uv_tcp_bind6(tcp_server: *uv_tcp_t,
++addr: *sockaddr_in6) -> libc::c_int; ++addr: *sockaddr_in6) -> libc::c_int;
unsafe fn rust_uv_tcp_getpeername(tcp_handle_ptr: *uv_tcp_t, unsafe fn rust_uv_tcp_getpeername(tcp_handle_ptr: *uv_tcp_t,
++name: *sockaddr_in) -> libc::c_int; ++name: *sockaddr_in)
-> libc::c_int;
unsafe fn rust_uv_tcp_getpeername6(tcp_handle_ptr: *uv_tcp_t, unsafe fn rust_uv_tcp_getpeername6(tcp_handle_ptr: *uv_tcp_t,
++name: *sockaddr_in6) ->libc::c_int; ++name: *sockaddr_in6)
-> libc::c_int;
unsafe fn rust_uv_listen(stream: *libc::c_void, unsafe fn rust_uv_listen(stream: *libc::c_void,
backlog: libc::c_int, backlog: libc::c_int,
cb: *u8) -> libc::c_int; cb: *u8) -> libc::c_int;
@ -852,7 +854,8 @@ pub mod rustrt {
-> *libc::c_void; -> *libc::c_void;
unsafe fn rust_uv_set_data_for_uv_handle(handle: *libc::c_void, unsafe fn rust_uv_set_data_for_uv_handle(handle: *libc::c_void,
data: *libc::c_void); data: *libc::c_void);
unsafe fn rust_uv_get_data_for_req(req: *libc::c_void) -> *libc::c_void; unsafe fn rust_uv_get_data_for_req(req: *libc::c_void)
-> *libc::c_void;
unsafe fn rust_uv_set_data_for_req(req: *libc::c_void, unsafe fn rust_uv_set_data_for_req(req: *libc::c_void,
data: *libc::c_void); data: *libc::c_void);
unsafe fn rust_uv_get_base_from_buf(++buf: uv_buf_t) -> *u8; unsafe fn rust_uv_get_base_from_buf(++buf: uv_buf_t) -> *u8;

View file

@ -8,23 +8,25 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#[abi = "rust-intrinsic"] pub mod rusti {
pub extern mod rusti { #[abi = "rust-intrinsic"]
fn atomic_cxchg(dst: &mut int, old: int, src: int) -> int; pub extern {
fn atomic_cxchg_acq(dst: &mut int, old: int, src: int) -> int; fn atomic_cxchg(dst: &mut int, old: int, src: int) -> int;
fn atomic_cxchg_rel(dst: &mut int, old: int, src: int) -> int; fn atomic_cxchg_acq(dst: &mut int, old: int, src: int) -> int;
fn atomic_cxchg_rel(dst: &mut int, old: int, src: int) -> int;
fn atomic_xchg(dst: &mut int, src: int) -> int; fn atomic_xchg(dst: &mut int, src: int) -> int;
fn atomic_xchg_acq(dst: &mut int, src: int) -> int; fn atomic_xchg_acq(dst: &mut int, src: int) -> int;
fn atomic_xchg_rel(dst: &mut int, src: int) -> int; fn atomic_xchg_rel(dst: &mut int, src: int) -> int;
fn atomic_xadd(dst: &mut int, src: int) -> int; fn atomic_xadd(dst: &mut int, src: int) -> int;
fn atomic_xadd_acq(dst: &mut int, src: int) -> int; fn atomic_xadd_acq(dst: &mut int, src: int) -> int;
fn atomic_xadd_rel(dst: &mut int, src: int) -> int; fn atomic_xadd_rel(dst: &mut int, src: int) -> int;
fn atomic_xsub(dst: &mut int, src: int) -> int; fn atomic_xsub(dst: &mut int, src: int) -> int;
fn atomic_xsub_acq(dst: &mut int, src: int) -> int; fn atomic_xsub_acq(dst: &mut int, src: int) -> int;
fn atomic_xsub_rel(dst: &mut int, src: int) -> int; fn atomic_xsub_rel(dst: &mut int, src: int) -> int;
}
} }
#[inline(always)] #[inline(always)]

View file

@ -13,9 +13,11 @@
#[crate_type = "lib"]; #[crate_type = "lib"];
pub extern mod rustrt { pub mod rustrt {
pub fn rust_dbg_call(cb: *u8, pub extern {
data: libc::uintptr_t) -> libc::uintptr_t; pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)
-> libc::uintptr_t;
}
} }
pub fn fact(n: uint) -> uint { pub fn fact(n: uint) -> uint {

View file

@ -10,6 +10,9 @@
#[link(name="foreign_lib", vers="0.0")]; #[link(name="foreign_lib", vers="0.0")];
pub extern mod rustrt { pub mod rustrt {
pub fn rust_get_argc() -> libc::c_int; pub extern {
pub fn rust_get_argc() -> libc::c_int;
}
} }

View file

@ -13,7 +13,9 @@ mod issue_3882 {
len: libc::size_t, len: libc::size_t,
} }
extern mod c { mod c {
fn linenoiseAddCompletion(lc: *mut Completions); extern {
fn linenoiseAddCompletion(lc: *mut Completions);
}
} }
} }

View file

@ -20,9 +20,11 @@ use core::os;
// because the the indirection through another dynamic linker // because the the indirection through another dynamic linker
// stub. Kind of shocking. Might be able to make it faster still with // stub. Kind of shocking. Might be able to make it faster still with
// an llvm intrinsic. // an llvm intrinsic.
#[nolink] mod libc {
extern mod libc { #[nolink]
pub fn sqrt(n: float) -> float; pub extern {
pub fn sqrt(n: float) -> float;
}
} }
fn main() { fn main() {

View file

@ -11,5 +11,5 @@
// error-pattern:empty #[link_name] not allowed; use #[nolink]. // error-pattern:empty #[link_name] not allowed; use #[nolink].
#[link_name = ""] #[link_name = ""]
extern mod foo { extern {
} }

View file

@ -13,5 +13,5 @@
#[link_name = ""] #[link_name = ""]
#[nolink] #[nolink]
extern mod foo { extern {
} }

View file

@ -10,9 +10,11 @@
// except according to those terms. // except according to those terms.
#[abi = "cdecl"] mod test {
extern mod test { #[abi = "cdecl"]
pub unsafe fn free(); pub extern {
pub unsafe fn free();
}
} }
fn main() { fn main() {

View file

@ -10,9 +10,11 @@
// except according to those terms. // except according to those terms.
#[abi = "cdecl"] mod test {
extern mod test { #[abi = "cdecl"]
pub unsafe fn free(); pub extern {
pub unsafe fn free();
}
} }
fn main() { fn main() {

View file

@ -16,6 +16,6 @@ the compiler output. */
#[link_args = "aFdEfSeVEEE"] #[link_args = "aFdEfSeVEEE"]
#[nolink] #[nolink]
extern mod m1 {} extern {}
fn main() { } fn main() { }

View file

@ -18,10 +18,10 @@
#[link_name= "m"] #[link_name= "m"]
#[link_args="-foo"] // this could have been elided. #[link_args="-foo"] // this could have been elided.
extern mod m1 { extern {
} }
#[link_name= "m"] #[link_name= "m"]
#[link_args="-bar"] // this is the actual error trigger. #[link_args="-bar"] // this is the actual error trigger.
extern mod m2 { extern {
} }

View file

@ -11,9 +11,11 @@
// error-pattern:found rust type // error-pattern:found rust type
#[deny(ctypes)]; #[deny(ctypes)];
#[nolink] mod libc {
extern mod libc { #[nolink]
pub fn malloc(size: int) -> *u8; pub extern {
pub fn malloc(size: int) -> *u8;
}
} }
fn main() { fn main() {

View file

@ -10,9 +10,11 @@
// compile-flags:-D ctypes // compile-flags:-D ctypes
// error-pattern:found rust type // error-pattern:found rust type
#[nolink] mod libc {
extern mod libc { #[nolink]
pub fn malloc(size: int) -> *u8; extern {
pub fn malloc(size: int) -> *u8;
}
} }
fn main() { fn main() {

View file

@ -9,9 +9,11 @@
// except according to those terms. // except according to those terms.
//error-pattern:libc::c_int or libc::c_long should be used //error-pattern:libc::c_int or libc::c_long should be used
extern mod xx { mod xx {
pub fn strlen(str: *u8) -> uint; pub extern {
pub fn foo(x: int, y: uint); pub fn strlen(str: *u8) -> uint;
pub fn foo(x: int, y: uint);
}
} }
fn main() { fn main() {

View file

@ -12,9 +12,11 @@
// Testing that runtime failure doesn't cause callbacks to abort abnormally. // Testing that runtime failure doesn't cause callbacks to abort abnormally.
// Instead the failure will be delivered after the callbacks return. // Instead the failure will be delivered after the callbacks return.
extern mod rustrt { mod rustrt {
pub fn rust_dbg_call(cb: *u8, pub extern {
data: libc::uintptr_t) -> libc::uintptr_t; pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)
-> libc::uintptr_t;
}
} }
extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t { extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t {

View file

@ -17,8 +17,10 @@
extern mod std; extern mod std;
extern mod rustrt { mod rustrt {
pub fn rust_get_argc() -> libc::c_int; pub extern {
pub fn rust_get_argc() -> libc::c_int;
}
} }
fn getbig_call_c_and_fail(i: int) { fn getbig_call_c_and_fail(i: int) {

View file

@ -79,11 +79,13 @@ fn test_ptr() {
} }
} }
#[abi = "cdecl"] mod test {
#[nolink] #[abi = "cdecl"]
extern mod test { #[nolink]
pub fn rust_get_sched_id() -> libc::intptr_t; pub extern {
pub fn get_task_id() -> libc::intptr_t; pub fn rust_get_sched_id() -> libc::intptr_t;
pub fn get_task_id() -> libc::intptr_t;
}
} }
#[deriving_eq] #[deriving_eq]

View file

@ -8,9 +8,11 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#[abi = "cdecl"] mod rustrt {
extern mod rustrt { #[abi = "cdecl"]
pub fn get_task_id() -> libc::intptr_t; pub extern {
pub fn get_task_id() -> libc::intptr_t;
}
} }
pub fn main() { pub fn main() {

View file

@ -10,11 +10,13 @@
extern mod std; extern mod std;
#[abi = "cdecl"] mod libc {
#[nolink] #[abi = "cdecl"]
extern mod libc { #[nolink]
pub fn atol(x: *u8) -> int; pub extern {
pub fn atoll(x: *u8) -> i64; pub fn atol(x: *u8) -> int;
pub fn atoll(x: *u8) -> i64;
}
} }
fn atol(s: ~str) -> int { fn atol(s: ~str) -> int {

View file

@ -19,17 +19,19 @@ const b: bool = false;
const b: bool = true; const b: bool = true;
#[cfg(bogus)] mod rustrt {
#[abi = "cdecl"] #[cfg(bogus)]
extern mod rustrt { #[abi = "cdecl"]
// This symbol doesn't exist and would be a link error if this pub extern {
// module was translated // This symbol doesn't exist and would be a link error if this
pub fn bogus(); // module was translated
pub fn bogus();
}
#[abi = "cdecl"]
pub extern {}
} }
#[abi = "cdecl"]
extern mod rustrt {}
#[cfg(bogus)] #[cfg(bogus)]
type t = int; type t = int;
@ -106,11 +108,13 @@ fn test_in_fn_ctxt() {
} }
mod test_foreign_items { mod test_foreign_items {
#[abi = "cdecl"] pub mod rustrt {
pub extern mod rustrt { #[abi = "cdecl"]
#[cfg(bogus)] pub extern {
pub fn rust_getcwd() -> ~str; #[cfg(bogus)]
pub fn rust_getcwd() -> ~str; pub fn rust_getcwd() -> ~str;
pub fn rust_getcwd() -> ~str;
}
} }
} }
@ -118,9 +122,11 @@ mod test_use_statements {
#[cfg(bogus)] #[cfg(bogus)]
use flippity_foo; use flippity_foo;
pub extern mod rustrt { pub mod rustrt {
#[cfg(bogus)] pub extern {
use flippity_foo; #[cfg(bogus)]
use flippity_foo;
}
} }
} }

View file

@ -8,9 +8,11 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
extern mod rustrt { mod rustrt {
pub fn rust_dbg_call(cb: *u8, pub extern {
data: libc::uintptr_t) -> libc::uintptr_t; pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)
-> libc::uintptr_t;
}
} }
extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t { extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t {

View file

@ -8,9 +8,11 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
extern mod rustrt { mod rustrt {
pub fn rust_dbg_call(cb: *u8, pub extern {
data: libc::uintptr_t) -> libc::uintptr_t; pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)
-> libc::uintptr_t;
}
} }
extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t { extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t {

View file

@ -12,9 +12,11 @@
// make sure the stack pointers are maintained properly in both // make sure the stack pointers are maintained properly in both
// directions // directions
extern mod rustrt { mod rustrt {
pub fn rust_dbg_call(cb: *u8, pub extern {
data: libc::uintptr_t) -> libc::uintptr_t; pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)
-> libc::uintptr_t;
}
} }
extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t { extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t {

View file

@ -8,9 +8,11 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
extern mod rustrt { mod rustrt {
pub fn rust_dbg_call(cb: *u8, pub extern {
data: libc::uintptr_t) -> libc::uintptr_t; pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)
-> libc::uintptr_t;
}
} }
extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t { extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t {

View file

@ -11,9 +11,11 @@
// This creates a bunch of yielding tasks that run concurrently // This creates a bunch of yielding tasks that run concurrently
// while holding onto C stacks // while holding onto C stacks
extern mod rustrt { mod rustrt {
pub fn rust_dbg_call(cb: *u8, pub extern {
data: libc::uintptr_t) -> libc::uintptr_t; pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)
-> libc::uintptr_t;
}
} }
extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t { extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t {

View file

@ -8,9 +8,11 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
extern mod rustrt { mod rustrt {
pub fn rust_dbg_call(cb: *u8, pub extern {
data: libc::uintptr_t) -> libc::uintptr_t; pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)
-> libc::uintptr_t;
}
} }
extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t { extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t {

View file

@ -11,16 +11,20 @@
// xfail-fast - Somehow causes check-fast to livelock?? Probably because we're // xfail-fast - Somehow causes check-fast to livelock?? Probably because we're
// calling pin_task and that's having wierd side-effects. // calling pin_task and that's having wierd side-effects.
#[abi = "cdecl"] mod rustrt1 {
#[link_name = "rustrt"] #[abi = "cdecl"]
extern mod rustrt1 { #[link_name = "rustrt"]
pub fn rust_get_argc() -> libc::c_int; pub extern {
pub fn rust_get_argc() -> libc::c_int;
}
} }
#[abi = "cdecl"] mod rustrt2 {
#[link_name = "rustrt"] #[abi = "cdecl"]
extern mod rustrt2 { #[link_name = "rustrt"]
pub fn rust_get_argc() -> libc::c_int; pub extern {
pub fn rust_get_argc() -> libc::c_int;
}
} }
pub fn main() { pub fn main() {

View file

@ -10,12 +10,13 @@
extern mod std; extern mod std;
mod libc {
#[nolink] #[nolink]
#[abi = "cdecl"] #[abi = "cdecl"]
extern mod libc { pub extern {
#[link_name = "strlen"] #[link_name = "strlen"]
pub fn my_strlen(str: *u8) -> uint; pub fn my_strlen(str: *u8) -> uint;
}
} }
fn strlen(str: ~str) -> uint { fn strlen(str: ~str) -> uint {

View file

@ -12,11 +12,13 @@
// compile-flags:-L. // compile-flags:-L.
// The -L flag is also used for linking foreign libraries // The -L flag is also used for linking foreign libraries
// FIXME: I want to name a mod that would not link successfully mod WHATGOESHERE {
// wouthout providing a -L argument to the compiler, and that // FIXME: I want to name a mod that would not link successfully
// will also be found successfully at runtime. // wouthout providing a -L argument to the compiler, and that
extern mod WHATGOESHERE { // will also be found successfully at runtime.
pub fn IDONTKNOW() -> u32; pub extern {
pub fn IDONTKNOW() -> u32;
}
} }
pub fn main() { pub fn main() {

View file

@ -8,9 +8,11 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#[nolink] mod foo {
extern mod foo { #[nolink]
pub const errno: int; pub extern {
pub const errno: int;
}
} }
pub fn main() { pub fn main() {

View file

@ -10,8 +10,10 @@
// ABI is cdecl by default // ABI is cdecl by default
extern mod rustrt { mod rustrt {
pub fn get_task_id() -> libc::intptr_t; pub extern {
pub fn get_task_id() -> libc::intptr_t;
}
} }
pub fn main() { pub fn main() {

View file

@ -11,11 +11,15 @@
// xfail-win32 // xfail-win32
// Passing enums by value // Passing enums by value
enum void { } pub enum void { }
#[nolink] mod bindgen {
extern mod bindgen { use super::void;
pub fn printf(++v: void);
#[nolink]
pub extern {
pub fn printf(++v: void);
}
} }
pub fn main() { } pub fn main() { }

View file

@ -8,23 +8,31 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#[abi = "cdecl"] mod bar {
#[nolink] #[abi = "cdecl"]
extern mod bar {} #[nolink]
pub extern {}
#[abi = "cdecl"]
#[nolink]
extern mod zed {}
#[abi = "cdecl"]
#[nolink]
extern mod libc {
pub fn write(fd: int, buf: *u8,
count: ::core::libc::size_t) -> ::core::libc::ssize_t;
} }
#[abi = "cdecl"] mod zed {
#[nolink] #[abi = "cdecl"]
extern mod baz {} #[nolink]
pub extern {}
}
mod libc {
#[abi = "cdecl"]
#[nolink]
pub extern {
pub fn write(fd: int, buf: *u8, count: ::core::libc::size_t)
-> ::core::libc::ssize_t;
}
}
mod baz {
#[abi = "cdecl"]
#[nolink]
pub extern {}
}
pub fn main() { } pub fn main() { }

View file

@ -15,9 +15,11 @@ mod spam {
pub fn eggs() { } pub fn eggs() { }
} }
#[abi = "cdecl"] mod rustrt {
extern mod rustrt { #[abi = "cdecl"]
pub use spam::{ham, eggs}; pub extern {
pub use spam::{ham, eggs};
}
} }
pub fn main() { rustrt::ham(); rustrt::eggs(); } pub fn main() { rustrt::ham(); rustrt::eggs(); }

View file

@ -10,10 +10,12 @@
// xfail-fast Does not work with main in a submodule // xfail-fast Does not work with main in a submodule
#[abi = "rust-intrinsic"] mod rusti {
extern mod rusti { #[abi = "rust-intrinsic"]
pub fn pref_align_of<T>() -> uint; pub extern {
pub fn min_align_of<T>() -> uint; pub fn pref_align_of<T>() -> uint;
pub fn min_align_of<T>() -> uint;
}
} }
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]

View file

@ -8,23 +8,25 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#[abi = "rust-intrinsic"] mod rusti {
extern mod rusti { #[abi = "rust-intrinsic"]
pub fn atomic_cxchg(dst: &mut int, old: int, src: int) -> int; pub extern {
pub fn atomic_cxchg_acq(dst: &mut int, old: int, src: int) -> int; pub fn atomic_cxchg(dst: &mut int, old: int, src: int) -> int;
pub fn atomic_cxchg_rel(dst: &mut int, old: int, src: int) -> int; pub fn atomic_cxchg_acq(dst: &mut int, old: int, src: int) -> int;
pub fn atomic_cxchg_rel(dst: &mut int, old: int, src: int) -> int;
pub fn atomic_xchg(dst: &mut int, src: int) -> int; pub fn atomic_xchg(dst: &mut int, src: int) -> int;
pub fn atomic_xchg_acq(dst: &mut int, src: int) -> int; pub fn atomic_xchg_acq(dst: &mut int, src: int) -> int;
pub fn atomic_xchg_rel(dst: &mut int, src: int) -> int; pub fn atomic_xchg_rel(dst: &mut int, src: int) -> int;
pub fn atomic_xadd(dst: &mut int, src: int) -> int; pub fn atomic_xadd(dst: &mut int, src: int) -> int;
pub fn atomic_xadd_acq(dst: &mut int, src: int) -> int; pub fn atomic_xadd_acq(dst: &mut int, src: int) -> int;
pub fn atomic_xadd_rel(dst: &mut int, src: int) -> int; pub fn atomic_xadd_rel(dst: &mut int, src: int) -> int;
pub fn atomic_xsub(dst: &mut int, src: int) -> int; pub fn atomic_xsub(dst: &mut int, src: int) -> int;
pub fn atomic_xsub_acq(dst: &mut int, src: int) -> int; pub fn atomic_xsub_acq(dst: &mut int, src: int) -> int;
pub fn atomic_xsub_rel(dst: &mut int, src: int) -> int; pub fn atomic_xsub_rel(dst: &mut int, src: int) -> int;
}
} }
pub fn main() { pub fn main() {

View file

@ -10,9 +10,12 @@
// xfail-fast // xfail-fast
#[legacy_modes]; #[legacy_modes];
#[abi = "rust-intrinsic"]
extern mod rusti { mod rusti {
pub fn frame_address(f: &once fn(*u8)); #[abi = "rust-intrinsic"]
pub extern {
pub fn frame_address(f: &once fn(*u8));
}
} }
pub fn main() { pub fn main() {

View file

@ -8,10 +8,12 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#[abi = "rust-intrinsic"] mod rusti {
extern mod rusti { #[abi = "rust-intrinsic"]
pub fn move_val_init<T>(dst: &mut T, -src: T); pub extern {
pub fn move_val<T>(dst: &mut T, -src: T); pub fn move_val_init<T>(dst: &mut T, -src: T);
pub fn move_val<T>(dst: &mut T, -src: T);
}
} }
pub fn main() { pub fn main() {

View file

@ -12,26 +12,28 @@
extern mod std; extern mod std;
#[abi = "rust-intrinsic"] mod rusti {
extern mod rusti { #[abi = "rust-intrinsic"]
fn ctpop8(x: i8) -> i8; pub extern {
fn ctpop16(x: i16) -> i16; fn ctpop8(x: i8) -> i8;
fn ctpop32(x: i32) -> i32; fn ctpop16(x: i16) -> i16;
fn ctpop64(x: i64) -> i64; fn ctpop32(x: i32) -> i32;
fn ctpop64(x: i64) -> i64;
fn ctlz8(x: i8) -> i8; fn ctlz8(x: i8) -> i8;
fn ctlz16(x: i16) -> i16; fn ctlz16(x: i16) -> i16;
fn ctlz32(x: i32) -> i32; fn ctlz32(x: i32) -> i32;
fn ctlz64(x: i64) -> i64; fn ctlz64(x: i64) -> i64;
fn cttz8(x: i8) -> i8; fn cttz8(x: i8) -> i8;
fn cttz16(x: i16) -> i16; fn cttz16(x: i16) -> i16;
fn cttz32(x: i32) -> i32; fn cttz32(x: i32) -> i32;
fn cttz64(x: i64) -> i64; fn cttz64(x: i64) -> i64;
fn bswap16(x: i16) -> i16; fn bswap16(x: i16) -> i16;
fn bswap32(x: i32) -> i32; fn bswap32(x: i32) -> i32;
fn bswap64(x: i64) -> i64; fn bswap64(x: i64) -> i64;
}
} }
pub fn main() { pub fn main() {

View file

@ -14,38 +14,40 @@ extern mod std;
use std::cmp::FuzzyEq; use std::cmp::FuzzyEq;
#[abi = "rust-intrinsic"] mod rusti {
extern mod rusti { #[abi = "rust-intrinsic"]
fn sqrtf32(x: f32) -> f32; pub extern {
fn sqrtf64(x: f64) -> f64; fn sqrtf32(x: f32) -> f32;
fn powif32(a: f32, x: i32) -> f32; fn sqrtf64(x: f64) -> f64;
fn powif64(a: f64, x: i32) -> f64; fn powif32(a: f32, x: i32) -> f32;
fn sinf32(x: f32) -> f32; fn powif64(a: f64, x: i32) -> f64;
fn sinf64(x: f64) -> f64; fn sinf32(x: f32) -> f32;
fn cosf32(x: f32) -> f32; fn sinf64(x: f64) -> f64;
fn cosf64(x: f64) -> f64; fn cosf32(x: f32) -> f32;
fn powf32(a: f32, x: f32) -> f32; fn cosf64(x: f64) -> f64;
fn powf64(a: f64, x: f64) -> f64; fn powf32(a: f32, x: f32) -> f32;
fn expf32(x: f32) -> f32; fn powf64(a: f64, x: f64) -> f64;
fn expf64(x: f64) -> f64; fn expf32(x: f32) -> f32;
fn exp2f32(x: f32) -> f32; fn expf64(x: f64) -> f64;
fn exp2f64(x: f64) -> f64; fn exp2f32(x: f32) -> f32;
fn logf32(x: f32) -> f32; fn exp2f64(x: f64) -> f64;
fn logf64(x: f64) -> f64; fn logf32(x: f32) -> f32;
fn log10f32(x: f32) -> f32; fn logf64(x: f64) -> f64;
fn log10f64(x: f64) -> f64; fn log10f32(x: f32) -> f32;
fn log2f32(x: f32) -> f32; fn log10f64(x: f64) -> f64;
fn log2f64(x: f64) -> f64; fn log2f32(x: f32) -> f32;
fn fmaf32(a: f32, b: f32, c: f32) -> f32; fn log2f64(x: f64) -> f64;
fn fmaf64(a: f64, b: f64, c: f64) -> f64; fn fmaf32(a: f32, b: f32, c: f32) -> f32;
fn fabsf32(x: f32) -> f32; fn fmaf64(a: f64, b: f64, c: f64) -> f64;
fn fabsf64(x: f64) -> f64; fn fabsf32(x: f32) -> f32;
fn floorf32(x: f32) -> f32; fn fabsf64(x: f64) -> f64;
fn floorf64(x: f64) -> f64; fn floorf32(x: f32) -> f32;
fn ceilf32(x: f32) -> f32; fn floorf64(x: f64) -> f64;
fn ceilf64(x: f64) -> f64; fn ceilf32(x: f32) -> f32;
fn truncf32(x: f32) -> f32; fn ceilf64(x: f64) -> f64;
fn truncf64(x: f64) -> f64; fn truncf32(x: f32) -> f32;
fn truncf64(x: f64) -> f64;
}
} }
pub fn main() { pub fn main() {

View file

@ -10,8 +10,10 @@
#[link(name = "get_task_id")]; #[link(name = "get_task_id")];
extern mod rustrt { mod rustrt {
pub fn get_task_id() -> libc::intptr_t; pub extern {
pub fn get_task_id() -> libc::intptr_t;
}
} }
pub fn main() { } pub fn main() { }

View file

@ -11,15 +11,19 @@
// xfail-test // xfail-test
mod a { mod a {
pub type rust_task = uint; pub type rust_task = uint;
pub extern mod rustrt { pub mod rustrt {
pub fn rust_task_is_unwinding(rt: *rust_task) -> bool; pub extern {
pub fn rust_task_is_unwinding(rt: *rust_task) -> bool;
}
} }
} }
mod b { mod b {
pub type rust_task = bool; pub type rust_task = bool;
pub extern mod rustrt { pub mod rustrt {
pub fn rust_task_is_unwinding(rt: *rust_task) -> bool; pub extern {
pub fn rust_task_is_unwinding(rt: *rust_task) -> bool;
}
} }
} }

View file

@ -26,16 +26,19 @@ fn lgamma(n: c_double, value: &mut int) -> c_double {
} }
} }
#[link_name = "m"] mod m {
#[abi = "cdecl"] use core::libc::{c_double, c_int};
extern mod m {
#[cfg(unix)]
#[link_name="lgamma_r"] pub fn lgamma(n: c_double, sign: &mut c_int)
-> c_double;
#[cfg(windows)]
#[link_name="__lgamma_r"] pub fn lgamma(n: c_double,
sign: &mut c_int) -> c_double;
#[link_name = "m"]
#[abi = "cdecl"]
pub extern {
#[cfg(unix)]
#[link_name="lgamma_r"]
pub fn lgamma(n: c_double, sign: &mut c_int) -> c_double;
#[cfg(windows)]
#[link_name="__lgamma_r"]
pub fn lgamma(n: c_double, sign: &mut c_int) -> c_double;
}
} }
pub fn main() { pub fn main() {

View file

@ -37,9 +37,11 @@ mod test_single_attr_outer {
#[attr = "val"] #[attr = "val"]
pub mod mod1 {} pub mod mod1 {}
#[attr = "val"] pub mod rustrt {
#[abi = "cdecl"] #[attr = "val"]
pub extern mod rustrt {} #[abi = "cdecl"]
pub extern {}
}
} }
mod test_multi_attr_outer { mod test_multi_attr_outer {
@ -55,10 +57,12 @@ mod test_multi_attr_outer {
#[attr2 = "val"] #[attr2 = "val"]
pub mod mod1 {} pub mod mod1 {}
#[attr1 = "val"] pub mod rustrt {
#[attr2 = "val"] #[attr1 = "val"]
#[abi = "cdecl"] #[attr2 = "val"]
pub extern mod rustrt {} #[abi = "cdecl"]
pub extern {}
}
#[attr1 = "val"] #[attr1 = "val"]
#[attr2 = "val"] #[attr2 = "val"]
@ -77,9 +81,11 @@ mod test_stmt_single_attr_outer {
mod mod1 { mod mod1 {
} }
#[attr = "val"] mod rustrt {
#[abi = "cdecl"] #[attr = "val"]
extern mod rustrt { #[abi = "cdecl"]
pub extern {
}
} }
} }
} }
@ -101,10 +107,12 @@ mod test_stmt_multi_attr_outer {
mod mod1 { mod mod1 {
} }
#[attr1 = "val"] pub mod rustrt {
#[attr2 = "val"] #[attr1 = "val"]
#[abi = "cdecl"] #[attr2 = "val"]
extern mod rustrt { #[abi = "cdecl"]
pub extern {
}
} }
*/ */
} }
@ -158,12 +166,14 @@ mod test_other_forms {
} }
mod test_foreign_items { mod test_foreign_items {
#[abi = "cdecl"] pub mod rustrt {
pub extern mod rustrt { #[abi = "cdecl"]
#[attr]; pub extern {
#[attr];
#[attr] #[attr]
fn get_task_id() -> libc::intptr_t; fn get_task_id() -> libc::intptr_t;
}
} }
} }

View file

@ -8,10 +8,12 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#[nolink] mod rusti {
#[abi = "rust-intrinsic"] #[nolink]
extern mod rusti { #[abi = "rust-intrinsic"]
pub fn morestack_addr() -> *(); pub extern {
pub fn morestack_addr() -> *();
}
} }
pub fn main() { pub fn main() {

View file

@ -11,15 +11,17 @@
// This test attempts to force the dynamic linker to resolve // This test attempts to force the dynamic linker to resolve
// external symbols as close to the red zone as possible. // external symbols as close to the red zone as possible.
extern mod rustrt { mod rustrt {
pub fn debug_get_stk_seg() -> *u8; pub extern {
pub fn debug_get_stk_seg() -> *u8;
pub fn rust_get_sched_id() -> libc::intptr_t; pub fn rust_get_sched_id() -> libc::intptr_t;
pub fn rust_get_argc() -> libc::c_int; pub fn rust_get_argc() -> libc::c_int;
pub fn rust_getcwd() -> ~str; pub fn rust_getcwd() -> ~str;
pub fn get_task_id() -> libc::intptr_t; pub fn get_task_id() -> libc::intptr_t;
pub fn rust_sched_threads(); pub fn rust_sched_threads();
pub fn rust_get_task(); pub fn rust_get_task();
}
} }
fn calllink01() { unsafe { rustrt::rust_get_sched_id(); } } fn calllink01() { unsafe { rustrt::rust_get_sched_id(); } }

View file

@ -9,8 +9,11 @@
// except according to those terms. // except according to those terms.
// Issue #901 // Issue #901
#[nolink] mod libc {
extern mod libc { #[nolink]
pub fn printf(x: ()); pub extern {
pub fn printf(x: ());
}
} }
pub fn main() { } pub fn main() { }

View file

@ -10,10 +10,12 @@
// Issue #2303 // Issue #2303
#[abi = "rust-intrinsic"] mod rusti {
extern mod rusti { #[abi = "rust-intrinsic"]
pub fn pref_align_of<T>() -> uint; pub extern {
pub fn min_align_of<T>() -> uint; pub fn pref_align_of<T>() -> uint;
pub fn min_align_of<T>() -> uint;
}
} }
// This is the type with the questionable alignment // This is the type with the questionable alignment

View file

@ -10,10 +10,12 @@
// Issue #2303 // Issue #2303
#[abi = "rust-intrinsic"] mod rusti {
extern mod rusti { #[abi = "rust-intrinsic"]
pub fn pref_align_of<T>() -> uint; pub extern {
pub fn min_align_of<T>() -> uint; pub fn pref_align_of<T>() -> uint;
pub fn min_align_of<T>() -> uint;
}
} }
// This is the type with the questionable alignment // This is the type with the questionable alignment

View file

@ -12,17 +12,21 @@
use core::comm::*; use core::comm::*;
type sched_id = int; pub type sched_id = int;
type task_id = *libc::c_void; pub type task_id = *libc::c_void;
type task = *libc::c_void; pub type task = *libc::c_void;
type closure = *libc::c_void; pub type closure = *libc::c_void;
extern mod rustrt { mod rustrt {
pub fn rust_new_sched(num_threads: libc::uintptr_t) -> sched_id; use super::{closure, sched_id, task, task_id};
pub fn rust_get_sched_id() -> sched_id;
pub fn rust_new_task_in_sched(id: sched_id) -> task_id; pub extern {
pub fn start_task(id: task_id, f: closure); pub fn rust_new_sched(num_threads: libc::uintptr_t) -> sched_id;
pub fn rust_get_sched_id() -> sched_id;
pub fn rust_new_task_in_sched(id: sched_id) -> task_id;
pub fn start_task(id: task_id, f: closure);
}
} }
pub fn main() { pub fn main() {

View file

@ -8,13 +8,17 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
struct Quad { a: u64, b: u64, c: u64, d: u64 } pub struct Quad { a: u64, b: u64, c: u64, d: u64 }
struct Floats { a: f64, b: u8, c: f64 } pub struct Floats { a: f64, b: u8, c: f64 }
#[nolink] mod rustrt {
extern mod rustrt { use super::{Floats, Quad};
pub fn debug_abi_1(++q: Quad) -> Quad;
pub fn debug_abi_2(++f: Floats) -> Floats; #[nolink]
pub extern {
pub fn debug_abi_1(++q: Quad) -> Quad;
pub fn debug_abi_2(++f: Floats) -> Floats;
}
} }
fn test1() { fn test1() {

View file

@ -12,9 +12,11 @@
#[allow(ctypes)]; #[allow(ctypes)];
#[nolink] mod libc {
extern mod libc { #[nolink]
pub fn malloc(size: int) -> *u8; pub extern {
pub fn malloc(size: int) -> *u8;
}
} }
pub fn main() { pub fn main() {

View file

@ -14,13 +14,15 @@ type SIZE_T = u32;
type LPVOID = uint; type LPVOID = uint;
type BOOL = u8; type BOOL = u8;
#[cfg(target_os = "win32")] mod kernel32 {
#[abi = "stdcall"] #[cfg(target_os = "win32")]
extern mod kernel32 { #[abi = "stdcall"]
pub fn GetProcessHeap() -> HANDLE; pub extern {
pub fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T) pub fn GetProcessHeap() -> HANDLE;
-> LPVOID; pub fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T)
pub fn HeapFree(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID) -> BOOL; -> LPVOID;
pub fn HeapFree(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID) -> BOOL;
}
} }