Skip to content

Commit 771e1c8

Browse files
committed
---
yaml --- r: 5954 b: refs/heads/master c: c78b163 h: refs/heads/master v: v3
1 parent ebcdedf commit 771e1c8

File tree

6 files changed

+41
-6
lines changed

6 files changed

+41
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: d41385a69be7ef002c71bfe3ad1bac796517370d
2+
refs/heads/master: c78b1639b445e31274858d0801d30a2f9cd3d7e6

trunk/src/comp/back/upcall.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import std::str;
33
import middle::trans;
44
import trans::decl_cdecl_fn;
55
import middle::trans_common::{T_f32, T_f64, T_fn, T_bool, T_i1, T_i8, T_i32,
6-
T_int, T_vec, T_nil, T_opaque_chan_ptr,
6+
T_i64, T_int, T_vec, T_nil, T_opaque_chan_ptr,
77
T_opaque_vec, T_opaque_port_ptr, T_ptr,
88
T_size_t, T_void, T_float};
99
import lib::llvm::type_names;
@@ -28,6 +28,7 @@ type upcalls =
2828
dynastack_free: ValueRef,
2929
alloc_c_stack: ValueRef,
3030
call_c_stack: ValueRef,
31+
call_c_stack_i64: ValueRef,
3132
call_c_stack_float: ValueRef,
3233
rust_personality: ValueRef};
3334

@@ -76,8 +77,11 @@ fn declare_upcalls(_tn: type_names, tydesc_type: TypeRef,
7677
dynastack_free: dv("dynastack_free", [T_ptr(T_i8())]),
7778
alloc_c_stack: d("alloc_c_stack", [T_size_t()], T_ptr(T_i8())),
7879
call_c_stack: d("call_c_stack",
79-
[T_ptr(T_fn([], T_int())), T_ptr(T_i8())],
80-
T_int()),
80+
[T_ptr(T_fn([], T_int())), T_ptr(T_i8())],
81+
T_int()),
82+
call_c_stack_i64: d("call_c_stack_i64",
83+
[T_ptr(T_fn([], T_int())), T_ptr(T_i8())],
84+
T_i64()),
8185
call_c_stack_float: d("call_c_stack_float",
8286
[T_ptr(T_fn([], T_int())), T_ptr(T_i8())],
8387
T_float()),

trunk/src/comp/middle/trans.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3878,13 +3878,19 @@ fn trans_c_stack_native_call(bcx: @block_ctxt, f: @ast::expr,
38783878
ccx.upcalls.call_c_stack_float
38793879
}
38803880

3881+
7 {
3882+
// LLVMIntegerTypeKind
3883+
let width = lib::llvm::llvm::LLVMGetIntTypeWidth(llretty);
3884+
if width == 64u { ccx.upcalls.call_c_stack_i64 }
3885+
else { ccx.upcalls.call_c_stack } // on 64-bit target, no diff
3886+
}
3887+
38813888
_ { ccx.upcalls.call_c_stack }
38823889
};
38833890

38843891
// Call and cast the return type.
38853892
// TODO: Invoke instead.
3886-
let llrawretval = Call(bcx, upcall_fn,
3887-
[llfn, llrawargbundle]);
3893+
let llrawretval = Call(bcx, upcall_fn, [llfn, llrawargbundle]);
38883894
let llretval;
38893895
if lib::llvm::llvm::LLVMGetTypeKind(llretty) as int == 11 { // pointer
38903896
llretval = IntToPtr(bcx, llrawretval, llretty);

trunk/src/rt/arch/i386/ccall.S

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@
66
// slower.
77
#if defined(__APPLE__) || defined(_WIN32)
88
.globl _upcall_call_c_stack
9+
.globl _upcall_call_c_stack_i64
910
.globl _upcall_call_c_stack_float
1011
_upcall_call_c_stack:
12+
_upcall_call_c_stack_i64:
1113
_upcall_call_c_stack_float:
1214
#else
1315
.globl upcall_call_c_stack
16+
.globl upcall_call_c_stack_i64
1417
.globl upcall_call_c_stack_float
1518
upcall_call_c_stack:
19+
upcall_call_c_stack_i64:
1620
upcall_call_c_stack_float:
1721
#endif
1822
pushl %ebp

trunk/src/rt/rustrt.def.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ task_join
6565
unsupervise
6666
upcall_alloc_c_stack
6767
upcall_call_c_stack
68+
upcall_call_c_stack_i64
6869
upcall_call_c_stack_float
6970
upcall_cmp_type
7071
upcall_dynastack_alloc
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
use std;
2+
import std::str;
3+
4+
native "c-stack-cdecl" mod libc = "" {
5+
fn atol(x: str::sbuf) -> int;
6+
fn atoll(x: str::sbuf) -> i64;
7+
}
8+
9+
fn atol(s: str) -> int {
10+
ret str::as_buf(s, { |x| libc::atol(x) });
11+
}
12+
13+
fn atoll(s: str) -> i64 {
14+
ret str::as_buf(s, { |x| libc::atoll(x) });
15+
}
16+
17+
fn main() {
18+
assert atol("1024") * 10 == atol("10240");
19+
assert (atoll("11111111111111111") * 10i64) == atoll("111111111111111110");
20+
}

0 commit comments

Comments
 (0)