librustc: Remove ptr::addr_of.
This commit is contained in:
@@ -14,7 +14,6 @@ use cast::transmute;
|
|||||||
use kinds::Copy;
|
use kinds::Copy;
|
||||||
use old_iter;
|
use old_iter;
|
||||||
use option::Option;
|
use option::Option;
|
||||||
use ptr::addr_of;
|
|
||||||
use sys;
|
use sys;
|
||||||
use uint;
|
use uint;
|
||||||
use vec;
|
use vec;
|
||||||
@@ -40,8 +39,7 @@ pub mod rustrt {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn capacity<T>(v: @[T]) -> uint {
|
pub fn capacity<T>(v: @[T]) -> uint {
|
||||||
unsafe {
|
unsafe {
|
||||||
let repr: **raw::VecRepr =
|
let repr: **raw::VecRepr = transmute(&v);
|
||||||
::cast::transmute(addr_of(&v));
|
|
||||||
(**repr).unboxed.alloc / sys::size_of::<T>()
|
(**repr).unboxed.alloc / sys::size_of::<T>()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -189,11 +187,10 @@ pub mod raw {
|
|||||||
use at_vec::{capacity, rustrt};
|
use at_vec::{capacity, rustrt};
|
||||||
use cast::transmute;
|
use cast::transmute;
|
||||||
use libc;
|
use libc;
|
||||||
use unstable::intrinsics::{move_val_init};
|
|
||||||
use ptr::addr_of;
|
|
||||||
use ptr;
|
use ptr;
|
||||||
use sys;
|
use sys;
|
||||||
use uint;
|
use uint;
|
||||||
|
use unstable::intrinsics::{move_val_init};
|
||||||
use vec;
|
use vec;
|
||||||
|
|
||||||
pub type VecRepr = vec::raw::VecRepr;
|
pub type VecRepr = vec::raw::VecRepr;
|
||||||
@@ -208,7 +205,7 @@ pub mod raw {
|
|||||||
*/
|
*/
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub unsafe fn set_len<T>(v: @[T], new_len: uint) {
|
pub unsafe fn set_len<T>(v: @[T], new_len: uint) {
|
||||||
let repr: **mut VecRepr = ::cast::transmute(addr_of(&v));
|
let repr: **mut VecRepr = transmute(&v);
|
||||||
(**repr).unboxed.fill = new_len * sys::size_of::<T>();
|
(**repr).unboxed.fill = new_len * sys::size_of::<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,7 +226,7 @@ pub mod raw {
|
|||||||
let repr: **mut VecRepr = ::cast::transmute(v);
|
let repr: **mut VecRepr = ::cast::transmute(v);
|
||||||
let fill = (**repr).unboxed.fill;
|
let fill = (**repr).unboxed.fill;
|
||||||
(**repr).unboxed.fill += sys::size_of::<T>();
|
(**repr).unboxed.fill += sys::size_of::<T>();
|
||||||
let p = addr_of(&((**repr).unboxed.data));
|
let p = &((**repr).unboxed.data);
|
||||||
let p = ptr::offset(p, fill) as *mut T;
|
let p = ptr::offset(p, fill) as *mut T;
|
||||||
move_val_init(&mut(*p), initval);
|
move_val_init(&mut(*p), initval);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -327,6 +327,7 @@ impl<T: Owned> ::clone::Clone for SharedChan<T> {
|
|||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub mod oneshot {
|
pub mod oneshot {
|
||||||
priv use core::kinds::Owned;
|
priv use core::kinds::Owned;
|
||||||
|
use ptr::to_unsafe_ptr;
|
||||||
|
|
||||||
pub fn init<T: Owned>() -> (client::Oneshot<T>, server::Oneshot<T>) {
|
pub fn init<T: Owned>() -> (client::Oneshot<T>, server::Oneshot<T>) {
|
||||||
pub use core::pipes::HasBuffer;
|
pub use core::pipes::HasBuffer;
|
||||||
@@ -341,7 +342,7 @@ pub mod oneshot {
|
|||||||
do ::core::pipes::entangle_buffer(buffer) |buffer, data| {
|
do ::core::pipes::entangle_buffer(buffer) |buffer, data| {
|
||||||
{
|
{
|
||||||
data.Oneshot.set_buffer(buffer);
|
data.Oneshot.set_buffer(buffer);
|
||||||
::ptr::addr_of(&(data.Oneshot))
|
to_unsafe_ptr(&data.Oneshot)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ pub fn deflate_bytes(bytes: &const [u8]) -> ~[u8] {
|
|||||||
let res =
|
let res =
|
||||||
rustrt::tdefl_compress_mem_to_heap(b as *c_void,
|
rustrt::tdefl_compress_mem_to_heap(b as *c_void,
|
||||||
len as size_t,
|
len as size_t,
|
||||||
ptr::addr_of(&outsz),
|
&outsz,
|
||||||
lz_norm);
|
lz_norm);
|
||||||
assert!(res as int != 0);
|
assert!(res as int != 0);
|
||||||
let out = vec::raw::from_buf_raw(res as *u8,
|
let out = vec::raw::from_buf_raw(res as *u8,
|
||||||
@@ -71,7 +71,7 @@ pub fn inflate_bytes(bytes: &const [u8]) -> ~[u8] {
|
|||||||
let res =
|
let res =
|
||||||
rustrt::tinfl_decompress_mem_to_heap(b as *c_void,
|
rustrt::tinfl_decompress_mem_to_heap(b as *c_void,
|
||||||
len as size_t,
|
len as size_t,
|
||||||
ptr::addr_of(&outsz),
|
&outsz,
|
||||||
0);
|
0);
|
||||||
assert!(res as int != 0);
|
assert!(res as int != 0);
|
||||||
let out = vec::raw::from_buf_raw(res as *u8,
|
let out = vec::raw::from_buf_raw(res as *u8,
|
||||||
|
|||||||
@@ -338,7 +338,7 @@ pub fn cleanup_stack_for_failure() {
|
|||||||
// own stack roots on the stack anyway.
|
// own stack roots on the stack anyway.
|
||||||
let sentinel_box = ~0;
|
let sentinel_box = ~0;
|
||||||
let sentinel: **Word = if expect_sentinel() {
|
let sentinel: **Word = if expect_sentinel() {
|
||||||
cast::transmute(ptr::addr_of(&sentinel_box))
|
cast::transmute(&sentinel_box)
|
||||||
} else {
|
} else {
|
||||||
ptr::null()
|
ptr::null()
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
//! Operations on managed box types
|
//! Operations on managed box types
|
||||||
|
|
||||||
use ptr;
|
use ptr::to_unsafe_ptr;
|
||||||
|
|
||||||
#[cfg(notest)] use cmp::{Eq, Ord};
|
#[cfg(notest)] use cmp::{Eq, Ord};
|
||||||
|
|
||||||
@@ -38,13 +38,15 @@ pub mod raw {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn ptr_eq<T>(a: @T, b: @T) -> bool {
|
pub fn ptr_eq<T>(a: @T, b: @T) -> bool {
|
||||||
//! Determine if two shared boxes point to the same object
|
//! Determine if two shared boxes point to the same object
|
||||||
ptr::addr_of(&(*a)) == ptr::addr_of(&(*b))
|
let a_ptr: *T = to_unsafe_ptr(&*a), b_ptr: *T = to_unsafe_ptr(&*b);
|
||||||
|
a_ptr == b_ptr
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn mut_ptr_eq<T>(a: @mut T, b: @mut T) -> bool {
|
pub fn mut_ptr_eq<T>(a: @mut T, b: @mut T) -> bool {
|
||||||
//! Determine if two mutable shared boxes point to the same object
|
//! Determine if two mutable shared boxes point to the same object
|
||||||
ptr::addr_of(&(*a)) == ptr::addr_of(&(*b))
|
let a_ptr: *T = to_unsafe_ptr(&*a), b_ptr: *T = to_unsafe_ptr(&*b);
|
||||||
|
a_ptr == b_ptr
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ use num::Zero;
|
|||||||
use old_iter::{BaseIter, MutableIter, ExtendedIter};
|
use old_iter::{BaseIter, MutableIter, ExtendedIter};
|
||||||
use old_iter;
|
use old_iter;
|
||||||
|
|
||||||
#[cfg(test)] use ptr;
|
|
||||||
#[cfg(test)] use str;
|
#[cfg(test)] use str;
|
||||||
|
|
||||||
/// The option type
|
/// The option type
|
||||||
@@ -481,12 +480,14 @@ pub impl<T:Copy + Zero> Option<T> {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_unwrap_ptr() {
|
fn test_unwrap_ptr() {
|
||||||
let x = ~0;
|
unsafe {
|
||||||
let addr_x = ptr::addr_of(&(*x));
|
let x = ~0;
|
||||||
let opt = Some(x);
|
let addr_x: *int = transmute(&*x);
|
||||||
let y = opt.unwrap();
|
let opt = Some(x);
|
||||||
let addr_y = ptr::addr_of(&(*y));
|
let y = opt.unwrap();
|
||||||
assert!(addr_x == addr_y);
|
let addr_y: *int = transmute(&*y);
|
||||||
|
assert!(addr_x == addr_y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ use vec;
|
|||||||
static SPIN_COUNT: uint = 0;
|
static SPIN_COUNT: uint = 0;
|
||||||
|
|
||||||
macro_rules! move_it (
|
macro_rules! move_it (
|
||||||
{ $x:expr } => ( unsafe { let y = *ptr::addr_of(&($x)); y } )
|
{ $x:expr } => ( unsafe { let y = *ptr::to_unsafe_ptr(&($x)); y } )
|
||||||
)
|
)
|
||||||
|
|
||||||
#[deriving(Eq)]
|
#[deriving(Eq)]
|
||||||
@@ -218,7 +218,7 @@ fn unibuffer<T>() -> ~Buffer<Packet<T>> {
|
|||||||
|
|
||||||
pub fn packet<T>() -> *Packet<T> {
|
pub fn packet<T>() -> *Packet<T> {
|
||||||
let b = unibuffer();
|
let b = unibuffer();
|
||||||
let p = ptr::addr_of(&(b.data));
|
let p = ptr::to_unsafe_ptr(&(b.data));
|
||||||
// We'll take over memory management from here.
|
// We'll take over memory management from here.
|
||||||
unsafe { forget(b) }
|
unsafe { forget(b) }
|
||||||
p
|
p
|
||||||
@@ -305,7 +305,7 @@ impl<T> ::ops::Drop for BufferResource<T> {
|
|||||||
fn finalize(&self) {
|
fn finalize(&self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let b = move_it!(self.buffer);
|
let b = move_it!(self.buffer);
|
||||||
//let p = ptr::addr_of(*b);
|
//let p = ptr::to_unsafe_ptr(*b);
|
||||||
//error!("drop %?", p);
|
//error!("drop %?", p);
|
||||||
let old_count = intrinsics::atomic_xsub_rel(&mut b.header.ref_count, 1);
|
let old_count = intrinsics::atomic_xsub_rel(&mut b.header.ref_count, 1);
|
||||||
//let old_count = atomic_xchng_rel(b.header.ref_count, 0);
|
//let old_count = atomic_xchng_rel(b.header.ref_count, 0);
|
||||||
@@ -322,7 +322,7 @@ impl<T> ::ops::Drop for BufferResource<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn BufferResource<T>(b: ~Buffer<T>) -> BufferResource<T> {
|
fn BufferResource<T>(b: ~Buffer<T>) -> BufferResource<T> {
|
||||||
//let p = ptr::addr_of(*b);
|
//let p = ptr::to_unsafe_ptr(*b);
|
||||||
//error!("take %?", p);
|
//error!("take %?", p);
|
||||||
unsafe { intrinsics::atomic_xadd_acq(&mut b.header.ref_count, 1) };
|
unsafe { intrinsics::atomic_xadd_acq(&mut b.header.ref_count, 1) };
|
||||||
|
|
||||||
@@ -336,7 +336,7 @@ pub fn send<T,Tbuffer>(p: SendPacketBuffered<T,Tbuffer>, payload: T) -> bool {
|
|||||||
let header = p.header();
|
let header = p.header();
|
||||||
let p_ = p.unwrap();
|
let p_ = p.unwrap();
|
||||||
let p = unsafe { &*p_ };
|
let p = unsafe { &*p_ };
|
||||||
assert!(ptr::addr_of(&(p.header)) == header);
|
assert!(ptr::to_unsafe_ptr(&(p.header)) == header);
|
||||||
assert!(p.payload.is_none());
|
assert!(p.payload.is_none());
|
||||||
p.payload = Some(payload);
|
p.payload = Some(payload);
|
||||||
let old_state = swap_state_rel(&mut p.header.state, Full);
|
let old_state = swap_state_rel(&mut p.header.state, Full);
|
||||||
@@ -356,7 +356,7 @@ pub fn send<T,Tbuffer>(p: SendPacketBuffered<T,Tbuffer>, payload: T) -> bool {
|
|||||||
unsafe {
|
unsafe {
|
||||||
rustrt::task_signal_event(
|
rustrt::task_signal_event(
|
||||||
old_task,
|
old_task,
|
||||||
ptr::addr_of(&(p.header)) as *libc::c_void);
|
ptr::to_unsafe_ptr(&(p.header)) as *libc::c_void);
|
||||||
rustrt::rust_task_deref(old_task);
|
rustrt::rust_task_deref(old_task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -521,7 +521,7 @@ fn sender_terminate<T:Owned>(p: *Packet<T>) {
|
|||||||
unsafe {
|
unsafe {
|
||||||
rustrt::task_signal_event(
|
rustrt::task_signal_event(
|
||||||
old_task,
|
old_task,
|
||||||
ptr::addr_of(&(p.header)) as *libc::c_void);
|
ptr::to_unsafe_ptr(&(p.header)) as *libc::c_void);
|
||||||
rustrt::rust_task_deref(old_task);
|
rustrt::rust_task_deref(old_task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -665,7 +665,7 @@ pub fn SendPacketBuffered<T,Tbuffer>(p: *Packet<T>)
|
|||||||
p: Some(p),
|
p: Some(p),
|
||||||
buffer: unsafe {
|
buffer: unsafe {
|
||||||
Some(BufferResource(
|
Some(BufferResource(
|
||||||
get_buffer(ptr::addr_of(&((*p).header)))))
|
get_buffer(ptr::to_unsafe_ptr(&((*p).header)))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -681,7 +681,7 @@ pub impl<T,Tbuffer> SendPacketBuffered<T,Tbuffer> {
|
|||||||
match self.p {
|
match self.p {
|
||||||
Some(packet) => unsafe {
|
Some(packet) => unsafe {
|
||||||
let packet = &*packet;
|
let packet = &*packet;
|
||||||
let header = ptr::addr_of(&(packet.header));
|
let header = ptr::to_unsafe_ptr(&(packet.header));
|
||||||
//forget(packet);
|
//forget(packet);
|
||||||
header
|
header
|
||||||
},
|
},
|
||||||
@@ -747,7 +747,7 @@ impl<T:Owned,Tbuffer:Owned> Selectable for RecvPacketBuffered<T, Tbuffer> {
|
|||||||
match self.p {
|
match self.p {
|
||||||
Some(packet) => unsafe {
|
Some(packet) => unsafe {
|
||||||
let packet = &*packet;
|
let packet = &*packet;
|
||||||
let header = ptr::addr_of(&(packet.header));
|
let header = ptr::to_unsafe_ptr(&(packet.header));
|
||||||
//forget(packet);
|
//forget(packet);
|
||||||
header
|
header
|
||||||
},
|
},
|
||||||
@@ -763,7 +763,7 @@ pub fn RecvPacketBuffered<T,Tbuffer>(p: *Packet<T>)
|
|||||||
p: Some(p),
|
p: Some(p),
|
||||||
buffer: unsafe {
|
buffer: unsafe {
|
||||||
Some(BufferResource(
|
Some(BufferResource(
|
||||||
get_buffer(ptr::addr_of(&((*p).header)))))
|
get_buffer(ptr::to_unsafe_ptr(&((*p).header)))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,17 +39,6 @@ pub mod libc_ {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod rusti {
|
|
||||||
#[abi = "rust-intrinsic"]
|
|
||||||
pub extern "rust-intrinsic" {
|
|
||||||
fn addr_of<T>(&&val: T) -> *T;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get an unsafe pointer to a value
|
|
||||||
#[inline(always)]
|
|
||||||
pub fn addr_of<T>(val: &T) -> *T { unsafe { rusti::addr_of(*val) } }
|
|
||||||
|
|
||||||
/// Calculate the offset from a pointer
|
/// Calculate the offset from a pointer
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn offset<T>(ptr: *T, count: uint) -> *T {
|
pub fn offset<T>(ptr: *T, count: uint) -> *T {
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ pub unsafe fn async_send(async_handle: *uv_async_t) {
|
|||||||
}
|
}
|
||||||
pub unsafe fn buf_init(input: *u8, len: uint) -> uv_buf_t {
|
pub unsafe fn buf_init(input: *u8, len: uint) -> uv_buf_t {
|
||||||
let out_buf = uv_buf_t { base: ptr::null(), len: 0 as size_t };
|
let out_buf = uv_buf_t { base: ptr::null(), len: 0 as size_t };
|
||||||
let out_buf_ptr = ptr::addr_of(&out_buf);
|
let out_buf_ptr = ptr::to_unsafe_ptr(&out_buf);
|
||||||
rust_uv_buf_init(out_buf_ptr, input, len as size_t);
|
rust_uv_buf_init(out_buf_ptr, input, len as size_t);
|
||||||
return out_buf;
|
return out_buf;
|
||||||
}
|
}
|
||||||
@@ -330,7 +330,7 @@ pub unsafe fn free_base_of_buf(buf: uv_buf_t) {
|
|||||||
|
|
||||||
pub unsafe fn get_last_err_info(uv_loop: *c_void) -> ~str {
|
pub unsafe fn get_last_err_info(uv_loop: *c_void) -> ~str {
|
||||||
let err = last_error(uv_loop);
|
let err = last_error(uv_loop);
|
||||||
let err_ptr = ptr::addr_of(&err);
|
let err_ptr = ptr::to_unsafe_ptr(&err);
|
||||||
let err_name = str::raw::from_c_str(err_name(err_ptr));
|
let err_name = str::raw::from_c_str(err_name(err_ptr));
|
||||||
let err_msg = str::raw::from_c_str(strerror(err_ptr));
|
let err_msg = str::raw::from_c_str(strerror(err_ptr));
|
||||||
return fmt!("LIBUV ERROR: name: %s msg: %s",
|
return fmt!("LIBUV ERROR: name: %s msg: %s",
|
||||||
@@ -339,7 +339,7 @@ pub unsafe fn get_last_err_info(uv_loop: *c_void) -> ~str {
|
|||||||
|
|
||||||
pub unsafe fn get_last_err_data(uv_loop: *c_void) -> uv_err_data {
|
pub unsafe fn get_last_err_data(uv_loop: *c_void) -> uv_err_data {
|
||||||
let err = last_error(uv_loop);
|
let err = last_error(uv_loop);
|
||||||
let err_ptr = ptr::addr_of(&err);
|
let err_ptr = ptr::to_unsafe_ptr(&err);
|
||||||
let err_name = str::raw::from_c_str(err_name(err_ptr));
|
let err_name = str::raw::from_c_str(err_name(err_ptr));
|
||||||
let err_msg = str::raw::from_c_str(strerror(err_ptr));
|
let err_msg = str::raw::from_c_str(strerror(err_ptr));
|
||||||
uv_err_data { err_name: err_name, err_msg: err_msg }
|
uv_err_data { err_name: err_name, err_msg: err_msg }
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use at_vec;
|
use at_vec;
|
||||||
|
use cast::transmute;
|
||||||
use cast;
|
use cast;
|
||||||
use char;
|
use char;
|
||||||
use clone::Clone;
|
use clone::Clone;
|
||||||
@@ -2045,7 +2046,7 @@ pub fn as_c_str<T>(s: &str, f: &fn(*libc::c_char) -> T) -> T {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn as_buf<T>(s: &str, f: &fn(*u8, uint) -> T) -> T {
|
pub fn as_buf<T>(s: &str, f: &fn(*u8, uint) -> T) -> T {
|
||||||
unsafe {
|
unsafe {
|
||||||
let v : *(*u8,uint) = ::cast::transmute(ptr::addr_of(&s));
|
let v : *(*u8,uint) = transmute(&s);
|
||||||
let (buf,len) = *v;
|
let (buf,len) = *v;
|
||||||
f(buf, len)
|
f(buf, len)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1028,10 +1028,10 @@ fn avoid_copying_the_body(spawnfn: &fn(v: ~fn())) {
|
|||||||
let (p, ch) = stream::<uint>();
|
let (p, ch) = stream::<uint>();
|
||||||
|
|
||||||
let x = ~1;
|
let x = ~1;
|
||||||
let x_in_parent = ptr::addr_of(&(*x)) as uint;
|
let x_in_parent = ptr::to_unsafe_ptr(&*x) as uint;
|
||||||
|
|
||||||
do spawnfn || {
|
do spawnfn || {
|
||||||
let x_in_child = ptr::addr_of(&(*x)) as uint;
|
let x_in_child = ptr::to_unsafe_ptr(&*x) as uint;
|
||||||
ch.send(x_in_child);
|
ch.send(x_in_child);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ use util;
|
|||||||
#[cfg(test)] use task::default_task_opts;
|
#[cfg(test)] use task::default_task_opts;
|
||||||
|
|
||||||
macro_rules! move_it (
|
macro_rules! move_it (
|
||||||
{ $x:expr } => ( unsafe { let y = *ptr::addr_of(&($x)); y } )
|
{ $x:expr } => ( unsafe { let y = *ptr::to_unsafe_ptr(&($x)); y } )
|
||||||
)
|
)
|
||||||
|
|
||||||
type TaskSet = HashSet<*rust_task>;
|
type TaskSet = HashSet<*rust_task>;
|
||||||
|
|||||||
@@ -48,8 +48,6 @@ pub extern "rust-intrinsic" {
|
|||||||
|
|
||||||
// XXX: intrinsic uses legacy modes
|
// XXX: intrinsic uses legacy modes
|
||||||
fn reinterpret_cast<T,U>(&&src: T) -> U;
|
fn reinterpret_cast<T,U>(&&src: T) -> U;
|
||||||
// XXX: intrinsic uses legacy modes
|
|
||||||
fn addr_of<T>(&&scr: T) -> *T;
|
|
||||||
|
|
||||||
pub fn needs_drop<T>() -> bool;
|
pub fn needs_drop<T>() -> bool;
|
||||||
|
|
||||||
|
|||||||
@@ -26,11 +26,11 @@ use iterator::Iterator;
|
|||||||
use kinds::Copy;
|
use kinds::Copy;
|
||||||
use libc;
|
use libc;
|
||||||
use option::{None, Option, Some};
|
use option::{None, Option, Some};
|
||||||
use unstable::intrinsics;
|
use ptr::to_unsafe_ptr;
|
||||||
use ptr;
|
use ptr;
|
||||||
use ptr::addr_of;
|
|
||||||
use sys;
|
use sys;
|
||||||
use uint;
|
use uint;
|
||||||
|
use unstable::intrinsics;
|
||||||
use vec;
|
use vec;
|
||||||
|
|
||||||
#[cfg(notest)] use cmp::Equiv;
|
#[cfg(notest)] use cmp::Equiv;
|
||||||
@@ -117,7 +117,7 @@ pub fn reserve_at_least<T>(v: &mut ~[T], n: uint) {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn capacity<T>(v: &const ~[T]) -> uint {
|
pub fn capacity<T>(v: &const ~[T]) -> uint {
|
||||||
unsafe {
|
unsafe {
|
||||||
let repr: **raw::VecRepr = ::cast::transmute(v);
|
let repr: **raw::VecRepr = transmute(v);
|
||||||
(**repr).unboxed.alloc / sys::nonzero_size_of::<T>()
|
(**repr).unboxed.alloc / sys::nonzero_size_of::<T>()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -131,7 +131,7 @@ pub fn len<T>(v: &const [T]) -> uint {
|
|||||||
// A botch to tide us over until core and std are fully demuted.
|
// A botch to tide us over until core and std are fully demuted.
|
||||||
pub fn uniq_len<T>(v: &const ~[T]) -> uint {
|
pub fn uniq_len<T>(v: &const ~[T]) -> uint {
|
||||||
unsafe {
|
unsafe {
|
||||||
let v: &~[T] = ::cast::transmute(v);
|
let v: &~[T] = transmute(v);
|
||||||
as_const_buf(*v, |_p, len| len)
|
as_const_buf(*v, |_p, len| len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -280,9 +280,8 @@ pub fn slice<'r,T>(v: &'r [T], start: uint, end: uint) -> &'r [T] {
|
|||||||
assert!(end <= len(v));
|
assert!(end <= len(v));
|
||||||
do as_imm_buf(v) |p, _len| {
|
do as_imm_buf(v) |p, _len| {
|
||||||
unsafe {
|
unsafe {
|
||||||
::cast::transmute(
|
transmute((ptr::offset(p, start),
|
||||||
(ptr::offset(p, start),
|
(end - start) * sys::nonzero_size_of::<T>()))
|
||||||
(end - start) * sys::nonzero_size_of::<T>()))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -295,9 +294,8 @@ pub fn mut_slice<'r,T>(v: &'r mut [T], start: uint, end: uint)
|
|||||||
assert!(end <= v.len());
|
assert!(end <= v.len());
|
||||||
do as_mut_buf(v) |p, _len| {
|
do as_mut_buf(v) |p, _len| {
|
||||||
unsafe {
|
unsafe {
|
||||||
::cast::transmute(
|
transmute((ptr::mut_offset(p, start),
|
||||||
(ptr::mut_offset(p, start),
|
(end - start) * sys::nonzero_size_of::<T>()))
|
||||||
(end - start) * sys::nonzero_size_of::<T>()))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -310,9 +308,8 @@ pub fn const_slice<'r,T>(v: &'r const [T], start: uint, end: uint)
|
|||||||
assert!(end <= len(v));
|
assert!(end <= len(v));
|
||||||
do as_const_buf(v) |p, _len| {
|
do as_const_buf(v) |p, _len| {
|
||||||
unsafe {
|
unsafe {
|
||||||
::cast::transmute(
|
transmute((ptr::const_offset(p, start),
|
||||||
(ptr::const_offset(p, start),
|
(end - start) * sys::nonzero_size_of::<T>()))
|
||||||
(end - start) * sys::nonzero_size_of::<T>()))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -489,14 +486,14 @@ pub fn shift<T>(v: &mut ~[T]) -> T {
|
|||||||
{
|
{
|
||||||
let first_slice = slice(*v, 0, 1);
|
let first_slice = slice(*v, 0, 1);
|
||||||
let last_slice = slice(*v, next_ln, ln);
|
let last_slice = slice(*v, next_ln, ln);
|
||||||
raw::copy_memory(::cast::transmute(last_slice), first_slice, 1);
|
raw::copy_memory(transmute(last_slice), first_slice, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Memcopy everything to the left one element
|
// Memcopy everything to the left one element
|
||||||
{
|
{
|
||||||
let init_slice = slice(*v, 0, next_ln);
|
let init_slice = slice(*v, 0, next_ln);
|
||||||
let tail_slice = slice(*v, 1, ln);
|
let tail_slice = slice(*v, 1, ln);
|
||||||
raw::copy_memory(::cast::transmute(init_slice),
|
raw::copy_memory(transmute(init_slice),
|
||||||
tail_slice,
|
tail_slice,
|
||||||
next_ln);
|
next_ln);
|
||||||
}
|
}
|
||||||
@@ -626,7 +623,7 @@ pub fn swap_remove<T>(v: &mut ~[T], index: uint) -> T {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn push<T>(v: &mut ~[T], initval: T) {
|
pub fn push<T>(v: &mut ~[T], initval: T) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let repr: **raw::VecRepr = ::cast::transmute(&mut *v);
|
let repr: **raw::VecRepr = transmute(&mut *v);
|
||||||
let fill = (**repr).unboxed.fill;
|
let fill = (**repr).unboxed.fill;
|
||||||
if (**repr).unboxed.alloc > fill {
|
if (**repr).unboxed.alloc > fill {
|
||||||
push_fast(v, initval);
|
push_fast(v, initval);
|
||||||
@@ -640,10 +637,10 @@ pub fn push<T>(v: &mut ~[T], initval: T) {
|
|||||||
// This doesn't bother to make sure we have space.
|
// This doesn't bother to make sure we have space.
|
||||||
#[inline(always)] // really pretty please
|
#[inline(always)] // really pretty please
|
||||||
unsafe fn push_fast<T>(v: &mut ~[T], initval: T) {
|
unsafe fn push_fast<T>(v: &mut ~[T], initval: T) {
|
||||||
let repr: **mut raw::VecRepr = ::cast::transmute(v);
|
let repr: **mut raw::VecRepr = transmute(v);
|
||||||
let fill = (**repr).unboxed.fill;
|
let fill = (**repr).unboxed.fill;
|
||||||
(**repr).unboxed.fill += sys::nonzero_size_of::<T>();
|
(**repr).unboxed.fill += sys::nonzero_size_of::<T>();
|
||||||
let p = addr_of(&((**repr).unboxed.data));
|
let p = to_unsafe_ptr(&((**repr).unboxed.data));
|
||||||
let p = ptr::offset(p, fill) as *mut T;
|
let p = ptr::offset(p, fill) as *mut T;
|
||||||
intrinsics::move_val_init(&mut(*p), initval);
|
intrinsics::move_val_init(&mut(*p), initval);
|
||||||
}
|
}
|
||||||
@@ -1622,8 +1619,7 @@ pub fn as_imm_buf<T,U>(s: &[T],
|
|||||||
// instead!
|
// instead!
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let v : *(*T,uint) =
|
let v : *(*T,uint) = transmute(&s);
|
||||||
::cast::transmute(addr_of(&s));
|
|
||||||
let (buf,len) = *v;
|
let (buf,len) = *v;
|
||||||
f(buf, len / sys::nonzero_size_of::<T>())
|
f(buf, len / sys::nonzero_size_of::<T>())
|
||||||
}
|
}
|
||||||
@@ -1633,8 +1629,7 @@ pub fn as_imm_buf<T,U>(s: &[T],
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn as_const_buf<T,U>(s: &const [T], f: &fn(*const T, uint) -> U) -> U {
|
pub fn as_const_buf<T,U>(s: &const [T], f: &fn(*const T, uint) -> U) -> U {
|
||||||
unsafe {
|
unsafe {
|
||||||
let v : *(*const T,uint) =
|
let v : *(*const T,uint) = transmute(&s);
|
||||||
::cast::transmute(addr_of(&s));
|
|
||||||
let (buf,len) = *v;
|
let (buf,len) = *v;
|
||||||
f(buf, len / sys::nonzero_size_of::<T>())
|
f(buf, len / sys::nonzero_size_of::<T>())
|
||||||
}
|
}
|
||||||
@@ -1644,8 +1639,7 @@ pub fn as_const_buf<T,U>(s: &const [T], f: &fn(*const T, uint) -> U) -> U {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn as_mut_buf<T,U>(s: &mut [T], f: &fn(*mut T, uint) -> U) -> U {
|
pub fn as_mut_buf<T,U>(s: &mut [T], f: &fn(*mut T, uint) -> U) -> U {
|
||||||
unsafe {
|
unsafe {
|
||||||
let v : *(*mut T,uint) =
|
let v : *(*mut T,uint) = transmute(&s);
|
||||||
::cast::transmute(addr_of(&s));
|
|
||||||
let (buf,len) = *v;
|
let (buf,len) = *v;
|
||||||
f(buf, len / sys::nonzero_size_of::<T>())
|
f(buf, len / sys::nonzero_size_of::<T>())
|
||||||
}
|
}
|
||||||
@@ -2429,13 +2423,13 @@ pub struct UnboxedVecRepr {
|
|||||||
|
|
||||||
/// Unsafe operations
|
/// Unsafe operations
|
||||||
pub mod raw {
|
pub mod raw {
|
||||||
|
use cast::transmute;
|
||||||
use kinds::Copy;
|
use kinds::Copy;
|
||||||
use managed;
|
use managed;
|
||||||
use option::{None, Some};
|
use option::{None, Some};
|
||||||
use unstable::intrinsics;
|
|
||||||
use ptr::addr_of;
|
|
||||||
use ptr;
|
use ptr;
|
||||||
use sys;
|
use sys;
|
||||||
|
use unstable::intrinsics;
|
||||||
use vec::{UnboxedVecRepr, as_const_buf, as_mut_buf, len, with_capacity};
|
use vec::{UnboxedVecRepr, as_const_buf, as_mut_buf, len, with_capacity};
|
||||||
|
|
||||||
/// The internal representation of a (boxed) vector
|
/// The internal representation of a (boxed) vector
|
||||||
@@ -2458,7 +2452,7 @@ pub mod raw {
|
|||||||
*/
|
*/
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub unsafe fn set_len<T>(v: &mut ~[T], new_len: uint) {
|
pub unsafe fn set_len<T>(v: &mut ~[T], new_len: uint) {
|
||||||
let repr: **mut VecRepr = ::cast::transmute(v);
|
let repr: **mut VecRepr = transmute(v);
|
||||||
(**repr).unboxed.fill = new_len * sys::nonzero_size_of::<T>();
|
(**repr).unboxed.fill = new_len * sys::nonzero_size_of::<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2473,22 +2467,22 @@ pub mod raw {
|
|||||||
*/
|
*/
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub unsafe fn to_ptr<T>(v: &[T]) -> *T {
|
pub unsafe fn to_ptr<T>(v: &[T]) -> *T {
|
||||||
let repr: **SliceRepr = ::cast::transmute(&v);
|
let repr: **SliceRepr = transmute(&v);
|
||||||
::cast::transmute(addr_of(&((**repr).data)))
|
transmute(&((**repr).data))
|
||||||
}
|
}
|
||||||
|
|
||||||
/** see `to_ptr()` */
|
/** see `to_ptr()` */
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub unsafe fn to_const_ptr<T>(v: &const [T]) -> *const T {
|
pub unsafe fn to_const_ptr<T>(v: &const [T]) -> *const T {
|
||||||
let repr: **SliceRepr = ::cast::transmute(&v);
|
let repr: **SliceRepr = transmute(&v);
|
||||||
::cast::transmute(addr_of(&((**repr).data)))
|
transmute(&((**repr).data))
|
||||||
}
|
}
|
||||||
|
|
||||||
/** see `to_ptr()` */
|
/** see `to_ptr()` */
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub unsafe fn to_mut_ptr<T>(v: &mut [T]) -> *mut T {
|
pub unsafe fn to_mut_ptr<T>(v: &mut [T]) -> *mut T {
|
||||||
let repr: **SliceRepr = ::cast::transmute(&v);
|
let repr: **SliceRepr = transmute(&v);
|
||||||
::cast::transmute(addr_of(&((**repr).data)))
|
transmute(&((**repr).data))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2500,8 +2494,7 @@ pub mod raw {
|
|||||||
len: uint,
|
len: uint,
|
||||||
f: &fn(v: &[T]) -> U) -> U {
|
f: &fn(v: &[T]) -> U) -> U {
|
||||||
let pair = (p, len * sys::nonzero_size_of::<T>());
|
let pair = (p, len * sys::nonzero_size_of::<T>());
|
||||||
let v : *(&'blk [T]) =
|
let v : *(&'blk [T]) = transmute(&pair);
|
||||||
::cast::transmute(addr_of(&pair));
|
|
||||||
f(*v)
|
f(*v)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2514,8 +2507,7 @@ pub mod raw {
|
|||||||
len: uint,
|
len: uint,
|
||||||
f: &fn(v: &mut [T]) -> U) -> U {
|
f: &fn(v: &mut [T]) -> U) -> U {
|
||||||
let pair = (p, len * sys::nonzero_size_of::<T>());
|
let pair = (p, len * sys::nonzero_size_of::<T>());
|
||||||
let v : *(&'blk mut [T]) =
|
let v : *(&'blk mut [T]) = transmute(&pair);
|
||||||
::cast::transmute(addr_of(&pair));
|
|
||||||
f(*v)
|
f(*v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ use syntax::ast_util::local_def;
|
|||||||
use syntax::visit::{default_simple_visitor, mk_simple_visitor, SimpleVisitor};
|
use syntax::visit::{default_simple_visitor, mk_simple_visitor, SimpleVisitor};
|
||||||
use syntax::visit::visit_crate;
|
use syntax::visit::visit_crate;
|
||||||
|
|
||||||
|
use core::cast::transmute;
|
||||||
use core::hashmap::HashMap;
|
use core::hashmap::HashMap;
|
||||||
use core::ptr;
|
|
||||||
|
|
||||||
pub enum LangItem {
|
pub enum LangItem {
|
||||||
ConstTraitLangItem, // 0
|
ConstTraitLangItem, // 0
|
||||||
@@ -366,20 +366,22 @@ pub impl<'self> LanguageItemCollector<'self> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn collect_local_language_items(&self) {
|
fn collect_local_language_items(&self) {
|
||||||
let this = ptr::addr_of(&self);
|
unsafe {
|
||||||
visit_crate(self.crate, (), mk_simple_visitor(@SimpleVisitor {
|
let this: *LanguageItemCollector<'self> = transmute(self);
|
||||||
visit_item: |item| {
|
visit_crate(self.crate, (), mk_simple_visitor(@SimpleVisitor {
|
||||||
for item.attrs.each |attribute| {
|
visit_item: |item| {
|
||||||
unsafe {
|
for item.attrs.each |attribute| {
|
||||||
(*this).match_and_collect_meta_item(
|
unsafe {
|
||||||
local_def(item.id),
|
(*this).match_and_collect_meta_item(
|
||||||
attribute.node.value
|
local_def(item.id),
|
||||||
);
|
attribute.node.value
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
.. *default_simple_visitor()
|
||||||
.. *default_simple_visitor()
|
}));
|
||||||
}));
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collect_external_language_items(&self) {
|
fn collect_external_language_items(&self) {
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ use middle::typeck;
|
|||||||
use middle::moves;
|
use middle::moves;
|
||||||
use util::ppaux::ty_to_str;
|
use util::ppaux::ty_to_str;
|
||||||
|
|
||||||
|
use core::cast::transmute;
|
||||||
use core::hashmap::HashMap;
|
use core::hashmap::HashMap;
|
||||||
use core::util::with;
|
use core::util::with;
|
||||||
use syntax::ast::*;
|
use syntax::ast::*;
|
||||||
@@ -418,7 +419,9 @@ fn visit_fn(fk: &visit::fn_kind,
|
|||||||
self.last_use_map,
|
self.last_use_map,
|
||||||
self.cur_item);
|
self.cur_item);
|
||||||
|
|
||||||
debug!("creating fn_maps: %x", ptr::addr_of(&(*fn_maps)) as uint);
|
unsafe {
|
||||||
|
debug!("creating fn_maps: %x", transmute(&*fn_maps));
|
||||||
|
}
|
||||||
|
|
||||||
for decl.inputs.each |arg| {
|
for decl.inputs.each |arg| {
|
||||||
let mode = ty::resolved_mode(self.tcx, arg.mode);
|
let mode = ty::resolved_mode(self.tcx, arg.mode);
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ pub fn IndirectBr(cx: block, Addr: ValueRef, NumDests: uint) {
|
|||||||
pub fn noname() -> *c_char {
|
pub fn noname() -> *c_char {
|
||||||
unsafe {
|
unsafe {
|
||||||
static cnull: uint = 0u;
|
static cnull: uint = 0u;
|
||||||
return cast::transmute(ptr::addr_of(&cnull));
|
return cast::transmute(&cnull);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -827,8 +827,8 @@ pub fn Phi(cx: block, Ty: TypeRef, vals: &[ValueRef], bbs: &[BasicBlockRef])
|
|||||||
pub fn AddIncomingToPhi(phi: ValueRef, val: ValueRef, bb: BasicBlockRef) {
|
pub fn AddIncomingToPhi(phi: ValueRef, val: ValueRef, bb: BasicBlockRef) {
|
||||||
unsafe {
|
unsafe {
|
||||||
if llvm::LLVMIsUndef(phi) == lib::llvm::True { return; }
|
if llvm::LLVMIsUndef(phi) == lib::llvm::True { return; }
|
||||||
let valptr = cast::transmute(ptr::addr_of(&val));
|
let valptr = cast::transmute(&val);
|
||||||
let bbptr = cast::transmute(ptr::addr_of(&bb));
|
let bbptr = cast::transmute(&bb);
|
||||||
llvm::LLVMAddIncoming(phi, valptr, bbptr, 1 as c_uint);
|
llvm::LLVMAddIncoming(phi, valptr, bbptr, 1 as c_uint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -750,13 +750,11 @@ pub impl block_ {
|
|||||||
t.repr(self.tcx())
|
t.repr(self.tcx())
|
||||||
}
|
}
|
||||||
fn to_str(@mut self) -> ~str {
|
fn to_str(@mut self) -> ~str {
|
||||||
match self.node_info {
|
unsafe {
|
||||||
Some(node_info) => {
|
match self.node_info {
|
||||||
fmt!("[block %d]", node_info.id)
|
Some(node_info) => fmt!("[block %d]", node_info.id),
|
||||||
}
|
None => fmt!("[block %x]", transmute(&*self)),
|
||||||
None => {
|
}
|
||||||
fmt!("[block %x]", ptr::addr_of(&(*self)) as uint)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -745,9 +745,6 @@ pub fn trans_intrinsic(ccx: @CrateContext,
|
|||||||
call_memcpy(bcx, llretptr, llcast, llsize_of(ccx, lltp_ty));
|
call_memcpy(bcx, llretptr, llcast, llsize_of(ccx, lltp_ty));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
~"addr_of" => {
|
|
||||||
Store(bcx, get_param(decl, first_real_arg), fcx.llretptr.get());
|
|
||||||
}
|
|
||||||
~"needs_drop" => {
|
~"needs_drop" => {
|
||||||
let tp_ty = substs.tys[0];
|
let tp_ty = substs.tys[0];
|
||||||
Store(bcx,
|
Store(bcx,
|
||||||
|
|||||||
@@ -135,8 +135,8 @@ pub fn type_uses_for(ccx: @CrateContext, fn_id: def_id, n_tps: uint)
|
|||||||
~"atomic_xsub_acq" | ~"atomic_xchg_rel" |
|
~"atomic_xsub_acq" | ~"atomic_xchg_rel" |
|
||||||
~"atomic_xadd_rel" | ~"atomic_xsub_rel" => 0,
|
~"atomic_xadd_rel" | ~"atomic_xsub_rel" => 0,
|
||||||
|
|
||||||
~"visit_tydesc" | ~"forget" | ~"addr_of" |
|
~"visit_tydesc" | ~"forget" | ~"frame_address" |
|
||||||
~"frame_address" | ~"morestack_addr" => 0,
|
~"morestack_addr" => 0,
|
||||||
|
|
||||||
~"memmove32" | ~"memmove64" => 0,
|
~"memmove32" | ~"memmove64" => 0,
|
||||||
|
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ use util::common::{block_query, indenter, loop_query};
|
|||||||
use util::ppaux::{bound_region_to_str};
|
use util::ppaux::{bound_region_to_str};
|
||||||
use util::ppaux;
|
use util::ppaux;
|
||||||
|
|
||||||
|
use core::cast::transmute;
|
||||||
use core::hashmap::HashMap;
|
use core::hashmap::HashMap;
|
||||||
use core::util::replace;
|
use core::util::replace;
|
||||||
use std::list::Nil;
|
use std::list::Nil;
|
||||||
@@ -706,7 +707,11 @@ impl region_scope for FnCtxt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub impl FnCtxt {
|
pub impl FnCtxt {
|
||||||
fn tag(&self) -> ~str { fmt!("%x", ptr::addr_of(&(*self)) as uint) }
|
fn tag(&self) -> ~str {
|
||||||
|
unsafe {
|
||||||
|
fmt!("%x", transmute(self))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn local_ty(&self, span: span, nid: ast::node_id) -> ty::t {
|
fn local_ty(&self, span: span, nid: ast::node_id) -> ty::t {
|
||||||
match self.inh.locals.find(&nid) {
|
match self.inh.locals.find(&nid) {
|
||||||
@@ -3436,8 +3441,6 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) {
|
|||||||
ty::mk_nil()),
|
ty::mk_nil()),
|
||||||
~"reinterpret_cast" => (2u, ~[arg(ast::by_ref, param(ccx, 0u))],
|
~"reinterpret_cast" => (2u, ~[arg(ast::by_ref, param(ccx, 0u))],
|
||||||
param(ccx, 1u)),
|
param(ccx, 1u)),
|
||||||
~"addr_of" => (1u, ~[arg(ast::by_ref, param(ccx, 0u))],
|
|
||||||
ty::mk_imm_ptr(tcx, param(ccx, 0u))),
|
|
||||||
~"move_val" | ~"move_val_init" => {
|
~"move_val" | ~"move_val_init" => {
|
||||||
(1u, ~[arg(ast::by_copy,
|
(1u, ~[arg(ast::by_copy,
|
||||||
ty::mk_mut_rptr(tcx, ty::re_bound(ty::br_anon(0)),
|
ty::mk_mut_rptr(tcx, ty::re_bound(ty::br_anon(0)),
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
//! Unsafe debugging functions for inspecting values.
|
//! Unsafe debugging functions for inspecting values.
|
||||||
|
|
||||||
use core::cast::transmute;
|
use core::cast::transmute;
|
||||||
use core::ptr;
|
|
||||||
use core::sys;
|
use core::sys;
|
||||||
|
|
||||||
pub mod rustrt {
|
pub mod rustrt {
|
||||||
@@ -37,36 +36,31 @@ pub fn debug_tydesc<T>() {
|
|||||||
|
|
||||||
pub fn debug_opaque<T>(x: T) {
|
pub fn debug_opaque<T>(x: T) {
|
||||||
unsafe {
|
unsafe {
|
||||||
rustrt::debug_opaque(sys::get_type_desc::<T>(),
|
rustrt::debug_opaque(sys::get_type_desc::<T>(), transmute(&x));
|
||||||
ptr::addr_of(&x) as *());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn debug_box<T>(x: @T) {
|
pub fn debug_box<T>(x: @T) {
|
||||||
unsafe {
|
unsafe {
|
||||||
rustrt::debug_box(sys::get_type_desc::<T>(),
|
rustrt::debug_box(sys::get_type_desc::<T>(), transmute(&x));
|
||||||
ptr::addr_of(&x) as *());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn debug_tag<T>(x: T) {
|
pub fn debug_tag<T>(x: T) {
|
||||||
unsafe {
|
unsafe {
|
||||||
rustrt::debug_tag(sys::get_type_desc::<T>(),
|
rustrt::debug_tag(sys::get_type_desc::<T>(), transmute(&x));
|
||||||
ptr::addr_of(&x) as *());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn debug_fn<T>(x: T) {
|
pub fn debug_fn<T>(x: T) {
|
||||||
unsafe {
|
unsafe {
|
||||||
rustrt::debug_fn(sys::get_type_desc::<T>(),
|
rustrt::debug_fn(sys::get_type_desc::<T>(), transmute(&x));
|
||||||
ptr::addr_of(&x) as *());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn ptr_cast<T, U>(x: @T) -> @U {
|
pub unsafe fn ptr_cast<T, U>(x: @T) -> @U {
|
||||||
transmute(
|
transmute(
|
||||||
rustrt::debug_ptrcast(sys::get_type_desc::<T>(),
|
rustrt::debug_ptrcast(sys::get_type_desc::<T>(), transmute(x)))
|
||||||
transmute(x)))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Triggers a debugger breakpoint
|
/// Triggers a debugger breakpoint
|
||||||
|
|||||||
@@ -110,18 +110,18 @@ enum IpGetAddrErr {
|
|||||||
* object in the case of failure
|
* object in the case of failure
|
||||||
*/
|
*/
|
||||||
pub fn get_addr(node: &str, iotask: &iotask)
|
pub fn get_addr(node: &str, iotask: &iotask)
|
||||||
-> result::Result<~[IpAddr], IpGetAddrErr> {
|
-> result::Result<~[IpAddr], IpGetAddrErr> {
|
||||||
let (output_po, output_ch) = stream();
|
let (output_po, output_ch) = stream();
|
||||||
let mut output_ch = Some(SharedChan::new(output_ch));
|
let mut output_ch = Some(SharedChan::new(output_ch));
|
||||||
do str::as_buf(node) |node_ptr, len| {
|
do str::as_buf(node) |node_ptr, len| {
|
||||||
let output_ch = output_ch.swap_unwrap();
|
let output_ch = output_ch.swap_unwrap();
|
||||||
debug!("slice len %?", len);
|
debug!("slice len %?", len);
|
||||||
let handle = create_uv_getaddrinfo_t();
|
let handle = create_uv_getaddrinfo_t();
|
||||||
let handle_ptr = ptr::addr_of(&handle);
|
let handle_ptr: *uv_getaddrinfo_t = &handle;
|
||||||
let handle_data = GetAddrData {
|
let handle_data = GetAddrData {
|
||||||
output_ch: output_ch.clone()
|
output_ch: output_ch.clone()
|
||||||
};
|
};
|
||||||
let handle_data_ptr = ptr::addr_of(&handle_data);
|
let handle_data_ptr: *GetAddrData = &handle_data;
|
||||||
do interact(iotask) |loop_ptr| {
|
do interact(iotask) |loop_ptr| {
|
||||||
unsafe {
|
unsafe {
|
||||||
let result = uv_getaddrinfo(
|
let result = uv_getaddrinfo(
|
||||||
@@ -189,7 +189,8 @@ pub mod v4 {
|
|||||||
impl AsUnsafeU32 for Ipv4Rep {
|
impl AsUnsafeU32 for Ipv4Rep {
|
||||||
// this is pretty dastardly, i know
|
// this is pretty dastardly, i know
|
||||||
unsafe fn as_u32(&self) -> u32 {
|
unsafe fn as_u32(&self) -> u32 {
|
||||||
*((ptr::addr_of(self)) as *u32)
|
let this: &mut u32 = transmute(self);
|
||||||
|
*this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn parse_to_ipv4_rep(ip: &str) -> result::Result<Ipv4Rep, ~str> {
|
pub fn parse_to_ipv4_rep(ip: &str) -> result::Result<Ipv4Rep, ~str> {
|
||||||
@@ -297,7 +298,8 @@ struct GetAddrData {
|
|||||||
output_ch: SharedChan<result::Result<~[IpAddr],IpGetAddrErr>>
|
output_ch: SharedChan<result::Result<~[IpAddr],IpGetAddrErr>>
|
||||||
}
|
}
|
||||||
|
|
||||||
extern fn get_addr_cb(handle: *uv_getaddrinfo_t, status: libc::c_int,
|
extern fn get_addr_cb(handle: *uv_getaddrinfo_t,
|
||||||
|
status: libc::c_int,
|
||||||
res: *addrinfo) {
|
res: *addrinfo) {
|
||||||
unsafe {
|
unsafe {
|
||||||
debug!("in get_addr_cb");
|
debug!("in get_addr_cb");
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ pub fn connect(input_ip: ip::IpAddr, port: uint,
|
|||||||
result_ch: result_ch,
|
result_ch: result_ch,
|
||||||
closed_signal_ch: closed_signal_ch
|
closed_signal_ch: closed_signal_ch
|
||||||
};
|
};
|
||||||
let conn_data_ptr = ptr::addr_of(&conn_data);
|
let conn_data_ptr: *ConnectReqData = &conn_data;
|
||||||
let (reader_po, reader_ch) = stream::<Result<~[u8], TcpErrData>>();
|
let (reader_po, reader_ch) = stream::<Result<~[u8], TcpErrData>>();
|
||||||
let reader_ch = SharedChan::new(reader_ch);
|
let reader_ch = SharedChan::new(reader_ch);
|
||||||
let stream_handle_ptr = malloc_uv_tcp_t();
|
let stream_handle_ptr = malloc_uv_tcp_t();
|
||||||
@@ -173,7 +173,7 @@ pub fn connect(input_ip: ip::IpAddr, port: uint,
|
|||||||
},
|
},
|
||||||
iotask: iotask.clone()
|
iotask: iotask.clone()
|
||||||
};
|
};
|
||||||
let socket_data_ptr = ptr::addr_of(&(*socket_data));
|
let socket_data_ptr: *TcpSocketData = &*socket_data;
|
||||||
// get an unsafe representation of our stream_handle_ptr that
|
// get an unsafe representation of our stream_handle_ptr that
|
||||||
// we can send into the interact cb to be handled in libuv..
|
// we can send into the interact cb to be handled in libuv..
|
||||||
debug!("stream_handle_ptr outside interact %?",
|
debug!("stream_handle_ptr outside interact %?",
|
||||||
@@ -187,8 +187,8 @@ pub fn connect(input_ip: ip::IpAddr, port: uint,
|
|||||||
0i32 => {
|
0i32 => {
|
||||||
debug!("tcp_init successful");
|
debug!("tcp_init successful");
|
||||||
debug!("dealing w/ ipv4 connection..");
|
debug!("dealing w/ ipv4 connection..");
|
||||||
let connect_req_ptr =
|
let connect_req_ptr: *uv::ll::uv_connect_t =
|
||||||
ptr::addr_of(&((*socket_data_ptr).connect_req));
|
&(*socket_data_ptr).connect_req;
|
||||||
let addr_str = ip::format_addr(&input_ip);
|
let addr_str = ip::format_addr(&input_ip);
|
||||||
let connect_result = match input_ip {
|
let connect_result = match input_ip {
|
||||||
ip::Ipv4(ref addr) => {
|
ip::Ipv4(ref addr) => {
|
||||||
@@ -205,7 +205,7 @@ pub fn connect(input_ip: ip::IpAddr, port: uint,
|
|||||||
uv::ll::tcp_connect(
|
uv::ll::tcp_connect(
|
||||||
connect_req_ptr,
|
connect_req_ptr,
|
||||||
stream_handle_ptr,
|
stream_handle_ptr,
|
||||||
ptr::addr_of(&in_addr),
|
&in_addr,
|
||||||
tcp_connect_on_connect_cb)
|
tcp_connect_on_connect_cb)
|
||||||
}
|
}
|
||||||
ip::Ipv6(ref addr) => {
|
ip::Ipv6(ref addr) => {
|
||||||
@@ -215,7 +215,7 @@ pub fn connect(input_ip: ip::IpAddr, port: uint,
|
|||||||
uv::ll::tcp_connect6(
|
uv::ll::tcp_connect6(
|
||||||
connect_req_ptr,
|
connect_req_ptr,
|
||||||
stream_handle_ptr,
|
stream_handle_ptr,
|
||||||
ptr::addr_of(&in_addr),
|
&in_addr,
|
||||||
tcp_connect_on_connect_cb)
|
tcp_connect_on_connect_cb)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -303,9 +303,8 @@ pub fn connect(input_ip: ip::IpAddr, port: uint,
|
|||||||
* `TcpErrData` value as the `Err` variant
|
* `TcpErrData` value as the `Err` variant
|
||||||
*/
|
*/
|
||||||
pub fn write(sock: &TcpSocket, raw_write_data: ~[u8])
|
pub fn write(sock: &TcpSocket, raw_write_data: ~[u8])
|
||||||
-> result::Result<(), TcpErrData>
|
-> result::Result<(), TcpErrData> {
|
||||||
{
|
let socket_data_ptr: *TcpSocketData = &*sock.socket_data;
|
||||||
let socket_data_ptr = ptr::addr_of(&(*(sock.socket_data)));
|
|
||||||
write_common_impl(socket_data_ptr, raw_write_data)
|
write_common_impl(socket_data_ptr, raw_write_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,7 +342,7 @@ pub fn write(sock: &TcpSocket, raw_write_data: ~[u8])
|
|||||||
pub fn write_future(sock: &TcpSocket, raw_write_data: ~[u8])
|
pub fn write_future(sock: &TcpSocket, raw_write_data: ~[u8])
|
||||||
-> future::Future<result::Result<(), TcpErrData>>
|
-> future::Future<result::Result<(), TcpErrData>>
|
||||||
{
|
{
|
||||||
let socket_data_ptr = ptr::addr_of(&(*(sock.socket_data)));
|
let socket_data_ptr: *TcpSocketData = &*sock.socket_data;
|
||||||
do future_spawn {
|
do future_spawn {
|
||||||
let data_copy = copy(raw_write_data);
|
let data_copy = copy(raw_write_data);
|
||||||
write_common_impl(socket_data_ptr, data_copy)
|
write_common_impl(socket_data_ptr, data_copy)
|
||||||
@@ -366,9 +365,10 @@ pub fn write_future(sock: &TcpSocket, raw_write_data: ~[u8])
|
|||||||
* `TcpErrData` record
|
* `TcpErrData` record
|
||||||
*/
|
*/
|
||||||
pub fn read_start(sock: &TcpSocket)
|
pub fn read_start(sock: &TcpSocket)
|
||||||
-> result::Result<@Port<
|
-> result::Result<@Port<result::Result<~[u8],
|
||||||
result::Result<~[u8], TcpErrData>>, TcpErrData> {
|
TcpErrData>>,
|
||||||
let socket_data = ptr::addr_of(&(*(sock.socket_data)));
|
TcpErrData> {
|
||||||
|
let socket_data: *TcpSocketData = &*sock.socket_data;
|
||||||
read_start_common_impl(socket_data)
|
read_start_common_impl(socket_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -380,7 +380,7 @@ pub fn read_start(sock: &TcpSocket)
|
|||||||
* * `sock` - a `net::tcp::TcpSocket` that you wish to stop reading on
|
* * `sock` - a `net::tcp::TcpSocket` that you wish to stop reading on
|
||||||
*/
|
*/
|
||||||
pub fn read_stop(sock: &TcpSocket) -> result::Result<(), TcpErrData> {
|
pub fn read_stop(sock: &TcpSocket) -> result::Result<(), TcpErrData> {
|
||||||
let socket_data = ptr::addr_of(&(*sock.socket_data));
|
let socket_data: *TcpSocketData = &*sock.socket_data;
|
||||||
read_stop_common_impl(socket_data)
|
read_stop_common_impl(socket_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -400,8 +400,8 @@ pub fn read_stop(sock: &TcpSocket) -> result::Result<(), TcpErrData> {
|
|||||||
* read attempt. Pass `0u` to wait indefinitely
|
* read attempt. Pass `0u` to wait indefinitely
|
||||||
*/
|
*/
|
||||||
pub fn read(sock: &TcpSocket, timeout_msecs: uint)
|
pub fn read(sock: &TcpSocket, timeout_msecs: uint)
|
||||||
-> result::Result<~[u8],TcpErrData> {
|
-> result::Result<~[u8],TcpErrData> {
|
||||||
let socket_data = ptr::addr_of(&(*(sock.socket_data)));
|
let socket_data: *TcpSocketData = &*sock.socket_data;
|
||||||
read_common_impl(socket_data, timeout_msecs)
|
read_common_impl(socket_data, timeout_msecs)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -435,8 +435,8 @@ pub fn read(sock: &TcpSocket, timeout_msecs: uint)
|
|||||||
* read attempt. Pass `0u` to wait indefinitely
|
* read attempt. Pass `0u` to wait indefinitely
|
||||||
*/
|
*/
|
||||||
fn read_future(sock: &TcpSocket, timeout_msecs: uint)
|
fn read_future(sock: &TcpSocket, timeout_msecs: uint)
|
||||||
-> future::Future<result::Result<~[u8],TcpErrData>> {
|
-> future::Future<result::Result<~[u8],TcpErrData>> {
|
||||||
let socket_data = ptr::addr_of(&(*(sock.socket_data)));
|
let socket_data: *TcpSocketData = &*sock.socket_data;
|
||||||
do future_spawn {
|
do future_spawn {
|
||||||
read_common_impl(socket_data, timeout_msecs)
|
read_common_impl(socket_data, timeout_msecs)
|
||||||
}
|
}
|
||||||
@@ -534,8 +534,8 @@ pub fn accept(new_conn: TcpNewConnection)
|
|||||||
ipv6: (*server_data_ptr).ipv6,
|
ipv6: (*server_data_ptr).ipv6,
|
||||||
iotask : iotask.clone()
|
iotask : iotask.clone()
|
||||||
};
|
};
|
||||||
let client_socket_data_ptr = ptr::addr_of(
|
let client_socket_data_ptr: *TcpSocketData =
|
||||||
&(*client_socket_data));
|
&*client_socket_data;
|
||||||
let client_stream_handle_ptr =
|
let client_stream_handle_ptr =
|
||||||
(*client_socket_data_ptr).stream_handle_ptr;
|
(*client_socket_data_ptr).stream_handle_ptr;
|
||||||
|
|
||||||
@@ -661,7 +661,7 @@ fn listen_common(host_ip: ip::IpAddr,
|
|||||||
let (kill_po, kill_ch) = stream::<Option<TcpErrData>>();
|
let (kill_po, kill_ch) = stream::<Option<TcpErrData>>();
|
||||||
let kill_ch = SharedChan::new(kill_ch);
|
let kill_ch = SharedChan::new(kill_ch);
|
||||||
let server_stream = uv::ll::tcp_t();
|
let server_stream = uv::ll::tcp_t();
|
||||||
let server_stream_ptr = ptr::addr_of(&server_stream);
|
let server_stream_ptr: *uv::ll::uv_tcp_t = &server_stream;
|
||||||
let server_data: TcpListenFcData = TcpListenFcData {
|
let server_data: TcpListenFcData = TcpListenFcData {
|
||||||
server_stream_ptr: server_stream_ptr,
|
server_stream_ptr: server_stream_ptr,
|
||||||
stream_closed_ch: stream_closed_ch,
|
stream_closed_ch: stream_closed_ch,
|
||||||
@@ -674,7 +674,7 @@ fn listen_common(host_ip: ip::IpAddr,
|
|||||||
},
|
},
|
||||||
mut active: true
|
mut active: true
|
||||||
};
|
};
|
||||||
let server_data_ptr = ptr::addr_of(&server_data);
|
let server_data_ptr: *TcpListenFcData = &server_data;
|
||||||
|
|
||||||
let (setup_po, setup_ch) = stream();
|
let (setup_po, setup_ch) = stream();
|
||||||
|
|
||||||
@@ -699,16 +699,14 @@ fn listen_common(host_ip: ip::IpAddr,
|
|||||||
let in_addr = uv::ll::ip4_addr(
|
let in_addr = uv::ll::ip4_addr(
|
||||||
addr_str,
|
addr_str,
|
||||||
port as int);
|
port as int);
|
||||||
uv::ll::tcp_bind(server_stream_ptr,
|
uv::ll::tcp_bind(server_stream_ptr, &in_addr)
|
||||||
ptr::addr_of(&in_addr))
|
|
||||||
}
|
}
|
||||||
ip::Ipv6(ref addr) => {
|
ip::Ipv6(ref addr) => {
|
||||||
debug!("addr: %?", addr);
|
debug!("addr: %?", addr);
|
||||||
let in_addr = uv::ll::ip6_addr(
|
let in_addr = uv::ll::ip6_addr(
|
||||||
addr_str,
|
addr_str,
|
||||||
port as int);
|
port as int);
|
||||||
uv::ll::tcp_bind6(server_stream_ptr,
|
uv::ll::tcp_bind6(server_stream_ptr, &in_addr)
|
||||||
ptr::addr_of(&in_addr))
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
match bind_result {
|
match bind_result {
|
||||||
@@ -856,12 +854,12 @@ pub impl TcpSocket {
|
|||||||
if self.socket_data.ipv6 {
|
if self.socket_data.ipv6 {
|
||||||
let addr = uv::ll::ip6_addr("", 0);
|
let addr = uv::ll::ip6_addr("", 0);
|
||||||
uv::ll::tcp_getpeername6(self.socket_data.stream_handle_ptr,
|
uv::ll::tcp_getpeername6(self.socket_data.stream_handle_ptr,
|
||||||
ptr::addr_of(&addr));
|
&addr);
|
||||||
ip::Ipv6(addr)
|
ip::Ipv6(addr)
|
||||||
} else {
|
} else {
|
||||||
let addr = uv::ll::ip4_addr("", 0);
|
let addr = uv::ll::ip4_addr("", 0);
|
||||||
uv::ll::tcp_getpeername(self.socket_data.stream_handle_ptr,
|
uv::ll::tcp_getpeername(self.socket_data.stream_handle_ptr,
|
||||||
ptr::addr_of(&addr));
|
&addr);
|
||||||
ip::Ipv4(addr)
|
ip::Ipv4(addr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -973,13 +971,12 @@ impl io::Reader for TcpSocketBuf {
|
|||||||
impl io::Writer for TcpSocketBuf {
|
impl io::Writer for TcpSocketBuf {
|
||||||
pub fn write(&self, data: &const [u8]) {
|
pub fn write(&self, data: &const [u8]) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let socket_data_ptr =
|
let socket_data_ptr: *TcpSocketData =
|
||||||
ptr::addr_of(&(*((*(self.data)).sock).socket_data));
|
&(*((*(self.data)).sock).socket_data);
|
||||||
let w_result = write_common_impl(socket_data_ptr,
|
let w_result = write_common_impl(socket_data_ptr,
|
||||||
vec::slice(data,
|
vec::slice(data,
|
||||||
0,
|
0,
|
||||||
vec::len(data)
|
data.len()).to_vec());
|
||||||
).to_vec());
|
|
||||||
if w_result.is_err() {
|
if w_result.is_err() {
|
||||||
let err_data = w_result.get_err();
|
let err_data = w_result.get_err();
|
||||||
debug!(
|
debug!(
|
||||||
@@ -1012,7 +1009,7 @@ fn tear_down_socket_data(socket_data: @TcpSocketData) {
|
|||||||
let close_data = TcpSocketCloseData {
|
let close_data = TcpSocketCloseData {
|
||||||
closed_ch: closed_ch
|
closed_ch: closed_ch
|
||||||
};
|
};
|
||||||
let close_data_ptr = ptr::addr_of(&close_data);
|
let close_data_ptr: *TcpSocketCloseData = &close_data;
|
||||||
let stream_handle_ptr = (*socket_data).stream_handle_ptr;
|
let stream_handle_ptr = (*socket_data).stream_handle_ptr;
|
||||||
do iotask::interact(&(*socket_data).iotask) |loop_ptr| {
|
do iotask::interact(&(*socket_data).iotask) |loop_ptr| {
|
||||||
unsafe {
|
unsafe {
|
||||||
@@ -1150,19 +1147,21 @@ fn write_common_impl(socket_data_ptr: *TcpSocketData,
|
|||||||
raw_write_data: ~[u8])
|
raw_write_data: ~[u8])
|
||||||
-> result::Result<(), TcpErrData> {
|
-> result::Result<(), TcpErrData> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let write_req_ptr = ptr::addr_of(&((*socket_data_ptr).write_req));
|
let write_req_ptr: *uv::ll::uv_write_t =
|
||||||
|
&(*socket_data_ptr).write_req;
|
||||||
let stream_handle_ptr =
|
let stream_handle_ptr =
|
||||||
(*socket_data_ptr).stream_handle_ptr;
|
(*socket_data_ptr).stream_handle_ptr;
|
||||||
let write_buf_vec = ~[ uv::ll::buf_init(
|
let write_buf_vec = ~[
|
||||||
vec::raw::to_ptr(raw_write_data),
|
uv::ll::buf_init(vec::raw::to_ptr(raw_write_data),
|
||||||
vec::len(raw_write_data)) ];
|
raw_write_data.len())
|
||||||
let write_buf_vec_ptr = ptr::addr_of(&write_buf_vec);
|
];
|
||||||
|
let write_buf_vec_ptr: *~[uv::ll::uv_buf_t] = &write_buf_vec;
|
||||||
let (result_po, result_ch) = stream::<TcpWriteResult>();
|
let (result_po, result_ch) = stream::<TcpWriteResult>();
|
||||||
let result_ch = SharedChan::new(result_ch);
|
let result_ch = SharedChan::new(result_ch);
|
||||||
let write_data = WriteReqData {
|
let write_data = WriteReqData {
|
||||||
result_ch: result_ch
|
result_ch: result_ch
|
||||||
};
|
};
|
||||||
let write_data_ptr = ptr::addr_of(&write_data);
|
let write_data_ptr: *WriteReqData = &write_data;
|
||||||
do iotask::interact(&(*socket_data_ptr).iotask) |loop_ptr| {
|
do iotask::interact(&(*socket_data_ptr).iotask) |loop_ptr| {
|
||||||
unsafe {
|
unsafe {
|
||||||
debug!("in interact cb for tcp::write %?",
|
debug!("in interact cb for tcp::write %?",
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ pub impl <T:Ord> PriorityQueue<T> {
|
|||||||
|
|
||||||
priv fn siftup(&mut self, start: uint, mut pos: uint) {
|
priv fn siftup(&mut self, start: uint, mut pos: uint) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let new = *addr_of(&self.data[pos]);
|
let new = *ptr::to_unsafe_ptr(&self.data[pos]);
|
||||||
|
|
||||||
while pos > start {
|
while pos > start {
|
||||||
let parent = (pos - 1) >> 1;
|
let parent = (pos - 1) >> 1;
|
||||||
@@ -171,7 +171,7 @@ pub impl <T:Ord> PriorityQueue<T> {
|
|||||||
priv fn siftdown_range(&mut self, mut pos: uint, end: uint) {
|
priv fn siftdown_range(&mut self, mut pos: uint, end: uint) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let start = pos;
|
let start = pos;
|
||||||
let new = *addr_of(&self.data[pos]);
|
let new = *ptr::to_unsafe_ptr(&self.data[pos]);
|
||||||
|
|
||||||
let mut child = 2 * pos + 1;
|
let mut child = 2 * pos + 1;
|
||||||
while child < end {
|
while child < end {
|
||||||
|
|||||||
@@ -828,7 +828,7 @@ mod tests {
|
|||||||
let m = ~Mutex();
|
let m = ~Mutex();
|
||||||
let m2 = m.clone();
|
let m2 = m.clone();
|
||||||
let mut sharedstate = ~0;
|
let mut sharedstate = ~0;
|
||||||
let ptr = ptr::addr_of(&(*sharedstate));
|
let ptr: *int = &*sharedstate;
|
||||||
do task::spawn || {
|
do task::spawn || {
|
||||||
let sharedstate: &mut int =
|
let sharedstate: &mut int =
|
||||||
unsafe { cast::transmute(ptr) };
|
unsafe { cast::transmute(ptr) };
|
||||||
@@ -1106,7 +1106,7 @@ mod tests {
|
|||||||
let (p,c) = comm::stream();
|
let (p,c) = comm::stream();
|
||||||
let x2 = (*x).clone();
|
let x2 = (*x).clone();
|
||||||
let mut sharedstate = ~0;
|
let mut sharedstate = ~0;
|
||||||
let ptr = ptr::addr_of(&(*sharedstate));
|
let ptr: *int = &*sharedstate;
|
||||||
do task::spawn || {
|
do task::spawn || {
|
||||||
let sharedstate: &mut int =
|
let sharedstate: &mut int =
|
||||||
unsafe { cast::transmute(ptr) };
|
unsafe { cast::transmute(ptr) };
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ pub fn delayed_send<T:Owned>(iotask: &IoTask,
|
|||||||
let (timer_done_po, timer_done_ch) = stream::<()>();
|
let (timer_done_po, timer_done_ch) = stream::<()>();
|
||||||
let timer_done_ch = SharedChan::new(timer_done_ch);
|
let timer_done_ch = SharedChan::new(timer_done_ch);
|
||||||
let timer = uv::ll::timer_t();
|
let timer = uv::ll::timer_t();
|
||||||
let timer_ptr = ptr::addr_of(&timer);
|
let timer_ptr: *uv::ll::uv_timer_t = &timer;
|
||||||
do iotask::interact(iotask) |loop_ptr| {
|
do iotask::interact(iotask) |loop_ptr| {
|
||||||
unsafe {
|
unsafe {
|
||||||
let init_result = uv::ll::timer_init(loop_ptr, timer_ptr);
|
let init_result = uv::ll::timer_init(loop_ptr, timer_ptr);
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ mod test {
|
|||||||
debug!("EXIT_CH_PTR newly created exit_ch_ptr: %?",
|
debug!("EXIT_CH_PTR newly created exit_ch_ptr: %?",
|
||||||
exit_ch_ptr);
|
exit_ch_ptr);
|
||||||
let timer_handle = ll::timer_t();
|
let timer_handle = ll::timer_t();
|
||||||
let timer_ptr = ptr::addr_of(&timer_handle);
|
let timer_ptr: *ll::uv_timer_t = &timer_handle;
|
||||||
do iotask::interact(iotask) |loop_ptr| {
|
do iotask::interact(iotask) |loop_ptr| {
|
||||||
unsafe {
|
unsafe {
|
||||||
debug!(~"user code inside interact loop!!!");
|
debug!(~"user code inside interact loop!!!");
|
||||||
|
|||||||
@@ -17,10 +17,9 @@
|
|||||||
|
|
||||||
use ll = uv_ll;
|
use ll = uv_ll;
|
||||||
|
|
||||||
|
use core::comm::{stream, Port, Chan, SharedChan};
|
||||||
use core::libc::c_void;
|
use core::libc::c_void;
|
||||||
use core::libc;
|
use core::libc;
|
||||||
use core::comm::{stream, Port, Chan, SharedChan};
|
|
||||||
use core::ptr::addr_of;
|
|
||||||
|
|
||||||
/// Used to abstract-away direct interaction with a libuv loop.
|
/// Used to abstract-away direct interaction with a libuv loop.
|
||||||
pub struct IoTask {
|
pub struct IoTask {
|
||||||
@@ -106,7 +105,7 @@ fn run_loop(iotask_ch: &Chan<IoTask>) {
|
|||||||
// set up the special async handle we'll use to allow multi-task
|
// set up the special async handle we'll use to allow multi-task
|
||||||
// communication with this loop
|
// communication with this loop
|
||||||
let async = ll::async_t();
|
let async = ll::async_t();
|
||||||
let async_handle = addr_of(&async);
|
let async_handle: *ll::uv_async_t = &async;
|
||||||
|
|
||||||
// associate the async handle with the loop
|
// associate the async handle with the loop
|
||||||
ll::async_init(loop_ptr, async_handle, wake_up_cb);
|
ll::async_init(loop_ptr, async_handle, wake_up_cb);
|
||||||
@@ -118,11 +117,11 @@ fn run_loop(iotask_ch: &Chan<IoTask>) {
|
|||||||
async_handle: async_handle,
|
async_handle: async_handle,
|
||||||
msg_po: msg_po
|
msg_po: msg_po
|
||||||
};
|
};
|
||||||
ll::set_data_for_uv_handle(async_handle, addr_of(&data));
|
ll::set_data_for_uv_handle(async_handle, &data);
|
||||||
|
|
||||||
// Send out a handle through which folks can talk to us
|
// Send out a handle through which folks can talk to us
|
||||||
// while we dwell in the I/O loop
|
// while we dwell in the I/O loop
|
||||||
let iotask = IoTask{
|
let iotask = IoTask {
|
||||||
async_handle: async_handle,
|
async_handle: async_handle,
|
||||||
op_chan: SharedChan::new(msg_ch)
|
op_chan: SharedChan::new(msg_ch)
|
||||||
};
|
};
|
||||||
@@ -223,7 +222,7 @@ struct AhData {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
fn impl_uv_iotask_async(iotask: &IoTask) {
|
fn impl_uv_iotask_async(iotask: &IoTask) {
|
||||||
let async_handle = ll::async_t();
|
let async_handle = ll::async_t();
|
||||||
let ah_ptr = ptr::addr_of(&async_handle);
|
let ah_ptr: *ll::uv_async_t = &async_handle;
|
||||||
let (exit_po, exit_ch) = stream::<()>();
|
let (exit_po, exit_ch) = stream::<()>();
|
||||||
let ah_data = AhData {
|
let ah_data = AhData {
|
||||||
iotask: iotask.clone(),
|
iotask: iotask.clone(),
|
||||||
|
|||||||
@@ -1021,19 +1021,17 @@ pub unsafe fn async_send(async_handle: *uv_async_t) {
|
|||||||
}
|
}
|
||||||
pub unsafe fn buf_init(input: *u8, len: uint) -> uv_buf_t {
|
pub unsafe fn buf_init(input: *u8, len: uint) -> uv_buf_t {
|
||||||
let out_buf = uv_buf_t { base: ptr::null(), len: 0 as libc::size_t };
|
let out_buf = uv_buf_t { base: ptr::null(), len: 0 as libc::size_t };
|
||||||
let out_buf_ptr = ptr::addr_of(&out_buf);
|
let out_buf_ptr: *uv_buf_t = &out_buf;
|
||||||
rustrt::rust_uv_buf_init(out_buf_ptr, input, len as size_t);
|
rustrt::rust_uv_buf_init(out_buf_ptr, input, len as size_t);
|
||||||
return out_buf;
|
return out_buf;
|
||||||
}
|
}
|
||||||
pub unsafe fn ip4_addr(ip: &str, port: int)
|
pub unsafe fn ip4_addr(ip: &str, port: int) -> sockaddr_in {
|
||||||
-> sockaddr_in {
|
|
||||||
do str::as_c_str(ip) |ip_buf| {
|
do str::as_c_str(ip) |ip_buf| {
|
||||||
rustrt::rust_uv_ip4_addr(ip_buf as *u8,
|
rustrt::rust_uv_ip4_addr(ip_buf as *u8,
|
||||||
port as libc::c_int)
|
port as libc::c_int)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub unsafe fn ip6_addr(ip: &str, port: int)
|
pub unsafe fn ip6_addr(ip: &str, port: int) -> sockaddr_in6 {
|
||||||
-> sockaddr_in6 {
|
|
||||||
do str::as_c_str(ip) |ip_buf| {
|
do str::as_c_str(ip) |ip_buf| {
|
||||||
rustrt::rust_uv_ip6_addr(ip_buf as *u8,
|
rustrt::rust_uv_ip6_addr(ip_buf as *u8,
|
||||||
port as libc::c_int)
|
port as libc::c_int)
|
||||||
@@ -1183,7 +1181,7 @@ pub unsafe fn free_base_of_buf(buf: uv_buf_t) {
|
|||||||
|
|
||||||
pub unsafe fn get_last_err_info(uv_loop: *libc::c_void) -> ~str {
|
pub unsafe fn get_last_err_info(uv_loop: *libc::c_void) -> ~str {
|
||||||
let err = last_error(uv_loop);
|
let err = last_error(uv_loop);
|
||||||
let err_ptr = ptr::addr_of(&err);
|
let err_ptr: *uv_err_t = &err;
|
||||||
let err_name = str::raw::from_c_str(err_name(err_ptr));
|
let err_name = str::raw::from_c_str(err_name(err_ptr));
|
||||||
let err_msg = str::raw::from_c_str(strerror(err_ptr));
|
let err_msg = str::raw::from_c_str(strerror(err_ptr));
|
||||||
return fmt!("LIBUV ERROR: name: %s msg: %s",
|
return fmt!("LIBUV ERROR: name: %s msg: %s",
|
||||||
@@ -1192,7 +1190,7 @@ pub unsafe fn get_last_err_info(uv_loop: *libc::c_void) -> ~str {
|
|||||||
|
|
||||||
pub unsafe fn get_last_err_data(uv_loop: *libc::c_void) -> uv_err_data {
|
pub unsafe fn get_last_err_data(uv_loop: *libc::c_void) -> uv_err_data {
|
||||||
let err = last_error(uv_loop);
|
let err = last_error(uv_loop);
|
||||||
let err_ptr = ptr::addr_of(&err);
|
let err_ptr: *uv_err_t = &err;
|
||||||
let err_name = str::raw::from_c_str(err_name(err_ptr));
|
let err_name = str::raw::from_c_str(err_name(err_ptr));
|
||||||
let err_msg = str::raw::from_c_str(strerror(err_ptr));
|
let err_msg = str::raw::from_c_str(strerror(err_ptr));
|
||||||
uv_err_data { err_name: err_name, err_msg: err_msg }
|
uv_err_data { err_name: err_name, err_msg: err_msg }
|
||||||
@@ -1347,9 +1345,9 @@ mod test {
|
|||||||
unsafe {
|
unsafe {
|
||||||
let test_loop = loop_new();
|
let test_loop = loop_new();
|
||||||
let tcp_handle = tcp_t();
|
let tcp_handle = tcp_t();
|
||||||
let tcp_handle_ptr = ptr::addr_of(&tcp_handle);
|
let tcp_handle_ptr: *uv_tcp_t = &tcp_handle;
|
||||||
let connect_handle = connect_t();
|
let connect_handle = connect_t();
|
||||||
let connect_req_ptr = ptr::addr_of(&connect_handle);
|
let connect_req_ptr: *uv_connect_t = &connect_handle;
|
||||||
|
|
||||||
// this is the persistent payload of data that we
|
// this is the persistent payload of data that we
|
||||||
// need to pass around to get this example to work.
|
// need to pass around to get this example to work.
|
||||||
@@ -1365,43 +1363,42 @@ mod test {
|
|||||||
// this is the enclosing record, we'll pass a ptr to
|
// this is the enclosing record, we'll pass a ptr to
|
||||||
// this to C..
|
// this to C..
|
||||||
let write_handle = write_t();
|
let write_handle = write_t();
|
||||||
let write_handle_ptr = ptr::addr_of(&write_handle);
|
let write_handle_ptr: *uv_write_t = &write_handle;
|
||||||
debug!("tcp req: tcp stream: %d write_handle: %d",
|
debug!("tcp req: tcp stream: %d write_handle: %d",
|
||||||
tcp_handle_ptr as int,
|
tcp_handle_ptr as int,
|
||||||
write_handle_ptr as int);
|
write_handle_ptr as int);
|
||||||
let client_data = request_wrapper {
|
let client_data = request_wrapper {
|
||||||
write_req: write_handle_ptr,
|
write_req: write_handle_ptr,
|
||||||
req_buf: ptr::addr_of(&req_msg),
|
req_buf: &req_msg,
|
||||||
read_chan: client_chan
|
read_chan: client_chan
|
||||||
};
|
};
|
||||||
|
|
||||||
let tcp_init_result = tcp_init(
|
let tcp_init_result = tcp_init(test_loop as *libc::c_void,
|
||||||
test_loop as *libc::c_void, tcp_handle_ptr);
|
tcp_handle_ptr);
|
||||||
if (tcp_init_result == 0i32) {
|
if (tcp_init_result == 0) {
|
||||||
debug!(~"sucessful tcp_init_result");
|
debug!(~"sucessful tcp_init_result");
|
||||||
|
|
||||||
debug!(~"building addr...");
|
debug!(~"building addr...");
|
||||||
let addr = ip4_addr(ip, port);
|
let addr = ip4_addr(ip, port);
|
||||||
// FIXME ref #2064
|
// FIXME ref #2064
|
||||||
let addr_ptr = ptr::addr_of(&addr);
|
let addr_ptr: *sockaddr_in = &addr;
|
||||||
debug!("after build addr in rust. port: %u",
|
debug!("after build addr in rust. port: %u",
|
||||||
addr.sin_port as uint);
|
addr.sin_port as uint);
|
||||||
|
|
||||||
// this should set up the connection request..
|
// this should set up the connection request..
|
||||||
debug!("b4 call tcp_connect connect cb: %u ",
|
debug!("b4 call tcp_connect connect cb: %u ",
|
||||||
on_connect_cb as uint);
|
on_connect_cb as uint);
|
||||||
let tcp_connect_result = tcp_connect(
|
let tcp_connect_result = tcp_connect(connect_req_ptr,
|
||||||
connect_req_ptr, tcp_handle_ptr,
|
tcp_handle_ptr,
|
||||||
addr_ptr, on_connect_cb);
|
addr_ptr,
|
||||||
if (tcp_connect_result == 0i32) {
|
on_connect_cb);
|
||||||
|
if (tcp_connect_result == 0) {
|
||||||
// not set the data on the connect_req
|
// not set the data on the connect_req
|
||||||
// until its initialized
|
// until its initialized
|
||||||
set_data_for_req(
|
set_data_for_req(connect_req_ptr as *libc::c_void,
|
||||||
connect_req_ptr as *libc::c_void,
|
transmute(&client_data));
|
||||||
ptr::addr_of(&client_data) as *libc::c_void);
|
set_data_for_uv_handle(tcp_handle_ptr as *libc::c_void,
|
||||||
set_data_for_uv_handle(
|
transmute(&client_data));
|
||||||
tcp_handle_ptr as *libc::c_void,
|
|
||||||
ptr::addr_of(&client_data) as *libc::c_void);
|
|
||||||
debug!(~"before run tcp req loop");
|
debug!(~"before run tcp req loop");
|
||||||
run(test_loop);
|
run(test_loop);
|
||||||
debug!(~"after run tcp req loop");
|
debug!(~"after run tcp req loop");
|
||||||
@@ -1607,37 +1604,37 @@ mod test {
|
|||||||
unsafe {
|
unsafe {
|
||||||
let test_loop = loop_new();
|
let test_loop = loop_new();
|
||||||
let tcp_server = tcp_t();
|
let tcp_server = tcp_t();
|
||||||
let tcp_server_ptr = ptr::addr_of(&tcp_server);
|
let tcp_server_ptr: *uv_tcp_t = &tcp_server;
|
||||||
|
|
||||||
let tcp_client = tcp_t();
|
let tcp_client = tcp_t();
|
||||||
let tcp_client_ptr = ptr::addr_of(&tcp_client);
|
let tcp_client_ptr: *uv_tcp_t = &tcp_client;
|
||||||
|
|
||||||
let server_write_req = write_t();
|
let server_write_req = write_t();
|
||||||
let server_write_req_ptr = ptr::addr_of(&server_write_req);
|
let server_write_req_ptr: *uv_write_t = &server_write_req;
|
||||||
|
|
||||||
let resp_str_bytes = str::to_bytes(server_resp_msg);
|
let resp_str_bytes = str::to_bytes(server_resp_msg);
|
||||||
let resp_msg_ptr: *u8 = vec::raw::to_ptr(resp_str_bytes);
|
let resp_msg_ptr: *u8 = vec::raw::to_ptr(resp_str_bytes);
|
||||||
debug!("resp_msg ptr: %u", resp_msg_ptr as uint);
|
debug!("resp_msg ptr: %u", resp_msg_ptr as uint);
|
||||||
let resp_msg = ~[
|
let resp_msg = ~[
|
||||||
buf_init(resp_msg_ptr, vec::len(resp_str_bytes))
|
buf_init(resp_msg_ptr, resp_str_bytes.len())
|
||||||
];
|
];
|
||||||
|
|
||||||
let continue_async_handle = async_t();
|
let continue_async_handle = async_t();
|
||||||
let continue_async_handle_ptr =
|
let continue_async_handle_ptr: *uv_async_t =
|
||||||
ptr::addr_of(&continue_async_handle);
|
&continue_async_handle;
|
||||||
let async_data =
|
let async_data =
|
||||||
async_handle_data { continue_chan: continue_chan };
|
async_handle_data { continue_chan: continue_chan };
|
||||||
let async_data_ptr = ptr::addr_of(&async_data);
|
let async_data_ptr: *async_handle_data = &async_data;
|
||||||
|
|
||||||
let server_data = tcp_server_data {
|
let server_data = tcp_server_data {
|
||||||
client: tcp_client_ptr,
|
client: tcp_client_ptr,
|
||||||
server: tcp_server_ptr,
|
server: tcp_server_ptr,
|
||||||
server_kill_msg: kill_server_msg,
|
server_kill_msg: kill_server_msg,
|
||||||
server_resp_buf: ptr::addr_of(&resp_msg),
|
server_resp_buf: &resp_msg,
|
||||||
server_chan: server_chan,
|
server_chan: server_chan,
|
||||||
server_write_req: server_write_req_ptr
|
server_write_req: server_write_req_ptr
|
||||||
};
|
};
|
||||||
let server_data_ptr = ptr::addr_of(&server_data);
|
let server_data_ptr: *tcp_server_data = &server_data;
|
||||||
set_data_for_uv_handle(tcp_server_ptr as *libc::c_void,
|
set_data_for_uv_handle(tcp_server_ptr as *libc::c_void,
|
||||||
server_data_ptr as *libc::c_void);
|
server_data_ptr as *libc::c_void);
|
||||||
|
|
||||||
@@ -1647,11 +1644,10 @@ mod test {
|
|||||||
if (tcp_init_result == 0i32) {
|
if (tcp_init_result == 0i32) {
|
||||||
let server_addr = ip4_addr(server_ip, server_port);
|
let server_addr = ip4_addr(server_ip, server_port);
|
||||||
// FIXME ref #2064
|
// FIXME ref #2064
|
||||||
let server_addr_ptr = ptr::addr_of(&server_addr);
|
let server_addr_ptr: *sockaddr_in = &server_addr;
|
||||||
|
|
||||||
// uv_tcp_bind()
|
// uv_tcp_bind()
|
||||||
let bind_result = tcp_bind(tcp_server_ptr,
|
let bind_result = tcp_bind(tcp_server_ptr, server_addr_ptr);
|
||||||
server_addr_ptr);
|
|
||||||
if (bind_result == 0i32) {
|
if (bind_result == 0i32) {
|
||||||
debug!(~"successful uv_tcp_bind, listening");
|
debug!(~"successful uv_tcp_bind, listening");
|
||||||
|
|
||||||
|
|||||||
@@ -75,10 +75,10 @@ impl gen_send for message {
|
|||||||
|
|
||||||
body += ~"let b = pipe.reuse_buffer();\n";
|
body += ~"let b = pipe.reuse_buffer();\n";
|
||||||
body += fmt!("let %s = ::core::pipes::SendPacketBuffered(\
|
body += fmt!("let %s = ::core::pipes::SendPacketBuffered(\
|
||||||
::ptr::addr_of(&(b.buffer.data.%s)));\n",
|
&(b.buffer.data.%s));\n",
|
||||||
sp, next.name);
|
sp, next.name);
|
||||||
body += fmt!("let %s = ::core::pipes::RecvPacketBuffered(\
|
body += fmt!("let %s = ::core::pipes::RecvPacketBuffered(\
|
||||||
::ptr::addr_of(&(b.buffer.data.%s)));\n",
|
&(b.buffer.data.%s));\n",
|
||||||
rp, next.name);
|
rp, next.name);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -365,9 +365,7 @@ impl gen_init for protocol {
|
|||||||
|s| ext_cx.parse_stmt(
|
|s| ext_cx.parse_stmt(
|
||||||
fmt!("data.%s.set_buffer(buffer)",
|
fmt!("data.%s.set_buffer(buffer)",
|
||||||
s.name))),
|
s.name))),
|
||||||
ext_cx.parse_expr(
|
ext_cx.parse_expr(fmt!("&(data.%s)", self.states[0].name))));
|
||||||
fmt!("::ptr::addr_of(&(data.%s))",
|
|
||||||
self.states[0].name))));
|
|
||||||
|
|
||||||
quote_expr!({
|
quote_expr!({
|
||||||
let buffer = $buffer;
|
let buffer = $buffer;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ use core::io::WriterUtil;
|
|||||||
use core::comm::{Port, Chan, SharedChan};
|
use core::comm::{Port, Chan, SharedChan};
|
||||||
|
|
||||||
macro_rules! move_out (
|
macro_rules! move_out (
|
||||||
{ $x:expr } => { unsafe { let y = *ptr::addr_of(&($x)); y } }
|
{ $x:expr } => { unsafe { let y = *ptr::to_unsafe_ptr(&($x)); y } }
|
||||||
)
|
)
|
||||||
|
|
||||||
enum request {
|
enum request {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use core::io::WriterUtil;
|
|||||||
use core::comm::{Port, PortSet, Chan, stream};
|
use core::comm::{Port, PortSet, Chan, stream};
|
||||||
|
|
||||||
macro_rules! move_out (
|
macro_rules! move_out (
|
||||||
{ $x:expr } => { unsafe { let y = *ptr::addr_of(&($x)); y } }
|
{ $x:expr } => { unsafe { let y = *ptr::to_unsafe_ptr(&($x)); y } }
|
||||||
)
|
)
|
||||||
|
|
||||||
enum request {
|
enum request {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ proto! ring (
|
|||||||
)
|
)
|
||||||
|
|
||||||
macro_rules! move_out (
|
macro_rules! move_out (
|
||||||
($x:expr) => { unsafe { let y = *ptr::addr_of(&$x); y } }
|
($x:expr) => { unsafe { let y = *ptr::to_unsafe_ptr(&$x); y } }
|
||||||
)
|
)
|
||||||
|
|
||||||
fn thread_ring(i: uint,
|
fn thread_ring(i: uint,
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ proto! pingpong_unbounded (
|
|||||||
|
|
||||||
// This stuff should go in libcore::pipes
|
// This stuff should go in libcore::pipes
|
||||||
macro_rules! move_it (
|
macro_rules! move_it (
|
||||||
{ $x:expr } => { let t = *ptr::addr_of(&($x)); t }
|
{ $x:expr } => { let t = *ptr::to_unsafe_ptr(&($x)); t }
|
||||||
)
|
)
|
||||||
|
|
||||||
macro_rules! follow (
|
macro_rules! follow (
|
||||||
|
|||||||
@@ -11,6 +11,6 @@
|
|||||||
enum bottom { }
|
enum bottom { }
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let x = ptr::addr_of(&()) as *bottom;
|
let x = ptr::to_unsafe_ptr(&()) as *bottom;
|
||||||
match x { } //~ ERROR non-exhaustive patterns
|
match x { } //~ ERROR non-exhaustive patterns
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let x : *~[int] = ptr::addr_of(&~[1,2,3]);
|
let x : *~[int] = &~[1,2,3];
|
||||||
let y : *libc::c_void = x as *libc::c_void;
|
let y : *libc::c_void = x as *libc::c_void;
|
||||||
unsafe {
|
unsafe {
|
||||||
let _z = copy *y;
|
let _z = copy *y;
|
||||||
|
|||||||
@@ -107,8 +107,8 @@ fn test_class() {
|
|||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
error!("q = %x, r = %x",
|
error!("q = %x, r = %x",
|
||||||
(::core::cast::reinterpret_cast::<*p, uint>(&ptr::addr_of(&q))),
|
(::core::cast::reinterpret_cast::<*p, uint>(& &q)),
|
||||||
(::core::cast::reinterpret_cast::<*p, uint>(&ptr::addr_of(&r))));
|
(::core::cast::reinterpret_cast::<*p, uint>(& &r)));
|
||||||
}
|
}
|
||||||
assert!((q == r));
|
assert!((q == r));
|
||||||
r.y = 17;
|
r.y = 17;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ fn borrow(x: &int, f: &fn(x: &int)) {
|
|||||||
|
|
||||||
fn test1(x: @~int) {
|
fn test1(x: @~int) {
|
||||||
do borrow(&*(*x).clone()) |p| {
|
do borrow(&*(*x).clone()) |p| {
|
||||||
let x_a = ptr::addr_of(&(**x));
|
let x_a = ptr::to_unsafe_ptr(&**x);
|
||||||
assert!((x_a as uint) != ptr::to_uint(p));
|
assert!((x_a as uint) != ptr::to_uint(p));
|
||||||
assert!(unsafe{*x_a} == *p);
|
assert!(unsafe{*x_a} == *p);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,13 +17,14 @@ pub fn main() {
|
|||||||
match x {
|
match x {
|
||||||
@F {f: ref b_x} => {
|
@F {f: ref b_x} => {
|
||||||
assert!(**b_x == 3);
|
assert!(**b_x == 3);
|
||||||
assert!(ptr::addr_of(&(*x.f)) == ptr::addr_of(&(**b_x)));
|
assert!(ptr::to_unsafe_ptr(&(*x.f)) == ptr::to_unsafe_ptr(&(**b_x)));
|
||||||
|
|
||||||
x = @F {f: ~4};
|
x = @F {f: ~4};
|
||||||
|
|
||||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(&(**b_x)) as uint);
|
debug!("ptr::to_unsafe_ptr(*b_x) = %x",
|
||||||
|
ptr::to_unsafe_ptr(&(**b_x)) as uint);
|
||||||
assert!(**b_x == 3);
|
assert!(**b_x == 3);
|
||||||
assert!(ptr::addr_of(&(*x.f)) != ptr::addr_of(&(**b_x)));
|
assert!(ptr::to_unsafe_ptr(&(*x.f)) != ptr::to_unsafe_ptr(&(**b_x)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,11 +23,12 @@ pub fn main() {
|
|||||||
let mut x = @F {f: ~3};
|
let mut x = @F {f: ~3};
|
||||||
do borrow(x.f) |b_x| {
|
do borrow(x.f) |b_x| {
|
||||||
assert!(*b_x == 3);
|
assert!(*b_x == 3);
|
||||||
assert!(ptr::addr_of(&(*x.f)) == ptr::addr_of(&(*b_x)));
|
assert!(ptr::to_unsafe_ptr(&(*x.f)) == ptr::to_unsafe_ptr(&(*b_x)));
|
||||||
x = @F {f: ~4};
|
x = @F {f: ~4};
|
||||||
|
|
||||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(&(*b_x)) as uint);
|
debug!("ptr::to_unsafe_ptr(*b_x) = %x",
|
||||||
|
ptr::to_unsafe_ptr(&(*b_x)) as uint);
|
||||||
assert!(*b_x == 3);
|
assert!(*b_x == 3);
|
||||||
assert!(ptr::addr_of(&(*x.f)) != ptr::addr_of(&(*b_x)));
|
assert!(ptr::to_unsafe_ptr(&(*x.f)) != ptr::to_unsafe_ptr(&(*b_x)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,13 +17,14 @@ pub fn main() {
|
|||||||
match x {
|
match x {
|
||||||
@@F{f: ref b_x} => {
|
@@F{f: ref b_x} => {
|
||||||
assert!(**b_x == 3);
|
assert!(**b_x == 3);
|
||||||
assert!(ptr::addr_of(&(x.f)) == ptr::addr_of(b_x));
|
assert!(ptr::to_unsafe_ptr(&(x.f)) == ptr::to_unsafe_ptr(b_x));
|
||||||
|
|
||||||
*x = @F {f: ~4};
|
*x = @F {f: ~4};
|
||||||
|
|
||||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(&(**b_x)) as uint);
|
debug!("ptr::to_unsafe_ptr(*b_x) = %x",
|
||||||
|
ptr::to_unsafe_ptr(&(**b_x)) as uint);
|
||||||
assert!(**b_x == 3);
|
assert!(**b_x == 3);
|
||||||
assert!(ptr::addr_of(&(*x.f)) != ptr::addr_of(&(**b_x)));
|
assert!(ptr::to_unsafe_ptr(&(*x.f)) != ptr::to_unsafe_ptr(&(**b_x)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,11 +23,12 @@ pub fn main() {
|
|||||||
let mut x = ~@F{f: ~3};
|
let mut x = ~@F{f: ~3};
|
||||||
do borrow(x.f) |b_x| {
|
do borrow(x.f) |b_x| {
|
||||||
assert!(*b_x == 3);
|
assert!(*b_x == 3);
|
||||||
assert!(ptr::addr_of(&(*x.f)) == ptr::addr_of(&(*b_x)));
|
assert!(ptr::to_unsafe_ptr(&(*x.f)) == ptr::to_unsafe_ptr(&(*b_x)));
|
||||||
*x = @F{f: ~4};
|
*x = @F{f: ~4};
|
||||||
|
|
||||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(&(*b_x)) as uint);
|
debug!("ptr::to_unsafe_ptr(*b_x) = %x",
|
||||||
|
ptr::to_unsafe_ptr(&(*b_x)) as uint);
|
||||||
assert!(*b_x == 3);
|
assert!(*b_x == 3);
|
||||||
assert!(ptr::addr_of(&(*x.f)) != ptr::addr_of(&(*b_x)));
|
assert!(ptr::to_unsafe_ptr(&(*x.f)) != ptr::to_unsafe_ptr(&(*b_x)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,11 +21,12 @@ pub fn main() {
|
|||||||
let mut x = @3;
|
let mut x = @3;
|
||||||
do borrow(x) |b_x| {
|
do borrow(x) |b_x| {
|
||||||
assert!(*b_x == 3);
|
assert!(*b_x == 3);
|
||||||
assert!(ptr::addr_of(&(*x)) == ptr::addr_of(&(*b_x)));
|
assert!(ptr::to_unsafe_ptr(&(*x)) == ptr::to_unsafe_ptr(&(*b_x)));
|
||||||
x = @22;
|
x = @22;
|
||||||
|
|
||||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(&(*b_x)) as uint);
|
debug!("ptr::to_unsafe_ptr(*b_x) = %x",
|
||||||
|
ptr::to_unsafe_ptr(&(*b_x)) as uint);
|
||||||
assert!(*b_x == 3);
|
assert!(*b_x == 3);
|
||||||
assert!(ptr::addr_of(&(*x)) != ptr::addr_of(&(*b_x)));
|
assert!(ptr::to_unsafe_ptr(&(*x)) != ptr::to_unsafe_ptr(&(*b_x)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,11 +23,12 @@ pub fn main() {
|
|||||||
let mut x = @F {f: ~3};
|
let mut x = @F {f: ~3};
|
||||||
do borrow((*x).f) |b_x| {
|
do borrow((*x).f) |b_x| {
|
||||||
assert!(*b_x == 3);
|
assert!(*b_x == 3);
|
||||||
assert!(ptr::addr_of(&(*x.f)) == ptr::addr_of(&(*b_x)));
|
assert!(ptr::to_unsafe_ptr(&(*x.f)) == ptr::to_unsafe_ptr(&(*b_x)));
|
||||||
x = @F {f: ~4};
|
x = @F {f: ~4};
|
||||||
|
|
||||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(&(*b_x)) as uint);
|
debug!("ptr::to_unsafe_ptr(*b_x) = %x",
|
||||||
|
ptr::to_unsafe_ptr(&(*b_x)) as uint);
|
||||||
assert!(*b_x == 3);
|
assert!(*b_x == 3);
|
||||||
assert!(ptr::addr_of(&(*x.f)) != ptr::addr_of(&(*b_x)));
|
assert!(ptr::to_unsafe_ptr(&(*x.f)) != ptr::to_unsafe_ptr(&(*b_x)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,22 +10,22 @@
|
|||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let x = ~1;
|
let x = ~1;
|
||||||
let y = ptr::addr_of(&(*x)) as uint;
|
let y = ptr::to_unsafe_ptr(&(*x)) as uint;
|
||||||
let lam_move: @fn() -> uint = || ptr::addr_of(&(*x)) as uint;
|
let lam_move: @fn() -> uint = || ptr::to_unsafe_ptr(&(*x)) as uint;
|
||||||
assert!(lam_move() == y);
|
assert!(lam_move() == y);
|
||||||
|
|
||||||
let x = ~2;
|
let x = ~2;
|
||||||
let y = ptr::addr_of(&(*x)) as uint;
|
let y = ptr::to_unsafe_ptr(&(*x)) as uint;
|
||||||
let lam_move: @fn() -> uint = || ptr::addr_of(&(*x)) as uint;
|
let lam_move: @fn() -> uint = || ptr::to_unsafe_ptr(&(*x)) as uint;
|
||||||
assert!(lam_move() == y);
|
assert!(lam_move() == y);
|
||||||
|
|
||||||
let x = ~3;
|
let x = ~3;
|
||||||
let y = ptr::addr_of(&(*x)) as uint;
|
let y = ptr::to_unsafe_ptr(&(*x)) as uint;
|
||||||
let snd_move: ~fn() -> uint = || ptr::addr_of(&(*x)) as uint;
|
let snd_move: ~fn() -> uint = || ptr::to_unsafe_ptr(&(*x)) as uint;
|
||||||
assert!(snd_move() == y);
|
assert!(snd_move() == y);
|
||||||
|
|
||||||
let x = ~4;
|
let x = ~4;
|
||||||
let y = ptr::addr_of(&(*x)) as uint;
|
let y = ptr::to_unsafe_ptr(&(*x)) as uint;
|
||||||
let lam_move: ~fn() -> uint = || ptr::addr_of(&(*x)) as uint;
|
let lam_move: ~fn() -> uint = || ptr::to_unsafe_ptr(&(*x)) as uint;
|
||||||
assert!(lam_move() == y);
|
assert!(lam_move() == y);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,5 +14,5 @@ static x: &'static Big = &([13, 14, 10, 13, 11, 14, 14, 15]);
|
|||||||
static y: &'static Pair<'static> = &Pair {a: 15, b: x};
|
static y: &'static Pair<'static> = &Pair {a: 15, b: x};
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
assert!(ptr::addr_of(x) == ptr::addr_of(y.b));
|
assert!(ptr::to_unsafe_ptr(x) == ptr::to_unsafe_ptr(y.b));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,12 +9,12 @@
|
|||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
fn addr_of<T>(ptr: &T) -> uint {
|
fn addr_of<T>(ptr: &T) -> uint {
|
||||||
let ptr = ptr::addr_of(ptr);
|
let ptr = ptr::to_unsafe_ptr(ptr);
|
||||||
unsafe { ptr as uint }
|
unsafe { ptr as uint }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_aligned<T>(ptr: &T) -> bool {
|
fn is_aligned<T>(ptr: &T) -> bool {
|
||||||
(addr_of(ptr) % sys::min_align_of::<T>()) == 0
|
(to_unsafe_ptr(ptr) % sys::min_align_of::<T>()) == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ pub mod pingpong {
|
|||||||
pub fn liberate_ping(+p: ping) -> ::pipes::send_packet<pong> {
|
pub fn liberate_ping(+p: ping) -> ::pipes::send_packet<pong> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let addr : *::pipes::send_packet<pong> = match &p {
|
let addr : *::pipes::send_packet<pong> = match &p {
|
||||||
&ping(ref x) => { cast::transmute(ptr::addr_of(x)) }
|
&ping(ref x) => { cast::transmute(x) }
|
||||||
};
|
};
|
||||||
let liberated_value = *addr;
|
let liberated_value = *addr;
|
||||||
cast::forget(p);
|
cast::forget(p);
|
||||||
@@ -243,7 +243,7 @@ pub mod pingpong {
|
|||||||
pub fn liberate_pong(+p: pong) -> ::pipes::send_packet<ping> {
|
pub fn liberate_pong(+p: pong) -> ::pipes::send_packet<ping> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let addr : *::pipes::send_packet<ping> = match &p {
|
let addr : *::pipes::send_packet<ping> = match &p {
|
||||||
&pong(ref x) => { cast::transmute(ptr::addr_of(x)) }
|
&pong(ref x) => { cast::transmute(x) }
|
||||||
};
|
};
|
||||||
let liberated_value = *addr;
|
let liberated_value = *addr;
|
||||||
cast::forget(p);
|
cast::forget(p);
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ proto! bank (
|
|||||||
)
|
)
|
||||||
|
|
||||||
macro_rules! move_it (
|
macro_rules! move_it (
|
||||||
{ $x:expr } => { unsafe { let y = *ptr::addr_of(&($x)); y } }
|
{ $x:expr } => { unsafe { let y = *ptr::to_unsafe_ptr(&($x)); y } }
|
||||||
)
|
)
|
||||||
|
|
||||||
fn switch<T:Owned,U>(+endp: pipes::RecvPacket<T>,
|
fn switch<T:Owned,U>(+endp: pipes::RecvPacket<T>,
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ mod pingpong {
|
|||||||
do pipes::entangle_buffer(buffer) |buffer, data| {
|
do pipes::entangle_buffer(buffer) |buffer, data| {
|
||||||
data.ping.set_buffer(buffer);
|
data.ping.set_buffer(buffer);
|
||||||
data.pong.set_buffer(buffer);
|
data.pong.set_buffer(buffer);
|
||||||
ptr::addr_of(&(data.ping))
|
ptr::to_unsafe_ptr(&(data.ping))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub struct ping(server::pong);
|
pub struct ping(server::pong);
|
||||||
@@ -53,8 +53,8 @@ mod pingpong {
|
|||||||
pub fn ping(+pipe: ping) -> pong {
|
pub fn ping(+pipe: ping) -> pong {
|
||||||
{
|
{
|
||||||
let b = pipe.reuse_buffer();
|
let b = pipe.reuse_buffer();
|
||||||
let s = SendPacketBuffered(ptr::addr_of(&(b.buffer.data.pong)));
|
let s = SendPacketBuffered(&b.buffer.data.pong);
|
||||||
let c = RecvPacketBuffered(ptr::addr_of(&(b.buffer.data.pong)));
|
let c = RecvPacketBuffered(&b.buffer.data.pong);
|
||||||
let message = ::pingpong::ping(s);
|
let message = ::pingpong::ping(s);
|
||||||
send(pipe, message);
|
send(pipe, message);
|
||||||
c
|
c
|
||||||
@@ -75,8 +75,8 @@ mod pingpong {
|
|||||||
pub fn pong(+pipe: pong) -> ping {
|
pub fn pong(+pipe: pong) -> ping {
|
||||||
{
|
{
|
||||||
let b = pipe.reuse_buffer();
|
let b = pipe.reuse_buffer();
|
||||||
let s = SendPacketBuffered(ptr::addr_of(&(b.buffer.data.ping)));
|
let s = SendPacketBuffered(&b.buffer.data.ping);
|
||||||
let c = RecvPacketBuffered(ptr::addr_of(&(b.buffer.data.ping)));
|
let c = RecvPacketBuffered(&b.buffer.data.ping);
|
||||||
let message = ::pingpong::pong(s);
|
let message = ::pingpong::pong(s);
|
||||||
send(pipe, message);
|
send(pipe, message);
|
||||||
c
|
c
|
||||||
|
|||||||
@@ -642,7 +642,7 @@ struct Triple { x: int, y: int, z: int }
|
|||||||
pub fn main() {
|
pub fn main() {
|
||||||
unsafe {
|
unsafe {
|
||||||
let r = (1,2,3,true,false, Triple {x:5,y:4,z:3}, (12,));
|
let r = (1,2,3,true,false, Triple {x:5,y:4,z:3}, (12,));
|
||||||
let p = ptr::addr_of(&r) as *c_void;
|
let p = ptr::to_unsafe_ptr(&r) as *c_void;
|
||||||
let u = my_visitor(@mut Stuff {ptr1: p,
|
let u = my_visitor(@mut Stuff {ptr1: p,
|
||||||
ptr2: p,
|
ptr2: p,
|
||||||
vals: ~[]});
|
vals: ~[]});
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ impl Drop for r {
|
|||||||
fn finalize(&self) {
|
fn finalize(&self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
debug!("r's dtor: self = %x, self.v = %x, self.v's value = %x",
|
debug!("r's dtor: self = %x, self.v = %x, self.v's value = %x",
|
||||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(self)),
|
cast::reinterpret_cast::<*r, uint>(&self),
|
||||||
cast::reinterpret_cast::<**int, uint>(&ptr::addr_of(&(self.v))),
|
cast::reinterpret_cast::<**int, uint>(& &(self.v)),
|
||||||
cast::reinterpret_cast::<*int, uint>(&self.v));
|
cast::reinterpret_cast::<*int, uint>(&self.v));
|
||||||
let v2: ~int = cast::reinterpret_cast(&self.v);
|
let v2: ~int = cast::reinterpret_cast(&self.v);
|
||||||
}
|
}
|
||||||
@@ -54,28 +54,26 @@ pub fn main() {
|
|||||||
next: None,
|
next: None,
|
||||||
r: {
|
r: {
|
||||||
let rs = r(i1p);
|
let rs = r(i1p);
|
||||||
debug!("r = %x",
|
debug!("r = %x", cast::reinterpret_cast::<*r, uint>(& &rs));
|
||||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(&rs)));
|
|
||||||
rs }
|
rs }
|
||||||
});
|
});
|
||||||
|
|
||||||
debug!("x1 = %x, x1.r = %x",
|
debug!("x1 = %x, x1.r = %x",
|
||||||
cast::reinterpret_cast::<@mut t, uint>(&x1),
|
cast::reinterpret_cast::<@mut t, uint>(&x1),
|
||||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(&(x1.r))));
|
cast::reinterpret_cast::<*r, uint>(& &(x1.r)));
|
||||||
|
|
||||||
let mut x2 = @mut t(Node{
|
let mut x2 = @mut t(Node{
|
||||||
next: None,
|
next: None,
|
||||||
r: {
|
r: {
|
||||||
let rs = r(i2p);
|
let rs = r(i2p);
|
||||||
debug!("r2 = %x",
|
debug!("r2 = %x", cast::reinterpret_cast::<*r, uint>(& &rs));
|
||||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(&rs)));
|
|
||||||
rs
|
rs
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
debug!("x2 = %x, x2.r = %x",
|
debug!("x2 = %x, x2.r = %x",
|
||||||
cast::reinterpret_cast::<@mut t, uint>(&x2),
|
cast::reinterpret_cast::<@mut t, uint>(&x2),
|
||||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(&(x2.r))));
|
cast::reinterpret_cast::<*r, uint>(& &(x2.r)));
|
||||||
|
|
||||||
x1.next = Some(x2);
|
x1.next = Some(x2);
|
||||||
x2.next = Some(x1);
|
x2.next = Some(x1);
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ pub fn main() {
|
|||||||
ch.send(());
|
ch.send(());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let fptr = cast::reinterpret_cast(&ptr::addr_of(&f));
|
let fptr = cast::reinterpret_cast(& &f);
|
||||||
rustrt::start_task(new_task_id, fptr);
|
rustrt::start_task(new_task_id, fptr);
|
||||||
cast::forget(f);
|
cast::forget(f);
|
||||||
po.recv();
|
po.recv();
|
||||||
|
|||||||
@@ -12,5 +12,5 @@
|
|||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let foo = 1;
|
let foo = 1;
|
||||||
assert!(ptr::addr_of(&foo) == ptr::addr_of(&foo));
|
assert!(ptr::to_unsafe_ptr(&foo) == ptr::to_unsafe_ptr(&foo));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ fn mk_rec() -> t_rec {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn is_8_byte_aligned(&&u: a_tag<u64>) -> bool {
|
fn is_8_byte_aligned(&&u: a_tag<u64>) -> bool {
|
||||||
let p = ptr::addr_of(u) as uint;
|
let p = ptr::to_unsafe_ptr(u) as uint;
|
||||||
return (p & 7u) == 0u;
|
return (p & 7u) == 0u;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ fn mk_rec<A:copy,B:copy>(a: A, b: B) -> t_rec<A,B> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn is_aligned<A>(amnt: uint, &&u: A) -> bool {
|
fn is_aligned<A>(amnt: uint, &&u: A) -> bool {
|
||||||
let p = ptr::addr_of(u) as uint;
|
let p = ptr::to_unsafe_ptr(u) as uint;
|
||||||
return (p & (amnt-1u)) == 0u;
|
return (p & (amnt-1u)) == 0u;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ fn mk_rec() -> t_rec {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn is_8_byte_aligned(&&u: a_tag) -> bool {
|
fn is_8_byte_aligned(&&u: a_tag) -> bool {
|
||||||
let p = ptr::addr_of(u) as u64;
|
let p = ptr::to_unsafe_ptr(u) as u64;
|
||||||
return (p & 7u64) == 0u64;
|
return (p & 7u64) == 0u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ impl Drop for notify {
|
|||||||
unsafe {
|
unsafe {
|
||||||
error!("notify: task=%? v=%x unwinding=%b b=%b",
|
error!("notify: task=%? v=%x unwinding=%b b=%b",
|
||||||
task::get_task(),
|
task::get_task(),
|
||||||
ptr::addr_of(&(*(self.v))) as uint,
|
ptr::to_unsafe_ptr(&(*(self.v))) as uint,
|
||||||
task::failing(),
|
task::failing(),
|
||||||
*(self.v));
|
*(self.v));
|
||||||
let b = *(self.v);
|
let b = *(self.v);
|
||||||
@@ -47,7 +47,7 @@ fn joinable(f: ~fn()) -> Port<bool> {
|
|||||||
let b = @mut false;
|
let b = @mut false;
|
||||||
error!("wrapper: task=%? allocated v=%x",
|
error!("wrapper: task=%? allocated v=%x",
|
||||||
task::get_task(),
|
task::get_task(),
|
||||||
ptr::addr_of(&(*b)) as uint);
|
ptr::to_unsafe_ptr(&(*b)) as uint);
|
||||||
let _r = notify(c, b);
|
let _r = notify(c, b);
|
||||||
f();
|
f();
|
||||||
*b = true;
|
*b = true;
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ pub fn main() {
|
|||||||
let (p, ch) = stream::<uint>();
|
let (p, ch) = stream::<uint>();
|
||||||
|
|
||||||
let x = ~1;
|
let x = ~1;
|
||||||
let x_in_parent = ptr::addr_of(&(*x)) as uint;
|
let x_in_parent = ptr::to_unsafe_ptr(&(*x)) as uint;
|
||||||
|
|
||||||
task::spawn(|| {
|
task::spawn(|| {
|
||||||
let x_in_child = ptr::addr_of(&(*x)) as uint;
|
let x_in_child = ptr::to_unsafe_ptr(&(*x)) as uint;
|
||||||
ch.send(x_in_child);
|
ch.send(x_in_child);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ struct Pointy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn make_uniq_closure<A:Owned + Copy>(a: A) -> ~fn() -> uint {
|
fn make_uniq_closure<A:Owned + Copy>(a: A) -> ~fn() -> uint {
|
||||||
let result: ~fn() -> uint = || ptr::addr_of(&a) as uint;
|
let result: ~fn() -> uint = || ptr::to_unsafe_ptr(&a) as uint;
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user