Permalink
Browse files

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.
  • Loading branch information...
1 parent 72ae426 commit b18320446e553a3f8436f87306dded57e16a4b94 @catamorphism catamorphism committed Oct 1, 2012
Showing with 169 additions and 172 deletions.
  1. +1 −1 doc/tutorial-ffi.md
  2. +1 −1 src/libcore/at_vec.rs
  3. +1 −1 src/libcore/box.rs
  4. +6 −6 src/libcore/comm.rs
  5. +2 −2 src/libcore/flate.rs
  6. +1 −1 src/libcore/gc.rs
  7. +9 −9 src/libcore/pipes.rs
  8. +1 −4 src/libcore/ptr.rs
  9. +1 −1 src/libcore/str.rs
  10. +1 −1 src/libcore/task/spawn.rs
  11. +1 −1 src/libcore/vec.rs
  12. +4 −4 src/libstd/dbg.rs
  13. +3 −3 src/libstd/net_ip.rs
  14. +21 −21 src/libstd/net_tcp.rs
  15. +2 −2 src/libstd/sync.rs
  16. +2 −2 src/libstd/timer.rs
  17. +2 −2 src/libstd/uv_global_loop.rs
  18. +5 −5 src/libstd/uv_iotask.rs
  19. +22 −22 src/libstd/uv_ll.rs
  20. +2 −2 src/libsyntax/ast.rs
  21. +1 −1 src/libsyntax/ext/fmt.rs
  22. +3 −3 src/libsyntax/ext/pipes/pipec.rs
  23. +1 −1 src/rustc/middle/lang_items.rs
  24. +1 −1 src/rustc/middle/liveness.rs
  25. +3 −3 src/rustc/middle/trans/build.rs
  26. +1 −1 src/rustc/middle/trans/common.rs
  27. +1 −1 src/rustc/middle/typeck/check.rs
  28. +3 −3 src/test/auxiliary/test_comm.rs
  29. +1 −1 src/test/bench/msgsend-pipes-shared.rs
  30. +1 −1 src/test/bench/msgsend-pipes.rs
  31. +1 −1 src/test/bench/msgsend-ring-pipes.rs
  32. +1 −1 src/test/bench/pingpong.rs
  33. +1 −1 src/test/bench/task-perf-word-count-generic.rs
  34. +2 −2 src/test/run-pass/binops.rs
  35. +1 −1 src/test/run-pass/borrowck-borrow-from-expr-block.rs
  36. +3 −3 src/test/run-pass/borrowck-preserve-box-in-discr.rs
  37. +3 −3 src/test/run-pass/borrowck-preserve-box-in-field.rs
  38. +3 −3 src/test/run-pass/borrowck-preserve-box-in-pat.rs
  39. +3 −3 src/test/run-pass/borrowck-preserve-box-in-uniq.rs
  40. +3 −3 src/test/run-pass/borrowck-preserve-box.rs
  41. +3 −3 src/test/run-pass/borrowck-preserve-expl-deref.rs
  42. +12 −12 src/test/run-pass/cap-clause-move.rs
  43. +2 −2 src/test/run-pass/issue-2718.rs
  44. +4 −4 src/test/run-pass/last-use-corner-cases.rs
  45. +1 −1 src/test/run-pass/pipe-bank-proto.rs
  46. +5 −5 src/test/run-pass/pipe-pingpong-bounded.rs
  47. +1 −1 src/test/run-pass/reflect-visit-data.rs
  48. +6 −6 src/test/run-pass/resource-cycle.rs
  49. +1 −1 src/test/run-pass/rt-sched-1.rs
  50. +1 −1 src/test/run-pass/select-macro.rs
  51. +1 −1 src/test/run-pass/stable-addr-of.rs
  52. +2 −2 src/test/run-pass/task-killjoin-rsrc.rs
  53. +4 −4 src/test/run-pass/task-spawn-move-and-copy.rs
  54. +1 −1 src/test/run-pass/uniq-cc-generic.rs
View
@@ -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);
}
View
@@ -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.
View
@@ -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
@findow

findow Oct 13, 2012

Shouldn't the description go outside function declaration?

@nikomatsakis

nikomatsakis Oct 14, 2012

Contributor

The "//!" comment means "the description applies to the enclosing item". So this is correct. I personally find this style easier to read, as well.

- 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 {
View
@@ -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);
}
View
@@ -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,
View
@@ -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()
};
View
@@ -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)))))
}
}
}
View
@@ -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
View
@@ -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,()>;
View
@@ -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;
View
@@ -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 {
View
@@ -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> {
Oops, something went wrong.

0 comments on commit b183204

Please sign in to comment.