Skip to content

Commit 564f5ba

Browse files
author
Eric Holk
committed
---
yaml --- r: 4452 b: refs/heads/master c: 200bbcf h: refs/heads/master v: v3
1 parent 4196342 commit 564f5ba

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
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: 244efa6331eab49fa1bf765bfd6974d512ed6719
2+
refs/heads/master: 200bbcf91b4eb190cff227127cc60a333f9c33a2

trunk/src/lib/comm.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ native "rust" mod rustrt {
2020
fn new_port(unit_sz : uint) -> *rust_port;
2121
fn del_port(po : *rust_port);
2222
fn drop_port(po : *rust_port);
23-
fn port_recv(dp : *void, po : *rust_port);
23+
}
24+
25+
native "rust-intrinsic" mod rusti {
26+
fn recv[T](port : *rustrt::rust_port) -> T;
2427
}
2528

2629
resource chan_ptr(ch: *rustrt::rust_chan) {
@@ -47,9 +50,8 @@ obj _port[T](raw_port : @port_ptr) {
4750
_chan(@chan_ptr(rustrt::new_chan(**raw_port)))
4851
}
4952

50-
fn recv_into(v : &T) {
51-
rustrt::port_recv(unsafe::reinterpret_cast(ptr::addr_of(v)),
52-
**raw_port);
53+
fn recv() -> T {
54+
ret rusti::recv(**raw_port)
5355
}
5456
}
5557

trunk/src/rt/intrinsics/intrinsics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,5 @@ rust_intrinsic_addr_of(rust_task *task, void **retptr, type_desc *ty,
5858
extern "C" void
5959
rust_intrinsic_recv(rust_task *task, void **retptr, type_desc *ty,
6060
rust_port *port) {
61-
port_recv(task, (uintptr_t*)*retptr, port);
61+
port_recv(task, (uintptr_t*)retptr, port);
6262
}

trunk/src/rt/intrinsics/intrinsics.ll.in

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,9 @@ entry:
133133
ret void
134134
}
135135

136-
define linkonce_odr void @rust_intrinsic_recv(%struct.rust_task* %task, i8** nocapture %retptr, %struct.type_desc* nocapture %ty, %class.rust_port* %port) {
136+
define linkonce_odr void @rust_intrinsic_recv(%struct.rust_task* %task, i8** %retptr, %struct.type_desc* nocapture %ty, %class.rust_port* %port) {
137137
entry:
138-
%tmp2 = load i8** %retptr, align 4, !tbaa !3
139-
%0 = bitcast i8* %tmp2 to i32*
138+
%0 = bitcast i8** %retptr to i32*
140139
tail call void @port_recv(%struct.rust_task* %task, i32* %0, %class.rust_port* %port)
141140
ret void
142141
}

trunk/src/test/stdtest/comm.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ fn send_recv() {
1313
let c = p.mk_chan();
1414

1515
c.send(42);
16-
let v = 0;
17-
p.recv_into(v);
18-
16+
let v = p.recv();
17+
log_err v;
1918
assert(42 == v);
20-
}
19+
}

0 commit comments

Comments
 (0)