Add AbiSet and integrate it into the AST.
I believe this patch incorporates all expected syntax changes from extern function reform (#3678). You can now write things like: extern "<abi>" fn foo(s: S) -> T { ... } extern "<abi>" mod { ... } extern "<abi>" fn(S) -> T The ABI for foreign functions is taken from this syntax (rather than from an annotation). We support the full ABI specification I described on the mailing list. The correct ABI is chosen based on the target architecture. Calls by pointer to C functions are not yet supported, and the Rust type of crust fns is still *u8.
This commit is contained in:
parent
f864934f54
commit
6965fe4bce
72 changed files with 879 additions and 352 deletions
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
pub mod rusti {
|
||||
#[abi = "rust-intrinsic"]
|
||||
pub extern {
|
||||
pub extern "rust-intrinsic" {
|
||||
fn atomic_cxchg(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;
|
||||
|
|
@ -18,11 +18,11 @@ pub mod rusti {
|
|||
fn atomic_xchg(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_xadd(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_xsub(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;
|
||||
|
|
|
|||
|
|
@ -19,5 +19,5 @@ fn main() {
|
|||
}
|
||||
|
||||
f(g);
|
||||
//~^ ERROR mismatched types: expected `extern fn(extern fn(extern fn()))`
|
||||
//~^ ERROR mismatched types: expected `extern "Rust" fn(extern "Rust" fn(extern "Rust" fn()))`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,5 +9,5 @@
|
|||
// except according to those terms.
|
||||
|
||||
fn main() -> char {
|
||||
//~^ ERROR Wrong type in main function: found `extern fn() -> char`
|
||||
//~^ ERROR Wrong type in main function: found `extern "Rust" fn() -> char`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,5 +14,5 @@ struct S {
|
|||
}
|
||||
|
||||
fn main(foo: S) {
|
||||
//~^ ERROR Wrong type in main function: found `extern fn(S)`
|
||||
//~^ ERROR Wrong type in main function: found `extern "Rust" fn(S)`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,6 @@ fn foo(f: &fn()) { f() }
|
|||
|
||||
fn main() {
|
||||
~"" || 42; //~ ERROR binary operation || cannot be applied to type `~str`
|
||||
foo || {}; //~ ERROR binary operation || cannot be applied to type `extern fn(&fn())`
|
||||
foo || {}; //~ ERROR binary operation || cannot be applied to type `extern "Rust" fn(&fn())`
|
||||
//~^ NOTE did you forget the `do` keyword for the call?
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
// pp-exact
|
||||
|
||||
fn from_foreign_fn(x: extern fn()) { }
|
||||
fn from_foreign_fn(x: extern "Rust" fn()) { }
|
||||
fn from_stack_closure(x: &fn()) { }
|
||||
fn from_box_closure(x: @fn()) { }
|
||||
fn from_unique_closure(x: ~fn()) { }
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
mod rusti {
|
||||
#[abi = "rust-intrinsic"]
|
||||
pub extern {
|
||||
pub extern "rust-intrinsic" {
|
||||
pub fn pref_align_of<T>() -> uint;
|
||||
pub fn min_align_of<T>() -> uint;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
mod rusti {
|
||||
#[abi = "rust-intrinsic"]
|
||||
pub extern {
|
||||
pub 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;
|
||||
pub fn atomic_cxchg_rel(dst: &mut int, old: int, src: int) -> int;
|
||||
|
|
@ -18,11 +18,11 @@ mod rusti {
|
|||
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_rel(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_rel(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_rel(dst: &mut int, src: int) -> int;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
mod rusti {
|
||||
#[abi = "rust-intrinsic"]
|
||||
pub extern {
|
||||
pub extern "rust-intrinsic" {
|
||||
pub fn frame_address(f: &once fn(*u8));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
mod rusti {
|
||||
#[abi = "rust-intrinsic"]
|
||||
pub extern {
|
||||
pub extern "rust-intrinsic" {
|
||||
pub fn move_val_init<T>(dst: &mut T, +src: T);
|
||||
pub fn move_val<T>(dst: &mut T, +src: T);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@
|
|||
extern mod std;
|
||||
|
||||
mod rusti {
|
||||
#[abi = "rust-intrinsic"]
|
||||
pub extern {
|
||||
#[abi = "rust-intrinsic"]
|
||||
pub extern "rust-intrinsic" {
|
||||
fn ctpop8(x: i8) -> i8;
|
||||
fn ctpop16(x: i16) -> i16;
|
||||
fn ctpop32(x: i32) -> i32;
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ extern mod std;
|
|||
use std::cmp::FuzzyEq;
|
||||
|
||||
mod rusti {
|
||||
#[abi = "rust-intrinsic"]
|
||||
pub extern {
|
||||
#[abi = "rust-intrinsic"]
|
||||
pub extern "rust-intrinsic" {
|
||||
fn sqrtf32(x: f32) -> f32;
|
||||
fn sqrtf64(x: f64) -> f64;
|
||||
fn powif32(a: f32, x: i32) -> f32;
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ pub mod pipes {
|
|||
}
|
||||
}
|
||||
|
||||
#[abi = "rust-intrinsic"]
|
||||
mod rusti {
|
||||
pub fn atomic_xchg(_dst: &mut int, _src: int) -> int { fail!(); }
|
||||
pub fn atomic_xchg_acq(_dst: &mut int, _src: int) -> int { fail!(); }
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
mod rusti {
|
||||
#[nolink]
|
||||
#[abi = "rust-intrinsic"]
|
||||
pub extern {
|
||||
pub extern "rust-intrinsic" {
|
||||
pub fn morestack_addr() -> *();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
mod rusti {
|
||||
#[abi = "rust-intrinsic"]
|
||||
pub extern {
|
||||
pub extern "rust-intrinsic" {
|
||||
pub fn pref_align_of<T>() -> uint;
|
||||
pub fn min_align_of<T>() -> uint;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
mod rusti {
|
||||
#[abi = "rust-intrinsic"]
|
||||
pub extern {
|
||||
pub extern "rust-intrinsic" {
|
||||
pub fn pref_align_of<T>() -> uint;
|
||||
pub fn min_align_of<T>() -> uint;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ mod kernel32 {
|
|||
|
||||
#[cfg(target_os = "win32")]
|
||||
#[abi = "stdcall"]
|
||||
pub extern {
|
||||
pub extern "stdcall" {
|
||||
pub fn GetProcessHeap() -> HANDLE;
|
||||
pub fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T)
|
||||
-> LPVOID;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue