diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-06-25 12:47:34 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-06-28 11:53:58 -0700 |
| commit | 0dfc90ab15475aa64bea393671463a8e9784ae3f (patch) | |
| tree | 41c9c856c504f33552abe4a0eca9fbdc3d5d215d /src/libstd | |
| parent | 2823be08b7d1b9106cbbd454437384c093c5a5fa (diff) | |
| download | rust-0dfc90ab15475aa64bea393671463a8e9784ae3f.tar.gz rust-0dfc90ab15475aa64bea393671463a8e9784ae3f.zip | |
Rename all raw pointers as necessary
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/c_vec.rs | 4 | ||||
| -rw-r--r-- | src/libstd/collections/hashmap.rs | 4 | ||||
| -rw-r--r-- | src/libstd/collections/lru_cache.rs | 2 | ||||
| -rw-r--r-- | src/libstd/dynamic_lib.rs | 67 | ||||
| -rw-r--r-- | src/libstd/gc.rs | 4 | ||||
| -rw-r--r-- | src/libstd/io/extensions.rs | 2 | ||||
| -rw-r--r-- | src/libstd/io/test.rs | 2 | ||||
| -rw-r--r-- | src/libstd/lib.rs | 2 | ||||
| -rw-r--r-- | src/libstd/os.rs | 74 | ||||
| -rw-r--r-- | src/libstd/rand/os.rs | 5 | ||||
| -rw-r--r-- | src/libstd/rt/backtrace.rs | 85 | ||||
| -rw-r--r-- | src/libstd/rt/mod.rs | 2 | ||||
| -rw-r--r-- | src/libstd/task.rs | 4 |
13 files changed, 135 insertions, 122 deletions
diff --git a/src/libstd/c_vec.rs b/src/libstd/c_vec.rs index e8a158ad230..1926d6b1b96 100644 --- a/src/libstd/c_vec.rs +++ b/src/libstd/c_vec.rs @@ -102,14 +102,14 @@ impl<T> CVec<T> { /// View the stored data as a slice. pub fn as_slice<'a>(&'a self) -> &'a [T] { unsafe { - mem::transmute(raw::Slice { data: self.base as *T, len: self.len }) + mem::transmute(raw::Slice { data: self.base as *const T, len: self.len }) } } /// View the stored data as a mutable slice. pub fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T] { unsafe { - mem::transmute(raw::Slice { data: self.base as *T, len: self.len }) + mem::transmute(raw::Slice { data: self.base as *const T, len: self.len }) } } diff --git a/src/libstd/collections/hashmap.rs b/src/libstd/collections/hashmap.rs index d06d4ea7177..b94141748d5 100644 --- a/src/libstd/collections/hashmap.rs +++ b/src/libstd/collections/hashmap.rs @@ -361,8 +361,8 @@ mod table { *self.hashes.offset(idx) = EMPTY_BUCKET; // Drop the mutable constraint. - let keys = self.keys as *K; - let vals = self.vals as *V; + let keys = self.keys as *const K; + let vals = self.vals as *const V; let k = ptr::read(keys.offset(idx)); let v = ptr::read(vals.offset(idx)); diff --git a/src/libstd/collections/lru_cache.rs b/src/libstd/collections/lru_cache.rs index 8ec5146c7b2..08f11581e83 100644 --- a/src/libstd/collections/lru_cache.rs +++ b/src/libstd/collections/lru_cache.rs @@ -49,7 +49,7 @@ use owned::Box; use ptr; use result::{Ok, Err}; -struct KeyRef<K> { k: *K } +struct KeyRef<K> { k: *const K } struct LruEntry<K, V> { next: *mut LruEntry<K, V>, diff --git a/src/libstd/dynamic_lib.rs b/src/libstd/dynamic_lib.rs index 79e01c8b966..ec2cc67a60a 100644 --- a/src/libstd/dynamic_lib.rs +++ b/src/libstd/dynamic_lib.rs @@ -33,7 +33,7 @@ use str; use string::String; use vec::Vec; -pub struct DynamicLibrary { handle: *u8} +pub struct DynamicLibrary { handle: *mut u8 } impl Drop for DynamicLibrary { fn drop(&mut self) { @@ -134,7 +134,7 @@ impl DynamicLibrary { } /// Access the value at the symbol of the dynamic library - pub unsafe fn symbol<T>(&self, symbol: &str) -> Result<*T, String> { + pub unsafe fn symbol<T>(&self, symbol: &str) -> Result<*mut T, String> { // This function should have a lifetime constraint of 'a on // T but that feature is still unimplemented @@ -175,7 +175,7 @@ mod test { let cosine: extern fn(libc::c_double) -> libc::c_double = unsafe { match libm.symbol("cos") { Err(error) => fail!("Could not load function cos: {}", error), - Ok(cosine) => mem::transmute::<*u8, _>(cosine) + Ok(cosine) => mem::transmute::<*mut u8, _>(cosine) } }; @@ -218,14 +218,14 @@ pub mod dl { use str::StrAllocating; use string::String; - pub unsafe fn open_external<T: ToCStr>(filename: T) -> *u8 { + pub unsafe fn open_external<T: ToCStr>(filename: T) -> *mut u8 { filename.with_c_str(|raw_name| { - dlopen(raw_name, Lazy as libc::c_int) as *u8 + dlopen(raw_name, Lazy as libc::c_int) as *mut u8 }) } - pub unsafe fn open_internal() -> *u8 { - dlopen(ptr::null(), Lazy as libc::c_int) as *u8 + pub unsafe fn open_internal() -> *mut u8 { + dlopen(ptr::null(), Lazy as libc::c_int) as *mut u8 } pub fn check_for_errors_in<T>(f: || -> T) -> Result<T, String> { @@ -239,7 +239,7 @@ pub mod dl { let result = f(); - let last_error = dlerror(); + let last_error = dlerror() as *const _; let ret = if ptr::null() == last_error { Ok(result) } else { @@ -252,11 +252,12 @@ pub mod dl { } } - pub unsafe fn symbol(handle: *u8, symbol: *libc::c_char) -> *u8 { - dlsym(handle as *libc::c_void, symbol) as *u8 + pub unsafe fn symbol(handle: *mut u8, + symbol: *const libc::c_char) -> *mut u8 { + dlsym(handle as *mut libc::c_void, symbol) as *mut u8 } - pub unsafe fn close(handle: *u8) { - dlclose(handle as *libc::c_void); () + pub unsafe fn close(handle: *mut u8) { + dlclose(handle as *mut libc::c_void); () } pub enum RTLD { @@ -268,10 +269,12 @@ pub mod dl { #[link_name = "dl"] extern { - fn dlopen(filename: *libc::c_char, flag: libc::c_int) -> *libc::c_void; - fn dlerror() -> *libc::c_char; - fn dlsym(handle: *libc::c_void, symbol: *libc::c_char) -> *libc::c_void; - fn dlclose(handle: *libc::c_void) -> libc::c_int; + fn dlopen(filename: *const libc::c_char, + flag: libc::c_int) -> *mut libc::c_void; + fn dlerror() -> *mut libc::c_char; + fn dlsym(handle: *mut libc::c_void, + symbol: *const libc::c_char) -> *mut libc::c_void; + fn dlclose(handle: *mut libc::c_void) -> libc::c_int; } } @@ -286,18 +289,18 @@ pub mod dl { use str; use string::String; - pub unsafe fn open_external<T: ToCStr>(filename: T) -> *u8 { + pub unsafe fn open_external<T: ToCStr>(filename: T) -> *mut u8 { // Windows expects Unicode data let filename_cstr = filename.to_c_str(); let filename_str = str::from_utf8(filename_cstr.as_bytes_no_nul()).unwrap(); let filename_str = filename_str.to_utf16().append_one(0); - LoadLibraryW(filename_str.as_ptr() as *libc::c_void) as *u8 + LoadLibraryW(filename_str.as_ptr() as *const libc::c_void) as *mut u8 } - pub unsafe fn open_internal() -> *u8 { - let handle = ptr::null(); - GetModuleHandleExW(0 as libc::DWORD, ptr::null(), &handle as **libc::c_void); - handle as *u8 + pub unsafe fn open_internal() -> *mut u8 { + let mut handle = ptr::mut_null(); + GetModuleHandleExW(0 as libc::DWORD, ptr::null(), &mut handle); + handle as *mut u8 } pub fn check_for_errors_in<T>(f: || -> T) -> Result<T, String> { @@ -315,20 +318,22 @@ pub mod dl { } } - pub unsafe fn symbol(handle: *u8, symbol: *libc::c_char) -> *u8 { - GetProcAddress(handle as *libc::c_void, symbol) as *u8 + pub unsafe fn symbol(handle: *mut u8, symbol: *const libc::c_char) -> *mut u8 { + GetProcAddress(handle as *mut libc::c_void, symbol) as *mut u8 } - pub unsafe fn close(handle: *u8) { - FreeLibrary(handle as *libc::c_void); () + pub unsafe fn close(handle: *mut u8) { + FreeLibrary(handle as *mut libc::c_void); () } #[allow(non_snake_case_functions)] extern "system" { fn SetLastError(error: libc::size_t); - fn LoadLibraryW(name: *libc::c_void) -> *libc::c_void; - fn GetModuleHandleExW(dwFlags: libc::DWORD, name: *u16, - handle: **libc::c_void) -> *libc::c_void; - fn GetProcAddress(handle: *libc::c_void, name: *libc::c_char) -> *libc::c_void; - fn FreeLibrary(handle: *libc::c_void); + fn LoadLibraryW(name: *const libc::c_void) -> *mut libc::c_void; + fn GetModuleHandleExW(dwFlags: libc::DWORD, name: *const u16, + handle: *mut *mut libc::c_void) + -> *mut libc::c_void; + fn GetProcAddress(handle: *mut libc::c_void, + name: *const libc::c_char) -> *mut libc::c_void; + fn FreeLibrary(handle: *mut libc::c_void); } } diff --git a/src/libstd/gc.rs b/src/libstd/gc.rs index 0f30e7231b1..363c577563e 100644 --- a/src/libstd/gc.rs +++ b/src/libstd/gc.rs @@ -33,7 +33,7 @@ use raw; task annihilation. For now, cycles need to be broken manually by using `Rc<T>` \ with a non-owning `Weak<T>` pointer. A tracing garbage collector is planned."] pub struct Gc<T> { - _ptr: *T, + _ptr: *mut T, marker: marker::NoSend, } @@ -83,7 +83,7 @@ impl<T: Default + 'static> Default for Gc<T> { } } -impl<T: 'static> raw::Repr<*raw::Box<T>> for Gc<T> {} +impl<T: 'static> raw::Repr<*const raw::Box<T>> for Gc<T> {} impl<S: hash::Writer, T: hash::Hash<S> + 'static> hash::Hash<S> for Gc<T> { fn hash(&self, s: &mut S) { diff --git a/src/libstd/io/extensions.rs b/src/libstd/io/extensions.rs index 5d9865fded3..277aca2332d 100644 --- a/src/libstd/io/extensions.rs +++ b/src/libstd/io/extensions.rs @@ -166,7 +166,7 @@ pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 { let ptr = data.as_ptr().offset(start as int); let out = buf.as_mut_ptr(); copy_nonoverlapping_memory(out.offset((8 - size) as int), ptr, size); - from_be64(*(out as *u64)) + from_be64(*(out as *const u64)) } } diff --git a/src/libstd/io/test.rs b/src/libstd/io/test.rs index 4d3dde46b57..26e854d9d99 100644 --- a/src/libstd/io/test.rs +++ b/src/libstd/io/test.rs @@ -155,7 +155,7 @@ mod darwin_fd_limit { oldp: *mut libc::c_void, oldlenp: *mut libc::size_t, newp: *mut libc::c_void, newlen: libc::size_t) -> libc::c_int; fn getrlimit(resource: libc::c_int, rlp: *mut rlimit) -> libc::c_int; - fn setrlimit(resource: libc::c_int, rlp: *rlimit) -> libc::c_int; + fn setrlimit(resource: libc::c_int, rlp: *const rlimit) -> libc::c_int; } static CTL_KERN: libc::c_int = 1; static KERN_MAXFILESPERPROC: libc::c_int = 29; diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index d1029c7a9ba..f63e69f3cca 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -183,7 +183,7 @@ pub use core_sync::comm; // threading mode than the default by reaching into the auto-generated // '__test' module. #[cfg(test)] #[start] -fn start(argc: int, argv: **u8) -> int { +fn start(argc: int, argv: *const *const u8) -> int { green::start(argc, argv, rustuv::event_loop, __test::main) } diff --git a/src/libstd/os.rs b/src/libstd/os.rs index a77242638eb..90f4cbb2577 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -276,7 +276,7 @@ pub fn env_as_bytes() -> Vec<(Vec<u8>,Vec<u8>)> { use c_str::CString; extern { - fn rust_env_pairs() -> **c_char; + fn rust_env_pairs() -> *const *const c_char; } let environ = rust_env_pairs(); if environ as uint == 0 { @@ -351,7 +351,7 @@ pub fn getenv_as_bytes(n: &str) -> Option<Vec<u8>> { if s.is_null() { None } else { - Some(Vec::from_slice(CString::new(s, + Some(Vec::from_slice(CString::new(s as *const i8, false).as_bytes_no_nul())) } }) @@ -598,19 +598,20 @@ pub fn self_exe_name() -> Option<Path> { unsafe { use libc::funcs::bsd44::*; use libc::consts::os::extra::*; - let mib = vec![CTL_KERN as c_int, - KERN_PROC as c_int, - KERN_PROC_PATHNAME as c_int, -1 as c_int]; + let mut mib = vec![CTL_KERN as c_int, + KERN_PROC as c_int, + KERN_PROC_PATHNAME as c_int, + -1 as c_int]; let mut sz: libc::size_t = 0; - let err = sysctl(mib.as_ptr(), mib.len() as ::libc::c_uint, - ptr::mut_null(), &mut sz, ptr::null(), + let err = sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint, + ptr::mut_null(), &mut sz, ptr::mut_null(), 0u as libc::size_t); if err != 0 { return None; } if sz == 0 { return None; } let mut v: Vec<u8> = Vec::with_capacity(sz as uint); - let err = sysctl(mib.as_ptr(), mib.len() as ::libc::c_uint, - v.as_mut_ptr() as *mut c_void, &mut sz, ptr::null(), - 0u as libc::size_t); + let err = sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint, + v.as_mut_ptr() as *mut c_void, &mut sz, + ptr::mut_null(), 0u as libc::size_t); if err != 0 { return None; } if sz == 0 { return None; } v.set_len(sz as uint - 1); // chop off trailing NUL @@ -827,9 +828,9 @@ pub fn errno() -> int { #[cfg(target_os = "macos")] #[cfg(target_os = "ios")] #[cfg(target_os = "freebsd")] - fn errno_location() -> *c_int { + fn errno_location() -> *const c_int { extern { - fn __error() -> *c_int; + fn __error() -> *const c_int; } unsafe { __error() @@ -838,9 +839,9 @@ pub fn errno() -> int { #[cfg(target_os = "linux")] #[cfg(target_os = "android")] - fn errno_location() -> *c_int { + fn errno_location() -> *const c_int { extern { - fn __errno_location() -> *c_int; + fn __errno_location() -> *const c_int; } unsafe { __errno_location() @@ -913,7 +914,7 @@ pub fn error_string(errnum: uint) -> String { fail!("strerror_r failure"); } - str::raw::from_c_str(p as *c_char).into_string() + str::raw::from_c_str(p as *const c_char).into_string() } } @@ -932,7 +933,7 @@ pub fn error_string(errnum: uint) -> String { langId: DWORD, buf: LPWSTR, nsize: DWORD, - args: *c_void) + args: *const c_void) -> DWORD; } @@ -997,7 +998,8 @@ pub fn get_exit_status() -> int { } #[cfg(target_os = "macos")] -unsafe fn load_argc_and_argv(argc: int, argv: **c_char) -> Vec<Vec<u8>> { +unsafe fn load_argc_and_argv(argc: int, + argv: *const *const c_char) -> Vec<Vec<u8>> { use c_str::CString; Vec::from_fn(argc as uint, |i| { @@ -1015,7 +1017,7 @@ unsafe fn load_argc_and_argv(argc: int, argv: **c_char) -> Vec<Vec<u8>> { fn real_args_as_bytes() -> Vec<Vec<u8>> { unsafe { let (argc, argv) = (*_NSGetArgc() as int, - *_NSGetArgv() as **c_char); + *_NSGetArgv() as *const *const c_char); load_argc_and_argv(argc, argv) } } @@ -1040,16 +1042,16 @@ fn real_args_as_bytes() -> Vec<Vec<u8>> { #[link(name = "objc")] extern { - fn sel_registerName(name: *libc::c_uchar) -> Sel; + fn sel_registerName(name: *const libc::c_uchar) -> Sel; fn objc_msgSend(obj: NsId, sel: Sel, ...) -> NsId; - fn objc_getClass(class_name: *libc::c_uchar) -> NsId; + fn objc_getClass(class_name: *const libc::c_uchar) -> NsId; } #[link(name = "Foundation", kind = "framework")] extern {} - type Sel = *libc::c_void; - type NsId = *libc::c_void; + type Sel = *const libc::c_void; + type NsId = *const libc::c_void; let mut res = Vec::new(); @@ -1067,7 +1069,8 @@ fn real_args_as_bytes() -> Vec<Vec<u8>> { let cnt: int = mem::transmute(objc_msgSend(args, countSel)); for i in range(0, cnt) { let tmp = objc_msgSend(args, objectAtSel, i); - let utf_c_str: *libc::c_char = mem::transmute(objc_msgSend(tmp, utf8Sel)); + let utf_c_str: *const libc::c_char = + mem::transmute(objc_msgSend(tmp, utf8Sel)); let s = CString::new(utf_c_str, false); if s.is_not_null() { res.push(Vec::from_slice(s.as_bytes_no_nul())) @@ -1114,14 +1117,14 @@ fn real_args() -> Vec<String> { while *ptr.offset(len as int) != 0 { len += 1; } // Push it onto the list. - let opt_s = slice::raw::buf_as_slice(ptr, len, |buf| { + let opt_s = slice::raw::buf_as_slice(ptr as *const _, len, |buf| { str::from_utf16(str::truncate_utf16_at_nul(buf)) }); opt_s.expect("CommandLineToArgvW returned invalid UTF-16") }); unsafe { - LocalFree(szArgList as *c_void); + LocalFree(szArgList as *mut c_void); } return args @@ -1132,19 +1135,20 @@ fn real_args_as_bytes() -> Vec<Vec<u8>> { real_args().move_iter().map(|s| s.into_bytes()).collect() } -type LPCWSTR = *u16; +type LPCWSTR = *const u16; #[cfg(windows)] #[link_name="kernel32"] extern "system" { fn GetCommandLineW() -> LPCWSTR; - fn LocalFree(ptr: *c_void); + fn LocalFree(ptr: *mut c_void); } #[cfg(windows)] #[link_name="shell32"] extern "system" { - fn CommandLineToArgvW(lpCmdLine: LPCWSTR, pNumArgs: *mut c_int) -> **u16; + fn CommandLineToArgvW(lpCmdLine: LPCWSTR, + pNumArgs: *mut c_int) -> *mut *mut u16; } /// Returns the arguments which this program was started with (normally passed @@ -1165,8 +1169,8 @@ pub fn args_as_bytes() -> Vec<Vec<u8>> { #[cfg(target_os = "macos")] extern { // These functions are in crt_externs.h. - pub fn _NSGetArgc() -> *c_int; - pub fn _NSGetArgv() -> ***c_char; + pub fn _NSGetArgc() -> *mut c_int; + pub fn _NSGetArgv() -> *mut *mut *mut c_char; } // Round up `from` to be divisible by `to` @@ -1224,7 +1228,7 @@ pub struct MemoryMap { pub enum MemoryMapKind { /// Virtual memory map. Usually used to change the permissions of a given /// chunk of memory. Corresponds to `VirtualAlloc` on Windows. - MapFile(*u8), + MapFile(*const u8), /// Virtual memory map. Usually used to change the permissions of a given /// chunk of memory, or for allocation. Corresponds to `VirtualAlloc` on /// Windows. @@ -1241,7 +1245,7 @@ pub enum MapOption { MapExecutable, /// Create a map for a specific address range. Corresponds to `MAP_FIXED` on /// POSIX. - MapAddr(*u8), + MapAddr(*const u8), /// Create a memory mapping for a file with a given fd. MapFd(c_int), /// When using `MapFd`, the start of the map is `uint` bytes from the start @@ -1342,7 +1346,7 @@ impl MemoryMap { if min_len == 0 { return Err(ErrZeroLength) } - let mut addr: *u8 = ptr::null(); + let mut addr: *const u8 = ptr::null(); let mut prot = 0; let mut flags = libc::MAP_PRIVATE; let mut fd = -1; @@ -1502,7 +1506,7 @@ impl MemoryMap { _ => Ok(MemoryMap { data: r as *mut u8, len: len, - kind: MapFile(mapping as *u8) + kind: MapFile(mapping as *const u8) }) } } @@ -1990,7 +1994,7 @@ mod tests { open(path, O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR) }); lseek_(fd, size); - "x".with_c_str(|x| assert!(write(fd, x as *c_void, 1) == 1)); + "x".with_c_str(|x| assert!(write(fd, x as *const c_void, 1) == 1)); fd }; let chunk = match MemoryMap::new(size / 2, [ diff --git a/src/libstd/rand/os.rs b/src/libstd/rand/os.rs index 1c1aab15361..60e2c4c8949 100644 --- a/src/libstd/rand/os.rs +++ b/src/libstd/rand/os.rs @@ -87,11 +87,12 @@ mod imp { struct SecRandom; - static kSecRandomDefault: *SecRandom = 0 as *SecRandom; + static kSecRandomDefault: *const SecRandom = 0 as *const SecRandom; #[link(name = "Security", kind = "framework")] extern "C" { - fn SecRandomCopyBytes(rnd: *SecRandom, count: size_t, bytes: *mut u8) -> c_int; + fn SecRandomCopyBytes(rnd: *const SecRandom, + count: size_t, bytes: *mut u8) -> c_int; } impl OsRng { diff --git a/src/libstd/rt/backtrace.rs b/src/libstd/rt/backtrace.rs index e3652ffac6e..8f51e834c6a 100644 --- a/src/libstd/rt/backtrace.rs +++ b/src/libstd/rt/backtrace.rs @@ -261,7 +261,8 @@ mod imp { use slice::{MutableVector}; extern { - fn backtrace(buf: *mut *libc::c_void, sz: libc::c_int) -> libc::c_int; + fn backtrace(buf: *mut *const libc::c_void, + sz: libc::c_int) -> libc::c_int; } // while it doesn't requires lock for work as everything is @@ -273,7 +274,7 @@ mod imp { try!(writeln!(w, "stack backtrace:")); // 100 lines should be enough static SIZE: libc::c_int = 100; - let mut buf: [*libc::c_void, ..SIZE] = unsafe {mem::zeroed()}; + let mut buf: [*const libc::c_void, ..SIZE] = unsafe {mem::zeroed()}; let cnt = unsafe { backtrace(buf.as_mut_ptr(), SIZE) as uint}; // skipping the first one as it is write itself @@ -307,7 +308,7 @@ mod imp { let mut cx = Context { writer: w, last_error: None, idx: 0 }; return match unsafe { uw::_Unwind_Backtrace(trace_fn, - &mut cx as *mut Context as *libc::c_void) + &mut cx as *mut Context as *mut libc::c_void) } { uw::_URC_NO_REASON => { match cx.last_error { @@ -318,10 +319,10 @@ mod imp { _ => Ok(()), }; - extern fn trace_fn(ctx: *uw::_Unwind_Context, - arg: *libc::c_void) -> uw::_Unwind_Reason_Code { + extern fn trace_fn(ctx: *mut uw::_Unwind_Context, + arg: *mut libc::c_void) -> uw::_Unwind_Reason_Code { let cx: &mut Context = unsafe { mem::transmute(arg) }; - let ip = unsafe { uw::_Unwind_GetIP(ctx) as *libc::c_void }; + let ip = unsafe { uw::_Unwind_GetIP(ctx) as *mut libc::c_void }; // dladdr() on osx gets whiny when we use FindEnclosingFunction, and // it appears to work fine without it, so we only use // FindEnclosingFunction on non-osx platforms. In doing so, we get a @@ -365,22 +366,22 @@ mod imp { #[cfg(target_os = "macos")] #[cfg(target_os = "ios")] - fn print(w: &mut Writer, idx: int, addr: *libc::c_void) -> IoResult<()> { + fn print(w: &mut Writer, idx: int, addr: *mut libc::c_void) -> IoResult<()> { use intrinsics; #[repr(C)] struct Dl_info { - dli_fname: *libc::c_char, - dli_fbase: *libc::c_void, - dli_sname: *libc::c_char, - dli_saddr: *libc::c_void, + dli_fname: *const libc::c_char, + dli_fbase: *mut libc::c_void, + dli_sname: *const libc::c_char, + dli_saddr: *mut libc::c_void, } extern { - fn dladdr(addr: *libc::c_void, + fn dladdr(addr: *const libc::c_void, info: *mut Dl_info) -> libc::c_int; } let mut info: Dl_info = unsafe { intrinsics::init() }; - if unsafe { dladdr(addr, &mut info) == 0 } { + if unsafe { dladdr(addr as *const libc::c_void, &mut info) == 0 } { output(w, idx,addr, None) } else { output(w, idx, addr, Some(unsafe { @@ -390,7 +391,7 @@ mod imp { } #[cfg(not(target_os = "macos"), not(target_os = "ios"))] - fn print(w: &mut Writer, idx: int, addr: *libc::c_void) -> IoResult<()> { + fn print(w: &mut Writer, idx: int, addr: *mut libc::c_void) -> IoResult<()> { use collections::Collection; use iter::Iterator; use os; @@ -405,17 +406,17 @@ mod imp { type backtrace_syminfo_callback = extern "C" fn(data: *mut libc::c_void, pc: libc::uintptr_t, - symname: *libc::c_char, + symname: *const libc::c_char, symval: libc::uintptr_t, symsize: libc::uintptr_t); type backtrace_error_callback = extern "C" fn(data: *mut libc::c_void, - msg: *libc::c_char, + msg: *const libc::c_char, errnum: libc::c_int); enum backtrace_state {} #[link(name = "backtrace", kind = "static")] extern { - fn backtrace_create_state(filename: *libc::c_char, + fn backtrace_create_state(filename: *const libc::c_char, threaded: libc::c_int, error: backtrace_error_callback, data: *mut libc::c_void) @@ -431,16 +432,16 @@ mod imp { // helper callbacks //////////////////////////////////////////////////////////////////////// - extern fn error_cb(_data: *mut libc::c_void, _msg: *libc::c_char, + extern fn error_cb(_data: *mut libc::c_void, _msg: *const libc::c_char, _errnum: libc::c_int) { // do nothing for now } extern fn syminfo_cb(data: *mut libc::c_void, _pc: libc::uintptr_t, - symname: *libc::c_char, + symname: *const libc::c_char, _symval: libc::uintptr_t, _symsize: libc::uintptr_t) { - let slot = data as *mut *libc::c_char; + let slot = data as *mut *const libc::c_char; unsafe { *slot = symname; } } @@ -502,8 +503,8 @@ mod imp { if state.is_null() { return output(w, idx, addr, None) } - let mut data = 0 as *libc::c_char; - let data_addr = &mut data as *mut *libc::c_char; + let mut data = 0 as *const libc::c_char; + let data_addr = &mut data as *mut *const libc::c_char; let ret = unsafe { backtrace_syminfo(state, addr as libc::uintptr_t, syminfo_cb, error_cb, @@ -517,7 +518,7 @@ mod imp { } // Finally, after all that work above, we can emit a symbol. - fn output(w: &mut Writer, idx: int, addr: *libc::c_void, + fn output(w: &mut Writer, idx: int, addr: *mut libc::c_void, s: Option<CString>) -> IoResult<()> { try!(write!(w, " {:2}: {:2$} - ", idx, addr, super::HEX_WIDTH)); match s.as_ref().and_then(|c| c.as_str()) { @@ -557,23 +558,23 @@ mod imp { pub enum _Unwind_Context {} pub type _Unwind_Trace_Fn = - extern fn(ctx: *_Unwind_Context, - arg: *libc::c_void) -> _Unwind_Reason_Code; + extern fn(ctx: *mut _Unwind_Context, + arg: *mut libc::c_void) -> _Unwind_Reason_Code; extern { // No native _Unwind_Backtrace on iOS #[cfg(not(target_os = "ios", target_arch = "arm"))] pub fn _Unwind_Backtrace(trace: _Unwind_Trace_Fn, - trace_argument: *libc::c_void) + trace_argument: *mut libc::c_void) -> _Unwind_Reason_Code; #[cfg(not(target_os = "android"), not(target_os = "linux", target_arch = "arm"))] - pub fn _Unwind_GetIP(ctx: *_Unwind_Context) -> libc::uintptr_t; + pub fn _Unwind_GetIP(ctx: *mut _Unwind_Context) -> libc::uintptr_t; #[cfg(not(target_os = "android"), not(target_os = "linux", target_arch = "arm"))] - pub fn _Unwind_FindEnclosingFunction(pc: *libc::c_void) - -> *libc::c_void; + pub fn _Unwind_FindEnclosingFunction(pc: *mut libc::c_void) + -> *mut libc::c_void; } // On android, the function _Unwind_GetIP is a macro, and this is the @@ -581,7 +582,7 @@ mod imp { // header file with the definition of _Unwind_GetIP. #[cfg(target_os = "android")] #[cfg(target_os = "linux", target_arch = "arm")] - pub unsafe fn _Unwind_GetIP(ctx: *_Unwind_Context) -> libc::uintptr_t { + pub unsafe fn _Unwind_GetIP(ctx: *mut _Unwind_Context) -> libc::uintptr_t { #[repr(C)] enum _Unwind_VRS_Result { _UVRSR_OK = 0, @@ -608,7 +609,7 @@ mod imp { type _Unwind_Word = libc::c_uint; extern { - fn _Unwind_VRS_Get(ctx: *_Unwind_Context, + fn _Unwind_VRS_Get(ctx: *mut _Unwind_Context, klass: _Unwind_VRS_RegClass, word: _Unwind_Word, repr: _Unwind_VRS_DataRepresentation, @@ -627,8 +628,8 @@ mod imp { // a no-op #[cfg(target_os = "android")] #[cfg(target_os = "linux", target_arch = "arm")] - pub unsafe fn _Unwind_FindEnclosingFunction(pc: *libc::c_void) - -> *libc::c_void + pub unsafe fn _Unwind_FindEnclosingFunction(pc: *mut libc::c_void) + -> *mut libc::c_void { pc } @@ -677,7 +678,7 @@ mod imp { extern "system" fn(libc::HANDLE, u64, *mut u64, *mut SYMBOL_INFO) -> libc::BOOL; type SymInitializeFn = - extern "system" fn(libc::HANDLE, *libc::c_void, + extern "system" fn(libc::HANDLE, *mut libc::c_void, libc::BOOL) -> libc::BOOL; type SymCleanupFn = extern "system" fn(libc::HANDLE) -> libc::BOOL; @@ -685,8 +686,8 @@ mod imp { type StackWalk64Fn = extern "system" fn(libc::DWORD, libc::HANDLE, libc::HANDLE, *mut STACKFRAME64, *mut arch::CONTEXT, - *libc::c_void, *libc::c_void, - *libc::c_void, *libc::c_void) -> libc::BOOL; + *mut libc::c_void, *mut libc::c_void, + *mut libc::c_void, *mut libc::c_void) -> libc::BOOL; static MAX_SYM_NAME: uint = 2000; static IMAGE_FILE_MACHINE_I386: libc::DWORD = 0x014c; @@ -735,7 +736,7 @@ mod imp { AddrFrame: ADDRESS64, AddrStack: ADDRESS64, AddrBStore: ADDRESS64, - FuncTableEntry: *libc::c_void, + FuncTableEntry: *mut libc::c_void, Params: [u64, ..4], Far: libc::BOOL, Virtual: libc::BOOL, @@ -924,7 +925,7 @@ mod imp { macro_rules! sym( ($e:expr, $t:ident) => (unsafe { match lib.symbol($e) { - Ok(f) => mem::transmute::<*u8, $t>(f), + Ok(f) => mem::transmute::<*mut u8, $t>(f), Err(..) => return Ok(()) } }) ) @@ -944,7 +945,7 @@ mod imp { let image = arch::init_frame(&mut frame, &context); // Initialize this process's symbols - let ret = SymInitialize(process, 0 as *libc::c_void, libc::TRUE); + let ret = SymInitialize(process, 0 as *mut libc::c_void, libc::TRUE); if ret != libc::TRUE { return Ok(()) } let _c = Cleanup { handle: process, SymCleanup: SymCleanup }; @@ -952,8 +953,10 @@ mod imp { let mut i = 0i; try!(write!(w, "stack backtrace:\n")); while StackWalk64(image, process, thread, &mut frame, &mut context, - 0 as *libc::c_void, 0 as *libc::c_void, - 0 as *libc::c_void, 0 as *libc::c_void) == libc::TRUE{ + 0 as *mut libc::c_void, + 0 as *mut libc::c_void, + 0 as *mut libc::c_void, + 0 as *mut libc::c_void) == libc::TRUE{ let addr = frame.AddrPC.Offset; if addr == frame.AddrReturn.Offset || addr == 0 || frame.AddrReturn.Offset == 0 { break } diff --git a/src/libstd/rt/mod.rs b/src/libstd/rt/mod.rs index 66e7059422b..19853138afd 100644 --- a/src/libstd/rt/mod.rs +++ b/src/libstd/rt/mod.rs @@ -79,7 +79,7 @@ mod util; /// the crate's logging flags, registering GC /// metadata, and storing the process arguments. #[allow(experimental)] -pub fn init(argc: int, argv: **u8) { +pub fn init(argc: int, argv: *const *const u8) { rustrt::init(argc, argv); unsafe { unwind::register(failure::on_fail); } } diff --git a/src/libstd/task.rs b/src/libstd/task.rs index e2d04a30a54..ad4edfdd153 100644 --- a/src/libstd/task.rs +++ b/src/libstd/task.rs @@ -511,10 +511,10 @@ mod test { let (tx, rx) = channel::<uint>(); let x = box 1; - let x_in_parent = (&*x) as *int as uint; + let x_in_parent = (&*x) as *const int as uint; spawnfn(proc() { - let x_in_child = (&*x) as *int as uint; + let x_in_child = (&*x) as *const int as uint; tx.send(x_in_child); }); |
