Skip to content

Commit ec61a28

Browse files
committed
---
yaml --- r: 6090 b: refs/heads/master c: 0a20eed h: refs/heads/master v: v3
1 parent 3db02e0 commit ec61a28

File tree

9 files changed

+23
-12
lines changed

9 files changed

+23
-12
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: eaf9e05611e966344c250353b8e220469885c93c
2+
refs/heads/master: 0a20eed2db233dad2eb9594cf28790842970c1d6

trunk/doc/tutorial/ffi.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,10 @@ This program uses the Posix function `gettimeofday` to get a
162162
microsecond-resolution timer.
163163

164164
use std;
165-
type timeval = {tv_sec: u32, tv_usec: u32};
165+
type timeval = {mutable tv_sec: u32,
166+
mutable tv_usec: u32};
166167
native "cdecl" mod libc = "" {
167-
fn gettimeofday(tv: *mutable timeval, tz: *()) -> i32;
168+
fn gettimeofday(tv: *timeval, tz: *()) -> i32;
168169
}
169170
fn unix_time_in_microseconds() -> u64 unsafe {
170171
let x = {tv_sec: 0u32, tv_usec: 0u32};

trunk/src/lib/linux_os.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ fn dylib_filename(base: str) -> str { ret "lib" + base + ".so"; }
6464

6565
fn pipe() -> {in: int, out: int} {
6666
let fds = {mutable in: 0, mutable out: 0};
67-
assert (os::libc::pipe(ptr::addr_of(fds.in)) == 0);
67+
assert (os::libc::pipe(ptr::mut_addr_of(fds.in)) == 0);
6868
ret {in: fds.in, out: fds.out};
6969
}
7070

trunk/src/lib/macos_os.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fn dylib_filename(base: str) -> str { ret "lib" + base + ".dylib"; }
5757

5858
fn pipe() -> {in: int, out: int} {
5959
let fds = {mutable in: 0, mutable out: 0};
60-
assert (os::libc::pipe(ptr::addr_of(fds.in)) == 0);
60+
assert (os::libc::pipe(ptr::mut_addr_of(fds.in)) == 0);
6161
ret {in: fds.in, out: fds.out};
6262
}
6363

@@ -82,7 +82,8 @@ fn get_exe_path() -> option::t<fs::path> {
8282
let bufsize = 1023u32;
8383
let path = str::unsafe_from_bytes(vec::init_elt(0u8, bufsize as uint));
8484
ret str::as_buf(path, { |path_buf|
85-
if libc::_NSGetExecutablePath(path_buf, ptr::addr_of(bufsize)) == 0 {
85+
if libc::_NSGetExecutablePath(path_buf,
86+
ptr::mut_addr_of(bufsize)) == 0 {
8687
option::some(fs::dirname(path) + fs::path_sep())
8788
} else {
8889
option::none

trunk/src/lib/ptr.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Module: ptr
44
Unsafe pointer utility functions
55
*/
66
native "rust-intrinsic" mod rusti {
7-
fn addr_of<T>(val: T) -> *mutable T;
7+
fn addr_of<T>(val: T) -> *T;
88
fn ptr_offset<T>(ptr: *T, count: uint) -> *T;
99
}
1010

@@ -13,7 +13,16 @@ Function: addr_of
1313
1414
Get an unsafe pointer to a value
1515
*/
16-
fn addr_of<T>(val: T) -> *mutable T { ret rusti::addr_of(val); }
16+
fn addr_of<T>(val: T) -> *T { ret rusti::addr_of(val); }
17+
18+
/*
19+
Function: mut_addr_of
20+
21+
Get an unsafe mutable pointer to a value
22+
*/
23+
fn mut_addr_of<T>(val: T) -> *mutable T unsafe {
24+
ret unsafe::reinterpret_cast(rusti::addr_of(val));
25+
}
1726

1827
/*
1928
Function: offset

trunk/src/lib/win32_os.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fn pipe() -> {in: int, out: int} {
6666
// first, as in rust_run_program.
6767
let fds = {mutable in: 0, mutable out: 0};
6868
let res =
69-
os::libc::_pipe(ptr::addr_of(fds.in), 1024u,
69+
os::libc::_pipe(ptr::mut_addr_of(fds.in), 1024u,
7070
libc_constants::O_BINARY() |
7171
libc_constants::O_NOINHERIT());
7272
assert (res == 0);

trunk/src/test/compile-fail/mutable-huh-ptr-assign.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fn main() {
1010

1111
unsafe {
1212
let a = 0;
13-
let v = std::ptr::addr_of(a);
13+
let v = std::ptr::mut_addr_of(a);
1414
f(v);
1515
}
1616
}

trunk/src/test/compile-fail/mutable-huh-variance-ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std;
44

55
fn main() {
66
let a = [0];
7-
let v: *mutable [int] = std::ptr::addr_of(a);
7+
let v: *mutable [int] = std::ptr::mut_addr_of(a);
88

99
fn f(&&v: *mutable [mutable? int]) {
1010
unsafe {

trunk/src/test/stdtest/ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ type pair = {mutable fst: int, mutable snd: int};
77
#[test]
88
fn test() unsafe {
99
let p = {mutable fst: 10, mutable snd: 20};
10-
let pptr: *mutable pair = ptr::addr_of(p);
10+
let pptr: *mutable pair = ptr::mut_addr_of(p);
1111
let iptr: *mutable int = unsafe::reinterpret_cast(pptr);
1212
assert (*iptr == 10);;
1313
*iptr = 30;

0 commit comments

Comments
 (0)