rust/src/test/run-pass/c-stack-returning-int64.rs
Haitao Li 88f29aab27 Use attributes for native module ABI and link name
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
2011-11-16 11:35:13 -08:00

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");
}