rust/src/test/run-pass/c-stack-returning-int64.rs
Graham Fawcett 7ddd353ef6 implement #[nolink]; deprecate #[link_name = ""]; note in stdlib to remove empty link_name.
Can't remove them from stdlib until the snapshotted compiler supports #[nolink].
2011-12-16 15:29:59 -08:00

24 lines
440 B
Rust

use std;
import str;
#[abi = "cdecl"]
#[nolink]
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");
}