preliminary work on making future's sendable

also various improvements to the ptr casting fns:
- rename assimilate() to to_unsafe_ptr() (fixes #3110)
- introduce `unsafe::copy_lifetime()` to copy the lifetime from one ptr to another
This commit is contained in:
Niko Matsakis 2012-08-27 16:08:17 -07:00
parent ff513b1bcd
commit 0a01d82f6f
4 changed files with 89 additions and 29 deletions

View file

@ -21,8 +21,8 @@
*/
import libc::size_t;
import ptr::assimilate;
import comm = core::comm;
import ptr::to_unsafe_ptr;
// libuv struct mappings
type uv_ip4_addr = {
@ -824,7 +824,7 @@ unsafe fn ip4_name(src: &sockaddr_in) -> ~str {
let dst: ~[u8] = ~[0u8,0u8,0u8,0u8,0u8,0u8,0u8,0u8,
0u8,0u8,0u8,0u8,0u8,0u8,0u8,0u8];
do vec::as_buf(dst) |dst_buf, size| {
rustrt::rust_uv_ip4_name(assimilate(src),
rustrt::rust_uv_ip4_name(to_unsafe_ptr(src),
dst_buf, size as libc::size_t);
// seems that checking the result of uv_ip4_name
// doesn't work too well..
@ -844,7 +844,7 @@ unsafe fn ip6_name(src: &sockaddr_in6) -> ~str {
0u8,0u8,0u8,0u8,0u8,0u8,0u8,0u8,
0u8,0u8,0u8,0u8,0u8,0u8];
do vec::as_buf(dst) |dst_buf, size| {
let src_unsafe_ptr = assimilate(src);
let src_unsafe_ptr = to_unsafe_ptr(src);
log(debug, fmt!("val of src *sockaddr_in6: %? sockaddr_in6: %?",
src_unsafe_ptr, src));
let result = rustrt::rust_uv_ip6_name(src_unsafe_ptr,