diff options
| author | Marijn Haverbeke <marijnh@gmail.com> | 2011-11-02 11:42:51 +0100 |
|---|---|---|
| committer | Marijn Haverbeke <marijnh@gmail.com> | 2011-11-02 12:20:12 +0100 |
| commit | 0a20eed2db233dad2eb9594cf28790842970c1d6 (patch) | |
| tree | 7388d493e37656a119d81cec71bd65a8cae11abe /src/lib | |
| parent | eaf9e05611e966344c250353b8e220469885c93c (diff) | |
| download | rust-0a20eed2db233dad2eb9594cf28790842970c1d6.tar.gz rust-0a20eed2db233dad2eb9594cf28790842970c1d6.zip | |
Make ptr::addr_of return an immutable vec, add mut_addr_of
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/linux_os.rs | 2 | ||||
| -rw-r--r-- | src/lib/macos_os.rs | 5 | ||||
| -rw-r--r-- | src/lib/ptr.rs | 13 | ||||
| -rw-r--r-- | src/lib/win32_os.rs | 2 |
4 files changed, 16 insertions, 6 deletions
diff --git a/src/lib/linux_os.rs b/src/lib/linux_os.rs index 49f029052d6..b2c93beb643 100644 --- a/src/lib/linux_os.rs +++ b/src/lib/linux_os.rs @@ -64,7 +64,7 @@ fn dylib_filename(base: str) -> str { ret "lib" + base + ".so"; } fn pipe() -> {in: int, out: int} { let fds = {mutable in: 0, mutable out: 0}; - assert (os::libc::pipe(ptr::addr_of(fds.in)) == 0); + assert (os::libc::pipe(ptr::mut_addr_of(fds.in)) == 0); ret {in: fds.in, out: fds.out}; } diff --git a/src/lib/macos_os.rs b/src/lib/macos_os.rs index f8f19b77387..9de76a170d5 100644 --- a/src/lib/macos_os.rs +++ b/src/lib/macos_os.rs @@ -57,7 +57,7 @@ fn dylib_filename(base: str) -> str { ret "lib" + base + ".dylib"; } fn pipe() -> {in: int, out: int} { let fds = {mutable in: 0, mutable out: 0}; - assert (os::libc::pipe(ptr::addr_of(fds.in)) == 0); + assert (os::libc::pipe(ptr::mut_addr_of(fds.in)) == 0); ret {in: fds.in, out: fds.out}; } @@ -82,7 +82,8 @@ fn get_exe_path() -> option::t<fs::path> { let bufsize = 1023u32; let path = str::unsafe_from_bytes(vec::init_elt(0u8, bufsize as uint)); ret str::as_buf(path, { |path_buf| - if libc::_NSGetExecutablePath(path_buf, ptr::addr_of(bufsize)) == 0 { + if libc::_NSGetExecutablePath(path_buf, + ptr::mut_addr_of(bufsize)) == 0 { option::some(fs::dirname(path) + fs::path_sep()) } else { option::none diff --git a/src/lib/ptr.rs b/src/lib/ptr.rs index 5c376831138..df30105b11d 100644 --- a/src/lib/ptr.rs +++ b/src/lib/ptr.rs @@ -4,7 +4,7 @@ Module: ptr Unsafe pointer utility functions */ native "rust-intrinsic" mod rusti { - fn addr_of<T>(val: T) -> *mutable T; + fn addr_of<T>(val: T) -> *T; fn ptr_offset<T>(ptr: *T, count: uint) -> *T; } @@ -13,7 +13,16 @@ Function: addr_of Get an unsafe pointer to a value */ -fn addr_of<T>(val: T) -> *mutable T { ret rusti::addr_of(val); } +fn addr_of<T>(val: T) -> *T { ret rusti::addr_of(val); } + +/* +Function: mut_addr_of + +Get an unsafe mutable pointer to a value +*/ +fn mut_addr_of<T>(val: T) -> *mutable T unsafe { + ret unsafe::reinterpret_cast(rusti::addr_of(val)); +} /* Function: offset diff --git a/src/lib/win32_os.rs b/src/lib/win32_os.rs index eaa895f1ef1..9cbb8adb5b6 100644 --- a/src/lib/win32_os.rs +++ b/src/lib/win32_os.rs @@ -66,7 +66,7 @@ fn pipe() -> {in: int, out: int} { // first, as in rust_run_program. let fds = {mutable in: 0, mutable out: 0}; let res = - os::libc::_pipe(ptr::addr_of(fds.in), 1024u, + os::libc::_pipe(ptr::mut_addr_of(fds.in), 1024u, libc_constants::O_BINARY() | libc_constants::O_NOINHERIT()); assert (res == 0); |
