diff --git a/src/comp/front/config.rs b/src/comp/front/config.rs index f0eceb093b3b..26ca6850e8af 100644 --- a/src/comp/front/config.rs +++ b/src/comp/front/config.rs @@ -45,8 +45,7 @@ fn fold_native_mod(cfg: ast::crate_cfg, nm: ast::native_mod, fld: fold::ast_fold) -> ast::native_mod { let filter = bind filter_native_item(cfg, _); let filtered_items = vec::filter_map(filter, nm.items); - ret {native_name: nm.native_name, - abi: nm.abi, + ret {abi: nm.abi, view_items: vec::map(fld.fold_view_item, nm.view_items), items: filtered_items}; } diff --git a/src/comp/lib/llvm.rs b/src/comp/lib/llvm.rs index 83edf143f335..68ba8624268c 100644 --- a/src/comp/lib/llvm.rs +++ b/src/comp/lib/llvm.rs @@ -110,7 +110,9 @@ const LLVMRealULE: uint = 13u; const LLVMRealUNE: uint = 14u; #[link_args = "-Lrustllvm"] -native "cdecl" mod llvm = "rustllvm" { +#[link_name = "rustllvm"] +#[abi = "cdecl"] +native mod llvm { type ModuleRef; type ContextRef; diff --git a/src/comp/metadata/creader.rs b/src/comp/metadata/creader.rs index 95929b3449c8..f4abe903e13b 100644 --- a/src/comp/metadata/creader.rs +++ b/src/comp/metadata/creader.rs @@ -54,7 +54,12 @@ fn visit_item(e: env, i: @ast::item) { ret; } let cstore = e.sess.get_cstore(); - if !cstore::add_used_library(cstore, m.native_name) { ret; } + let native_name = i.ident; + alt attr::get_meta_item_value_str_by_name(i.attrs, "link_name") { + some(nn) { native_name = nn; } + none. { } + } + if !cstore::add_used_library(cstore, native_name) { ret; } for a: ast::attribute in attr::find_attrs_by_name(i.attrs, "link_args") { diff --git a/src/comp/syntax/ast.rs b/src/comp/syntax/ast.rs index 16d0d0d53c89..b2117810c6db 100644 --- a/src/comp/syntax/ast.rs +++ b/src/comp/syntax/ast.rs @@ -432,7 +432,7 @@ tag native_abi { } type native_mod = - {native_name: str, + {// FIXME: Removing abi from AST. Depends on Issue #1179. abi: native_abi, view_items: [@view_item], items: [@native_item]}; diff --git a/src/comp/syntax/fold.rs b/src/comp/syntax/fold.rs index 56e6aecbab1f..f9b6d5739c8f 100644 --- a/src/comp/syntax/fold.rs +++ b/src/comp/syntax/fold.rs @@ -452,8 +452,7 @@ fn noop_fold_mod(m: _mod, fld: ast_fold) -> _mod { } fn noop_fold_native_mod(nm: native_mod, fld: ast_fold) -> native_mod { - ret {native_name: nm.native_name, - abi: nm.abi, + ret {abi: nm.abi, view_items: vec::map(fld.fold_view_item, nm.view_items), items: vec::map(fld.fold_native_item, nm.items)} } diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index 580822d9f1d8..05f508edfd00 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -1978,7 +1978,7 @@ fn parse_native_item(p: parser, attrs: [ast::attribute]) -> } else { unexpected(p, p.peek()); } } -fn parse_native_mod_items(p: parser, native_name: str, abi: ast::native_abi, +fn parse_native_mod_items(p: parser, abi: ast::native_abi, first_item_attrs: [ast::attribute]) -> ast::native_mod { // Shouldn't be any view items since we've already parsed an item attr @@ -1993,63 +1993,37 @@ fn parse_native_mod_items(p: parser, native_name: str, abi: ast::native_abi, initial_attrs = []; items += [parse_native_item(p, attrs)]; } - ret {native_name: native_name, - abi: abi, + ret {abi: abi, view_items: view_items, items: items}; } fn parse_item_native_mod(p: parser, attrs: [ast::attribute]) -> @ast::item { let lo = p.get_last_lo_pos(); - let abi = ast::native_abi_cdecl; - if !is_word(p, "mod") { - let t = parse_str(p); - if str::eq(t, "rust-intrinsic") { - abi = ast::native_abi_rust_intrinsic; - } else if str::eq(t, "cdecl") { - abi = ast::native_abi_cdecl; - } else if str::eq(t, "stdcall") { - abi = ast::native_abi_stdcall; - } else { - p.fatal("unsupported abi: " + t); - } - } else { - abi = - alt attr::get_meta_item_value_str_by_name(attrs, "abi") { - none. { ast::native_abi_cdecl } - some("rust-intrinsic") { - ast::native_abi_rust_intrinsic - } - some("cdecl") { - ast::native_abi_cdecl - } - some("stdcall") { - ast::native_abi_stdcall - } - some(t) { - p.fatal("unsupported abi: " + t); - } - }; - } expect_word(p, "mod"); let id = parse_ident(p); - let native_name; - if p.peek() == token::EQ { - expect(p, token::EQ); - native_name = parse_str(p); - } else { - native_name = - alt attr::get_meta_item_value_str_by_name(attrs, "link_name") { - none. { id } - some(nn) { nn } - }; - } expect(p, token::LBRACE); let more_attrs = parse_inner_attrs_and_next(p); let inner_attrs = more_attrs.inner; let first_item_outer_attrs = more_attrs.next; - let m = - parse_native_mod_items(p, native_name, abi, first_item_outer_attrs); + let abi = + alt attr::get_meta_item_value_str_by_name( + attrs + inner_attrs, "abi") { + none. { ast::native_abi_cdecl } + some("rust-intrinsic") { + ast::native_abi_rust_intrinsic + } + some("cdecl") { + ast::native_abi_cdecl + } + some("stdcall") { + ast::native_abi_stdcall + } + some(t) { + p.fatal("unsupported abi: " + t); + } + }; + let m = parse_native_mod_items(p, abi, first_item_outer_attrs); let hi = p.get_hi_pos(); expect(p, token::RBRACE); ret mk_item(p, lo, hi, id, ast::item_native_mod(m), attrs + inner_attrs); diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs index 21cfaa9e072f..93a4293a5d15 100644 --- a/src/comp/syntax/print/pprust.rs +++ b/src/comp/syntax/print/pprust.rs @@ -395,24 +395,8 @@ fn print_item(s: ps, &&item: @ast::item) { } ast::item_native_mod(nmod) { head(s, "native"); - alt nmod.abi { - ast::native_abi_rust_intrinsic. { - word_nbsp(s, "\"rust-intrinsic\""); - } - ast::native_abi_cdecl. { - word_nbsp(s, "\"cdecl\""); - } - ast::native_abi_stdcall. { - word_nbsp(s, "\"stdcall\""); - } - } word_nbsp(s, "mod"); word_nbsp(s, item.ident); - if !str::eq(nmod.native_name, item.ident) { - word_space(s, "="); - print_string(s, nmod.native_name); - nbsp(s); - } bopen(s); print_native_mod(s, nmod, item.attrs); bclose(s, item.span); diff --git a/src/lib/comm.rs b/src/lib/comm.rs index 4aca724a01c3..a01db908821c 100644 --- a/src/lib/comm.rs +++ b/src/lib/comm.rs @@ -34,7 +34,8 @@ export recv; export chan; export port; -native "cdecl" mod rustrt { +#[abi = "cdecl"] +native mod rustrt { type void; type rust_port; @@ -48,7 +49,8 @@ native "cdecl" mod rustrt { fn rust_port_size(po: *rust_port) -> ctypes::size_t; } -native "rust-intrinsic" mod rusti { +#[abi = "rust-intrinsic"] +native mod rusti { fn recv(port: *rustrt::rust_port) -> T; } diff --git a/src/lib/dbg.rs b/src/lib/dbg.rs index 470341308f2f..a6c039d581a8 100644 --- a/src/lib/dbg.rs +++ b/src/lib/dbg.rs @@ -8,7 +8,8 @@ * logging. */ -native "cdecl" mod rustrt { +#[abi = "cdecl"] +native mod rustrt { fn debug_tydesc(td: *sys::type_desc); fn debug_opaque(td: *sys::type_desc, x: T); fn debug_box(td: *sys::type_desc, x: @T); diff --git a/src/lib/fs.rs b/src/lib/fs.rs index 7c8c3ef11285..d5885a3baec1 100644 --- a/src/lib/fs.rs +++ b/src/lib/fs.rs @@ -7,7 +7,8 @@ File system manipulation import os::getcwd; import os_fs; -native "cdecl" mod rustrt { +#[abi = "cdecl"] +native mod rustrt { fn rust_file_is_dir(path: str::sbuf) -> int; } diff --git a/src/lib/io.rs b/src/lib/io.rs index afba61423775..78a5384db137 100644 --- a/src/lib/io.rs +++ b/src/lib/io.rs @@ -1,5 +1,6 @@ -native "cdecl" mod rustrt { +#[abi = "cdecl"] +native mod rustrt { fn rust_get_stdin() -> os::libc::FILE; fn rust_get_stdout() -> os::libc::FILE; fn rust_get_stderr() -> os::libc::FILE; diff --git a/src/lib/linux_os.rs b/src/lib/linux_os.rs index 7a0e09769607..c8c4aeed84d2 100644 --- a/src/lib/linux_os.rs +++ b/src/lib/linux_os.rs @@ -6,7 +6,9 @@ TODO: Restructure and document // FIXME Somehow merge stuff duplicated here and macosx_os.rs. Made difficult // by https://github.com/graydon/rust/issues#issue/268 -native "cdecl" mod libc = "" { +#[link_name = ""] +#[abi = "cdecl"] +native mod libc { fn read(fd: int, buf: *u8, count: uint) -> int; fn write(fd: int, buf: *u8, count: uint) -> int; fn fread(buf: *u8, size: uint, n: uint, f: libc::FILE) -> uint; @@ -81,7 +83,8 @@ fn waitpid(pid: int) -> int { ret status; } -native "cdecl" mod rustrt { +#[abi = "cdecl"] +native mod rustrt { fn rust_getcwd() -> str; } diff --git a/src/lib/macos_os.rs b/src/lib/macos_os.rs index 9bc1fab3c0e7..db93ac649fb8 100644 --- a/src/lib/macos_os.rs +++ b/src/lib/macos_os.rs @@ -1,5 +1,7 @@ -native "cdecl" mod libc = "" { +#[link_name = ""] +#[abi = "cdecl"] +native mod libc { fn read(fd: int, buf: *u8, count: uint) -> int; fn write(fd: int, buf: *u8, count: uint) -> int; fn fread(buf: *u8, size: uint, n: uint, f: libc::FILE) -> uint; @@ -74,7 +76,8 @@ fn waitpid(pid: int) -> int { ret status; } -native "cdecl" mod rustrt { +#[abi = "cdecl"] +native mod rustrt { fn rust_getcwd() -> str; } diff --git a/src/lib/math.rs b/src/lib/math.rs index fe33b133a86c..6c6a30a0b8ef 100644 --- a/src/lib/math.rs +++ b/src/lib/math.rs @@ -1,6 +1,8 @@ /* Module: math */ -native "cdecl" mod libc = "" { +#[link_name = ""] +#[abi = "cdecl"] +native mod libc { fn sqrt(n: float) -> float; fn sin(n: float) -> float; fn asin(n: float) -> float; diff --git a/src/lib/posix_fs.rs b/src/lib/posix_fs.rs index 0966b96d9241..fe8dbb4d4f13 100644 --- a/src/lib/posix_fs.rs +++ b/src/lib/posix_fs.rs @@ -1,4 +1,5 @@ -native "cdecl" mod rustrt { +#[abi = "cdecl"] +native mod rustrt { fn rust_list_files(path: str) -> [str]; } diff --git a/src/lib/ptr.rs b/src/lib/ptr.rs index df30105b11d5..1654f9188a08 100644 --- a/src/lib/ptr.rs +++ b/src/lib/ptr.rs @@ -3,7 +3,8 @@ Module: ptr Unsafe pointer utility functions */ -native "rust-intrinsic" mod rusti { +#[abi = "rust-intrinsic"] +native mod rusti { fn addr_of(val: T) -> *T; fn ptr_offset(ptr: *T, count: uint) -> *T; } diff --git a/src/lib/rand.rs b/src/lib/rand.rs index 777fdb027bfa..ae610ae86084 100644 --- a/src/lib/rand.rs +++ b/src/lib/rand.rs @@ -3,7 +3,8 @@ Module: rand Random number generation */ -native "cdecl" mod rustrt { +#[abi = "cdecl"] +native mod rustrt { type rctx; fn rand_new() -> rctx; fn rand_next(c: rctx) -> u32; diff --git a/src/lib/run_program.rs b/src/lib/run_program.rs index f8f84fa40e53..915e6c0f3253 100644 --- a/src/lib/run_program.rs +++ b/src/lib/run_program.rs @@ -12,7 +12,8 @@ export program_output; export spawn_process; export waitpid; -native "cdecl" mod rustrt { +#[abi = "cdecl"] +native mod rustrt { fn rust_run_program(argv: *sbuf, in_fd: int, out_fd: int, err_fd: int) -> int; } diff --git a/src/lib/str.rs b/src/lib/str.rs index 2d76aa0017dd..4184e8b2050e 100644 --- a/src/lib/str.rs +++ b/src/lib/str.rs @@ -16,7 +16,8 @@ export eq, lteq, hash, is_empty, is_not_empty, is_whitespace, byte_len, contains, iter_chars, loop_chars, loop_chars_sub, escape; -native "cdecl" mod rustrt { +#[abi = "cdecl"] +native mod rustrt { fn rust_str_push(&s: str, ch: u8); } diff --git a/src/lib/sys.rs b/src/lib/sys.rs index e7d04c4bcf44..3ebfae525345 100644 --- a/src/lib/sys.rs +++ b/src/lib/sys.rs @@ -7,7 +7,8 @@ tag type_desc { type_desc(@type_desc); } -native "cdecl" mod rustrt { +#[abi = "cdecl"] +native mod rustrt { // Explicitly re-export native stuff we want to be made // available outside this crate. Otherwise it's // visible-in-crate, but not re-exported. @@ -19,7 +20,8 @@ native "cdecl" mod rustrt { fn unsupervise(); } -native "rust-intrinsic" mod rusti { +#[abi = "rust-intrinsic"] +native mod rusti { fn get_type_desc() -> *type_desc; } diff --git a/src/lib/task.rs b/src/lib/task.rs index 3dd475765620..72a73763427c 100644 --- a/src/lib/task.rs +++ b/src/lib/task.rs @@ -50,12 +50,15 @@ export spawn; export spawn_notify; export spawn_joinable; -native "rust-intrinsic" mod rusti { +#[abi = "rust-intrinsic"] +native mod rusti { // these must run on the Rust stack so that they can swap stacks etc: fn task_sleep(time_in_us: uint); } -native "cdecl" mod rustrt = "rustrt" { +#[link_name = "rustrt"] +#[abi = "cdecl"] +native mod rustrt { // these can run on the C stack: fn pin_task(); fn unpin_task(); diff --git a/src/lib/test.rs b/src/lib/test.rs index daa86bb8b40c..db34b391f2ff 100644 --- a/src/lib/test.rs +++ b/src/lib/test.rs @@ -25,7 +25,8 @@ export default_test_to_task; export configure_test_task; export joinable; -native "cdecl" mod rustrt { +#[abi = "cdecl"] +native mod rustrt { fn sched_threads() -> uint; } diff --git a/src/lib/time.rs b/src/lib/time.rs index 39ce8c59b681..2865666fdc83 100644 --- a/src/lib/time.rs +++ b/src/lib/time.rs @@ -4,7 +4,8 @@ Module: time // FIXME: Document what these functions do -native "cdecl" mod rustrt { +#[abi = "cdecl"] +native mod rustrt { fn get_time(&sec: u32, &usec: u32); fn nano_time(&ns: u64); } diff --git a/src/lib/unicode.rs b/src/lib/unicode.rs index 3f4452ed7cc5..5038721d26e5 100644 --- a/src/lib/unicode.rs +++ b/src/lib/unicode.rs @@ -148,7 +148,9 @@ mod icu { // FIXME: should be -1, change when compiler supports negative // constants - native "cdecl" mod libicu = "icuuc" { + #[link_name = "icuuc"] + #[abi = "cdecl"] + native mod libicu { fn u_hasBinaryProperty(c: UChar32, which: UProperty) -> UBool; } } diff --git a/src/lib/unsafe.rs b/src/lib/unsafe.rs index 6db33a4aba2f..0162c10ea22b 100644 --- a/src/lib/unsafe.rs +++ b/src/lib/unsafe.rs @@ -4,11 +4,13 @@ Module: unsafe Unsafe operations */ -native "rust-intrinsic" mod rusti { +#[abi = "rust-intrinsic"] +native mod rusti { fn cast(src: T) -> U; } -native "cdecl" mod rustrt { +#[abi = "cdecl"] +native mod rustrt { fn leak(-thing: T); } diff --git a/src/lib/vec.rs b/src/lib/vec.rs index 5fc890b53593..3d51560741b2 100644 --- a/src/lib/vec.rs +++ b/src/lib/vec.rs @@ -6,11 +6,13 @@ import option::{some, none}; import uint::next_power_of_two; import ptr::addr_of; -native "rust-intrinsic" mod rusti { +#[abi = "rust-intrinsic"] +native mod rusti { fn vec_len(&&v: [mutable? T]) -> uint; } -native "cdecl" mod rustrt { +#[abi = "cdecl"] +native mod rustrt { fn vec_reserve_shared(t: *sys::type_desc, &v: [mutable? T], n: uint); diff --git a/src/lib/win32_fs.rs b/src/lib/win32_fs.rs index 12a33cdeeedb..6960b836ca4f 100644 --- a/src/lib/win32_fs.rs +++ b/src/lib/win32_fs.rs @@ -1,6 +1,7 @@ -native "cdecl" mod rustrt { +#[abi = "cdecl"] +native mod rustrt { fn rust_list_files(path: str) -> [str]; } diff --git a/src/lib/win32_os.rs b/src/lib/win32_os.rs index 006dd17fa23e..c7c5f323b11d 100644 --- a/src/lib/win32_os.rs +++ b/src/lib/win32_os.rs @@ -1,5 +1,7 @@ -native "cdecl" mod libc = "" { +#[abi = "cdecl"] +#[link_name = ""] +native mod libc { fn read(fd: int, buf: *u8, count: uint) -> int; fn write(fd: int, buf: *u8, count: uint) -> int; fn fread(buf: *u8, size: uint, n: uint, f: libc::FILE) -> uint; @@ -39,7 +41,8 @@ type DWORD = u32; type HMODULE = uint; type LPTSTR = str::sbuf; -native "stdcall" mod kernel32 { +#[abi = "stdcall"] +native mod kernel32 { fn GetEnvironmentVariableA(n: str::sbuf, v: str::sbuf, nsize: uint) -> uint; fn SetEnvironmentVariableA(n: str::sbuf, v: str::sbuf) -> int; @@ -83,7 +86,8 @@ fn fclose(file: libc::FILE) { libc::fclose(file) } -native "cdecl" mod rustrt { +#[abi = "cdecl"] +native mod rustrt { fn rust_process_wait(handle: int) -> int; fn rust_getcwd() -> str; } diff --git a/src/test/bench/shootout-nbody.rs b/src/test/bench/shootout-nbody.rs index 72f127976fff..a560e6e1d7a9 100644 --- a/src/test/bench/shootout-nbody.rs +++ b/src/test/bench/shootout-nbody.rs @@ -1,7 +1,9 @@ // based on: // http://shootout.alioth.debian.org/u32/benchmark.php?test=nbody&lang=java -native "cdecl" mod llvm = "" { +#[abi = "cdecl"] +#[link_name = ""] +native mod llvm { fn sqrt(n: float) -> float; } diff --git a/src/test/compile-fail/native-unsafe-fn-called.rs b/src/test/compile-fail/native-unsafe-fn-called.rs index 6e9d7ac18fcc..6459a423611b 100644 --- a/src/test/compile-fail/native-unsafe-fn-called.rs +++ b/src/test/compile-fail/native-unsafe-fn-called.rs @@ -1,6 +1,7 @@ // -*- rust -*- // error-pattern: safe function calls function marked unsafe -native "cdecl" mod test { +#[abi = "cdecl"] +native mod test { unsafe fn free(); } diff --git a/src/test/compile-fail/native-unsafe-fn.rs b/src/test/compile-fail/native-unsafe-fn.rs index 2a2ce4b3246e..3d2c0e1f02b0 100644 --- a/src/test/compile-fail/native-unsafe-fn.rs +++ b/src/test/compile-fail/native-unsafe-fn.rs @@ -1,7 +1,8 @@ // -*- rust -*- // error-pattern: unsafe functions can only be called -native "cdecl" mod test { +#[abi = "cdecl"] +native mod test { unsafe fn free(); } diff --git a/src/test/run-pass/bind-native.rs b/src/test/run-pass/bind-native.rs index ecd63a91eebe..dddbf575d807 100644 --- a/src/test/run-pass/bind-native.rs +++ b/src/test/run-pass/bind-native.rs @@ -2,7 +2,8 @@ Can we bind native things? */ -native "cdecl" mod rustrt { +#[abi = "cdecl"] +native mod rustrt { fn pin_task(); } diff --git a/src/test/run-pass/binops.rs b/src/test/run-pass/binops.rs index 2d421947eef2..c627d28e52bc 100644 --- a/src/test/run-pass/binops.rs +++ b/src/test/run-pass/binops.rs @@ -117,7 +117,9 @@ fn test_fn() { assert (h1 >= h2); } -native "cdecl" mod native_mod = "" { +#[abi = "cdecl"] +#[link_name = ""] +native mod test { fn do_gc(); fn unsupervise(); } diff --git a/src/test/run-pass/c-stack-as-value.rs b/src/test/run-pass/c-stack-as-value.rs index 2a13e6d35638..d06a6d1b5ea9 100644 --- a/src/test/run-pass/c-stack-as-value.rs +++ b/src/test/run-pass/c-stack-as-value.rs @@ -1,6 +1,7 @@ // xfail-test -native "cdecl" mod rustrt { +#[abi = "cdecl"] +native mod rustrt { fn unsupervise(); } diff --git a/src/test/run-pass/c-stack-returning-int64.rs b/src/test/run-pass/c-stack-returning-int64.rs index 278417050475..9d1536c0ce79 100644 --- a/src/test/run-pass/c-stack-returning-int64.rs +++ b/src/test/run-pass/c-stack-returning-int64.rs @@ -1,7 +1,9 @@ use std; import std::str; -native "cdecl" mod libc = "" { +#[abi = "cdecl"] +#[link_name = ""] +native mod libc { fn atol(x: str::sbuf) -> int; fn atoll(x: str::sbuf) -> i64; } diff --git a/src/test/run-pass/conditional-compile.rs b/src/test/run-pass/conditional-compile.rs index 10b9dcd98839..921f7a2fae78 100644 --- a/src/test/run-pass/conditional-compile.rs +++ b/src/test/run-pass/conditional-compile.rs @@ -4,13 +4,15 @@ const b: bool = false; const b: bool = true; #[cfg(bogus)] -native "cdecl" mod rustrt { +#[abi = "cdecl"] +native mod rustrt { // This symbol doesn't exist and would be a link error if this // module was translated fn bogus(); } -native "cdecl" mod rustrt { } +#[abi = "cdecl"] +native mod rustrt { } #[cfg(bogus)] type t = int; @@ -79,7 +81,8 @@ fn test_in_fn_ctxt() { } mod test_native_items { - native "cdecl" mod rustrt { + #[abi = "cdecl"] + native mod rustrt { #[cfg(bogus)] fn vec_from_buf_shared(ptr: *T, count: uint) -> [T]; fn vec_from_buf_shared(ptr: *T, count: uint) -> [T]; diff --git a/src/test/run-pass/import-from-native.rs b/src/test/run-pass/import-from-native.rs index 4167f89eaa10..af1914268205 100644 --- a/src/test/run-pass/import-from-native.rs +++ b/src/test/run-pass/import-from-native.rs @@ -3,7 +3,8 @@ mod spam { fn eggs() { } } -native "cdecl" mod rustrt { +#[abi = "cdecl"] +native mod rustrt { import spam::{ham, eggs}; export ham; export eggs; diff --git a/src/test/run-pass/import-glob-1.rs b/src/test/run-pass/import-glob-1.rs index d9c1b653217b..e40d6cbb9cc2 100644 --- a/src/test/run-pass/import-glob-1.rs +++ b/src/test/run-pass/import-glob-1.rs @@ -20,7 +20,9 @@ mod a1 { // | | | mod a2 { // | | | - native "cdecl" mod b1 = "" { + #[abi = "cdecl"] + #[link_name = ""] + native mod b1 { // | | | import a1::b2::*; // | <-/ -/ diff --git a/src/test/run-pass/interior-vec.rs b/src/test/run-pass/interior-vec.rs index b28367790464..988cea0042fe 100644 --- a/src/test/run-pass/interior-vec.rs +++ b/src/test/run-pass/interior-vec.rs @@ -1,6 +1,7 @@ import rusti::vec_len; -native "rust-intrinsic" mod rusti { +#[abi = "rust-intrinsic"] +native mod rusti { fn vec_len(&&v: [T]) -> uint; } diff --git a/src/test/run-pass/issue-506.rs b/src/test/run-pass/issue-506.rs index e8b2d64d7f21..28f1a92bbf8e 100644 --- a/src/test/run-pass/issue-506.rs +++ b/src/test/run-pass/issue-506.rs @@ -10,7 +10,8 @@ use std; import std::task; -native "cdecl" mod rustrt { +#[abi = "cdecl"] +native mod rustrt { fn task_yield(); } diff --git a/src/test/run-pass/item-attributes.rs b/src/test/run-pass/item-attributes.rs index 033504e2e0d8..42874894ab83 100644 --- a/src/test/run-pass/item-attributes.rs +++ b/src/test/run-pass/item-attributes.rs @@ -29,7 +29,8 @@ mod test_single_attr_outer { mod mod1 { } #[attr = "val"] - native "cdecl" mod rustrt { } + #[abi = "cdecl"] + native mod rustrt { } #[attr = "val"] type t = obj { }; @@ -55,7 +56,8 @@ mod test_multi_attr_outer { #[attr1 = "val"] #[attr2 = "val"] - native "cdecl" mod rustrt { } + #[abi = "cdecl"] + native mod rustrt { } #[attr1 = "val"] #[attr2 = "val"] @@ -83,7 +85,8 @@ mod test_stmt_single_attr_outer { } #[attr = "val"] - native "cdecl" mod rustrt { + #[abi = "cdecl"] + native mod rustrt { } */ @@ -116,7 +119,8 @@ mod test_stmt_multi_attr_outer { #[attr1 = "val"] #[attr2 = "val"] - native "cdecl" mod rustrt { + #[abi = "cdecl"] + native mod rustrt { } */ @@ -182,7 +186,8 @@ mod test_other_forms { } mod test_native_items { - native "cdecl" mod rustrt { + #[abi = "cdecl"] + native mod rustrt { #[attr]; #[attr] diff --git a/src/test/run-pass/native-dupe.rs b/src/test/run-pass/native-dupe.rs index fd0b941980aa..22c53fda4f39 100644 --- a/src/test/run-pass/native-dupe.rs +++ b/src/test/run-pass/native-dupe.rs @@ -1,11 +1,15 @@ // xfail-fast - Somehow causes check-fast to livelock?? Probably because we're // calling pin_task and that's having wierd side-effects. -native "cdecl" mod rustrt1 = "rustrt" { +#[abi = "cdecl"] +#[link_name = "rustrt"] +native mod rustrt1 { fn pin_task(); } -native "cdecl" mod rustrt2 = "rustrt" { +#[abi = "cdecl"] +#[link_name = "rustrt"] +native mod rustrt2 { fn pin_task(); } diff --git a/src/test/run-pass/native-fn-linkname.rs b/src/test/run-pass/native-fn-linkname.rs index 5dc6faac8980..785ec5edda5e 100644 --- a/src/test/run-pass/native-fn-linkname.rs +++ b/src/test/run-pass/native-fn-linkname.rs @@ -3,7 +3,9 @@ use std; import std::vec; import std::str; -native "cdecl" mod libc = "" { +#[link_name = ""] +#[abi = "cdecl"] +native mod libc { #[link_name = "strlen"] fn my_strlen(str: *u8) -> uint; } diff --git a/src/test/run-pass/native-opaque-type.rs b/src/test/run-pass/native-opaque-type.rs index 6ec8b4dba6a7..e8df623d1b87 100644 --- a/src/test/run-pass/native-opaque-type.rs +++ b/src/test/run-pass/native-opaque-type.rs @@ -1,6 +1,8 @@ -native "cdecl" mod libc = "" { +#[abi = "cdecl"] +#[link_name = ""] +native mod libc { type file_handle; } diff --git a/src/test/run-pass/native2.rs b/src/test/run-pass/native2.rs index 03b0038c0d6a..07cb455cf0fe 100644 --- a/src/test/run-pass/native2.rs +++ b/src/test/run-pass/native2.rs @@ -1,17 +1,26 @@ -native "cdecl" mod rustrt { +#[abi = "cdecl"] +native mod rustrt { fn unsupervise(); } -native "cdecl" mod bar = "" { } +#[abi = "cdecl"] +#[link_name = ""] +native mod bar { } -native "cdecl" mod zed = "" { } +#[abi = "cdecl"] +#[link_name = ""] +native mod zed { } -native "cdecl" mod libc = "" { +#[abi = "cdecl"] +#[link_name = ""] +native mod libc { fn write(fd: int, buf: *u8, count: uint) -> int; } -native "cdecl" mod baz = "" { } +#[abi = "cdecl"] +#[link_name = ""] +native mod baz { } fn main(args: [str]) { } diff --git a/src/test/run-pass/x86stdcall2.rs b/src/test/run-pass/x86stdcall2.rs index 4edb8dc73e03..6c5093a13299 100644 --- a/src/test/run-pass/x86stdcall2.rs +++ b/src/test/run-pass/x86stdcall2.rs @@ -5,7 +5,8 @@ type LPVOID = uint; type BOOL = u8; #[cfg(target_os = "win32")] -native "stdcall" mod kernel32 { +#[abi = "stdcall"] +native mod kernel32 { fn GetProcessHeap() -> HANDLE; fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T) -> LPVOID; fn HeapFree(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID) -> BOOL;