Skip to content

Commit c8e77d5

Browse files
committed
auto merge of #9606 : steveklabnik/rust/abi_removal, r=alexcrichton
They've been replaced by putting the name on the extern block. #[abi = "foo"] goes to extern "foo" { } Closes #9483.
2 parents b571039 + 309ab95 commit c8e77d5

34 files changed

+4
-77
lines changed

doc/tutorial-ffi.md

+4-7
Original file line numberDiff line numberDiff line change
@@ -415,21 +415,18 @@ fn main() {
415415

416416
Most foreign code exposes a C ABI, and Rust uses the platform's C calling convention by default when
417417
calling foreign functions. Some foreign functions, most notably the Windows API, use other calling
418-
conventions. Rust provides the `abi` attribute as a way to hint to the compiler which calling
419-
convention to use:
418+
conventions. Rust provides a way to tell the compiler which convention to use:
420419

421420
~~~~
422421
#[cfg(target_os = "win32")]
423-
#[abi = "stdcall"]
424422
#[link_name = "kernel32"]
425-
extern {
423+
extern "stdcall" {
426424
fn SetEnvironmentVariableA(n: *u8, v: *u8) -> int;
427425
}
428426
~~~~
429427

430-
The `abi` attribute applies to a foreign module (it cannot be applied to a single function within a
431-
module), and must be either `"cdecl"` or `"stdcall"`. The compiler may eventually support other
432-
calling conventions.
428+
This applies to the entire `extern` block, and must be either `"cdecl"` or
429+
`"stdcall"`. The compiler may eventually support other calling conventions.
433430

434431
# Interoperability with foreign code
435432

src/libextra/time.rs

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ static NSEC_PER_SEC: i32 = 1_000_000_000_i32;
1919
pub mod rustrt {
2020
use super::Tm;
2121

22-
#[abi = "cdecl"]
2322
extern {
2423
pub fn get_time(sec: &mut i64, nsec: &mut i32);
2524
pub fn precise_time_ns(ns: &mut u64);

src/libextra/unicode.rs

-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ pub mod icu {
162162

163163
// #[link_name = "icuuc"]
164164
#[link_args = "-licuuc"]
165-
#[abi = "cdecl"]
166165
extern {
167166
pub fn u_hasBinaryProperty(c: UChar32, which: UProperty) -> UBool;
168167
pub fn u_isdigit(c: UChar32) -> UBool;

src/librustc/lib/llvm.rs

-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,6 @@ pub mod llvm {
300300

301301
#[link_args = "-Lrustllvm -lrustllvm"]
302302
#[link_name = "rustllvm"]
303-
#[abi = "cdecl"]
304303
extern {
305304
/* Create and destroy contexts. */
306305
pub fn LLVMContextCreate() -> ContextRef;

src/libstd/io.rs

-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ pub type fd_t = c_int;
7676
pub mod rustrt {
7777
use libc;
7878

79-
#[abi = "cdecl"]
8079
#[link_name = "rustrt"]
8180
extern {
8281
pub fn rust_get_stdin() -> *libc::FILE;

src/libstd/libc.rs

-26
Original file line numberDiff line numberDiff line change
@@ -2663,7 +2663,6 @@ pub mod funcs {
26632663

26642664
pub mod c95 {
26652665
#[nolink]
2666-
#[abi = "cdecl"]
26672666
pub mod ctype {
26682667
use libc::types::os::arch::c95::{c_char, c_int};
26692668

@@ -2685,7 +2684,6 @@ pub mod funcs {
26852684
}
26862685

26872686
#[nolink]
2688-
#[abi = "cdecl"]
26892687
pub mod stdio {
26902688
use libc::types::common::c95::{FILE, c_void, fpos_t};
26912689
use libc::types::os::arch::c95::{c_char, c_int, c_long, size_t};
@@ -2742,7 +2740,6 @@ pub mod funcs {
27422740
}
27432741

27442742
#[nolink]
2745-
#[abi = "cdecl"]
27462743
pub mod stdlib {
27472744
use libc::types::common::c95::c_void;
27482745
use libc::types::os::arch::c95::{c_char, c_double, c_int};
@@ -2776,7 +2773,6 @@ pub mod funcs {
27762773
}
27772774

27782775
#[nolink]
2779-
#[abi = "cdecl"]
27802776
pub mod string {
27812777
use libc::types::common::c95::c_void;
27822778
use libc::types::os::arch::c95::{c_char, c_int, size_t};
@@ -2826,7 +2822,6 @@ pub mod funcs {
28262822
#[cfg(target_os = "win32")]
28272823
pub mod posix88 {
28282824
#[nolink]
2829-
#[abi = "cdecl"]
28302825
pub mod stat_ {
28312826
use libc::types::os::common::posix01::stat;
28322827
use libc::types::os::arch::c95::{c_int, c_char};
@@ -2844,7 +2839,6 @@ pub mod funcs {
28442839
}
28452840

28462841
#[nolink]
2847-
#[abi = "cdecl"]
28482842
pub mod stdio {
28492843
use libc::types::common::c95::FILE;
28502844
use libc::types::os::arch::c95::{c_int, c_char};
@@ -2862,7 +2856,6 @@ pub mod funcs {
28622856
}
28632857

28642858
#[nolink]
2865-
#[abi = "cdecl"]
28662859
pub mod fcntl {
28672860
use libc::types::os::arch::c95::{c_int, c_char};
28682861
extern {
@@ -2875,13 +2868,11 @@ pub mod funcs {
28752868
}
28762869

28772870
#[nolink]
2878-
#[abi = "cdecl"]
28792871
pub mod dirent {
28802872
// Not supplied at all.
28812873
}
28822874

28832875
#[nolink]
2884-
#[abi = "cdecl"]
28852876
pub mod unistd {
28862877
use libc::types::common::c95::c_void;
28872878
use libc::types::os::arch::c95::{c_int, c_uint, c_char,
@@ -2949,7 +2940,6 @@ pub mod funcs {
29492940
use libc::types::os::arch::posix88::mode_t;
29502941

29512942
#[nolink]
2952-
#[abi = "cdecl"]
29532943
extern {
29542944
pub fn chmod(path: *c_char, mode: mode_t) -> c_int;
29552945
pub fn fchmod(fd: c_int, mode: mode_t) -> c_int;
@@ -2978,7 +2968,6 @@ pub mod funcs {
29782968
}
29792969

29802970
#[nolink]
2981-
#[abi = "cdecl"]
29822971
pub mod stdio {
29832972
use libc::types::common::c95::FILE;
29842973
use libc::types::os::arch::c95::{c_char, c_int};
@@ -2992,7 +2981,6 @@ pub mod funcs {
29922981
}
29932982

29942983
#[nolink]
2995-
#[abi = "cdecl"]
29962984
pub mod fcntl {
29972985
use libc::types::os::arch::c95::{c_char, c_int};
29982986
use libc::types::os::arch::posix88::mode_t;
@@ -3006,7 +2994,6 @@ pub mod funcs {
30062994
}
30072995

30082996
#[nolink]
3009-
#[abi = "cdecl"]
30102997
pub mod dirent {
30112998
use libc::types::common::posix88::{DIR, dirent_t};
30122999
use libc::types::os::arch::c95::{c_char, c_int, c_long};
@@ -3040,7 +3027,6 @@ pub mod funcs {
30403027
}
30413028

30423029
#[nolink]
3043-
#[abi = "cdecl"]
30443030
pub mod unistd {
30453031
use libc::types::common::c95::c_void;
30463032
use libc::types::os::arch::c95::{c_char, c_int, c_long, c_uint};
@@ -3100,7 +3086,6 @@ pub mod funcs {
31003086
}
31013087

31023088
#[nolink]
3103-
#[abi = "cdecl"]
31043089
pub mod signal {
31053090
use libc::types::os::arch::c95::{c_int};
31063091
use libc::types::os::arch::posix88::{pid_t};
@@ -3111,7 +3096,6 @@ pub mod funcs {
31113096
}
31123097

31133098
#[nolink]
3114-
#[abi = "cdecl"]
31153099
pub mod mman {
31163100
use libc::types::common::c95::{c_void};
31173101
use libc::types::os::arch::c95::{size_t, c_int, c_char};
@@ -3150,7 +3134,6 @@ pub mod funcs {
31503134
#[cfg(target_os = "freebsd")]
31513135
pub mod posix01 {
31523136
#[nolink]
3153-
#[abi = "cdecl"]
31543137
pub mod stat_ {
31553138
use libc::types::os::arch::c95::{c_char, c_int};
31563139
use libc::types::os::arch::posix01::stat;
@@ -3168,7 +3151,6 @@ pub mod funcs {
31683151
}
31693152

31703153
#[nolink]
3171-
#[abi = "cdecl"]
31723154
pub mod unistd {
31733155
use libc::types::os::arch::c95::{c_char, c_int, size_t};
31743156
use libc::types::os::arch::posix88::{ssize_t};
@@ -3195,7 +3177,6 @@ pub mod funcs {
31953177
}
31963178

31973179
#[nolink]
3198-
#[abi = "cdecl"]
31993180
pub mod wait {
32003181
use libc::types::os::arch::c95::{c_int};
32013182
use libc::types::os::arch::posix88::{pid_t};
@@ -3207,7 +3188,6 @@ pub mod funcs {
32073188
}
32083189

32093190
#[nolink]
3210-
#[abi = "cdecl"]
32113191
pub mod glob {
32123192
use libc::types::os::arch::c95::{c_char, c_int};
32133193
use libc::types::os::common::posix01::{glob_t};
@@ -3223,7 +3203,6 @@ pub mod funcs {
32233203
}
32243204

32253205
#[nolink]
3226-
#[abi = "cdecl"]
32273206
pub mod mman {
32283207
use libc::types::common::c95::{c_void};
32293208
use libc::types::os::arch::c95::{c_int, size_t};
@@ -3271,7 +3250,6 @@ pub mod funcs {
32713250
use libc::types::os::arch::c95::{c_char, c_uchar, c_int, c_uint,
32723251
size_t};
32733252

3274-
#[abi = "cdecl"]
32753253
extern {
32763254
pub fn sysctl(name: *c_int,
32773255
namelen: c_uint,
@@ -3305,7 +3283,6 @@ pub mod funcs {
33053283
use libc::types::common::c95::{c_void};
33063284
use libc::types::os::arch::c95::{c_uchar, c_int, size_t};
33073285

3308-
#[abi = "cdecl"]
33093286
extern {
33103287
pub fn getdtablesize() -> c_int;
33113288
pub fn madvise(addr: *c_void, len: size_t, advice: c_int)
@@ -3325,7 +3302,6 @@ pub mod funcs {
33253302
pub mod extra {
33263303
use libc::types::os::arch::c95::{c_char, c_int};
33273304

3328-
#[abi = "cdecl"]
33293305
extern {
33303306
pub fn _NSGetExecutablePath(buf: *mut c_char, bufsize: *mut u32)
33313307
-> c_int;
@@ -3358,7 +3334,6 @@ pub mod funcs {
33583334
use libc::types::os::arch::extra::{HANDLE, LPHANDLE};
33593335

33603336
#[cfg(target_arch = "x86")]
3361-
#[abi = "stdcall"]
33623337
extern "stdcall" {
33633338
pub fn GetEnvironmentVariableW(n: LPCWSTR,
33643339
v: LPWSTR,
@@ -3572,7 +3547,6 @@ pub mod funcs {
35723547
pub mod msvcrt {
35733548
use libc::types::os::arch::c95::{c_int, c_long};
35743549

3575-
#[abi = "cdecl"]
35763550
#[nolink]
35773551
extern {
35783552
#[link_name = "_commit"]

src/libstd/num/cmath.rs

-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ pub mod c_double_utils {
1818
use libc::{c_double, c_int};
1919

2020
#[link_name = "m"]
21-
#[abi = "cdecl"]
2221
extern {
2322
// Alpabetically sorted by link_name
2423

@@ -107,7 +106,6 @@ pub mod c_float_utils {
107106
use libc::{c_float, c_int};
108107

109108
#[link_name = "m"]
110-
#[abi = "cdecl"]
111109
extern {
112110
// Alpabetically sorted by link_name
113111

src/libstd/os.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,6 @@ pub fn errno() -> uint {
10391039

10401040
#[cfg(target_arch = "x86")]
10411041
#[link_name = "kernel32"]
1042-
#[abi = "stdcall"]
10431042
extern "stdcall" {
10441043
fn GetLastError() -> DWORD;
10451044
}
@@ -1118,7 +1117,6 @@ pub fn last_os_error() -> ~str {
11181117

11191118
#[cfg(target_arch = "x86")]
11201119
#[link_name = "kernel32"]
1121-
#[abi = "stdcall"]
11221120
extern "stdcall" {
11231121
fn FormatMessageW(flags: DWORD,
11241122
lpSrc: LPVOID,

src/libstd/rt/thread_local_storage.rs

-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ pub unsafe fn get(key: Key) -> *mut c_void {
8484
}
8585

8686
#[cfg(windows, target_arch = "x86")]
87-
#[abi = "stdcall"]
8887
extern "stdcall" {
8988
fn TlsAlloc() -> DWORD;
9089
fn TlsSetValue(dwTlsIndex: DWORD, lpTlsvalue: LPVOID) -> BOOL;

src/libstd/unstable/intrinsics.rs

-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ pub trait TyVisitor {
170170
fn visit_closure_ptr(&mut self, ck: uint) -> bool;
171171
}
172172

173-
#[abi = "rust-intrinsic"]
174173
extern "rust-intrinsic" {
175174

176175
/// Atomic compare and exchange, sequentially consistent.

src/libsyntax/ext/expand.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,6 @@ pub fn std_macros() -> @str {
10591059
// It is intended to be used like:
10601060
//
10611061
// externfn!(#[nolink]
1062-
// #[abi = \"cdecl\"]
10631062
// fn memcmp(cx: *u8, ct: *u8, n: u32) -> u32)
10641063
//
10651064
// Due to limitations in the macro parser, this pattern must be

src/test/auxiliary/anon-extern-mod-cross-crate-1.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#[abi = "cdecl"];
1211
#[link_name = "rustrt"];
1312
#[link(name = "anonexternmod",
1413
vers = "0.1")];

src/test/auxiliary/cci_intrinsic.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

1111
pub mod rusti {
12-
#[abi = "rust-intrinsic"]
1312
extern "rust-intrinsic" {
1413
pub fn atomic_cxchg(dst: &mut int, old: int, src: int) -> int;
1514
pub fn atomic_cxchg_acq(dst: &mut int, old: int, src: int) -> int;

src/test/compile-fail/foreign-unsafe-fn-called.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212

1313
mod test {
14-
#[abi = "cdecl"]
1514
extern {
1615
pub fn free();
1716
}

src/test/run-pass/anon-extern-mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
use std::libc;
1212

13-
#[abi = "cdecl"]
1413
#[link_name = "rustrt"]
1514
extern {
1615
fn rust_get_test_int() -> libc::intptr_t;

src/test/run-pass/c-stack-as-value.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
mod rustrt {
1212
use std::libc;
1313

14-
#[abi = "cdecl"]
1514
extern {
1615
pub fn rust_get_test_int() -> libc::intptr_t;
1716
}

src/test/run-pass/c-stack-returning-int64.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
mod libc {
1212
use std::libc::{c_char, c_long, c_longlong};
1313

14-
#[abi = "cdecl"]
1514
#[nolink]
1615
extern {
1716
pub fn atol(x: *c_char) -> c_long;

src/test/run-pass/conditional-compile.rs

-3
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@ static b: bool = true;
2121

2222
mod rustrt {
2323
#[cfg(bogus)]
24-
#[abi = "cdecl"]
2524
extern {
2625
// This symbol doesn't exist and would be a link error if this
2726
// module was translated
2827
pub fn bogus();
2928
}
3029

31-
#[abi = "cdecl"]
3230
extern {}
3331
}
3432

@@ -109,7 +107,6 @@ fn test_in_fn_ctxt() {
109107

110108
mod test_foreign_items {
111109
pub mod rustrt {
112-
#[abi = "cdecl"]
113110
extern {
114111
#[cfg(bogus)]
115112
pub fn rust_get_stdin() -> ~str;

0 commit comments

Comments
 (0)