88f29aab27
This patch changes how to specify ABI and link name of a native module. Before: native "cdecl" mod llvm = "rustllvm" {...} After: #[abi = "cdecl"] #[link_name = "rustllvm"] native mod llvm {...} The old optional syntax for ABI and link name is no longer supported. Fixes issue #547
24 lines
453 B
Rust
24 lines
453 B
Rust
use std;
|
|
import std::str;
|
|
|
|
#[abi = "cdecl"]
|
|
#[link_name = ""]
|
|
native mod libc {
|
|
fn atol(x: str::sbuf) -> int;
|
|
fn atoll(x: str::sbuf) -> i64;
|
|
}
|
|
|
|
fn atol(s: str) -> int {
|
|
ret str::as_buf(s, { |x| libc::atol(x) });
|
|
}
|
|
|
|
fn atoll(s: str) -> i64 {
|
|
ret str::as_buf(s, { |x| libc::atoll(x) });
|
|
}
|
|
|
|
fn main() {
|
|
assert atol("1024") * 10 == atol("10240");
|
|
assert (atoll("11111111111111111") * 10i64)
|
|
== atoll("111111111111111110");
|
|
}
|