Move over to calling ptr::addr_of
Everything should now call ptr::addr_of instead of ptr::p2::addr_of. Only the pipes macro code when compiled by stage0 will call ptr::p2::addr_of. Needs a snapshot to get rid of that.
This commit is contained in:
parent
72ae42627b
commit
b18320446e
|
@ -231,7 +231,7 @@ fn unix_time_in_microseconds() -> u64 unsafe {
|
|||
mut tv_sec: 0 as c_ulonglong,
|
||||
mut tv_usec: 0 as c_ulonglong
|
||||
};
|
||||
lib_c::gettimeofday(ptr::addr_of(x), ptr::null());
|
||||
lib_c::gettimeofday(ptr::addr_of(&x), ptr::null());
|
||||
return (x.tv_sec as u64) * 1000_000_u64 + (x.tv_usec as u64);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#[forbid(deprecated_pattern)];
|
||||
|
||||
use cast::transmute;
|
||||
use ptr::p2::addr_of;
|
||||
use ptr::addr_of;
|
||||
|
||||
/// Code for dealing with @-vectors. This is pretty incomplete, and
|
||||
/// contains a bunch of duplication from the code for ~-vectors.
|
||||
|
|
|
@ -24,7 +24,7 @@ pub mod raw {
|
|||
|
||||
pub pure fn ptr_eq<T>(a: @T, b: @T) -> bool {
|
||||
//! Determine if two shared boxes point to the same object
|
||||
unsafe { ptr::p2::addr_of(&(*a)) == ptr::p2::addr_of(&(*b)) }
|
||||
unsafe { ptr::addr_of(&(*a)) == ptr::addr_of(&(*b)) }
|
||||
}
|
||||
|
||||
impl<T:Eq> @const T : Eq {
|
||||
|
|
|
@ -103,7 +103,7 @@ struct PortPtr<T:Send> {
|
|||
// Once the port is detached it's guaranteed not to receive further
|
||||
// messages
|
||||
let yield = 0;
|
||||
let yieldp = ptr::p2::addr_of(&yield);
|
||||
let yieldp = ptr::addr_of(&yield);
|
||||
rustrt::rust_port_begin_detach(self.po, yieldp);
|
||||
if yield != 0 {
|
||||
// Need to wait for the port to be detached
|
||||
|
@ -176,7 +176,7 @@ pub fn Chan<T: Send>(p: Port<T>) -> Chan<T> {
|
|||
*/
|
||||
pub fn send<T: Send>(ch: Chan<T>, +data: T) {
|
||||
let Chan_(p) = ch;
|
||||
let data_ptr = ptr::p2::addr_of(&data) as *();
|
||||
let data_ptr = ptr::addr_of(&data) as *();
|
||||
let res = rustrt::rust_port_id_send(p, data_ptr);
|
||||
if res != 0 unsafe {
|
||||
// Data sent successfully
|
||||
|
@ -206,10 +206,10 @@ fn peek_chan<T: Send>(ch: comm::Chan<T>) -> bool {
|
|||
/// Receive on a raw port pointer
|
||||
fn recv_<T: Send>(p: *rust_port) -> T {
|
||||
let yield = 0;
|
||||
let yieldp = ptr::p2::addr_of(&yield);
|
||||
let yieldp = ptr::addr_of(&yield);
|
||||
let mut res;
|
||||
res = rusti::init::<T>();
|
||||
rustrt::port_recv(ptr::p2::addr_of(&res) as *uint, p, yieldp);
|
||||
rustrt::port_recv(ptr::addr_of(&res) as *uint, p, yieldp);
|
||||
|
||||
if yield != 0 {
|
||||
// Data isn't available yet, so res has not been initialized.
|
||||
|
@ -233,12 +233,12 @@ fn peek_(p: *rust_port) -> bool {
|
|||
pub fn select2<A: Send, B: Send>(p_a: Port<A>, p_b: Port<B>)
|
||||
-> Either<A, B> {
|
||||
let ports = ~[(**p_a).po, (**p_b).po];
|
||||
let yield = 0, yieldp = ptr::p2::addr_of(&yield);
|
||||
let yield = 0, yieldp = ptr::addr_of(&yield);
|
||||
|
||||
let mut resport: *rust_port;
|
||||
resport = rusti::init::<*rust_port>();
|
||||
do vec::as_imm_buf(ports) |ports, n_ports| {
|
||||
rustrt::rust_port_select(ptr::p2::addr_of(&resport), ports,
|
||||
rustrt::rust_port_select(ptr::addr_of(&resport), ports,
|
||||
n_ports as size_t, yieldp);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ pub fn deflate_bytes(bytes: &[const u8]) -> ~[u8] {
|
|||
let res =
|
||||
rustrt::tdefl_compress_mem_to_heap(b as *c_void,
|
||||
len as size_t,
|
||||
ptr::addr_of(outsz),
|
||||
ptr::addr_of(&outsz),
|
||||
lz_norm);
|
||||
assert res as int != 0;
|
||||
let out = vec::raw::from_buf(res as *u8,
|
||||
|
@ -52,7 +52,7 @@ pub fn inflate_bytes(bytes: &[const u8]) -> ~[u8] {
|
|||
let res =
|
||||
rustrt::tinfl_decompress_mem_to_heap(b as *c_void,
|
||||
len as size_t,
|
||||
ptr::addr_of(outsz),
|
||||
ptr::addr_of(&outsz),
|
||||
0);
|
||||
assert res as int != 0;
|
||||
let out = vec::raw::from_buf(res as *u8,
|
||||
|
|
|
@ -316,7 +316,7 @@ pub fn cleanup_stack_for_failure() {
|
|||
// own stack roots on the stack anyway.
|
||||
let sentinel_box = ~0;
|
||||
let sentinel: **Word = if expect_sentinel() {
|
||||
cast::reinterpret_cast(&ptr::p2::addr_of(&sentinel_box))
|
||||
cast::reinterpret_cast(&ptr::addr_of(&sentinel_box))
|
||||
} else {
|
||||
ptr::null()
|
||||
};
|
||||
|
|
|
@ -85,7 +85,7 @@ use option::unwrap;
|
|||
const SPIN_COUNT: uint = 0;
|
||||
|
||||
macro_rules! move_it (
|
||||
{ $x:expr } => { unsafe { let y <- *ptr::addr_of($x); move y } }
|
||||
{ $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); move y } }
|
||||
)
|
||||
|
||||
#[doc(hidden)]
|
||||
|
@ -219,7 +219,7 @@ fn unibuffer<T: Send>() -> ~Buffer<Packet<T>> {
|
|||
#[doc(hidden)]
|
||||
pub fn packet<T: Send>() -> *Packet<T> {
|
||||
let b = unibuffer();
|
||||
let p = ptr::p2::addr_of(&(b.data));
|
||||
let p = ptr::addr_of(&(b.data));
|
||||
// We'll take over memory management from here.
|
||||
unsafe { forget(move b) }
|
||||
p
|
||||
|
@ -359,7 +359,7 @@ pub fn send<T: Send, Tbuffer: Send>(+p: SendPacketBuffered<T, Tbuffer>,
|
|||
let header = p.header();
|
||||
let p_ = p.unwrap();
|
||||
let p = unsafe { &*p_ };
|
||||
assert ptr::p2::addr_of(&(p.header)) == header;
|
||||
assert ptr::addr_of(&(p.header)) == header;
|
||||
assert p.payload.is_none();
|
||||
p.payload <- Some(move payload);
|
||||
let old_state = swap_state_rel(&mut p.header.state, Full);
|
||||
|
@ -377,7 +377,7 @@ pub fn send<T: Send, Tbuffer: Send>(+p: SendPacketBuffered<T, Tbuffer>,
|
|||
let old_task = swap_task(&mut p.header.blocked_task, ptr::null());
|
||||
if !old_task.is_null() {
|
||||
rustrt::task_signal_event(
|
||||
old_task, ptr::p2::addr_of(&(p.header)) as *libc::c_void);
|
||||
old_task, ptr::addr_of(&(p.header)) as *libc::c_void);
|
||||
rustrt::rust_task_deref(old_task);
|
||||
}
|
||||
|
||||
|
@ -529,7 +529,7 @@ fn sender_terminate<T: Send>(p: *Packet<T>) {
|
|||
if !old_task.is_null() {
|
||||
rustrt::task_signal_event(
|
||||
old_task,
|
||||
ptr::p2::addr_of(&(p.header)) as *libc::c_void);
|
||||
ptr::addr_of(&(p.header)) as *libc::c_void);
|
||||
rustrt::rust_task_deref(old_task);
|
||||
}
|
||||
// The receiver will eventually clean up.
|
||||
|
@ -744,7 +744,7 @@ pub fn SendPacketBuffered<T: Send, Tbuffer: Send>(p: *Packet<T>)
|
|||
p: Some(p),
|
||||
buffer: unsafe {
|
||||
Some(BufferResource(
|
||||
get_buffer(ptr::p2::addr_of(&((*p).header)))))
|
||||
get_buffer(ptr::addr_of(&((*p).header)))))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -760,7 +760,7 @@ impl<T: Send, Tbuffer: Send> SendPacketBuffered<T, Tbuffer> {
|
|||
match self.p {
|
||||
Some(packet) => unsafe {
|
||||
let packet = &*packet;
|
||||
let header = ptr::p2::addr_of(&(packet.header));
|
||||
let header = ptr::addr_of(&(packet.header));
|
||||
//forget(packet);
|
||||
header
|
||||
},
|
||||
|
@ -815,7 +815,7 @@ impl<T: Send, Tbuffer: Send> RecvPacketBuffered<T, Tbuffer> : Selectable {
|
|||
match self.p {
|
||||
Some(packet) => unsafe {
|
||||
let packet = &*packet;
|
||||
let header = ptr::p2::addr_of(&(packet.header));
|
||||
let header = ptr::addr_of(&(packet.header));
|
||||
//forget(packet);
|
||||
header
|
||||
},
|
||||
|
@ -838,7 +838,7 @@ pub fn RecvPacketBuffered<T: Send, Tbuffer: Send>(p: *Packet<T>)
|
|||
p: Some(p),
|
||||
buffer: unsafe {
|
||||
Some(BufferResource(
|
||||
get_buffer(ptr::p2::addr_of(&((*p).header)))))
|
||||
get_buffer(ptr::addr_of(&((*p).header)))))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,12 +24,9 @@ extern mod rusti {
|
|||
fn addr_of<T>(val: T) -> *T;
|
||||
}
|
||||
|
||||
/*
|
||||
Remove this after snapshot; make p2::addr_of addr_of
|
||||
*/
|
||||
/// Get an unsafe pointer to a value
|
||||
#[inline(always)]
|
||||
pub pure fn addr_of<T>(val: T) -> *T { unsafe { rusti::addr_of(val) } }
|
||||
pub pure fn addr_of<T>(val: &T) -> *T { unsafe { rusti::addr_of(*val) } }
|
||||
|
||||
pub mod p2 {
|
||||
/// Get an unsafe pointer to a value
|
||||
|
|
|
@ -1780,7 +1780,7 @@ pub pure fn as_c_str<T>(s: &str, f: fn(*libc::c_char) -> T) -> T {
|
|||
#[inline(always)]
|
||||
pub pure fn as_buf<T>(s: &str, f: fn(*u8, uint) -> T) -> T {
|
||||
unsafe {
|
||||
let v : *(*u8,uint) = ::cast::reinterpret_cast(&ptr::p2::addr_of(&s));
|
||||
let v : *(*u8,uint) = ::cast::reinterpret_cast(&ptr::addr_of(&s));
|
||||
let (buf,len) = *v;
|
||||
f(buf, len)
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ use rt::rust_task;
|
|||
use rt::rust_closure;
|
||||
|
||||
macro_rules! move_it (
|
||||
{ $x:expr } => { unsafe { let y <- *ptr::p2::addr_of(&($x)); move y } }
|
||||
{ $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); move y } }
|
||||
)
|
||||
|
||||
type TaskSet = send_map::linear::LinearMap<*rust_task,()>;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
use cmp::{Eq, Ord};
|
||||
use option::{Some, None};
|
||||
use ptr::p2::addr_of;
|
||||
use ptr::addr_of;
|
||||
use libc::size_t;
|
||||
|
||||
export append;
|
||||
|
|
|
@ -21,19 +21,19 @@ pub fn debug_tydesc<T>() {
|
|||
}
|
||||
|
||||
pub fn debug_opaque<T>(+x: T) {
|
||||
rustrt::debug_opaque(sys::get_type_desc::<T>(), ptr::addr_of(x) as *());
|
||||
rustrt::debug_opaque(sys::get_type_desc::<T>(), ptr::addr_of(&x) as *());
|
||||
}
|
||||
|
||||
pub fn debug_box<T>(x: @T) {
|
||||
rustrt::debug_box(sys::get_type_desc::<T>(), ptr::addr_of(x) as *());
|
||||
rustrt::debug_box(sys::get_type_desc::<T>(), ptr::addr_of(&x) as *());
|
||||
}
|
||||
|
||||
pub fn debug_tag<T>(+x: T) {
|
||||
rustrt::debug_tag(sys::get_type_desc::<T>(), ptr::addr_of(x) as *());
|
||||
rustrt::debug_tag(sys::get_type_desc::<T>(), ptr::addr_of(&x) as *());
|
||||
}
|
||||
|
||||
pub fn debug_fn<T>(+x: T) {
|
||||
rustrt::debug_fn(sys::get_type_desc::<T>(), ptr::addr_of(x) as *());
|
||||
rustrt::debug_fn(sys::get_type_desc::<T>(), ptr::addr_of(&x) as *());
|
||||
}
|
||||
|
||||
pub unsafe fn ptr_cast<T, U>(x: @T) -> @U {
|
||||
|
|
|
@ -89,11 +89,11 @@ fn get_addr(node: &str, iotask: iotask)
|
|||
do str::as_buf(node) |node_ptr, len| unsafe {
|
||||
log(debug, fmt!("slice len %?", len));
|
||||
let handle = create_uv_getaddrinfo_t();
|
||||
let handle_ptr = ptr::addr_of(handle);
|
||||
let handle_ptr = ptr::addr_of(&handle);
|
||||
let handle_data: GetAddrData = {
|
||||
output_ch: output_ch
|
||||
};
|
||||
let handle_data_ptr = ptr::addr_of(handle_data);
|
||||
let handle_data_ptr = ptr::addr_of(&handle_data);
|
||||
do interact(iotask) |loop_ptr| unsafe {
|
||||
let result = uv_getaddrinfo(
|
||||
loop_ptr,
|
||||
|
@ -150,7 +150,7 @@ mod v4 {
|
|||
impl Ipv4Rep: AsUnsafeU32 {
|
||||
// this is pretty dastardly, i know
|
||||
unsafe fn as_u32() -> u32 {
|
||||
*((ptr::addr_of(self)) as *u32)
|
||||
*((ptr::addr_of(&self)) as *u32)
|
||||
}
|
||||
}
|
||||
fn parse_to_ipv4_rep(ip: &str) -> result::Result<Ipv4Rep, ~str> {
|
||||
|
|
|
@ -138,7 +138,7 @@ fn connect(+input_ip: ip::IpAddr, port: uint,
|
|||
result_ch: core::comm::Chan(result_po),
|
||||
closed_signal_ch: core::comm::Chan(closed_signal_po)
|
||||
};
|
||||
let conn_data_ptr = ptr::addr_of(conn_data);
|
||||
let conn_data_ptr = ptr::addr_of(&conn_data);
|
||||
let reader_po = core::comm::Port::<result::Result<~[u8], TcpErrData>>();
|
||||
let stream_handle_ptr = malloc_uv_tcp_t();
|
||||
*(stream_handle_ptr as *mut uv::ll::uv_tcp_t) = uv::ll::tcp_t();
|
||||
|
@ -150,7 +150,7 @@ fn connect(+input_ip: ip::IpAddr, port: uint,
|
|||
write_req: uv::ll::write_t(),
|
||||
iotask: iotask
|
||||
};
|
||||
let socket_data_ptr = ptr::addr_of(*socket_data);
|
||||
let socket_data_ptr = ptr::addr_of(&(*socket_data));
|
||||
log(debug, fmt!("tcp_connect result_ch %?", conn_data.result_ch));
|
||||
// get an unsafe representation of our stream_handle_ptr that
|
||||
// we can send into the interact cb to be handled in libuv..
|
||||
|
@ -165,7 +165,7 @@ fn connect(+input_ip: ip::IpAddr, port: uint,
|
|||
log(debug, ~"tcp_init successful");
|
||||
log(debug, ~"dealing w/ ipv4 connection..");
|
||||
let connect_req_ptr =
|
||||
ptr::addr_of((*socket_data_ptr).connect_req);
|
||||
ptr::addr_of(&((*socket_data_ptr).connect_req));
|
||||
let addr_str = ip::format_addr(&input_ip);
|
||||
let connect_result = match input_ip {
|
||||
ip::Ipv4(ref addr) => {
|
||||
|
@ -179,7 +179,7 @@ fn connect(+input_ip: ip::IpAddr, port: uint,
|
|||
uv::ll::tcp_connect(
|
||||
connect_req_ptr,
|
||||
stream_handle_ptr,
|
||||
ptr::addr_of(in_addr),
|
||||
ptr::addr_of(&in_addr),
|
||||
tcp_connect_on_connect_cb)
|
||||
}
|
||||
ip::Ipv6(ref addr) => {
|
||||
|
@ -188,7 +188,7 @@ fn connect(+input_ip: ip::IpAddr, port: uint,
|
|||
uv::ll::tcp_connect6(
|
||||
connect_req_ptr,
|
||||
stream_handle_ptr,
|
||||
ptr::addr_of(in_addr),
|
||||
ptr::addr_of(&in_addr),
|
||||
tcp_connect_on_connect_cb)
|
||||
}
|
||||
};
|
||||
|
@ -264,7 +264,7 @@ fn connect(+input_ip: ip::IpAddr, port: uint,
|
|||
*/
|
||||
fn write(sock: &TcpSocket, raw_write_data: ~[u8])
|
||||
-> result::Result<(), TcpErrData> unsafe {
|
||||
let socket_data_ptr = ptr::addr_of(*(sock.socket_data));
|
||||
let socket_data_ptr = ptr::addr_of(&(*(sock.socket_data)));
|
||||
write_common_impl(socket_data_ptr, raw_write_data)
|
||||
}
|
||||
|
||||
|
@ -301,7 +301,7 @@ fn write(sock: &TcpSocket, raw_write_data: ~[u8])
|
|||
*/
|
||||
fn write_future(sock: &TcpSocket, raw_write_data: ~[u8])
|
||||
-> future::Future<result::Result<(), TcpErrData>> unsafe {
|
||||
let socket_data_ptr = ptr::addr_of(*(sock.socket_data));
|
||||
let socket_data_ptr = ptr::addr_of(&(*(sock.socket_data)));
|
||||
do future_spawn {
|
||||
let data_copy = copy(raw_write_data);
|
||||
write_common_impl(socket_data_ptr, data_copy)
|
||||
|
@ -326,7 +326,7 @@ fn write_future(sock: &TcpSocket, raw_write_data: ~[u8])
|
|||
fn read_start(sock: &TcpSocket)
|
||||
-> result::Result<comm::Port<
|
||||
result::Result<~[u8], TcpErrData>>, TcpErrData> unsafe {
|
||||
let socket_data = ptr::addr_of(*(sock.socket_data));
|
||||
let socket_data = ptr::addr_of(&(*(sock.socket_data)));
|
||||
read_start_common_impl(socket_data)
|
||||
}
|
||||
|
||||
|
@ -341,7 +341,7 @@ fn read_stop(sock: &TcpSocket,
|
|||
+read_port: comm::Port<result::Result<~[u8], TcpErrData>>) ->
|
||||
result::Result<(), TcpErrData> unsafe {
|
||||
log(debug, fmt!("taking the read_port out of commission %?", read_port));
|
||||
let socket_data = ptr::addr_of(*sock.socket_data);
|
||||
let socket_data = ptr::addr_of(&(*sock.socket_data));
|
||||
read_stop_common_impl(socket_data)
|
||||
}
|
||||
|
||||
|
@ -362,7 +362,7 @@ fn read_stop(sock: &TcpSocket,
|
|||
*/
|
||||
fn read(sock: &TcpSocket, timeout_msecs: uint)
|
||||
-> result::Result<~[u8],TcpErrData> {
|
||||
let socket_data = ptr::addr_of(*(sock.socket_data));
|
||||
let socket_data = ptr::addr_of(&(*(sock.socket_data)));
|
||||
read_common_impl(socket_data, timeout_msecs)
|
||||
}
|
||||
|
||||
|
@ -397,7 +397,7 @@ fn read(sock: &TcpSocket, timeout_msecs: uint)
|
|||
*/
|
||||
fn read_future(sock: &TcpSocket, timeout_msecs: uint)
|
||||
-> future::Future<result::Result<~[u8],TcpErrData>> {
|
||||
let socket_data = ptr::addr_of(*(sock.socket_data));
|
||||
let socket_data = ptr::addr_of(&(*(sock.socket_data)));
|
||||
do future_spawn {
|
||||
read_common_impl(socket_data, timeout_msecs)
|
||||
}
|
||||
|
@ -491,7 +491,7 @@ fn accept(new_conn: TcpNewConnection)
|
|||
write_req : uv::ll::write_t(),
|
||||
iotask : iotask
|
||||
};
|
||||
let client_socket_data_ptr = ptr::addr_of(*client_socket_data);
|
||||
let client_socket_data_ptr = ptr::addr_of(&(*client_socket_data));
|
||||
let client_stream_handle_ptr =
|
||||
(*client_socket_data_ptr).stream_handle_ptr;
|
||||
|
||||
|
@ -596,7 +596,7 @@ fn listen_common(+host_ip: ip::IpAddr, port: uint, backlog: uint,
|
|||
let kill_po = core::comm::Port::<Option<TcpErrData>>();
|
||||
let kill_ch = core::comm::Chan(kill_po);
|
||||
let server_stream = uv::ll::tcp_t();
|
||||
let server_stream_ptr = ptr::addr_of(server_stream);
|
||||
let server_stream_ptr = ptr::addr_of(&server_stream);
|
||||
let server_data = {
|
||||
server_stream_ptr: server_stream_ptr,
|
||||
stream_closed_ch: core::comm::Chan(stream_closed_po),
|
||||
|
@ -605,7 +605,7 @@ fn listen_common(+host_ip: ip::IpAddr, port: uint, backlog: uint,
|
|||
iotask: iotask,
|
||||
mut active: true
|
||||
};
|
||||
let server_data_ptr = ptr::addr_of(server_data);
|
||||
let server_data_ptr = ptr::addr_of(&server_data);
|
||||
|
||||
let setup_result = do core::comm::listen |setup_ch| {
|
||||
// this is to address a compiler warning about
|
||||
|
@ -627,13 +627,13 @@ fn listen_common(+host_ip: ip::IpAddr, port: uint, backlog: uint,
|
|||
log(debug, fmt!("addr: %?", addr));
|
||||
let in_addr = uv::ll::ip4_addr(addr_str, port as int);
|
||||
uv::ll::tcp_bind(server_stream_ptr,
|
||||
ptr::addr_of(in_addr))
|
||||
ptr::addr_of(&in_addr))
|
||||
}
|
||||
ip::Ipv6(ref addr) => {
|
||||
log(debug, fmt!("addr: %?", addr));
|
||||
let in_addr = uv::ll::ip6_addr(addr_str, port as int);
|
||||
uv::ll::tcp_bind6(server_stream_ptr,
|
||||
ptr::addr_of(in_addr))
|
||||
ptr::addr_of(&in_addr))
|
||||
}
|
||||
};
|
||||
match bind_result {
|
||||
|
@ -818,7 +818,7 @@ impl TcpSocketBuf: io::Reader {
|
|||
impl TcpSocketBuf: io::Writer {
|
||||
fn write(data: &[const u8]) unsafe {
|
||||
let socket_data_ptr =
|
||||
ptr::addr_of(*((*(self.data)).sock).socket_data);
|
||||
ptr::addr_of(&(*((*(self.data)).sock).socket_data));
|
||||
let w_result = write_common_impl(socket_data_ptr,
|
||||
vec::slice(data, 0, vec::len(data)));
|
||||
if w_result.is_err() {
|
||||
|
@ -850,7 +850,7 @@ fn tear_down_socket_data(socket_data: @TcpSocketData) unsafe {
|
|||
let close_data = {
|
||||
closed_ch: closed_ch
|
||||
};
|
||||
let close_data_ptr = ptr::addr_of(close_data);
|
||||
let close_data_ptr = ptr::addr_of(&close_data);
|
||||
let stream_handle_ptr = (*socket_data).stream_handle_ptr;
|
||||
do iotask::interact((*socket_data).iotask) |loop_ptr| unsafe {
|
||||
log(debug, fmt!("interact dtor for tcp_socket stream %? loop %?",
|
||||
|
@ -966,18 +966,18 @@ fn read_start_common_impl(socket_data: *TcpSocketData)
|
|||
fn write_common_impl(socket_data_ptr: *TcpSocketData,
|
||||
raw_write_data: ~[u8])
|
||||
-> result::Result<(), TcpErrData> unsafe {
|
||||
let write_req_ptr = ptr::addr_of((*socket_data_ptr).write_req);
|
||||
let write_req_ptr = ptr::addr_of(&((*socket_data_ptr).write_req));
|
||||
let stream_handle_ptr =
|
||||
(*socket_data_ptr).stream_handle_ptr;
|
||||
let write_buf_vec = ~[ uv::ll::buf_init(
|
||||
vec::raw::to_ptr(raw_write_data),
|
||||
vec::len(raw_write_data)) ];
|
||||
let write_buf_vec_ptr = ptr::addr_of(write_buf_vec);
|
||||
let write_buf_vec_ptr = ptr::addr_of(&write_buf_vec);
|
||||
let result_po = core::comm::Port::<TcpWriteResult>();
|
||||
let write_data = {
|
||||
result_ch: core::comm::Chan(result_po)
|
||||
};
|
||||
let write_data_ptr = ptr::addr_of(write_data);
|
||||
let write_data_ptr = ptr::addr_of(&write_data);
|
||||
do iotask::interact((*socket_data_ptr).iotask) |loop_ptr| unsafe {
|
||||
log(debug, fmt!("in interact cb for tcp::write %?", loop_ptr));
|
||||
match uv::ll::write(write_req_ptr,
|
||||
|
|
|
@ -773,7 +773,7 @@ mod tests {
|
|||
let m = ~Mutex();
|
||||
let m2 = ~m.clone();
|
||||
let mut sharedstate = ~0;
|
||||
let ptr = ptr::addr_of(*sharedstate);
|
||||
let ptr = ptr::p2::addr_of(&(*sharedstate));
|
||||
do task::spawn {
|
||||
let sharedstate: &mut int =
|
||||
unsafe { cast::reinterpret_cast(&ptr) };
|
||||
|
@ -1045,7 +1045,7 @@ mod tests {
|
|||
let (c,p) = pipes::stream();
|
||||
let x2 = ~x.clone();
|
||||
let mut sharedstate = ~0;
|
||||
let ptr = ptr::addr_of(*sharedstate);
|
||||
let ptr = ptr::p2::addr_of(&(*sharedstate));
|
||||
do task::spawn {
|
||||
let sharedstate: &mut int =
|
||||
unsafe { cast::reinterpret_cast(&ptr) };
|
||||
|
|
|
@ -28,9 +28,9 @@ pub fn delayed_send<T: Copy Send>(iotask: IoTask,
|
|||
unsafe {
|
||||
let timer_done_po = core::comm::Port::<()>();
|
||||
let timer_done_ch = core::comm::Chan(timer_done_po);
|
||||
let timer_done_ch_ptr = ptr::addr_of(timer_done_ch);
|
||||
let timer_done_ch_ptr = ptr::addr_of(&timer_done_ch);
|
||||
let timer = uv::ll::timer_t();
|
||||
let timer_ptr = ptr::addr_of(timer);
|
||||
let timer_ptr = ptr::addr_of(&timer);
|
||||
do iotask::interact(iotask) |loop_ptr| unsafe {
|
||||
let init_result = uv::ll::timer_init(loop_ptr, timer_ptr);
|
||||
if (init_result == 0i32) {
|
||||
|
|
|
@ -138,11 +138,11 @@ mod test {
|
|||
fn impl_uv_hl_simple_timer(iotask: IoTask) unsafe {
|
||||
let exit_po = core::comm::Port::<bool>();
|
||||
let exit_ch = core::comm::Chan(exit_po);
|
||||
let exit_ch_ptr = ptr::addr_of(exit_ch);
|
||||
let exit_ch_ptr = ptr::p2::addr_of(&exit_ch);
|
||||
log(debug, fmt!("EXIT_CH_PTR newly created exit_ch_ptr: %?",
|
||||
exit_ch_ptr));
|
||||
let timer_handle = ll::timer_t();
|
||||
let timer_ptr = ptr::addr_of(timer_handle);
|
||||
let timer_ptr = ptr::p2::addr_of(&timer_handle);
|
||||
do iotask::interact(iotask) |loop_ptr| unsafe {
|
||||
log(debug, ~"user code inside interact loop!!!");
|
||||
let init_status = ll::timer_init(loop_ptr, timer_ptr);
|
||||
|
|
|
@ -13,7 +13,7 @@ export interact;
|
|||
export exit;
|
||||
|
||||
use libc::c_void;
|
||||
use ptr::addr_of;
|
||||
use ptr::p2::addr_of;
|
||||
use comm = core::comm;
|
||||
use comm::{Port, Chan, listen};
|
||||
use task::TaskBuilder;
|
||||
|
@ -96,7 +96,7 @@ fn run_loop(iotask_ch: Chan<IoTask>) unsafe {
|
|||
// set up the special async handle we'll use to allow multi-task
|
||||
// communication with this loop
|
||||
let async = ll::async_t();
|
||||
let async_handle = addr_of(async);
|
||||
let async_handle = addr_of(&async);
|
||||
|
||||
// associate the async handle with the loop
|
||||
ll::async_init(loop_ptr, async_handle, wake_up_cb);
|
||||
|
@ -106,7 +106,7 @@ fn run_loop(iotask_ch: Chan<IoTask>) unsafe {
|
|||
async_handle: async_handle,
|
||||
msg_po: Port()
|
||||
};
|
||||
ll::set_data_for_uv_handle(async_handle, addr_of(data));
|
||||
ll::set_data_for_uv_handle(async_handle, addr_of(&data));
|
||||
|
||||
// Send out a handle through which folks can talk to us
|
||||
// while we dwell in the I/O loop
|
||||
|
@ -188,14 +188,14 @@ mod test {
|
|||
};
|
||||
fn impl_uv_iotask_async(iotask: IoTask) unsafe {
|
||||
let async_handle = ll::async_t();
|
||||
let ah_ptr = ptr::addr_of(async_handle);
|
||||
let ah_ptr = ptr::addr_of(&async_handle);
|
||||
let exit_po = core::comm::Port::<()>();
|
||||
let exit_ch = core::comm::Chan(exit_po);
|
||||
let ah_data = {
|
||||
iotask: iotask,
|
||||
exit_ch: exit_ch
|
||||
};
|
||||
let ah_data_ptr = ptr::addr_of(ah_data);
|
||||
let ah_data_ptr = ptr::addr_of(&ah_data);
|
||||
do interact(iotask) |loop_ptr| unsafe {
|
||||
ll::async_init(loop_ptr, ah_ptr, async_handle_cb);
|
||||
ll::set_data_for_uv_handle(ah_ptr, ah_data_ptr as *libc::c_void);
|
||||
|
|
|
@ -796,7 +796,7 @@ unsafe fn async_send(async_handle: *uv_async_t) {
|
|||
}
|
||||
unsafe fn buf_init(input: *u8, len: uint) -> uv_buf_t {
|
||||
let out_buf = { base: ptr::null(), len: 0 as libc::size_t };
|
||||
let out_buf_ptr = ptr::addr_of(out_buf);
|
||||
let out_buf_ptr = ptr::addr_of(&out_buf);
|
||||
log(debug, fmt!("buf_init - input %u len %u out_buf: %u",
|
||||
input as uint,
|
||||
len as uint,
|
||||
|
@ -968,7 +968,7 @@ unsafe fn free_base_of_buf(buf: uv_buf_t) {
|
|||
|
||||
unsafe fn get_last_err_info(uv_loop: *libc::c_void) -> ~str {
|
||||
let err = last_error(uv_loop);
|
||||
let err_ptr = ptr::addr_of(err);
|
||||
let err_ptr = ptr::addr_of(&err);
|
||||
let err_name = str::raw::from_c_str(err_name(err_ptr));
|
||||
let err_msg = str::raw::from_c_str(strerror(err_ptr));
|
||||
return fmt!("LIBUV ERROR: name: %s msg: %s",
|
||||
|
@ -977,7 +977,7 @@ unsafe fn get_last_err_info(uv_loop: *libc::c_void) -> ~str {
|
|||
|
||||
unsafe fn get_last_err_data(uv_loop: *libc::c_void) -> uv_err_data {
|
||||
let err = last_error(uv_loop);
|
||||
let err_ptr = ptr::addr_of(err);
|
||||
let err_ptr = ptr::addr_of(&err);
|
||||
let err_name = str::raw::from_c_str(err_name(err_ptr));
|
||||
let err_msg = str::raw::from_c_str(strerror(err_ptr));
|
||||
{ err_name: err_name, err_msg: err_msg }
|
||||
|
@ -1120,9 +1120,9 @@ mod test {
|
|||
client_chan: *comm::Chan<~str>) unsafe {
|
||||
let test_loop = loop_new();
|
||||
let tcp_handle = tcp_t();
|
||||
let tcp_handle_ptr = ptr::addr_of(tcp_handle);
|
||||
let tcp_handle_ptr = ptr::addr_of(&tcp_handle);
|
||||
let connect_handle = connect_t();
|
||||
let connect_req_ptr = ptr::addr_of(connect_handle);
|
||||
let connect_req_ptr = ptr::addr_of(&connect_handle);
|
||||
|
||||
// this is the persistent payload of data that we
|
||||
// need to pass around to get this example to work.
|
||||
|
@ -1138,12 +1138,12 @@ mod test {
|
|||
// this is the enclosing record, we'll pass a ptr to
|
||||
// this to C..
|
||||
let write_handle = write_t();
|
||||
let write_handle_ptr = ptr::addr_of(write_handle);
|
||||
let write_handle_ptr = ptr::addr_of(&write_handle);
|
||||
log(debug, fmt!("tcp req: tcp stream: %d write_handle: %d",
|
||||
tcp_handle_ptr as int,
|
||||
write_handle_ptr as int));
|
||||
let client_data = { writer_handle: write_handle_ptr,
|
||||
req_buf: ptr::addr_of(req_msg),
|
||||
req_buf: ptr::addr_of(&req_msg),
|
||||
read_chan: client_chan };
|
||||
|
||||
let tcp_init_result = tcp_init(
|
||||
|
@ -1154,7 +1154,7 @@ mod test {
|
|||
log(debug, ~"building addr...");
|
||||
let addr = ip4_addr(ip, port);
|
||||
// FIXME ref #2064
|
||||
let addr_ptr = ptr::addr_of(addr);
|
||||
let addr_ptr = ptr::addr_of(&addr);
|
||||
log(debug, fmt!("after build addr in rust. port: %u",
|
||||
addr.sin_port as uint));
|
||||
|
||||
|
@ -1169,10 +1169,10 @@ mod test {
|
|||
// until its initialized
|
||||
set_data_for_req(
|
||||
connect_req_ptr as *libc::c_void,
|
||||
ptr::addr_of(client_data) as *libc::c_void);
|
||||
ptr::addr_of(&client_data) as *libc::c_void);
|
||||
set_data_for_uv_handle(
|
||||
tcp_handle_ptr as *libc::c_void,
|
||||
ptr::addr_of(client_data) as *libc::c_void);
|
||||
ptr::addr_of(&client_data) as *libc::c_void);
|
||||
log(debug, ~"before run tcp req loop");
|
||||
run(test_loop);
|
||||
log(debug, ~"after run tcp req loop");
|
||||
|
@ -1369,13 +1369,13 @@ mod test {
|
|||
continue_chan: *comm::Chan<bool>) unsafe {
|
||||
let test_loop = loop_new();
|
||||
let tcp_server = tcp_t();
|
||||
let tcp_server_ptr = ptr::addr_of(tcp_server);
|
||||
let tcp_server_ptr = ptr::addr_of(&tcp_server);
|
||||
|
||||
let tcp_client = tcp_t();
|
||||
let tcp_client_ptr = ptr::addr_of(tcp_client);
|
||||
let tcp_client_ptr = ptr::addr_of(&tcp_client);
|
||||
|
||||
let server_write_req = write_t();
|
||||
let server_write_req_ptr = ptr::addr_of(server_write_req);
|
||||
let server_write_req_ptr = ptr::addr_of(&server_write_req);
|
||||
|
||||
let resp_str_bytes = str::to_bytes(server_resp_msg);
|
||||
let resp_msg_ptr: *u8 = vec::raw::to_ptr(resp_str_bytes);
|
||||
|
@ -1386,20 +1386,20 @@ mod test {
|
|||
|
||||
let continue_async_handle = async_t();
|
||||
let continue_async_handle_ptr =
|
||||
ptr::addr_of(continue_async_handle);
|
||||
ptr::addr_of(&continue_async_handle);
|
||||
let async_data =
|
||||
{ continue_chan: continue_chan };
|
||||
let async_data_ptr = ptr::addr_of(async_data);
|
||||
let async_data_ptr = ptr::addr_of(&async_data);
|
||||
|
||||
let server_data: tcp_server_data = {
|
||||
client: tcp_client_ptr,
|
||||
server: tcp_server_ptr,
|
||||
server_kill_msg: kill_server_msg,
|
||||
server_resp_buf: ptr::addr_of(resp_msg),
|
||||
server_resp_buf: ptr::addr_of(&resp_msg),
|
||||
server_chan: server_chan,
|
||||
server_write_req: server_write_req_ptr
|
||||
};
|
||||
let server_data_ptr = ptr::addr_of(server_data);
|
||||
let server_data_ptr = ptr::addr_of(&server_data);
|
||||
set_data_for_uv_handle(tcp_server_ptr as *libc::c_void,
|
||||
server_data_ptr as *libc::c_void);
|
||||
|
||||
|
@ -1409,7 +1409,7 @@ mod test {
|
|||
if (tcp_init_result == 0i32) {
|
||||
let server_addr = ip4_addr(server_ip, server_port);
|
||||
// FIXME ref #2064
|
||||
let server_addr_ptr = ptr::addr_of(server_addr);
|
||||
let server_addr_ptr = ptr::addr_of(&server_addr);
|
||||
|
||||
// uv_tcp_bind()
|
||||
let bind_result = tcp_bind(tcp_server_ptr,
|
||||
|
@ -1478,13 +1478,13 @@ mod test {
|
|||
|
||||
let continue_port = core::comm::Port::<bool>();
|
||||
let continue_chan = core::comm::Chan::<bool>(continue_port);
|
||||
let continue_chan_ptr = ptr::addr_of(continue_chan);
|
||||
let continue_chan_ptr = ptr::addr_of(&continue_chan);
|
||||
|
||||
do task::spawn_sched(task::ManualThreads(1u)) {
|
||||
do task::spawn_sched(task::ManualThreads(1)) {
|
||||
impl_uv_tcp_server(bind_ip, port,
|
||||
kill_server_msg,
|
||||
server_resp_msg,
|
||||
ptr::addr_of(server_chan),
|
||||
ptr::addr_of(&server_chan),
|
||||
continue_chan_ptr);
|
||||
};
|
||||
|
||||
|
@ -1496,7 +1496,7 @@ mod test {
|
|||
do task::spawn_sched(task::ManualThreads(1u)) {
|
||||
impl_uv_tcp_request(request_ip, port,
|
||||
kill_server_msg,
|
||||
ptr::addr_of(client_chan));
|
||||
ptr::addr_of(&client_chan));
|
||||
};
|
||||
|
||||
let msg_from_client = core::comm::recv(server_port);
|
||||
|
|
|
@ -1094,10 +1094,10 @@ enum ty_ {
|
|||
// since we only care about this for normalizing them to "real" types.
|
||||
impl ty : cmp::Eq {
|
||||
pure fn eq(other: &ty) -> bool {
|
||||
ptr::addr_of(self) == ptr::addr_of((*other))
|
||||
ptr::addr_of(&self) == ptr::addr_of(&(*other))
|
||||
}
|
||||
pure fn ne(other: &ty) -> bool {
|
||||
ptr::addr_of(self) != ptr::addr_of((*other))
|
||||
ptr::addr_of(&self) != ptr::addr_of(&(*other))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -188,7 +188,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
|
|||
return make_conv_call(cx, arg.span, ~"float", cnv, arg);
|
||||
}
|
||||
TyPoly => return make_conv_call(cx, arg.span, ~"poly", cnv,
|
||||
mk_addr_of(cx, sp, arg))
|
||||
mk_addr_of(cx, sp, arg))
|
||||
}
|
||||
}
|
||||
fn log_conv(c: Conv) {
|
||||
|
|
|
@ -71,10 +71,10 @@ impl message: gen_send {
|
|||
|
||||
body += ~"let b = pipe.reuse_buffer();\n";
|
||||
body += fmt!("let %s = pipes::SendPacketBuffered(\
|
||||
ptr::p2::addr_of(&(b.buffer.data.%s)));\n",
|
||||
ptr::addr_of(&(b.buffer.data.%s)));\n",
|
||||
sp, next.name);
|
||||
body += fmt!("let %s = pipes::RecvPacketBuffered(\
|
||||
ptr::p2::addr_of(&(b.buffer.data.%s)));\n",
|
||||
ptr::addr_of(&(b.buffer.data.%s)));\n",
|
||||
rp, next.name);
|
||||
}
|
||||
else {
|
||||
|
@ -351,7 +351,7 @@ impl protocol: gen_init {
|
|||
fmt!("data.%s.set_buffer_(buffer)",
|
||||
s.name))),
|
||||
ext_cx.parse_expr(
|
||||
fmt!("ptr::p2::addr_of(&(data.%s))",
|
||||
fmt!("ptr::addr_of(&(data.%s))",
|
||||
self.states[0].name))));
|
||||
|
||||
#ast {{
|
||||
|
|
|
@ -179,7 +179,7 @@ impl LanguageItemCollector {
|
|||
}
|
||||
|
||||
fn collect_local_language_items() {
|
||||
let this = unsafe { ptr::addr_of(self) };
|
||||
let this = unsafe { ptr::addr_of(&self) };
|
||||
visit_crate(*self.crate, (), mk_simple_visitor(@{
|
||||
visit_item: |item| {
|
||||
for item.attrs.each |attribute| {
|
||||
|
|
|
@ -416,7 +416,7 @@ fn visit_fn(fk: visit::fn_kind, decl: fn_decl, body: blk,
|
|||
let fn_maps = @IrMaps(self.tcx, self.method_map,
|
||||
self.last_use_map);
|
||||
|
||||
debug!("creating fn_maps: %x", ptr::addr_of(*fn_maps) as uint);
|
||||
debug!("creating fn_maps: %x", ptr::addr_of(&(*fn_maps)) as uint);
|
||||
|
||||
for decl.inputs.each |arg| {
|
||||
debug!("adding argument %d", arg.id);
|
||||
|
|
|
@ -134,7 +134,7 @@ fn IndirectBr(cx: block, Addr: ValueRef, NumDests: uint) {
|
|||
// lot more efficient) than doing str::as_c_str("", ...) every time.
|
||||
fn noname() -> *libc::c_char unsafe {
|
||||
const cnull: uint = 0u;
|
||||
return cast::reinterpret_cast(&ptr::addr_of(cnull));
|
||||
return cast::reinterpret_cast(&ptr::addr_of(&cnull));
|
||||
}
|
||||
|
||||
fn Invoke(cx: block, Fn: ValueRef, Args: ~[ValueRef],
|
||||
|
@ -629,8 +629,8 @@ fn Phi(cx: block, Ty: TypeRef, vals: ~[ValueRef], bbs: ~[BasicBlockRef])
|
|||
fn AddIncomingToPhi(phi: ValueRef, val: ValueRef, bb: BasicBlockRef) {
|
||||
if llvm::LLVMIsUndef(phi) == lib::llvm::True { return; }
|
||||
unsafe {
|
||||
let valptr = cast::reinterpret_cast(&ptr::addr_of(val));
|
||||
let bbptr = cast::reinterpret_cast(&ptr::addr_of(bb));
|
||||
let valptr = cast::reinterpret_cast(&ptr::addr_of(&val));
|
||||
let bbptr = cast::reinterpret_cast(&ptr::addr_of(&bb));
|
||||
llvm::LLVMAddIncoming(phi, valptr, bbptr, 1 as c_uint);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -645,7 +645,7 @@ impl block {
|
|||
fmt!("[block %d]", node_info.id)
|
||||
}
|
||||
None => {
|
||||
fmt!("[block %x]", ptr::addr_of(*self) as uint)
|
||||
fmt!("[block %x]", ptr::addr_of(&(*self)) as uint)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -605,7 +605,7 @@ impl @fn_ctxt: region_scope {
|
|||
}
|
||||
|
||||
impl @fn_ctxt {
|
||||
fn tag() -> ~str { fmt!("%x", ptr::addr_of(*self) as uint) }
|
||||
fn tag() -> ~str { fmt!("%x", ptr::addr_of(&(*self)) as uint) }
|
||||
|
||||
fn expr_to_str(expr: @ast::expr) -> ~str {
|
||||
fmt!("expr(%?:%s)", expr.id,
|
||||
|
|
|
@ -34,7 +34,7 @@ struct port_ptr<T:Send> {
|
|||
debug!("in the port_ptr destructor");
|
||||
do task::unkillable {
|
||||
let yield = 0u;
|
||||
let yieldp = ptr::addr_of(yield);
|
||||
let yieldp = ptr::addr_of(&yield);
|
||||
rustrt::rust_port_begin_detach(self.po, yieldp);
|
||||
if yield != 0u {
|
||||
task::yield();
|
||||
|
@ -66,10 +66,10 @@ fn recv<T: Send>(p: port<T>) -> T { recv_((**p).po) }
|
|||
/// Receive on a raw port pointer
|
||||
fn recv_<T: Send>(p: *rust_port) -> T {
|
||||
let yield = 0u;
|
||||
let yieldp = ptr::addr_of(yield);
|
||||
let yieldp = ptr::addr_of(&yield);
|
||||
let mut res;
|
||||
res = rusti::init::<T>();
|
||||
rustrt::port_recv(ptr::addr_of(res) as *uint, p, yieldp);
|
||||
rustrt::port_recv(ptr::addr_of(&res) as *uint, p, yieldp);
|
||||
|
||||
if yield != 0u {
|
||||
// Data isn't available yet, so res has not been initialized.
|
||||
|
|
|
@ -19,7 +19,7 @@ use io::WriterUtil;
|
|||
use pipes::{Port, Chan, SharedChan};
|
||||
|
||||
macro_rules! move_out (
|
||||
{ $x:expr } => { unsafe { let y <- *ptr::addr_of($x); y } }
|
||||
{ $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); y } }
|
||||
)
|
||||
|
||||
enum request {
|
||||
|
|
|
@ -15,7 +15,7 @@ use io::WriterUtil;
|
|||
use pipes::{Port, PortSet, Chan};
|
||||
|
||||
macro_rules! move_out (
|
||||
{ $x:expr } => { unsafe { let y <- *ptr::addr_of($x); y } }
|
||||
{ $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); y } }
|
||||
)
|
||||
|
||||
enum request {
|
||||
|
|
|
@ -24,7 +24,7 @@ proto! ring (
|
|||
fn macros() {
|
||||
#macro[
|
||||
[#move_out[x],
|
||||
unsafe { let y <- *ptr::addr_of(x); y }]
|
||||
unsafe { let y <- *ptr::addr_of(&x); y }]
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ proto! pingpong_unbounded (
|
|||
|
||||
// This stuff should go in libcore::pipes
|
||||
macro_rules! move_it (
|
||||
{ $x:expr } => { let t <- *ptr::addr_of($x); t }
|
||||
{ $x:expr } => { let t <- *ptr::addr_of(&($x)); t }
|
||||
)
|
||||
|
||||
macro_rules! follow (
|
||||
|
|
|
@ -32,7 +32,7 @@ use cmp::Eq;
|
|||
use to_bytes::IterBytes;
|
||||
|
||||
macro_rules! move_out (
|
||||
{ $x:expr } => { unsafe { let y <- *ptr::addr_of($x); y } }
|
||||
{ $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); y } }
|
||||
)
|
||||
|
||||
trait word_reader {
|
||||
|
|
|
@ -103,8 +103,8 @@ fn test_class() {
|
|||
|
||||
unsafe {
|
||||
error!("q = %x, r = %x",
|
||||
(cast::reinterpret_cast::<*p, uint>(&ptr::addr_of(q))),
|
||||
(cast::reinterpret_cast::<*p, uint>(&ptr::addr_of(r))));
|
||||
(cast::reinterpret_cast::<*p, uint>(&ptr::addr_of(&q))),
|
||||
(cast::reinterpret_cast::<*p, uint>(&ptr::addr_of(&r))));
|
||||
}
|
||||
assert(q == r);
|
||||
r.y = 17;
|
||||
|
|
|
@ -7,7 +7,7 @@ fn borrow(x: &int, f: fn(x: &int)) {
|
|||
fn test1(x: @~int) {
|
||||
// Right now, at least, this induces a copy of the unique pointer:
|
||||
do borrow({*x}) |p| {
|
||||
let x_a = ptr::addr_of(**x);
|
||||
let x_a = ptr::addr_of(&(**x));
|
||||
assert (x_a as uint) != to_uint(p);
|
||||
assert unsafe{*x_a} == *p;
|
||||
}
|
||||
|
|
|
@ -5,13 +5,13 @@ fn main() {
|
|||
match *x {
|
||||
{f: b_x} => {
|
||||
assert *b_x == 3;
|
||||
assert ptr::addr_of(*x.f) == ptr::addr_of(*b_x);
|
||||
assert ptr::addr_of(&(*x.f)) == ptr::addr_of(&(*b_x));
|
||||
|
||||
x = @{f: ~4};
|
||||
|
||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(*b_x) as uint);
|
||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(&(*b_x)) as uint);
|
||||
assert *b_x == 3;
|
||||
assert ptr::addr_of(*x.f) != ptr::addr_of(*b_x);
|
||||
assert ptr::addr_of(&(*x.f)) != ptr::addr_of(&(*b_x));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,11 +11,11 @@ fn main() {
|
|||
let mut x = @{f: ~3};
|
||||
do borrow(x.f) |b_x| {
|
||||
assert *b_x == 3;
|
||||
assert ptr::addr_of(*x.f) == ptr::addr_of(*b_x);
|
||||
assert ptr::addr_of(&(*x.f)) == ptr::addr_of(&(*b_x));
|
||||
x = @{f: ~4};
|
||||
|
||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(*b_x) as uint);
|
||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(&(*b_x)) as uint);
|
||||
assert *b_x == 3;
|
||||
assert ptr::addr_of(*x.f) != ptr::addr_of(*b_x);
|
||||
assert ptr::addr_of(&(*x.f)) != ptr::addr_of(&(*b_x));
|
||||
}
|
||||
}
|
|
@ -5,13 +5,13 @@ fn main() {
|
|||
match x {
|
||||
@@{f: b_x} => {
|
||||
assert *b_x == 3;
|
||||
assert ptr::addr_of(x.f) == ptr::addr_of(b_x);
|
||||
assert ptr::addr_of(&(x.f)) == ptr::addr_of(&(b_x));
|
||||
|
||||
*x = @{f: ~4};
|
||||
|
||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(*b_x) as uint);
|
||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(&(*b_x)) as uint);
|
||||
assert *b_x == 3;
|
||||
assert ptr::addr_of(*x.f) != ptr::addr_of(*b_x);
|
||||
assert ptr::addr_of(&(*x.f)) != ptr::addr_of(&(*b_x));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,11 +11,11 @@ fn main() {
|
|||
let mut x = ~mut @{f: ~3};
|
||||
do borrow(x.f) |b_x| {
|
||||
assert *b_x == 3;
|
||||
assert ptr::addr_of(*x.f) == ptr::addr_of(*b_x);
|
||||
assert ptr::addr_of(&(*x.f)) == ptr::addr_of(&(*b_x));
|
||||
*x = @{f: ~4};
|
||||
|
||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(*b_x) as uint);
|
||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(&(*b_x)) as uint);
|
||||
assert *b_x == 3;
|
||||
assert ptr::addr_of(*x.f) != ptr::addr_of(*b_x);
|
||||
assert ptr::addr_of(&(*x.f)) != ptr::addr_of(&(*b_x));
|
||||
}
|
||||
}
|
|
@ -11,11 +11,11 @@ fn main() {
|
|||
let mut x = @3;
|
||||
do borrow(x) |b_x| {
|
||||
assert *b_x == 3;
|
||||
assert ptr::addr_of(*x) == ptr::addr_of(*b_x);
|
||||
assert ptr::addr_of(&(*x)) == ptr::addr_of(&(*b_x));
|
||||
x = @22;
|
||||
|
||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(*b_x) as uint);
|
||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(&(*b_x)) as uint);
|
||||
assert *b_x == 3;
|
||||
assert ptr::addr_of(*x) != ptr::addr_of(*b_x);
|
||||
assert ptr::addr_of(&(*x)) != ptr::addr_of(&(*b_x));
|
||||
}
|
||||
}
|
|
@ -11,11 +11,11 @@ fn main() {
|
|||
let mut x = @{f: ~3};
|
||||
do borrow((*x).f) |b_x| {
|
||||
assert *b_x == 3;
|
||||
assert ptr::addr_of(*x.f) == ptr::addr_of(*b_x);
|
||||
assert ptr::addr_of(&(*x.f)) == ptr::addr_of(&(*b_x));
|
||||
x = @{f: ~4};
|
||||
|
||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(*b_x) as uint);
|
||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(&(*b_x)) as uint);
|
||||
assert *b_x == 3;
|
||||
assert ptr::addr_of(*x.f) != ptr::addr_of(*b_x);
|
||||
assert ptr::addr_of(&(*x.f)) != ptr::addr_of(&(*b_x));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
fn main() {
|
||||
let x = ~1;
|
||||
let y = ptr::addr_of(*x) as uint;
|
||||
let lam_copy = fn@(copy x) -> uint { ptr::addr_of(*x) as uint };
|
||||
let lam_move = fn@(move x) -> uint { ptr::addr_of(*x) as uint };
|
||||
let y = ptr::addr_of(&(*x)) as uint;
|
||||
let lam_copy = fn@(copy x) -> uint { ptr::addr_of(&(*x)) as uint };
|
||||
let lam_move = fn@(move x) -> uint { ptr::addr_of(&(*x)) as uint };
|
||||
assert lam_copy() != y;
|
||||
assert lam_move() == y;
|
||||
|
||||
let x = ~2;
|
||||
let y = ptr::addr_of(*x) as uint;
|
||||
let lam_copy: fn@() -> uint = |copy x| ptr::addr_of(*x) as uint;
|
||||
let lam_move: fn@() -> uint = |move x| ptr::addr_of(*x) as uint;
|
||||
let y = ptr::addr_of(&(*x)) as uint;
|
||||
let lam_copy: fn@() -> uint = |copy x| ptr::addr_of(&(*x)) as uint;
|
||||
let lam_move: fn@() -> uint = |move x| ptr::addr_of(&(*x)) as uint;
|
||||
assert lam_copy() != y;
|
||||
assert lam_move() == y;
|
||||
|
||||
let x = ~3;
|
||||
let y = ptr::addr_of(*x) as uint;
|
||||
let snd_copy = fn~(copy x) -> uint { ptr::addr_of(*x) as uint };
|
||||
let snd_move = fn~(move x) -> uint { ptr::addr_of(*x) as uint };
|
||||
let y = ptr::addr_of(&(*x)) as uint;
|
||||
let snd_copy = fn~(copy x) -> uint { ptr::addr_of(&(*x)) as uint };
|
||||
let snd_move = fn~(move x) -> uint { ptr::addr_of(&(*x)) as uint };
|
||||
assert snd_copy() != y;
|
||||
assert snd_move() == y;
|
||||
|
||||
let x = ~4;
|
||||
let y = ptr::addr_of(*x) as uint;
|
||||
let lam_copy: fn~() -> uint = |copy x| ptr::addr_of(*x) as uint;
|
||||
let lam_move: fn~() -> uint = |move x| ptr::addr_of(*x) as uint;
|
||||
let y = ptr::addr_of(&(*x)) as uint;
|
||||
let lam_copy: fn~() -> uint = |copy x| ptr::addr_of(&(*x)) as uint;
|
||||
let lam_move: fn~() -> uint = |move x| ptr::addr_of(&(*x)) as uint;
|
||||
assert lam_copy() != y;
|
||||
assert lam_move() == y;
|
||||
}
|
||||
|
|
|
@ -201,7 +201,7 @@ mod pingpong {
|
|||
|
||||
fn liberate_ping(-p: ping) -> pipes::send_packet<pong> unsafe {
|
||||
let addr : *pipes::send_packet<pong> = match p {
|
||||
ping(x) => { cast::transmute(ptr::addr_of(x)) }
|
||||
ping(x) => { cast::transmute(ptr::addr_of(&x)) }
|
||||
};
|
||||
let liberated_value <- *addr;
|
||||
cast::forget(p);
|
||||
|
@ -210,7 +210,7 @@ mod pingpong {
|
|||
|
||||
fn liberate_pong(-p: pong) -> pipes::send_packet<ping> unsafe {
|
||||
let addr : *pipes::send_packet<ping> = match p {
|
||||
pong(x) => { cast::transmute(ptr::addr_of(x)) }
|
||||
pong(x) => { cast::transmute(ptr::addr_of(&x)) }
|
||||
};
|
||||
let liberated_value <- *addr;
|
||||
cast::forget(p);
|
||||
|
|
|
@ -4,14 +4,14 @@
|
|||
fn main() {
|
||||
// Make sure closing over can be a last use
|
||||
let q = ~10;
|
||||
let addr = ptr::addr_of(*q);
|
||||
let f = fn@() -> *int { ptr::addr_of(*q) };
|
||||
let addr = ptr::addr_of(&(*q));
|
||||
let f = fn@() -> *int { ptr::addr_of(&(*q)) };
|
||||
assert addr == f();
|
||||
|
||||
// But only when it really is the last use
|
||||
let q = ~20;
|
||||
let f = fn@() -> *int { ptr::addr_of(*q) };
|
||||
assert ptr::addr_of(*q) != f();
|
||||
let f = fn@() -> *int { ptr::addr_of(&(*q)) };
|
||||
assert ptr::addr_of(&(*q)) != f();
|
||||
|
||||
// Ensure function arguments and box arguments interact sanely.
|
||||
fn call_me(x: fn() -> int, y: ~int) { assert x() == *y; }
|
||||
|
|
|
@ -33,7 +33,7 @@ proto! bank (
|
|||
)
|
||||
|
||||
macro_rules! move_it (
|
||||
{ $x:expr } => { unsafe { let y <- *ptr::addr_of($x); y } }
|
||||
{ $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); y } }
|
||||
)
|
||||
|
||||
fn switch<T: Send, U>(+endp: pipes::RecvPacket<T>,
|
||||
|
|
|
@ -28,7 +28,7 @@ mod pingpong {
|
|||
do pipes::entangle_buffer(buffer) |buffer, data| {
|
||||
data.ping.set_buffer_(buffer);
|
||||
data.pong.set_buffer_(buffer);
|
||||
ptr::addr_of(data.ping)
|
||||
ptr::addr_of(&(data.ping))
|
||||
}
|
||||
}
|
||||
enum ping = server::pong;
|
||||
|
@ -38,8 +38,8 @@ mod pingpong {
|
|||
fn ping(+pipe: ping) -> pong {
|
||||
{
|
||||
let b = pipe.reuse_buffer();
|
||||
let s = SendPacketBuffered(ptr::addr_of(b.buffer.data.pong));
|
||||
let c = RecvPacketBuffered(ptr::addr_of(b.buffer.data.pong));
|
||||
let s = SendPacketBuffered(ptr::addr_of(&(b.buffer.data.pong)));
|
||||
let c = RecvPacketBuffered(ptr::addr_of(&(b.buffer.data.pong)));
|
||||
let message = pingpong::ping(s);
|
||||
pipes::send(pipe, message);
|
||||
c
|
||||
|
@ -57,8 +57,8 @@ mod pingpong {
|
|||
fn pong(+pipe: pong) -> ping {
|
||||
{
|
||||
let b = pipe.reuse_buffer();
|
||||
let s = SendPacketBuffered(ptr::addr_of(b.buffer.data.ping));
|
||||
let c = RecvPacketBuffered(ptr::addr_of(b.buffer.data.ping));
|
||||
let s = SendPacketBuffered(ptr::addr_of(&(b.buffer.data.ping)));
|
||||
let c = RecvPacketBuffered(ptr::addr_of(&(b.buffer.data.ping)));
|
||||
let message = pingpong::pong(s);
|
||||
pipes::send(pipe, message);
|
||||
c
|
||||
|
|
|
@ -612,7 +612,7 @@ fn get_tydesc_for<T>(&&_t: T) -> *TyDesc {
|
|||
|
||||
fn main() {
|
||||
let r = (1,2,3,true,false,{x:5,y:4,z:3});
|
||||
let p = ptr::addr_of(r) as *c_void;
|
||||
let p = ptr::addr_of(&r) as *c_void;
|
||||
let u = my_visitor(@{mut ptr1: p,
|
||||
mut ptr2: p,
|
||||
mut vals: ~[]});
|
||||
|
|
|
@ -4,8 +4,8 @@ struct r {
|
|||
v: *int,
|
||||
drop unsafe {
|
||||
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::<**int, uint>(&ptr::addr_of(self.v)),
|
||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(&self)),
|
||||
cast::reinterpret_cast::<**int, uint>(&ptr::addr_of(&(self.v))),
|
||||
cast::reinterpret_cast::<*int, uint>(&self.v));
|
||||
let v2: ~int = cast::reinterpret_cast(&self.v); }
|
||||
}
|
||||
|
@ -34,27 +34,27 @@ fn main() unsafe {
|
|||
r: {
|
||||
let rs = r(i1p);
|
||||
debug!("r = %x",
|
||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(rs)));
|
||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(&rs)));
|
||||
rs }
|
||||
});
|
||||
|
||||
debug!("x1 = %x, x1.r = %x",
|
||||
cast::reinterpret_cast::<@t, uint>(&x1),
|
||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(x1.r)));
|
||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(&(x1.r))));
|
||||
|
||||
let x2 = @t({
|
||||
mut next: None,
|
||||
r: {
|
||||
let rs = r(i2p);
|
||||
debug!("r2 = %x",
|
||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(rs)));
|
||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(&rs)));
|
||||
rs
|
||||
}
|
||||
});
|
||||
|
||||
debug!("x2 = %x, x2.r = %x",
|
||||
cast::reinterpret_cast::<@t, uint>(&x2),
|
||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(x2.r)));
|
||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(&(x2.r))));
|
||||
|
||||
x1.next = Some(x2);
|
||||
x2.next = Some(x1);
|
||||
|
|
|
@ -33,7 +33,7 @@ fn main() unsafe {
|
|||
assert child_sched_id == new_sched_id;
|
||||
comm::send(ch, ());
|
||||
};
|
||||
let fptr = cast::reinterpret_cast(&ptr::addr_of(f));
|
||||
let fptr = cast::reinterpret_cast(&ptr::addr_of(&f));
|
||||
rustrt::start_task(new_task_id, fptr);
|
||||
cast::forget(f);
|
||||
comm::recv(po);
|
||||
|
|
|
@ -28,7 +28,7 @@ macro_rules! select_if (
|
|||
match move pipes::try_recv($port) {
|
||||
$(Some($message($($(ref $x,)+)* ref next)) => {
|
||||
// FIXME (#2329) we really want move out of enum here.
|
||||
let $next = unsafe { let x <- *ptr::addr_of(*next); x };
|
||||
let $next = unsafe { let x <- *ptr::addr_of(&(*next)); x };
|
||||
$e
|
||||
})+
|
||||
_ => fail
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
|
||||
fn main() {
|
||||
let foo = 1;
|
||||
assert ptr::addr_of(foo) == ptr::addr_of(foo);
|
||||
assert ptr::addr_of(&foo) == ptr::addr_of(&foo);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ struct notify {
|
|||
drop {
|
||||
error!("notify: task=%? v=%x unwinding=%b b=%b",
|
||||
task::get_task(),
|
||||
ptr::addr_of(*(self.v)) as uint,
|
||||
ptr::addr_of(&(*(self.v))) as uint,
|
||||
task::failing(),
|
||||
*(self.v));
|
||||
let b = *(self.v);
|
||||
|
@ -30,7 +30,7 @@ fn joinable(+f: fn~()) -> comm::Port<bool> {
|
|||
let b = @mut false;
|
||||
error!("wrapper: task=%? allocated v=%x",
|
||||
task::get_task(),
|
||||
ptr::addr_of(*b) as uint);
|
||||
ptr::addr_of(&(*b)) as uint);
|
||||
let _r = notify(c, b);
|
||||
f();
|
||||
*b = true;
|
||||
|
|
|
@ -3,16 +3,16 @@ fn main() {
|
|||
let ch = comm::Chan(p);
|
||||
|
||||
let x = ~1;
|
||||
let x_in_parent = ptr::addr_of(*x) as uint;
|
||||
let x_in_parent = ptr::addr_of(&(*x)) as uint;
|
||||
|
||||
let y = ~2;
|
||||
let y_in_parent = ptr::addr_of(*y) as uint;
|
||||
let y_in_parent = ptr::addr_of(&(*y)) as uint;
|
||||
|
||||
task::spawn(fn~(copy ch, copy y, move x) {
|
||||
let x_in_child = ptr::addr_of(*x) as uint;
|
||||
let x_in_child = ptr::addr_of(&(*x)) as uint;
|
||||
comm::send(ch, x_in_child);
|
||||
|
||||
let y_in_child = ptr::addr_of(*y) as uint;
|
||||
let y_in_child = ptr::addr_of(&(*y)) as uint;
|
||||
comm::send(ch, y_in_child);
|
||||
});
|
||||
// Ensure last-use analysis doesn't move y to child.
|
||||
|
|
|
@ -9,7 +9,7 @@ type pointy = {
|
|||
};
|
||||
|
||||
fn make_uniq_closure<A:Send Copy>(a: A) -> fn~() -> uint {
|
||||
fn~() -> uint { ptr::addr_of(a) as uint }
|
||||
fn~() -> uint { ptr::addr_of(&a) as uint }
|
||||
}
|
||||
|
||||
fn empty_pointy() -> @pointy {
|
||||
|
|
Loading…
Reference in New Issue