Skip to content

Commit b183204

Browse files
committed
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.
1 parent 72ae426 commit b183204

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+169
-172
lines changed

doc/tutorial-ffi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ fn unix_time_in_microseconds() -> u64 unsafe {
231231
mut tv_sec: 0 as c_ulonglong,
232232
mut tv_usec: 0 as c_ulonglong
233233
};
234-
lib_c::gettimeofday(ptr::addr_of(x), ptr::null());
234+
lib_c::gettimeofday(ptr::addr_of(&x), ptr::null());
235235
return (x.tv_sec as u64) * 1000_000_u64 + (x.tv_usec as u64);
236236
}
237237

src/libcore/at_vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#[forbid(deprecated_pattern)];
66

77
use cast::transmute;
8-
use ptr::p2::addr_of;
8+
use ptr::addr_of;
99

1010
/// Code for dealing with @-vectors. This is pretty incomplete, and
1111
/// contains a bunch of duplication from the code for ~-vectors.

src/libcore/box.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub mod raw {
2424

2525
pub pure fn ptr_eq<T>(a: @T, b: @T) -> bool {
2626
//! Determine if two shared boxes point to the same object
27-
unsafe { ptr::p2::addr_of(&(*a)) == ptr::p2::addr_of(&(*b)) }
27+
unsafe { ptr::addr_of(&(*a)) == ptr::addr_of(&(*b)) }
2828
}
2929

3030
impl<T:Eq> @const T : Eq {

src/libcore/comm.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ struct PortPtr<T:Send> {
103103
// Once the port is detached it's guaranteed not to receive further
104104
// messages
105105
let yield = 0;
106-
let yieldp = ptr::p2::addr_of(&yield);
106+
let yieldp = ptr::addr_of(&yield);
107107
rustrt::rust_port_begin_detach(self.po, yieldp);
108108
if yield != 0 {
109109
// Need to wait for the port to be detached
@@ -176,7 +176,7 @@ pub fn Chan<T: Send>(p: Port<T>) -> Chan<T> {
176176
*/
177177
pub fn send<T: Send>(ch: Chan<T>, +data: T) {
178178
let Chan_(p) = ch;
179-
let data_ptr = ptr::p2::addr_of(&data) as *();
179+
let data_ptr = ptr::addr_of(&data) as *();
180180
let res = rustrt::rust_port_id_send(p, data_ptr);
181181
if res != 0 unsafe {
182182
// Data sent successfully
@@ -206,10 +206,10 @@ fn peek_chan<T: Send>(ch: comm::Chan<T>) -> bool {
206206
/// Receive on a raw port pointer
207207
fn recv_<T: Send>(p: *rust_port) -> T {
208208
let yield = 0;
209-
let yieldp = ptr::p2::addr_of(&yield);
209+
let yieldp = ptr::addr_of(&yield);
210210
let mut res;
211211
res = rusti::init::<T>();
212-
rustrt::port_recv(ptr::p2::addr_of(&res) as *uint, p, yieldp);
212+
rustrt::port_recv(ptr::addr_of(&res) as *uint, p, yieldp);
213213

214214
if yield != 0 {
215215
// Data isn't available yet, so res has not been initialized.
@@ -233,12 +233,12 @@ fn peek_(p: *rust_port) -> bool {
233233
pub fn select2<A: Send, B: Send>(p_a: Port<A>, p_b: Port<B>)
234234
-> Either<A, B> {
235235
let ports = ~[(**p_a).po, (**p_b).po];
236-
let yield = 0, yieldp = ptr::p2::addr_of(&yield);
236+
let yield = 0, yieldp = ptr::addr_of(&yield);
237237

238238
let mut resport: *rust_port;
239239
resport = rusti::init::<*rust_port>();
240240
do vec::as_imm_buf(ports) |ports, n_ports| {
241-
rustrt::rust_port_select(ptr::p2::addr_of(&resport), ports,
241+
rustrt::rust_port_select(ptr::addr_of(&resport), ports,
242242
n_ports as size_t, yieldp);
243243
}
244244

src/libcore/flate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub fn deflate_bytes(bytes: &[const u8]) -> ~[u8] {
3434
let res =
3535
rustrt::tdefl_compress_mem_to_heap(b as *c_void,
3636
len as size_t,
37-
ptr::addr_of(outsz),
37+
ptr::addr_of(&outsz),
3838
lz_norm);
3939
assert res as int != 0;
4040
let out = vec::raw::from_buf(res as *u8,
@@ -52,7 +52,7 @@ pub fn inflate_bytes(bytes: &[const u8]) -> ~[u8] {
5252
let res =
5353
rustrt::tinfl_decompress_mem_to_heap(b as *c_void,
5454
len as size_t,
55-
ptr::addr_of(outsz),
55+
ptr::addr_of(&outsz),
5656
0);
5757
assert res as int != 0;
5858
let out = vec::raw::from_buf(res as *u8,

src/libcore/gc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ pub fn cleanup_stack_for_failure() {
316316
// own stack roots on the stack anyway.
317317
let sentinel_box = ~0;
318318
let sentinel: **Word = if expect_sentinel() {
319-
cast::reinterpret_cast(&ptr::p2::addr_of(&sentinel_box))
319+
cast::reinterpret_cast(&ptr::addr_of(&sentinel_box))
320320
} else {
321321
ptr::null()
322322
};

src/libcore/pipes.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ use option::unwrap;
8585
const SPIN_COUNT: uint = 0;
8686

8787
macro_rules! move_it (
88-
{ $x:expr } => { unsafe { let y <- *ptr::addr_of($x); move y } }
88+
{ $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); move y } }
8989
)
9090

9191
#[doc(hidden)]
@@ -219,7 +219,7 @@ fn unibuffer<T: Send>() -> ~Buffer<Packet<T>> {
219219
#[doc(hidden)]
220220
pub fn packet<T: Send>() -> *Packet<T> {
221221
let b = unibuffer();
222-
let p = ptr::p2::addr_of(&(b.data));
222+
let p = ptr::addr_of(&(b.data));
223223
// We'll take over memory management from here.
224224
unsafe { forget(move b) }
225225
p
@@ -359,7 +359,7 @@ pub fn send<T: Send, Tbuffer: Send>(+p: SendPacketBuffered<T, Tbuffer>,
359359
let header = p.header();
360360
let p_ = p.unwrap();
361361
let p = unsafe { &*p_ };
362-
assert ptr::p2::addr_of(&(p.header)) == header;
362+
assert ptr::addr_of(&(p.header)) == header;
363363
assert p.payload.is_none();
364364
p.payload <- Some(move payload);
365365
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>,
377377
let old_task = swap_task(&mut p.header.blocked_task, ptr::null());
378378
if !old_task.is_null() {
379379
rustrt::task_signal_event(
380-
old_task, ptr::p2::addr_of(&(p.header)) as *libc::c_void);
380+
old_task, ptr::addr_of(&(p.header)) as *libc::c_void);
381381
rustrt::rust_task_deref(old_task);
382382
}
383383

@@ -529,7 +529,7 @@ fn sender_terminate<T: Send>(p: *Packet<T>) {
529529
if !old_task.is_null() {
530530
rustrt::task_signal_event(
531531
old_task,
532-
ptr::p2::addr_of(&(p.header)) as *libc::c_void);
532+
ptr::addr_of(&(p.header)) as *libc::c_void);
533533
rustrt::rust_task_deref(old_task);
534534
}
535535
// The receiver will eventually clean up.
@@ -744,7 +744,7 @@ pub fn SendPacketBuffered<T: Send, Tbuffer: Send>(p: *Packet<T>)
744744
p: Some(p),
745745
buffer: unsafe {
746746
Some(BufferResource(
747-
get_buffer(ptr::p2::addr_of(&((*p).header)))))
747+
get_buffer(ptr::addr_of(&((*p).header)))))
748748
}
749749
}
750750
}
@@ -760,7 +760,7 @@ impl<T: Send, Tbuffer: Send> SendPacketBuffered<T, Tbuffer> {
760760
match self.p {
761761
Some(packet) => unsafe {
762762
let packet = &*packet;
763-
let header = ptr::p2::addr_of(&(packet.header));
763+
let header = ptr::addr_of(&(packet.header));
764764
//forget(packet);
765765
header
766766
},
@@ -815,7 +815,7 @@ impl<T: Send, Tbuffer: Send> RecvPacketBuffered<T, Tbuffer> : Selectable {
815815
match self.p {
816816
Some(packet) => unsafe {
817817
let packet = &*packet;
818-
let header = ptr::p2::addr_of(&(packet.header));
818+
let header = ptr::addr_of(&(packet.header));
819819
//forget(packet);
820820
header
821821
},
@@ -838,7 +838,7 @@ pub fn RecvPacketBuffered<T: Send, Tbuffer: Send>(p: *Packet<T>)
838838
p: Some(p),
839839
buffer: unsafe {
840840
Some(BufferResource(
841-
get_buffer(ptr::p2::addr_of(&((*p).header)))))
841+
get_buffer(ptr::addr_of(&((*p).header)))))
842842
}
843843
}
844844
}

src/libcore/ptr.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,9 @@ extern mod rusti {
2424
fn addr_of<T>(val: T) -> *T;
2525
}
2626

27-
/*
28-
Remove this after snapshot; make p2::addr_of addr_of
29-
*/
3027
/// Get an unsafe pointer to a value
3128
#[inline(always)]
32-
pub pure fn addr_of<T>(val: T) -> *T { unsafe { rusti::addr_of(val) } }
29+
pub pure fn addr_of<T>(val: &T) -> *T { unsafe { rusti::addr_of(*val) } }
3330

3431
pub mod p2 {
3532
/// Get an unsafe pointer to a value

src/libcore/str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1780,7 +1780,7 @@ pub pure fn as_c_str<T>(s: &str, f: fn(*libc::c_char) -> T) -> T {
17801780
#[inline(always)]
17811781
pub pure fn as_buf<T>(s: &str, f: fn(*u8, uint) -> T) -> T {
17821782
unsafe {
1783-
let v : *(*u8,uint) = ::cast::reinterpret_cast(&ptr::p2::addr_of(&s));
1783+
let v : *(*u8,uint) = ::cast::reinterpret_cast(&ptr::addr_of(&s));
17841784
let (buf,len) = *v;
17851785
f(buf, len)
17861786
}

src/libcore/task/spawn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ use rt::rust_task;
6666
use rt::rust_closure;
6767

6868
macro_rules! move_it (
69-
{ $x:expr } => { unsafe { let y <- *ptr::p2::addr_of(&($x)); move y } }
69+
{ $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); move y } }
7070
)
7171

7272
type TaskSet = send_map::linear::LinearMap<*rust_task,()>;

src/libcore/vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
use cmp::{Eq, Ord};
88
use option::{Some, None};
9-
use ptr::p2::addr_of;
9+
use ptr::addr_of;
1010
use libc::size_t;
1111

1212
export append;

src/libstd/dbg.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@ pub fn debug_tydesc<T>() {
2121
}
2222

2323
pub fn debug_opaque<T>(+x: T) {
24-
rustrt::debug_opaque(sys::get_type_desc::<T>(), ptr::addr_of(x) as *());
24+
rustrt::debug_opaque(sys::get_type_desc::<T>(), ptr::addr_of(&x) as *());
2525
}
2626

2727
pub fn debug_box<T>(x: @T) {
28-
rustrt::debug_box(sys::get_type_desc::<T>(), ptr::addr_of(x) as *());
28+
rustrt::debug_box(sys::get_type_desc::<T>(), ptr::addr_of(&x) as *());
2929
}
3030

3131
pub fn debug_tag<T>(+x: T) {
32-
rustrt::debug_tag(sys::get_type_desc::<T>(), ptr::addr_of(x) as *());
32+
rustrt::debug_tag(sys::get_type_desc::<T>(), ptr::addr_of(&x) as *());
3333
}
3434

3535
pub fn debug_fn<T>(+x: T) {
36-
rustrt::debug_fn(sys::get_type_desc::<T>(), ptr::addr_of(x) as *());
36+
rustrt::debug_fn(sys::get_type_desc::<T>(), ptr::addr_of(&x) as *());
3737
}
3838

3939
pub unsafe fn ptr_cast<T, U>(x: @T) -> @U {

src/libstd/net_ip.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ fn get_addr(node: &str, iotask: iotask)
8989
do str::as_buf(node) |node_ptr, len| unsafe {
9090
log(debug, fmt!("slice len %?", len));
9191
let handle = create_uv_getaddrinfo_t();
92-
let handle_ptr = ptr::addr_of(handle);
92+
let handle_ptr = ptr::addr_of(&handle);
9393
let handle_data: GetAddrData = {
9494
output_ch: output_ch
9595
};
96-
let handle_data_ptr = ptr::addr_of(handle_data);
96+
let handle_data_ptr = ptr::addr_of(&handle_data);
9797
do interact(iotask) |loop_ptr| unsafe {
9898
let result = uv_getaddrinfo(
9999
loop_ptr,
@@ -150,7 +150,7 @@ mod v4 {
150150
impl Ipv4Rep: AsUnsafeU32 {
151151
// this is pretty dastardly, i know
152152
unsafe fn as_u32() -> u32 {
153-
*((ptr::addr_of(self)) as *u32)
153+
*((ptr::addr_of(&self)) as *u32)
154154
}
155155
}
156156
fn parse_to_ipv4_rep(ip: &str) -> result::Result<Ipv4Rep, ~str> {

0 commit comments

Comments
 (0)