Skip to content

Commit

Permalink
auto merge of #9606 : steveklabnik/rust/abi_removal, r=alexcrichton
Browse files Browse the repository at this point in the history
They've been replaced by putting the name on the extern block.

  #[abi = "foo"]

goes to

  extern "foo" { }

Closes #9483.
  • Loading branch information
bors committed Oct 14, 2013
2 parents b571039 + 309ab95 commit c8e77d5
Show file tree
Hide file tree
Showing 34 changed files with 4 additions and 77 deletions.
11 changes: 4 additions & 7 deletions doc/tutorial-ffi.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,21 +415,18 @@ fn main() {

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

~~~~
#[cfg(target_os = "win32")]
#[abi = "stdcall"]
#[link_name = "kernel32"]
extern {
extern "stdcall" {
fn SetEnvironmentVariableA(n: *u8, v: *u8) -> int;
}
~~~~

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

# Interoperability with foreign code

Expand Down
1 change: 0 additions & 1 deletion src/libextra/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ static NSEC_PER_SEC: i32 = 1_000_000_000_i32;
pub mod rustrt {
use super::Tm;

#[abi = "cdecl"]
extern {
pub fn get_time(sec: &mut i64, nsec: &mut i32);
pub fn precise_time_ns(ns: &mut u64);
Expand Down
1 change: 0 additions & 1 deletion src/libextra/unicode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ pub mod icu {

// #[link_name = "icuuc"]
#[link_args = "-licuuc"]
#[abi = "cdecl"]
extern {
pub fn u_hasBinaryProperty(c: UChar32, which: UProperty) -> UBool;
pub fn u_isdigit(c: UChar32) -> UBool;
Expand Down
1 change: 0 additions & 1 deletion src/librustc/lib/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ pub mod llvm {

#[link_args = "-Lrustllvm -lrustllvm"]
#[link_name = "rustllvm"]
#[abi = "cdecl"]
extern {
/* Create and destroy contexts. */
pub fn LLVMContextCreate() -> ContextRef;
Expand Down
1 change: 0 additions & 1 deletion src/libstd/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ pub type fd_t = c_int;
pub mod rustrt {
use libc;

#[abi = "cdecl"]
#[link_name = "rustrt"]
extern {
pub fn rust_get_stdin() -> *libc::FILE;
Expand Down
26 changes: 0 additions & 26 deletions src/libstd/libc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2663,7 +2663,6 @@ pub mod funcs {

pub mod c95 {
#[nolink]
#[abi = "cdecl"]
pub mod ctype {
use libc::types::os::arch::c95::{c_char, c_int};

Expand All @@ -2685,7 +2684,6 @@ pub mod funcs {
}

#[nolink]
#[abi = "cdecl"]
pub mod stdio {
use libc::types::common::c95::{FILE, c_void, fpos_t};
use libc::types::os::arch::c95::{c_char, c_int, c_long, size_t};
Expand Down Expand Up @@ -2742,7 +2740,6 @@ pub mod funcs {
}

#[nolink]
#[abi = "cdecl"]
pub mod stdlib {
use libc::types::common::c95::c_void;
use libc::types::os::arch::c95::{c_char, c_double, c_int};
Expand Down Expand Up @@ -2776,7 +2773,6 @@ pub mod funcs {
}

#[nolink]
#[abi = "cdecl"]
pub mod string {
use libc::types::common::c95::c_void;
use libc::types::os::arch::c95::{c_char, c_int, size_t};
Expand Down Expand Up @@ -2826,7 +2822,6 @@ pub mod funcs {
#[cfg(target_os = "win32")]
pub mod posix88 {
#[nolink]
#[abi = "cdecl"]
pub mod stat_ {
use libc::types::os::common::posix01::stat;
use libc::types::os::arch::c95::{c_int, c_char};
Expand All @@ -2844,7 +2839,6 @@ pub mod funcs {
}

#[nolink]
#[abi = "cdecl"]
pub mod stdio {
use libc::types::common::c95::FILE;
use libc::types::os::arch::c95::{c_int, c_char};
Expand All @@ -2862,7 +2856,6 @@ pub mod funcs {
}

#[nolink]
#[abi = "cdecl"]
pub mod fcntl {
use libc::types::os::arch::c95::{c_int, c_char};
extern {
Expand All @@ -2875,13 +2868,11 @@ pub mod funcs {
}

#[nolink]
#[abi = "cdecl"]
pub mod dirent {
// Not supplied at all.
}

#[nolink]
#[abi = "cdecl"]
pub mod unistd {
use libc::types::common::c95::c_void;
use libc::types::os::arch::c95::{c_int, c_uint, c_char,
Expand Down Expand Up @@ -2949,7 +2940,6 @@ pub mod funcs {
use libc::types::os::arch::posix88::mode_t;

#[nolink]
#[abi = "cdecl"]
extern {
pub fn chmod(path: *c_char, mode: mode_t) -> c_int;
pub fn fchmod(fd: c_int, mode: mode_t) -> c_int;
Expand Down Expand Up @@ -2978,7 +2968,6 @@ pub mod funcs {
}

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

#[nolink]
#[abi = "cdecl"]
pub mod fcntl {
use libc::types::os::arch::c95::{c_char, c_int};
use libc::types::os::arch::posix88::mode_t;
Expand All @@ -3006,7 +2994,6 @@ pub mod funcs {
}

#[nolink]
#[abi = "cdecl"]
pub mod dirent {
use libc::types::common::posix88::{DIR, dirent_t};
use libc::types::os::arch::c95::{c_char, c_int, c_long};
Expand Down Expand Up @@ -3040,7 +3027,6 @@ pub mod funcs {
}

#[nolink]
#[abi = "cdecl"]
pub mod unistd {
use libc::types::common::c95::c_void;
use libc::types::os::arch::c95::{c_char, c_int, c_long, c_uint};
Expand Down Expand Up @@ -3100,7 +3086,6 @@ pub mod funcs {
}

#[nolink]
#[abi = "cdecl"]
pub mod signal {
use libc::types::os::arch::c95::{c_int};
use libc::types::os::arch::posix88::{pid_t};
Expand All @@ -3111,7 +3096,6 @@ pub mod funcs {
}

#[nolink]
#[abi = "cdecl"]
pub mod mman {
use libc::types::common::c95::{c_void};
use libc::types::os::arch::c95::{size_t, c_int, c_char};
Expand Down Expand Up @@ -3150,7 +3134,6 @@ pub mod funcs {
#[cfg(target_os = "freebsd")]
pub mod posix01 {
#[nolink]
#[abi = "cdecl"]
pub mod stat_ {
use libc::types::os::arch::c95::{c_char, c_int};
use libc::types::os::arch::posix01::stat;
Expand All @@ -3168,7 +3151,6 @@ pub mod funcs {
}

#[nolink]
#[abi = "cdecl"]
pub mod unistd {
use libc::types::os::arch::c95::{c_char, c_int, size_t};
use libc::types::os::arch::posix88::{ssize_t};
Expand All @@ -3195,7 +3177,6 @@ pub mod funcs {
}

#[nolink]
#[abi = "cdecl"]
pub mod wait {
use libc::types::os::arch::c95::{c_int};
use libc::types::os::arch::posix88::{pid_t};
Expand All @@ -3207,7 +3188,6 @@ pub mod funcs {
}

#[nolink]
#[abi = "cdecl"]
pub mod glob {
use libc::types::os::arch::c95::{c_char, c_int};
use libc::types::os::common::posix01::{glob_t};
Expand All @@ -3223,7 +3203,6 @@ pub mod funcs {
}

#[nolink]
#[abi = "cdecl"]
pub mod mman {
use libc::types::common::c95::{c_void};
use libc::types::os::arch::c95::{c_int, size_t};
Expand Down Expand Up @@ -3271,7 +3250,6 @@ pub mod funcs {
use libc::types::os::arch::c95::{c_char, c_uchar, c_int, c_uint,
size_t};

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

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

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

#[cfg(target_arch = "x86")]
#[abi = "stdcall"]
extern "stdcall" {
pub fn GetEnvironmentVariableW(n: LPCWSTR,
v: LPWSTR,
Expand Down Expand Up @@ -3572,7 +3547,6 @@ pub mod funcs {
pub mod msvcrt {
use libc::types::os::arch::c95::{c_int, c_long};

#[abi = "cdecl"]
#[nolink]
extern {
#[link_name = "_commit"]
Expand Down
2 changes: 0 additions & 2 deletions src/libstd/num/cmath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ pub mod c_double_utils {
use libc::{c_double, c_int};

#[link_name = "m"]
#[abi = "cdecl"]
extern {
// Alpabetically sorted by link_name

Expand Down Expand Up @@ -107,7 +106,6 @@ pub mod c_float_utils {
use libc::{c_float, c_int};

#[link_name = "m"]
#[abi = "cdecl"]
extern {
// Alpabetically sorted by link_name

Expand Down
2 changes: 0 additions & 2 deletions src/libstd/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,6 @@ pub fn errno() -> uint {

#[cfg(target_arch = "x86")]
#[link_name = "kernel32"]
#[abi = "stdcall"]
extern "stdcall" {
fn GetLastError() -> DWORD;
}
Expand Down Expand Up @@ -1118,7 +1117,6 @@ pub fn last_os_error() -> ~str {

#[cfg(target_arch = "x86")]
#[link_name = "kernel32"]
#[abi = "stdcall"]
extern "stdcall" {
fn FormatMessageW(flags: DWORD,
lpSrc: LPVOID,
Expand Down
1 change: 0 additions & 1 deletion src/libstd/rt/thread_local_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ pub unsafe fn get(key: Key) -> *mut c_void {
}

#[cfg(windows, target_arch = "x86")]
#[abi = "stdcall"]
extern "stdcall" {
fn TlsAlloc() -> DWORD;
fn TlsSetValue(dwTlsIndex: DWORD, lpTlsvalue: LPVOID) -> BOOL;
Expand Down
1 change: 0 additions & 1 deletion src/libstd/unstable/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ pub trait TyVisitor {
fn visit_closure_ptr(&mut self, ck: uint) -> bool;
}

#[abi = "rust-intrinsic"]
extern "rust-intrinsic" {

/// Atomic compare and exchange, sequentially consistent.
Expand Down
1 change: 0 additions & 1 deletion src/libsyntax/ext/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,6 @@ pub fn std_macros() -> @str {
// It is intended to be used like:
//
// externfn!(#[nolink]
// #[abi = \"cdecl\"]
// fn memcmp(cx: *u8, ct: *u8, n: u32) -> u32)
//
// Due to limitations in the macro parser, this pattern must be
Expand Down
1 change: 0 additions & 1 deletion src/test/auxiliary/anon-extern-mod-cross-crate-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#[abi = "cdecl"];
#[link_name = "rustrt"];
#[link(name = "anonexternmod",
vers = "0.1")];
Expand Down
1 change: 0 additions & 1 deletion src/test/auxiliary/cci_intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// except according to those terms.

pub mod rusti {
#[abi = "rust-intrinsic"]
extern "rust-intrinsic" {
pub fn atomic_cxchg(dst: &mut int, old: int, src: int) -> int;
pub fn atomic_cxchg_acq(dst: &mut int, old: int, src: int) -> int;
Expand Down
1 change: 0 additions & 1 deletion src/test/compile-fail/foreign-unsafe-fn-called.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@


mod test {
#[abi = "cdecl"]
extern {
pub fn free();
}
Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/anon-extern-mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

use std::libc;

#[abi = "cdecl"]
#[link_name = "rustrt"]
extern {
fn rust_get_test_int() -> libc::intptr_t;
Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/c-stack-as-value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
mod rustrt {
use std::libc;

#[abi = "cdecl"]
extern {
pub fn rust_get_test_int() -> libc::intptr_t;
}
Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/c-stack-returning-int64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
mod libc {
use std::libc::{c_char, c_long, c_longlong};

#[abi = "cdecl"]
#[nolink]
extern {
pub fn atol(x: *c_char) -> c_long;
Expand Down
3 changes: 0 additions & 3 deletions src/test/run-pass/conditional-compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@ static b: bool = true;

mod rustrt {
#[cfg(bogus)]
#[abi = "cdecl"]
extern {
// This symbol doesn't exist and would be a link error if this
// module was translated
pub fn bogus();
}

#[abi = "cdecl"]
extern {}
}

Expand Down Expand Up @@ -109,7 +107,6 @@ fn test_in_fn_ctxt() {

mod test_foreign_items {
pub mod rustrt {
#[abi = "cdecl"]
extern {
#[cfg(bogus)]
pub fn rust_get_stdin() -> ~str;
Expand Down
Loading

0 comments on commit c8e77d5

Please sign in to comment.