1
Fork 0

Rename all raw pointers as necessary

This commit is contained in:
Alex Crichton 2014-06-25 12:47:34 -07:00
parent 2823be08b7
commit 0dfc90ab15
223 changed files with 1800 additions and 1666 deletions

View file

@ -42,7 +42,7 @@ pub mod common;
pub mod errors; pub mod errors;
#[start] #[start]
fn start(argc: int, argv: **u8) -> int { fn start(argc: int, argv: *const *const u8) -> int {
green::start(argc, argv, rustuv::event_loop, main) green::start(argc, argv, rustuv::event_loop, main)
} }

View file

@ -50,19 +50,19 @@ use libc::{c_int, size_t};
#[link(name = "snappy")] #[link(name = "snappy")]
extern { extern {
fn snappy_compress(input: *u8, fn snappy_compress(input: *const u8,
input_length: size_t, input_length: size_t,
compressed: *mut u8, compressed: *mut u8,
compressed_length: *mut size_t) -> c_int; compressed_length: *mut size_t) -> c_int;
fn snappy_uncompress(compressed: *u8, fn snappy_uncompress(compressed: *const u8,
compressed_length: size_t, compressed_length: size_t,
uncompressed: *mut u8, uncompressed: *mut u8,
uncompressed_length: *mut size_t) -> c_int; uncompressed_length: *mut size_t) -> c_int;
fn snappy_max_compressed_length(source_length: size_t) -> size_t; fn snappy_max_compressed_length(source_length: size_t) -> size_t;
fn snappy_uncompressed_length(compressed: *u8, fn snappy_uncompressed_length(compressed: *const u8,
compressed_length: size_t, compressed_length: size_t,
result: *mut size_t) -> c_int; result: *mut size_t) -> c_int;
fn snappy_validate_compressed_buffer(compressed: *u8, fn snappy_validate_compressed_buffer(compressed: *const u8,
compressed_length: size_t) -> c_int; compressed_length: size_t) -> c_int;
} }
# fn main() {} # fn main() {}
@ -82,7 +82,7 @@ the allocated memory. The length is less than or equal to the capacity.
~~~~ ~~~~
# extern crate libc; # extern crate libc;
# use libc::{c_int, size_t}; # use libc::{c_int, size_t};
# unsafe fn snappy_validate_compressed_buffer(_: *u8, _: size_t) -> c_int { 0 } # unsafe fn snappy_validate_compressed_buffer(_: *const u8, _: size_t) -> c_int { 0 }
# fn main() {} # fn main() {}
pub fn validate_compressed_buffer(src: &[u8]) -> bool { pub fn validate_compressed_buffer(src: &[u8]) -> bool {
unsafe { unsafe {
@ -106,7 +106,7 @@ the true length after compression for setting the length.
~~~~ ~~~~
# extern crate libc; # extern crate libc;
# use libc::{size_t, c_int}; # use libc::{size_t, c_int};
# unsafe fn snappy_compress(a: *u8, b: size_t, c: *mut u8, # unsafe fn snappy_compress(a: *const u8, b: size_t, c: *mut u8,
# d: *mut size_t) -> c_int { 0 } # d: *mut size_t) -> c_int { 0 }
# unsafe fn snappy_max_compressed_length(a: size_t) -> size_t { a } # unsafe fn snappy_max_compressed_length(a: size_t) -> size_t { a }
# fn main() {} # fn main() {}
@ -132,11 +132,11 @@ format and `snappy_uncompressed_length` will retrieve the exact buffer size requ
~~~~ ~~~~
# extern crate libc; # extern crate libc;
# use libc::{size_t, c_int}; # use libc::{size_t, c_int};
# unsafe fn snappy_uncompress(compressed: *u8, # unsafe fn snappy_uncompress(compressed: *const u8,
# compressed_length: size_t, # compressed_length: size_t,
# uncompressed: *mut u8, # uncompressed: *mut u8,
# uncompressed_length: *mut size_t) -> c_int { 0 } # uncompressed_length: *mut size_t) -> c_int { 0 }
# unsafe fn snappy_uncompressed_length(compressed: *u8, # unsafe fn snappy_uncompressed_length(compressed: *const u8,
# compressed_length: size_t, # compressed_length: size_t,
# result: *mut size_t) -> c_int { 0 } # result: *mut size_t) -> c_int { 0 }
# fn main() {} # fn main() {}
@ -418,7 +418,7 @@ Unsafe functions, on the other hand, advertise it to the world. An unsafe functi
this: this:
~~~~ ~~~~
unsafe fn kaboom(ptr: *int) -> int { *ptr } unsafe fn kaboom(ptr: *const int) -> int { *ptr }
~~~~ ~~~~
This function can only be called from an `unsafe` block or another `unsafe` function. This function can only be called from an `unsafe` block or another `unsafe` function.
@ -453,7 +453,7 @@ use std::ptr;
#[link(name = "readline")] #[link(name = "readline")]
extern { extern {
static mut rl_prompt: *libc::c_char; static mut rl_prompt: *const libc::c_char;
} }
fn main() { fn main() {
@ -478,7 +478,7 @@ extern crate libc;
#[link(name = "kernel32")] #[link(name = "kernel32")]
#[allow(non_snake_case_functions)] #[allow(non_snake_case_functions)]
extern "stdcall" { extern "stdcall" {
fn SetEnvironmentVariableA(n: *u8, v: *u8) -> libc::c_int; fn SetEnvironmentVariableA(n: *const u8, v: *const u8) -> libc::c_int;
} }
# fn main() { } # fn main() { }
~~~~ ~~~~

View file

@ -245,7 +245,7 @@ extern crate green;
extern crate rustuv; extern crate rustuv;
#[start] #[start]
fn start(argc: int, argv: **u8) -> int { fn start(argc: int, argv: *const *const u8) -> int {
green::start(argc, argv, rustuv::event_loop, main) green::start(argc, argv, rustuv::event_loop, main)
} }
@ -261,7 +261,9 @@ inside of an OS thread.
extern crate native; extern crate native;
#[start] #[start]
fn start(argc: int, argv: **u8) -> int { native::start(argc, argv, main) } fn start(argc: int, argv: *const *const u8) -> int {
native::start(argc, argv, main)
}
fn main() {} fn main() {}
~~~ ~~~

View file

@ -79,7 +79,7 @@ let ref_2: &mut u8 = unsafe { mem::transmute(&mut *ref_1) };
## Raw pointers ## Raw pointers
Rust offers two additional pointer types "raw pointers", written as Rust offers two additional pointer types "raw pointers", written as
`*T` and `*mut T`. They're an approximation of C's `const T*` and `T*` `*const T` and `*mut T`. They're an approximation of C's `const T*` and `T*`
respectively; indeed, one of their most common uses is for FFI, respectively; indeed, one of their most common uses is for FFI,
interfacing with external C libraries. interfacing with external C libraries.
@ -100,7 +100,7 @@ offered by the Rust language and libraries. For example, they
- lack any form of lifetimes, unlike `&`, and so the compiler cannot - lack any form of lifetimes, unlike `&`, and so the compiler cannot
reason about dangling pointers; and reason about dangling pointers; and
- have no guarantees about aliasing or mutability other than mutation - have no guarantees about aliasing or mutability other than mutation
not being allowed directly through a `*T`. not being allowed directly through a `*const T`.
Fortunately, they come with a redeeming feature: the weaker guarantees Fortunately, they come with a redeeming feature: the weaker guarantees
mean weaker restrictions. The missing restrictions make raw pointers mean weaker restrictions. The missing restrictions make raw pointers
@ -131,13 +131,13 @@ unsafe, and neither is converting to an integer.
At runtime, a raw pointer `*` and a reference pointing to the same At runtime, a raw pointer `*` and a reference pointing to the same
piece of data have an identical representation. In fact, an `&T` piece of data have an identical representation. In fact, an `&T`
reference will implicitly coerce to an `*T` raw pointer in safe code reference will implicitly coerce to an `*const T` raw pointer in safe code
and similarly for the `mut` variants (both coercions can be performed and similarly for the `mut` variants (both coercions can be performed
explicitly with, respectively, `value as *T` and `value as *mut T`). explicitly with, respectively, `value as *const T` and `value as *mut T`).
Going the opposite direction, from `*` to a reference `&`, is not Going the opposite direction, from `*const` to a reference `&`, is not
safe. A `&T` is always valid, and so, at a minimum, the raw pointer safe. A `&T` is always valid, and so, at a minimum, the raw pointer
`*T` has to be a valid to a valid instance of type `T`. Furthermore, `*const T` has to be a valid to a valid instance of type `T`. Furthermore,
the resulting pointer must satisfy the aliasing and mutability laws of the resulting pointer must satisfy the aliasing and mutability laws of
references. The compiler assumes these properties are true for any references. The compiler assumes these properties are true for any
references, no matter how they are created, and so any conversion from references, no matter how they are created, and so any conversion from
@ -149,7 +149,7 @@ The recommended method for the conversion is
``` ```
let i: u32 = 1; let i: u32 = 1;
// explicit cast // explicit cast
let p_imm: *u32 = &i as *u32; let p_imm: *const u32 = &i as *const u32;
let mut m: u32 = 2; let mut m: u32 = 2;
// implicit coercion // implicit coercion
let p_mut: *mut u32 = &mut m; let p_mut: *mut u32 = &mut m;
@ -256,7 +256,7 @@ impl<T: Send> Drop for Unique<T> {
// Copy the object out from the pointer onto the stack, // Copy the object out from the pointer onto the stack,
// where it is covered by normal Rust destructor semantics // where it is covered by normal Rust destructor semantics
// and cleans itself up, if necessary // and cleans itself up, if necessary
ptr::read(self.ptr as *T); ptr::read(self.ptr as *const T);
// clean-up our allocation // clean-up our allocation
free(self.ptr as *mut c_void) free(self.ptr as *mut c_void)
@ -457,7 +457,7 @@ extern crate libc;
// Entry point for this program // Entry point for this program
#[start] #[start]
fn start(_argc: int, _argv: **u8) -> int { fn start(_argc: int, _argv: *const *const u8) -> int {
0 0
} }
@ -482,7 +482,7 @@ compiler's name mangling too:
extern crate libc; extern crate libc;
#[no_mangle] // ensure that this symbol is called `main` in the output #[no_mangle] // ensure that this symbol is called `main` in the output
pub extern fn main(argc: int, argv: **u8) -> int { pub extern fn main(argc: int, argv: *const *const u8) -> int {
0 0
} }
@ -540,8 +540,8 @@ use core::mem;
use core::raw::Slice; use core::raw::Slice;
#[no_mangle] #[no_mangle]
pub extern fn dot_product(a: *u32, a_len: u32, pub extern fn dot_product(a: *const u32, a_len: u32,
b: *u32, b_len: u32) -> u32 { b: *const u32, b_len: u32) -> u32 {
// Convert the provided arrays into Rust slices. // Convert the provided arrays into Rust slices.
// The core::raw module guarantees that the Slice // The core::raw module guarantees that the Slice
// structure has the same memory layout as a &[T] // structure has the same memory layout as a &[T]
@ -573,7 +573,7 @@ extern fn begin_unwind(args: &core::fmt::Arguments,
#[lang = "stack_exhausted"] extern fn stack_exhausted() {} #[lang = "stack_exhausted"] extern fn stack_exhausted() {}
#[lang = "eh_personality"] extern fn eh_personality() {} #[lang = "eh_personality"] extern fn eh_personality() {}
# #[start] fn start(argc: int, argv: **u8) -> int { 0 } # #[start] fn start(argc: int, argv: *const *const u8) -> int { 0 }
# fn main() {} # fn main() {}
``` ```
@ -595,7 +595,7 @@ standard library itself.
> parts of the language may never be full specified and so details may > parts of the language may never be full specified and so details may
> differ wildly between implementations (and even versions of `rustc` > differ wildly between implementations (and even versions of `rustc`
> itself). > itself).
> >
> Furthermore, this is just an overview; the best form of > Furthermore, this is just an overview; the best form of
> documentation for specific instances of these features are their > documentation for specific instances of these features are their
> definitions and uses in `std`. > definitions and uses in `std`.
@ -627,7 +627,7 @@ via a declaration like
extern "rust-intrinsic" { extern "rust-intrinsic" {
fn transmute<T, U>(x: T) -> U; fn transmute<T, U>(x: T) -> U;
fn offset<T>(dst: *T, offset: int) -> *T; fn offset<T>(dst: *const T, offset: int) -> *const T;
} }
``` ```
@ -677,7 +677,7 @@ unsafe fn deallocate(ptr: *mut u8, _size: uint, _align: uint) {
} }
#[start] #[start]
fn main(argc: int, argv: **u8) -> int { fn main(argc: int, argv: *const *const u8) -> int {
let x = box 1; let x = box 1;
0 0

View file

@ -1614,7 +1614,7 @@ extern crate libc;
use libc::{c_char, FILE}; use libc::{c_char, FILE};
extern { extern {
fn fopen(filename: *c_char, mode: *c_char) -> *FILE; fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE;
} }
# fn main() {} # fn main() {}
~~~~ ~~~~

View file

@ -99,7 +99,7 @@ pub static mut EMPTY: uint = 12345;
#[inline] #[inline]
unsafe fn exchange_malloc(size: uint, align: uint) -> *mut u8 { unsafe fn exchange_malloc(size: uint, align: uint) -> *mut u8 {
if size == 0 { if size == 0 {
&EMPTY as *uint as *mut u8 &EMPTY as *const uint as *mut u8
} else { } else {
allocate(size, align) allocate(size, align)
} }
@ -144,9 +144,10 @@ mod imp {
flags: c_int) -> size_t; flags: c_int) -> size_t;
fn je_dallocx(ptr: *mut c_void, flags: c_int); fn je_dallocx(ptr: *mut c_void, flags: c_int);
fn je_nallocx(size: size_t, flags: c_int) -> size_t; fn je_nallocx(size: size_t, flags: c_int) -> size_t;
fn je_malloc_stats_print(write_cb: Option<extern "C" fn(cbopaque: *mut c_void, *c_char)>, fn je_malloc_stats_print(write_cb: Option<extern "C" fn(cbopaque: *mut c_void,
*const c_char)>,
cbopaque: *mut c_void, cbopaque: *mut c_void,
opts: *c_char); opts: *const c_char);
} }
// -lpthread needs to occur after -ljemalloc, the earlier argument isn't enough // -lpthread needs to occur after -ljemalloc, the earlier argument isn't enough
@ -226,7 +227,7 @@ mod imp {
// a block of memory, so we special case everything under `*uint` to // a block of memory, so we special case everything under `*uint` to
// just pass it to malloc, which is guaranteed to align to at least the // just pass it to malloc, which is guaranteed to align to at least the
// size of `*uint`. // size of `*uint`.
if align < mem::size_of::<*uint>() { if align < mem::size_of::<uint>() {
libc_heap::malloc_raw(size) libc_heap::malloc_raw(size)
} else { } else {
let mut out = 0 as *mut libc::c_void; let mut out = 0 as *mut libc::c_void;
@ -244,7 +245,7 @@ mod imp {
pub unsafe fn reallocate(ptr: *mut u8, size: uint, align: uint, pub unsafe fn reallocate(ptr: *mut u8, size: uint, align: uint,
old_size: uint) -> *mut u8 { old_size: uint) -> *mut u8 {
let new_ptr = allocate(size, align); let new_ptr = allocate(size, align);
ptr::copy_memory(new_ptr, ptr as *u8, old_size); ptr::copy_memory(new_ptr, ptr as *const u8, old_size);
deallocate(ptr, old_size, align); deallocate(ptr, old_size, align);
return new_ptr; return new_ptr;
} }

View file

@ -36,7 +36,7 @@ pub static HEAP: () = ();
/// A type that represents a uniquely-owned value. /// A type that represents a uniquely-owned value.
#[lang="owned_box"] #[lang="owned_box"]
pub struct Box<T>(*T); pub struct Box<T>(*mut T);
impl<T: Default> Default for Box<T> { impl<T: Default> Default for Box<T> {
fn default() -> Box<T> { box Default::default() } fn default() -> Box<T> { box Default::default() }

View file

@ -55,7 +55,7 @@ impl Chunk {
self.data.borrow().capacity() self.data.borrow().capacity()
} }
unsafe fn as_ptr(&self) -> *u8 { unsafe fn as_ptr(&self) -> *const u8 {
self.data.borrow().as_ptr() self.data.borrow().as_ptr()
} }
} }
@ -140,22 +140,22 @@ unsafe fn destroy_chunk(chunk: &Chunk) {
let fill = chunk.fill.get(); let fill = chunk.fill.get();
while idx < fill { while idx < fill {
let tydesc_data: *uint = mem::transmute(buf.offset(idx as int)); let tydesc_data: *const uint = mem::transmute(buf.offset(idx as int));
let (tydesc, is_done) = un_bitpack_tydesc_ptr(*tydesc_data); let (tydesc, is_done) = un_bitpack_tydesc_ptr(*tydesc_data);
let (size, align) = ((*tydesc).size, (*tydesc).align); let (size, align) = ((*tydesc).size, (*tydesc).align);
let after_tydesc = idx + mem::size_of::<*TyDesc>(); let after_tydesc = idx + mem::size_of::<*const TyDesc>();
let start = round_up(after_tydesc, align); let start = round_up(after_tydesc, align);
//debug!("freeing object: idx = {}, size = {}, align = {}, done = {}", //debug!("freeing object: idx = {}, size = {}, align = {}, done = {}",
// start, size, align, is_done); // start, size, align, is_done);
if is_done { if is_done {
((*tydesc).drop_glue)(buf.offset(start as int) as *i8); ((*tydesc).drop_glue)(buf.offset(start as int) as *const i8);
} }
// Find where the next tydesc lives // Find where the next tydesc lives
idx = round_up(start + size, mem::align_of::<*TyDesc>()); idx = round_up(start + size, mem::align_of::<*const TyDesc>());
} }
} }
@ -164,12 +164,12 @@ unsafe fn destroy_chunk(chunk: &Chunk) {
// is necessary in order to properly do cleanup if a failure occurs // is necessary in order to properly do cleanup if a failure occurs
// during an initializer. // during an initializer.
#[inline] #[inline]
fn bitpack_tydesc_ptr(p: *TyDesc, is_done: bool) -> uint { fn bitpack_tydesc_ptr(p: *const TyDesc, is_done: bool) -> uint {
p as uint | (is_done as uint) p as uint | (is_done as uint)
} }
#[inline] #[inline]
fn un_bitpack_tydesc_ptr(p: uint) -> (*TyDesc, bool) { fn un_bitpack_tydesc_ptr(p: uint) -> (*const TyDesc, bool) {
((p & !1) as *TyDesc, p & 1 == 1) ((p & !1) as *const TyDesc, p & 1 == 1)
} }
impl Arena { impl Arena {
@ -178,7 +178,7 @@ impl Arena {
} }
// Functions for the POD part of the arena // Functions for the POD part of the arena
fn alloc_copy_grow(&self, n_bytes: uint, align: uint) -> *u8 { fn alloc_copy_grow(&self, n_bytes: uint, align: uint) -> *const u8 {
// Allocate a new chunk. // Allocate a new chunk.
let new_min_chunk_size = cmp::max(n_bytes, self.chunk_size()); let new_min_chunk_size = cmp::max(n_bytes, self.chunk_size());
self.chunks.borrow_mut().push(self.copy_head.borrow().clone()); self.chunks.borrow_mut().push(self.copy_head.borrow().clone());
@ -190,7 +190,7 @@ impl Arena {
} }
#[inline] #[inline]
fn alloc_copy_inner(&self, n_bytes: uint, align: uint) -> *u8 { fn alloc_copy_inner(&self, n_bytes: uint, align: uint) -> *const u8 {
let start = round_up(self.copy_head.borrow().fill.get(), align); let start = round_up(self.copy_head.borrow().fill.get(), align);
let end = start + n_bytes; let end = start + n_bytes;
@ -218,7 +218,8 @@ impl Arena {
} }
// Functions for the non-POD part of the arena // Functions for the non-POD part of the arena
fn alloc_noncopy_grow(&self, n_bytes: uint, align: uint) -> (*u8, *u8) { fn alloc_noncopy_grow(&self, n_bytes: uint,
align: uint) -> (*const u8, *const u8) {
// Allocate a new chunk. // Allocate a new chunk.
let new_min_chunk_size = cmp::max(n_bytes, self.chunk_size()); let new_min_chunk_size = cmp::max(n_bytes, self.chunk_size());
self.chunks.borrow_mut().push(self.head.borrow().clone()); self.chunks.borrow_mut().push(self.head.borrow().clone());
@ -230,7 +231,8 @@ impl Arena {
} }
#[inline] #[inline]
fn alloc_noncopy_inner(&self, n_bytes: uint, align: uint) -> (*u8, *u8) { fn alloc_noncopy_inner(&self, n_bytes: uint,
align: uint) -> (*const u8, *const u8) {
// Be careful to not maintain any `head` borrows active, because // Be careful to not maintain any `head` borrows active, because
// `alloc_noncopy_grow` borrows it mutably. // `alloc_noncopy_grow` borrows it mutably.
let (start, end, tydesc_start, head_capacity) = { let (start, end, tydesc_start, head_capacity) = {
@ -238,7 +240,7 @@ impl Arena {
let fill = head.fill.get(); let fill = head.fill.get();
let tydesc_start = fill; let tydesc_start = fill;
let after_tydesc = fill + mem::size_of::<*TyDesc>(); let after_tydesc = fill + mem::size_of::<*const TyDesc>();
let start = round_up(after_tydesc, align); let start = round_up(after_tydesc, align);
let end = start + n_bytes; let end = start + n_bytes;
@ -250,7 +252,7 @@ impl Arena {
} }
let head = self.head.borrow(); let head = self.head.borrow();
head.fill.set(round_up(end, mem::align_of::<*TyDesc>())); head.fill.set(round_up(end, mem::align_of::<*const TyDesc>()));
unsafe { unsafe {
let buf = head.as_ptr(); let buf = head.as_ptr();
@ -348,11 +350,11 @@ fn test_arena_destructors_fail() {
/// run again for these objects. /// run again for these objects.
pub struct TypedArena<T> { pub struct TypedArena<T> {
/// A pointer to the next object to be allocated. /// A pointer to the next object to be allocated.
ptr: Cell<*T>, ptr: Cell<*const T>,
/// A pointer to the end of the allocated area. When this pointer is /// A pointer to the end of the allocated area. When this pointer is
/// reached, a new chunk is allocated. /// reached, a new chunk is allocated.
end: Cell<*T>, end: Cell<*const T>,
/// A pointer to the first arena segment. /// A pointer to the first arena segment.
first: RefCell<TypedArenaChunkRef<T>>, first: RefCell<TypedArenaChunkRef<T>>,
@ -398,7 +400,7 @@ impl<T> TypedArenaChunk<T> {
if intrinsics::needs_drop::<T>() { if intrinsics::needs_drop::<T>() {
let mut start = self.start(); let mut start = self.start();
for _ in range(0, len) { for _ in range(0, len) {
ptr::read(start as *T); // run the destructor on the pointer ptr::read(start as *const T); // run the destructor on the pointer
start = start.offset(mem::size_of::<T>() as int) start = start.offset(mem::size_of::<T>() as int)
} }
} }
@ -417,8 +419,8 @@ impl<T> TypedArenaChunk<T> {
// Returns a pointer to the first allocated object. // Returns a pointer to the first allocated object.
#[inline] #[inline]
fn start(&self) -> *u8 { fn start(&self) -> *const u8 {
let this: *TypedArenaChunk<T> = self; let this: *const TypedArenaChunk<T> = self;
unsafe { unsafe {
mem::transmute(round_up(this.offset(1) as uint, mem::transmute(round_up(this.offset(1) as uint,
mem::min_align_of::<T>())) mem::min_align_of::<T>()))
@ -427,7 +429,7 @@ impl<T> TypedArenaChunk<T> {
// Returns a pointer to the end of the allocated space. // Returns a pointer to the end of the allocated space.
#[inline] #[inline]
fn end(&self) -> *u8 { fn end(&self) -> *const u8 {
unsafe { unsafe {
let size = mem::size_of::<T>().checked_mul(&self.capacity).unwrap(); let size = mem::size_of::<T>().checked_mul(&self.capacity).unwrap();
self.start().offset(size as int) self.start().offset(size as int)
@ -448,8 +450,8 @@ impl<T> TypedArena<T> {
pub fn with_capacity(capacity: uint) -> TypedArena<T> { pub fn with_capacity(capacity: uint) -> TypedArena<T> {
let chunk = TypedArenaChunk::<T>::new(None, capacity); let chunk = TypedArenaChunk::<T>::new(None, capacity);
TypedArena { TypedArena {
ptr: Cell::new(chunk.start() as *T), ptr: Cell::new(chunk.start() as *const T),
end: Cell::new(chunk.end() as *T), end: Cell::new(chunk.end() as *const T),
first: RefCell::new(Some(chunk)), first: RefCell::new(Some(chunk)),
} }
} }
@ -477,8 +479,8 @@ impl<T> TypedArena<T> {
let chunk = self.first.borrow_mut().take_unwrap(); let chunk = self.first.borrow_mut().take_unwrap();
let new_capacity = chunk.capacity.checked_mul(&2).unwrap(); let new_capacity = chunk.capacity.checked_mul(&2).unwrap();
let chunk = TypedArenaChunk::<T>::new(Some(chunk), new_capacity); let chunk = TypedArenaChunk::<T>::new(Some(chunk), new_capacity);
self.ptr.set(chunk.start() as *T); self.ptr.set(chunk.start() as *const T);
self.end.set(chunk.end() as *T); self.end.set(chunk.end() as *const T);
*self.first.borrow_mut() = Some(chunk) *self.first.borrow_mut() = Some(chunk)
} }
} }

View file

@ -652,7 +652,7 @@ mod tests {
(None , None ) => {} (None , None ) => {}
(None , _ ) => fail!("prev link for list_head"), (None , _ ) => fail!("prev link for list_head"),
(Some(p), Some(pptr)) => { (Some(p), Some(pptr)) => {
assert_eq!(p as *Node<T>, pptr as *Node<T>); assert_eq!(p as *const Node<T>, pptr as *const Node<T>);
} }
_ => fail!("prev link is none, not good"), _ => fail!("prev link is none, not good"),
} }

View file

@ -247,7 +247,7 @@ impl<S: Writer, T: Hash<S>> Hash<S> for Option<T> {
} }
} }
impl<S: Writer, T> Hash<S> for *T { impl<S: Writer, T> Hash<S> for *const T {
#[inline] #[inline]
fn hash(&self, state: &mut S) { fn hash(&self, state: &mut S) {
// NB: raw-pointer Hash does _not_ dereference // NB: raw-pointer Hash does _not_ dereference
@ -342,7 +342,7 @@ mod tests {
assert_eq!(hasher.hash(& &[1u8, 2u8, 3u8]), 9); assert_eq!(hasher.hash(& &[1u8, 2u8, 3u8]), 9);
unsafe { unsafe {
let ptr: *int = mem::transmute(5); let ptr: *const int = mem::transmute(5);
assert_eq!(hasher.hash(&ptr), 5); assert_eq!(hasher.hash(&ptr), 5);
} }

View file

@ -341,7 +341,7 @@ fn insertion_sort<T>(v: &mut [T], compare: |&T, &T| -> Ordering) {
let mut j = i; let mut j = i;
unsafe { unsafe {
// `i` is in bounds. // `i` is in bounds.
let read_ptr = buf_v.offset(i) as *T; let read_ptr = buf_v.offset(i) as *const T;
// find where to insert, we need to do strict <, // find where to insert, we need to do strict <,
// rather than <=, to maintain stability. // rather than <=, to maintain stability.
@ -365,7 +365,7 @@ fn insertion_sort<T>(v: &mut [T], compare: |&T, &T| -> Ordering) {
&*buf_v.offset(j), &*buf_v.offset(j),
(i - j) as uint); (i - j) as uint);
ptr::copy_nonoverlapping_memory(buf_v.offset(j), ptr::copy_nonoverlapping_memory(buf_v.offset(j),
&tmp as *T, &tmp as *const T,
1); 1);
mem::forget(tmp); mem::forget(tmp);
} }

View file

@ -661,7 +661,7 @@ pub mod raw {
pub use core::str::raw::{slice_unchecked}; pub use core::str::raw::{slice_unchecked};
/// Create a Rust string from a *u8 buffer of the given length /// Create a Rust string from a *u8 buffer of the given length
pub unsafe fn from_buf_len(buf: *u8, len: uint) -> String { pub unsafe fn from_buf_len(buf: *const u8, len: uint) -> String {
let mut result = String::new(); let mut result = String::new();
result.push_bytes(mem::transmute(Slice { result.push_bytes(mem::transmute(Slice {
data: buf, data: buf,
@ -671,7 +671,7 @@ pub mod raw {
} }
/// Create a Rust string from a null-terminated C string /// Create a Rust string from a null-terminated C string
pub unsafe fn from_c_str(c_string: *i8) -> String { pub unsafe fn from_c_str(c_string: *const i8) -> String {
let mut buf = String::new(); let mut buf = String::new();
let mut len = 0; let mut len = 0;
while *c_string.offset(len) != 0 { while *c_string.offset(len) != 0 {

View file

@ -287,7 +287,7 @@ pub struct Entries<'a, K, V> {
// See the comment on MutEntries; this is just to allow // See the comment on MutEntries; this is just to allow
// code-sharing (for this immutable-values iterator it *could* very // code-sharing (for this immutable-values iterator it *could* very
// well be Option<&'a TreeNode<K,V>>). // well be Option<&'a TreeNode<K,V>>).
node: *TreeNode<K, V>, node: *const TreeNode<K, V>,
remaining_min: uint, remaining_min: uint,
remaining_max: uint remaining_max: uint
} }
@ -468,11 +468,11 @@ define_iterator! {
addr_mut = mut addr_mut = mut
} }
fn deref<'a, K, V>(node: &'a Option<Box<TreeNode<K, V>>>) -> *TreeNode<K, V> { fn deref<'a, K, V>(node: &'a Option<Box<TreeNode<K, V>>>) -> *const TreeNode<K, V> {
match *node { match *node {
Some(ref n) => { Some(ref n) => {
let n: &TreeNode<K, V> = *n; let n: &TreeNode<K, V> = *n;
n as *TreeNode<K, V> n as *const TreeNode<K, V>
} }
None => ptr::null() None => ptr::null()
} }

View file

@ -189,7 +189,9 @@ macro_rules! bound {
// We like sharing code so much that even a little unsafe won't // We like sharing code so much that even a little unsafe won't
// stop us. // stop us.
let this = $this; let this = $this;
let mut node = addr!(& $($mut_)* this.root as * $($mut_)* TrieNode<T>); let mut node = unsafe {
mem::transmute::<_, uint>(&this.root) as *mut TrieNode<T>
};
let key = $key; let key = $key;
@ -205,7 +207,10 @@ macro_rules! bound {
let child_id = chunk(key, it.length); let child_id = chunk(key, it.length);
let (slice_idx, ret) = match children[child_id] { let (slice_idx, ret) = match children[child_id] {
Internal(ref $($mut_)* n) => { Internal(ref $($mut_)* n) => {
node = addr!(& $($mut_)* **n as * $($mut_)* TrieNode<T>); node = unsafe {
mem::transmute::<_, uint>(&**n)
as *mut TrieNode<T>
};
(child_id + 1, false) (child_id + 1, false)
} }
External(stored, _) => { External(stored, _) => {

View file

@ -615,7 +615,7 @@ impl<T> Vec<T> {
} }
unsafe { unsafe {
let end = (self.ptr as *T).offset(self.len as int) as *mut T; let end = (self.ptr as *const T).offset(self.len as int) as *mut T;
ptr::write(&mut *end, value); ptr::write(&mut *end, value);
self.len += 1; self.len += 1;
} }
@ -674,7 +674,10 @@ impl<T> Vec<T> {
#[inline] #[inline]
pub fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T] { pub fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T] {
unsafe { unsafe {
mem::transmute(Slice { data: self.as_mut_ptr() as *T, len: self.len }) mem::transmute(Slice {
data: self.as_mut_ptr() as *const T,
len: self.len,
})
} }
} }
@ -1011,7 +1014,7 @@ impl<T> Vec<T> {
let ptr = self.as_mut_ptr().offset(index as int); let ptr = self.as_mut_ptr().offset(index as int);
// copy it out, unsafely having a copy of the value on // copy it out, unsafely having a copy of the value on
// the stack and in the vector at the same time. // the stack and in the vector at the same time.
ret = Some(ptr::read(ptr as *T)); ret = Some(ptr::read(ptr as *const T));
// Shift everything down to fill in that spot. // Shift everything down to fill in that spot.
ptr::copy_memory(ptr, &*ptr.offset(1), len - index - 1); ptr::copy_memory(ptr, &*ptr.offset(1), len - index - 1);
@ -1200,15 +1203,15 @@ impl<T> Vec<T> {
/// Modifying the vector may cause its buffer to be reallocated, which /// Modifying the vector may cause its buffer to be reallocated, which
/// would also make any pointers to it invalid. /// would also make any pointers to it invalid.
#[inline] #[inline]
pub fn as_ptr(&self) -> *T { pub fn as_ptr(&self) -> *const T {
// If we have a 0-sized vector, then the base pointer should not be NULL // If we have a 0-sized vector, then the base pointer should not be NULL
// because an iterator over the slice will attempt to yield the base // because an iterator over the slice will attempt to yield the base
// pointer as the first element in the vector, but this will end up // pointer as the first element in the vector, but this will end up
// being Some(NULL) which is optimized to None. // being Some(NULL) which is optimized to None.
if mem::size_of::<T>() == 0 { if mem::size_of::<T>() == 0 {
1 as *T 1 as *const T
} else { } else {
self.ptr as *T self.ptr as *const T
} }
} }
@ -1542,7 +1545,7 @@ pub mod raw {
/// The elements of the buffer are copied into the vector without cloning, /// The elements of the buffer are copied into the vector without cloning,
/// as if `ptr::read()` were called on them. /// as if `ptr::read()` were called on them.
#[inline] #[inline]
pub unsafe fn from_buf<T>(ptr: *T, elts: uint) -> Vec<T> { pub unsafe fn from_buf<T>(ptr: *const T, elts: uint) -> Vec<T> {
let mut dst = Vec::with_capacity(elts); let mut dst = Vec::with_capacity(elts);
dst.set_len(elts); dst.set_len(elts);
ptr::copy_nonoverlapping_memory(dst.as_mut_ptr(), ptr, elts); ptr::copy_nonoverlapping_memory(dst.as_mut_ptr(), ptr, elts);

View file

@ -94,7 +94,7 @@ impl AtomicBool {
/// Load the value /// Load the value
#[inline] #[inline]
pub fn load(&self, order: Ordering) -> bool { pub fn load(&self, order: Ordering) -> bool {
unsafe { atomic_load(self.v.get() as *uint, order) > 0 } unsafe { atomic_load(self.v.get() as *const uint, order) > 0 }
} }
/// Store the value /// Store the value
@ -295,7 +295,7 @@ impl AtomicInt {
/// Load the value /// Load the value
#[inline] #[inline]
pub fn load(&self, order: Ordering) -> int { pub fn load(&self, order: Ordering) -> int {
unsafe { atomic_load(self.v.get() as *int, order) } unsafe { atomic_load(self.v.get() as *const int, order) }
} }
/// Store the value /// Store the value
@ -407,7 +407,7 @@ impl AtomicUint {
/// Load the value /// Load the value
#[inline] #[inline]
pub fn load(&self, order: Ordering) -> uint { pub fn load(&self, order: Ordering) -> uint {
unsafe { atomic_load(self.v.get() as *uint, order) } unsafe { atomic_load(self.v.get() as *const uint, order) }
} }
/// Store the value /// Store the value
@ -520,7 +520,7 @@ impl<T> AtomicPtr<T> {
#[inline] #[inline]
pub fn load(&self, order: Ordering) -> *mut T { pub fn load(&self, order: Ordering) -> *mut T {
unsafe { unsafe {
atomic_load(self.p.get() as **mut T, order) as *mut T atomic_load(self.p.get() as *const *mut T, order) as *mut T
} }
} }
@ -560,7 +560,7 @@ unsafe fn atomic_store<T>(dst: *mut T, val: T, order:Ordering) {
} }
#[inline] #[inline]
unsafe fn atomic_load<T>(dst: *T, order:Ordering) -> T { unsafe fn atomic_load<T>(dst: *const T, order:Ordering) -> T {
match order { match order {
Acquire => intrinsics::atomic_load_acq(dst), Acquire => intrinsics::atomic_load_acq(dst),
Relaxed => intrinsics::atomic_load_relaxed(dst), Relaxed => intrinsics::atomic_load_relaxed(dst),

View file

@ -314,11 +314,11 @@ impl<'a> Formatter<'a> {
rt::CountImplied => { None } rt::CountImplied => { None }
rt::CountIsParam(i) => { rt::CountIsParam(i) => {
let v = self.args[i].value; let v = self.args[i].value;
unsafe { Some(*(v as *any::Void as *uint)) } unsafe { Some(*(v as *const _ as *const uint)) }
} }
rt::CountIsNextParam => { rt::CountIsNextParam => {
let v = self.curarg.next().unwrap().value; let v = self.curarg.next().unwrap().value;
unsafe { Some(*(v as *any::Void as *uint)) } unsafe { Some(*(v as *const _ as *const uint)) }
} }
} }
} }
@ -565,7 +565,7 @@ impl Char for char {
} }
} }
impl<T> Pointer for *T { impl<T> Pointer for *const T {
fn fmt(&self, f: &mut Formatter) -> Result { fn fmt(&self, f: &mut Formatter) -> Result {
f.flags |= 1 << (rt::FlagAlternate as uint); f.flags |= 1 << (rt::FlagAlternate as uint);
secret_lower_hex::<uint>(&(*self as uint), f) secret_lower_hex::<uint>(&(*self as uint), f)
@ -573,17 +573,17 @@ impl<T> Pointer for *T {
} }
impl<T> Pointer for *mut T { impl<T> Pointer for *mut T {
fn fmt(&self, f: &mut Formatter) -> Result { fn fmt(&self, f: &mut Formatter) -> Result {
secret_pointer::<*T>(&(*self as *T), f) secret_pointer::<*const T>(&(*self as *const T), f)
} }
} }
impl<'a, T> Pointer for &'a T { impl<'a, T> Pointer for &'a T {
fn fmt(&self, f: &mut Formatter) -> Result { fn fmt(&self, f: &mut Formatter) -> Result {
secret_pointer::<*T>(&(&**self as *T), f) secret_pointer::<*const T>(&(&**self as *const T), f)
} }
} }
impl<'a, T> Pointer for &'a mut T { impl<'a, T> Pointer for &'a mut T {
fn fmt(&self, f: &mut Formatter) -> Result { fn fmt(&self, f: &mut Formatter) -> Result {
secret_pointer::<*T>(&(&**self as *T), f) secret_pointer::<*const T>(&(&**self as *const T), f)
} }
} }
@ -669,7 +669,7 @@ delegate!(char to char)
delegate!(f32 to float) delegate!(f32 to float)
delegate!(f64 to float) delegate!(f64 to float)
impl<T> Show for *T { impl<T> Show for *const T {
fn fmt(&self, f: &mut Formatter) -> Result { secret_pointer(self, f) } fn fmt(&self, f: &mut Formatter) -> Result { secret_pointer(self, f) }
} }
impl<T> Show for *mut T { impl<T> Show for *mut T {

View file

@ -48,7 +48,7 @@ A quick refresher on memory ordering:
#[cfg(test)] #[cfg(test)]
pub use realcore::intrinsics::{TyDesc, Opaque, TyVisitor, TypeId}; pub use realcore::intrinsics::{TyDesc, Opaque, TyVisitor, TypeId};
pub type GlueFn = extern "Rust" fn(*i8); pub type GlueFn = extern "Rust" fn(*const i8);
#[lang="ty_desc"] #[lang="ty_desc"]
#[cfg(not(test))] #[cfg(not(test))]
@ -102,55 +102,58 @@ pub trait TyVisitor {
fn visit_estr_slice(&mut self) -> bool; fn visit_estr_slice(&mut self) -> bool;
fn visit_estr_fixed(&mut self, n: uint, sz: uint, align: uint) -> bool; fn visit_estr_fixed(&mut self, n: uint, sz: uint, align: uint) -> bool;
fn visit_box(&mut self, mtbl: uint, inner: *TyDesc) -> bool; fn visit_box(&mut self, mtbl: uint, inner: *const TyDesc) -> bool;
fn visit_uniq(&mut self, mtbl: uint, inner: *TyDesc) -> bool; fn visit_uniq(&mut self, mtbl: uint, inner: *const TyDesc) -> bool;
fn visit_ptr(&mut self, mtbl: uint, inner: *TyDesc) -> bool; fn visit_ptr(&mut self, mtbl: uint, inner: *const TyDesc) -> bool;
fn visit_rptr(&mut self, mtbl: uint, inner: *TyDesc) -> bool; fn visit_rptr(&mut self, mtbl: uint, inner: *const TyDesc) -> bool;
fn visit_evec_slice(&mut self, mtbl: uint, inner: *TyDesc) -> bool; fn visit_evec_slice(&mut self, mtbl: uint, inner: *const TyDesc) -> bool;
fn visit_evec_fixed(&mut self, n: uint, sz: uint, align: uint, fn visit_evec_fixed(&mut self, n: uint, sz: uint, align: uint,
mtbl: uint, inner: *TyDesc) -> bool; mtbl: uint, inner: *const TyDesc) -> bool;
fn visit_enter_rec(&mut self, n_fields: uint, fn visit_enter_rec(&mut self, n_fields: uint,
sz: uint, align: uint) -> bool; sz: uint, align: uint) -> bool;
fn visit_rec_field(&mut self, i: uint, name: &str, fn visit_rec_field(&mut self, i: uint, name: &str,
mtbl: uint, inner: *TyDesc) -> bool; mtbl: uint, inner: *const TyDesc) -> bool;
fn visit_leave_rec(&mut self, n_fields: uint, fn visit_leave_rec(&mut self, n_fields: uint,
sz: uint, align: uint) -> bool; sz: uint, align: uint) -> bool;
fn visit_enter_class(&mut self, name: &str, named_fields: bool, n_fields: uint, fn visit_enter_class(&mut self, name: &str, named_fields: bool, n_fields: uint,
sz: uint, align: uint) -> bool; sz: uint, align: uint) -> bool;
fn visit_class_field(&mut self, i: uint, name: &str, named: bool, fn visit_class_field(&mut self, i: uint, name: &str, named: bool,
mtbl: uint, inner: *TyDesc) -> bool; mtbl: uint, inner: *const TyDesc) -> bool;
fn visit_leave_class(&mut self, name: &str, named_fields: bool, n_fields: uint, fn visit_leave_class(&mut self, name: &str, named_fields: bool, n_fields: uint,
sz: uint, align: uint) -> bool; sz: uint, align: uint) -> bool;
fn visit_enter_tup(&mut self, n_fields: uint, fn visit_enter_tup(&mut self, n_fields: uint,
sz: uint, align: uint) -> bool; sz: uint, align: uint) -> bool;
fn visit_tup_field(&mut self, i: uint, inner: *TyDesc) -> bool; fn visit_tup_field(&mut self, i: uint, inner: *const TyDesc) -> bool;
fn visit_leave_tup(&mut self, n_fields: uint, fn visit_leave_tup(&mut self, n_fields: uint,
sz: uint, align: uint) -> bool; sz: uint, align: uint) -> bool;
fn visit_enter_enum(&mut self, n_variants: uint, fn visit_enter_enum(&mut self, n_variants: uint,
get_disr: unsafe extern fn(ptr: *Opaque) -> Disr, get_disr: unsafe extern fn(ptr: *const Opaque) -> Disr,
sz: uint, align: uint) -> bool; sz: uint, align: uint) -> bool;
fn visit_enter_enum_variant(&mut self, variant: uint, fn visit_enter_enum_variant(&mut self, variant: uint,
disr_val: Disr, disr_val: Disr,
n_fields: uint, n_fields: uint,
name: &str) -> bool; name: &str) -> bool;
fn visit_enum_variant_field(&mut self, i: uint, offset: uint, inner: *TyDesc) -> bool; fn visit_enum_variant_field(&mut self, i: uint, offset: uint,
inner: *const TyDesc) -> bool;
fn visit_leave_enum_variant(&mut self, variant: uint, fn visit_leave_enum_variant(&mut self, variant: uint,
disr_val: Disr, disr_val: Disr,
n_fields: uint, n_fields: uint,
name: &str) -> bool; name: &str) -> bool;
fn visit_leave_enum(&mut self, n_variants: uint, fn visit_leave_enum(&mut self, n_variants: uint,
get_disr: unsafe extern fn(ptr: *Opaque) -> Disr, get_disr: unsafe extern fn(ptr: *const Opaque) -> Disr,
sz: uint, align: uint) -> bool; sz: uint, align: uint) -> bool;
fn visit_enter_fn(&mut self, purity: uint, proto: uint, fn visit_enter_fn(&mut self, purity: uint, proto: uint,
n_inputs: uint, retstyle: uint) -> bool; n_inputs: uint, retstyle: uint) -> bool;
fn visit_fn_input(&mut self, i: uint, mode: uint, inner: *TyDesc) -> bool; fn visit_fn_input(&mut self, i: uint, mode: uint,
fn visit_fn_output(&mut self, retstyle: uint, variadic: bool, inner: *TyDesc) -> bool; inner: *const TyDesc) -> bool;
fn visit_fn_output(&mut self, retstyle: uint, variadic: bool,
inner: *const TyDesc) -> bool;
fn visit_leave_fn(&mut self, purity: uint, proto: uint, fn visit_leave_fn(&mut self, purity: uint, proto: uint,
n_inputs: uint, retstyle: uint) -> bool; n_inputs: uint, retstyle: uint) -> bool;
@ -170,9 +173,9 @@ extern "rust-intrinsic" {
pub fn atomic_cxchg_acqrel<T>(dst: *mut T, old: T, src: T) -> T; pub fn atomic_cxchg_acqrel<T>(dst: *mut T, old: T, src: T) -> T;
pub fn atomic_cxchg_relaxed<T>(dst: *mut T, old: T, src: T) -> T; pub fn atomic_cxchg_relaxed<T>(dst: *mut T, old: T, src: T) -> T;
pub fn atomic_load<T>(src: *T) -> T; pub fn atomic_load<T>(src: *const T) -> T;
pub fn atomic_load_acq<T>(src: *T) -> T; pub fn atomic_load_acq<T>(src: *const T) -> T;
pub fn atomic_load_relaxed<T>(src: *T) -> T; pub fn atomic_load_relaxed<T>(src: *const T) -> T;
pub fn atomic_store<T>(dst: *mut T, val: T); pub fn atomic_store<T>(dst: *mut T, val: T);
pub fn atomic_store_rel<T>(dst: *mut T, val: T); pub fn atomic_store_rel<T>(dst: *mut T, val: T);
@ -276,7 +279,7 @@ extern "rust-intrinsic" {
pub fn pref_align_of<T>() -> uint; pub fn pref_align_of<T>() -> uint;
/// Get a static pointer to a type descriptor. /// Get a static pointer to a type descriptor.
pub fn get_tydesc<T>() -> *TyDesc; pub fn get_tydesc<T>() -> *const TyDesc;
/// Gets an identifier which is globally unique to the specified type. This /// Gets an identifier which is globally unique to the specified type. This
/// function will return the same value for a type regardless of whichever /// function will return the same value for a type regardless of whichever
@ -320,7 +323,7 @@ extern "rust-intrinsic" {
/// Returns `true` if a type is managed (will be allocated on the local heap) /// Returns `true` if a type is managed (will be allocated on the local heap)
pub fn owns_managed<T>() -> bool; pub fn owns_managed<T>() -> bool;
pub fn visit_tydesc(td: *TyDesc, tv: &mut TyVisitor); pub fn visit_tydesc(td: *const TyDesc, tv: &mut TyVisitor);
/// Calculates the offset from a pointer. The offset *must* be in-bounds of /// Calculates the offset from a pointer. The offset *must* be in-bounds of
/// the object, or one-byte-past-the-end. An arithmetic overflow is also /// the object, or one-byte-past-the-end. An arithmetic overflow is also
@ -328,17 +331,17 @@ extern "rust-intrinsic" {
/// ///
/// This is implemented as an intrinsic to avoid converting to and from an /// This is implemented as an intrinsic to avoid converting to and from an
/// integer, since the conversion would throw away aliasing information. /// integer, since the conversion would throw away aliasing information.
pub fn offset<T>(dst: *T, offset: int) -> *T; pub fn offset<T>(dst: *const T, offset: int) -> *const T;
/// Equivalent to the appropriate `llvm.memcpy.p0i8.0i8.*` intrinsic, with /// Equivalent to the appropriate `llvm.memcpy.p0i8.0i8.*` intrinsic, with
/// a size of `count` * `size_of::<T>()` and an alignment of /// a size of `count` * `size_of::<T>()` and an alignment of
/// `min_align_of::<T>()` /// `min_align_of::<T>()`
pub fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *T, count: uint); pub fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: uint);
/// Equivalent to the appropriate `llvm.memmove.p0i8.0i8.*` intrinsic, with /// Equivalent to the appropriate `llvm.memmove.p0i8.0i8.*` intrinsic, with
/// a size of `count` * `size_of::<T>()` and an alignment of /// a size of `count` * `size_of::<T>()` and an alignment of
/// `min_align_of::<T>()` /// `min_align_of::<T>()`
pub fn copy_memory<T>(dst: *mut T, src: *T, count: uint); pub fn copy_memory<T>(dst: *mut T, src: *const T, count: uint);
/// Equivalent to the appropriate `llvm.memset.p0i8.*` intrinsic, with a /// Equivalent to the appropriate `llvm.memset.p0i8.*` intrinsic, with a
/// size of `count` * `size_of::<T>()` and an alignment of /// size of `count` * `size_of::<T>()` and an alignment of
@ -350,13 +353,14 @@ extern "rust-intrinsic" {
/// `min_align_of::<T>()` /// `min_align_of::<T>()`
/// ///
/// The volatile parameter parameter is set to `true`, so it will not be optimized out. /// The volatile parameter parameter is set to `true`, so it will not be optimized out.
pub fn volatile_copy_nonoverlapping_memory<T>(dst: *mut T, src: *T, count: uint); pub fn volatile_copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T,
count: uint);
/// Equivalent to the appropriate `llvm.memmove.p0i8.0i8.*` intrinsic, with /// Equivalent to the appropriate `llvm.memmove.p0i8.0i8.*` intrinsic, with
/// a size of `count` * `size_of::<T>()` and an alignment of /// a size of `count` * `size_of::<T>()` and an alignment of
/// `min_align_of::<T>()` /// `min_align_of::<T>()`
/// ///
/// The volatile parameter parameter is set to `true`, so it will not be optimized out. /// The volatile parameter parameter is set to `true`, so it will not be optimized out.
pub fn volatile_copy_memory<T>(dst: *mut T, src: *T, count: uint); pub fn volatile_copy_memory<T>(dst: *mut T, src: *const T, count: uint);
/// Equivalent to the appropriate `llvm.memset.p0i8.*` intrinsic, with a /// Equivalent to the appropriate `llvm.memset.p0i8.*` intrinsic, with a
/// size of `count` * `size_of::<T>()` and an alignment of /// size of `count` * `size_of::<T>()` and an alignment of
/// `min_align_of::<T>()`. /// `min_align_of::<T>()`.
@ -365,7 +369,7 @@ extern "rust-intrinsic" {
pub fn volatile_set_memory<T>(dst: *mut T, val: u8, count: uint); pub fn volatile_set_memory<T>(dst: *mut T, val: u8, count: uint);
/// Perform a volatile load from the `src` pointer. /// Perform a volatile load from the `src` pointer.
pub fn volatile_load<T>(src: *T) -> T; pub fn volatile_load<T>(src: *const T) -> T;
/// Perform a volatile store to the `dst` pointer. /// Perform a volatile store to the `dst` pointer.
pub fn volatile_store<T>(dst: *mut T, val: T); pub fn volatile_store<T>(dst: *mut T, val: T);

View file

@ -155,7 +155,7 @@ pub mod marker {
/// ``` /// ```
/// use std::mem; /// use std::mem;
/// ///
/// struct S<T> { x: *() } /// struct S<T> { x: *const () }
/// fn get<T>(s: &S<T>, v: T) { /// fn get<T>(s: &S<T>, v: T) {
/// unsafe { /// unsafe {
/// let x: fn(T) = mem::transmute(s.x); /// let x: fn(T) = mem::transmute(s.x);

View file

@ -363,7 +363,7 @@ pub unsafe fn forget<T>(thing: T) { intrinsics::forget(thing) }
#[inline] #[inline]
#[stable] #[stable]
pub unsafe fn transmute_copy<T, U>(src: &T) -> U { pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
ptr::read(src as *T as *U) ptr::read(src as *const T as *const U)
} }
/// Transforms lifetime of the second pointer to match the first. /// Transforms lifetime of the second pointer to match the first.
@ -407,14 +407,14 @@ mod tests {
#[cfg(target_arch = "mipsel")] #[cfg(target_arch = "mipsel")]
fn size_of_32() { fn size_of_32() {
assert_eq!(size_of::<uint>(), 4u); assert_eq!(size_of::<uint>(), 4u);
assert_eq!(size_of::<*uint>(), 4u); assert_eq!(size_of::<*const uint>(), 4u);
} }
#[test] #[test]
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
fn size_of_64() { fn size_of_64() {
assert_eq!(size_of::<uint>(), 8u); assert_eq!(size_of::<uint>(), 8u);
assert_eq!(size_of::<*uint>(), 8u); assert_eq!(size_of::<*const uint>(), 8u);
} }
#[test] #[test]
@ -439,14 +439,14 @@ mod tests {
#[cfg(target_arch = "mipsel")] #[cfg(target_arch = "mipsel")]
fn align_of_32() { fn align_of_32() {
assert_eq!(align_of::<uint>(), 4u); assert_eq!(align_of::<uint>(), 4u);
assert_eq!(align_of::<*uint>(), 4u); assert_eq!(align_of::<*const uint>(), 4u);
} }
#[test] #[test]
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
fn align_of_64() { fn align_of_64() {
assert_eq!(align_of::<uint>(), 8u); assert_eq!(align_of::<uint>(), 8u);
assert_eq!(align_of::<*uint>(), 8u); assert_eq!(align_of::<*const uint>(), 8u);
} }
#[test] #[test]
@ -486,7 +486,7 @@ mod tests {
let a = box 100i as Box<Foo>; let a = box 100i as Box<Foo>;
unsafe { unsafe {
let x: raw::TraitObject = transmute(a); let x: raw::TraitObject = transmute(a);
assert!(*(x.data as *int) == 100); assert!(*(x.data as *const int) == 100);
let _x: Box<Foo> = transmute(x); let _x: Box<Foo> = transmute(x);
} }

View file

@ -628,10 +628,10 @@ mod tests {
fn test_get_ptr() { fn test_get_ptr() {
unsafe { unsafe {
let x = box 0; let x = box 0;
let addr_x: *int = ::mem::transmute(&*x); let addr_x: *const int = ::mem::transmute(&*x);
let opt = Some(x); let opt = Some(x);
let y = opt.unwrap(); let y = opt.unwrap();
let addr_y: *int = ::mem::transmute(&*y); let addr_y: *const int = ::mem::transmute(&*y);
assert_eq!(addr_x, addr_y); assert_eq!(addr_x, addr_y);
} }
} }

View file

@ -10,7 +10,7 @@
// FIXME: talk about offset, copy_memory, copy_nonoverlapping_memory // FIXME: talk about offset, copy_memory, copy_nonoverlapping_memory
//! Operations on unsafe pointers, `*T`, and `*mut T`. //! Operations on unsafe pointers, `*const T`, and `*mut T`.
//! //!
//! Working with unsafe pointers in Rust is uncommon, //! Working with unsafe pointers in Rust is uncommon,
//! typically limited to a few patterns. //! typically limited to a few patterns.
@ -29,7 +29,7 @@
//! //!
//! ``` //! ```
//! let my_num: int = 10; //! let my_num: int = 10;
//! let my_num_ptr: *int = &my_num; //! let my_num_ptr: *const int = &my_num;
//! let mut my_speed: int = 88; //! let mut my_speed: int = 88;
//! let my_speed_ptr: *mut int = &mut my_speed; //! let my_speed_ptr: *mut int = &mut my_speed;
//! ``` //! ```
@ -42,7 +42,7 @@
//! //!
//! The `transmute` function takes, by value, whatever it's given //! The `transmute` function takes, by value, whatever it's given
//! and returns it as whatever type is requested, as long as the //! and returns it as whatever type is requested, as long as the
//! types are the same size. Because `Box<T>` and `*T` have the same //! types are the same size. Because `Box<T>` and `*mut T` have the same
//! representation they can be trivially, //! representation they can be trivially,
//! though unsafely, transformed from one type to the other. //! though unsafely, transformed from one type to the other.
//! //!
@ -51,7 +51,7 @@
//! //!
//! unsafe { //! unsafe {
//! let my_num: Box<int> = box 10; //! let my_num: Box<int> = box 10;
//! let my_num: *int = mem::transmute(my_num); //! let my_num: *const int = mem::transmute(my_num);
//! let my_speed: Box<int> = box 88; //! let my_speed: Box<int> = box 88;
//! let my_speed: *mut int = mem::transmute(my_speed); //! let my_speed: *mut int = mem::transmute(my_speed);
//! //!
@ -102,12 +102,12 @@ use option::{Some, None, Option};
/// ``` /// ```
/// use std::ptr; /// use std::ptr;
/// ///
/// let p: *int = ptr::null(); /// let p: *const int = ptr::null();
/// assert!(p.is_null()); /// assert!(p.is_null());
/// ``` /// ```
#[inline] #[inline]
#[unstable = "may need a different name after pending changes to pointer types"] #[unstable = "may need a different name after pending changes to pointer types"]
pub fn null<T>() -> *T { 0 as *T } pub fn null<T>() -> *const T { 0 as *const T }
/// Create an unsafe mutable null pointer. /// Create an unsafe mutable null pointer.
/// ///
@ -137,7 +137,7 @@ pub fn mut_null<T>() -> *mut T { 0 as *mut T }
/// ``` /// ```
/// use std::ptr; /// use std::ptr;
/// ///
/// unsafe fn from_buf_raw<T>(ptr: *T, elts: uint) -> Vec<T> { /// unsafe fn from_buf_raw<T>(ptr: *const T, elts: uint) -> Vec<T> {
/// let mut dst = Vec::with_capacity(elts); /// let mut dst = Vec::with_capacity(elts);
/// dst.set_len(elts); /// dst.set_len(elts);
/// ptr::copy_memory(dst.as_mut_ptr(), ptr, elts); /// ptr::copy_memory(dst.as_mut_ptr(), ptr, elts);
@ -147,7 +147,7 @@ pub fn mut_null<T>() -> *mut T { 0 as *mut T }
/// ///
#[inline] #[inline]
#[unstable] #[unstable]
pub unsafe fn copy_memory<T>(dst: *mut T, src: *T, count: uint) { pub unsafe fn copy_memory<T>(dst: *mut T, src: *const T, count: uint) {
intrinsics::copy_memory(dst, src, count) intrinsics::copy_memory(dst, src, count)
} }
@ -190,7 +190,7 @@ pub unsafe fn copy_memory<T>(dst: *mut T, src: *T, count: uint) {
#[inline] #[inline]
#[unstable] #[unstable]
pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T, pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T,
src: *T, src: *const T,
count: uint) { count: uint) {
intrinsics::copy_nonoverlapping_memory(dst, src, count) intrinsics::copy_nonoverlapping_memory(dst, src, count)
} }
@ -242,7 +242,7 @@ pub unsafe fn replace<T>(dest: *mut T, mut src: T) -> T {
/// Reads the value from `*src` and returns it. /// Reads the value from `*src` and returns it.
#[inline(always)] #[inline(always)]
#[unstable] #[unstable]
pub unsafe fn read<T>(src: *T) -> T { pub unsafe fn read<T>(src: *const T) -> T {
let mut tmp: T = mem::uninitialized(); let mut tmp: T = mem::uninitialized();
copy_nonoverlapping_memory(&mut tmp, src, 1); copy_nonoverlapping_memory(&mut tmp, src, 1);
tmp tmp
@ -275,11 +275,12 @@ pub unsafe fn write<T>(dst: *mut T, src: T) {
intrinsics::move_val_init(&mut *dst, src) intrinsics::move_val_init(&mut *dst, src)
} }
/// Given a **T (pointer to an array of pointers), /// Given a *const *const T (pointer to an array of pointers),
/// iterate through each *T, up to the provided `len`, /// iterate through each *const T, up to the provided `len`,
/// passing to the provided callback function /// passing to the provided callback function
#[deprecated = "old-style iteration. use a loop and RawPtr::offset"] #[deprecated = "old-style iteration. use a loop and RawPtr::offset"]
pub unsafe fn array_each_with_len<T>(arr: **T, len: uint, cb: |*T|) { pub unsafe fn array_each_with_len<T>(arr: *const *const T, len: uint,
cb: |*const T|) {
if arr.is_null() { if arr.is_null() {
fail!("ptr::array_each_with_len failure: arr input is null pointer"); fail!("ptr::array_each_with_len failure: arr input is null pointer");
} }
@ -290,8 +291,8 @@ pub unsafe fn array_each_with_len<T>(arr: **T, len: uint, cb: |*T|) {
} }
} }
/// Given a null-pointer-terminated **T (pointer to /// Given a null-pointer-terminated *const *const T (pointer to
/// an array of pointers), iterate through each *T, /// an array of pointers), iterate through each *const T,
/// passing to the provided callback function /// passing to the provided callback function
/// ///
/// # Safety Note /// # Safety Note
@ -300,7 +301,7 @@ pub unsafe fn array_each_with_len<T>(arr: **T, len: uint, cb: |*T|) {
/// pointer array. /// pointer array.
#[deprecated = "old-style iteration. use a loop and RawPtr::offset"] #[deprecated = "old-style iteration. use a loop and RawPtr::offset"]
#[allow(deprecated)] #[allow(deprecated)]
pub unsafe fn array_each<T>(arr: **T, cb: |*T|) { pub unsafe fn array_each<T>(arr: *const *const T, cb: |*const T|) {
if arr.is_null() { if arr.is_null() {
fail!("ptr::array_each_with_len failure: arr input is null pointer"); fail!("ptr::array_each_with_len failure: arr input is null pointer");
} }
@ -312,14 +313,14 @@ pub unsafe fn array_each<T>(arr: **T, cb: |*T|) {
#[inline] #[inline]
#[deprecated = "use a loop and RawPtr::offset"] #[deprecated = "use a loop and RawPtr::offset"]
#[allow(deprecated)] #[allow(deprecated)]
pub unsafe fn buf_len<T>(buf: **T) -> uint { pub unsafe fn buf_len<T>(buf: *const *const T) -> uint {
position(buf, |i| *i == null()) position(buf, |i| *i == null())
} }
/// Return the first offset `i` such that `f(buf[i]) == true`. /// Return the first offset `i` such that `f(buf[i]) == true`.
#[inline] #[inline]
#[deprecated = "old-style iteration. use a loop and RawPtr::offset"] #[deprecated = "old-style iteration. use a loop and RawPtr::offset"]
pub unsafe fn position<T>(buf: *T, f: |&T| -> bool) -> uint { pub unsafe fn position<T>(buf: *const T, f: |&T| -> bool) -> uint {
let mut i = 0; let mut i = 0;
loop { loop {
if f(&(*buf.offset(i as int))) { return i; } if f(&(*buf.offset(i as int))) { return i; }
@ -352,9 +353,9 @@ pub trait RawPtr<T> {
unsafe fn offset(self, count: int) -> Self; unsafe fn offset(self, count: int) -> Self;
} }
impl<T> RawPtr<T> for *T { impl<T> RawPtr<T> for *const T {
#[inline] #[inline]
fn null() -> *T { null() } fn null() -> *const T { null() }
#[inline] #[inline]
fn is_null(&self) -> bool { *self == RawPtr::null() } fn is_null(&self) -> bool { *self == RawPtr::null() }
@ -363,7 +364,9 @@ impl<T> RawPtr<T> for *T {
fn to_uint(&self) -> uint { *self as uint } fn to_uint(&self) -> uint { *self as uint }
#[inline] #[inline]
unsafe fn offset(self, count: int) -> *T { intrinsics::offset(self, count) } unsafe fn offset(self, count: int) -> *const T {
intrinsics::offset(self, count)
}
#[inline] #[inline]
unsafe fn to_option(&self) -> Option<&T> { unsafe fn to_option(&self) -> Option<&T> {
@ -387,7 +390,7 @@ impl<T> RawPtr<T> for *mut T {
#[inline] #[inline]
unsafe fn offset(self, count: int) -> *mut T { unsafe fn offset(self, count: int) -> *mut T {
intrinsics::offset(self as *T, count) as *mut T intrinsics::offset(self as *const T, count) as *mut T
} }
#[inline] #[inline]
@ -402,17 +405,17 @@ impl<T> RawPtr<T> for *mut T {
// Equality for pointers // Equality for pointers
#[cfg(not(test))] #[cfg(not(test))]
impl<T> PartialEq for *T { impl<T> PartialEq for *const T {
#[inline] #[inline]
fn eq(&self, other: &*T) -> bool { fn eq(&self, other: &*const T) -> bool {
*self == *other *self == *other
} }
#[inline] #[inline]
fn ne(&self, other: &*T) -> bool { !self.eq(other) } fn ne(&self, other: &*const T) -> bool { !self.eq(other) }
} }
#[cfg(not(test))] #[cfg(not(test))]
impl<T> Eq for *T {} impl<T> Eq for *const T {}
#[cfg(not(test))] #[cfg(not(test))]
impl<T> PartialEq for *mut T { impl<T> PartialEq for *mut T {
@ -429,22 +432,22 @@ impl<T> Eq for *mut T {}
// Equivalence for pointers // Equivalence for pointers
#[cfg(not(test))] #[cfg(not(test))]
impl<T> Equiv<*mut T> for *T { impl<T> Equiv<*mut T> for *const T {
fn equiv(&self, other: &*mut T) -> bool { fn equiv(&self, other: &*mut T) -> bool {
self.to_uint() == other.to_uint() self.to_uint() == other.to_uint()
} }
} }
#[cfg(not(test))] #[cfg(not(test))]
impl<T> Equiv<*T> for *mut T { impl<T> Equiv<*const T> for *mut T {
fn equiv(&self, other: &*T) -> bool { fn equiv(&self, other: &*const T) -> bool {
self.to_uint() == other.to_uint() self.to_uint() == other.to_uint()
} }
} }
impl<T> Clone for *T { impl<T> Clone for *const T {
#[inline] #[inline]
fn clone(&self) -> *T { fn clone(&self) -> *const T {
*self *self
} }
} }
@ -465,8 +468,8 @@ mod externfnpointers {
impl<_R> PartialEq for extern "C" fn() -> _R { impl<_R> PartialEq for extern "C" fn() -> _R {
#[inline] #[inline]
fn eq(&self, other: &extern "C" fn() -> _R) -> bool { fn eq(&self, other: &extern "C" fn() -> _R) -> bool {
let self_: *() = unsafe { mem::transmute(*self) }; let self_: *const () = unsafe { mem::transmute(*self) };
let other_: *() = unsafe { mem::transmute(*other) }; let other_: *const () = unsafe { mem::transmute(*other) };
self_ == other_ self_ == other_
} }
} }
@ -475,8 +478,9 @@ mod externfnpointers {
impl<_R,$($p),*> PartialEq for extern "C" fn($($p),*) -> _R { impl<_R,$($p),*> PartialEq for extern "C" fn($($p),*) -> _R {
#[inline] #[inline]
fn eq(&self, other: &extern "C" fn($($p),*) -> _R) -> bool { fn eq(&self, other: &extern "C" fn($($p),*) -> _R) -> bool {
let self_: *() = unsafe { mem::transmute(*self) }; let self_: *const () = unsafe { mem::transmute(*self) };
let other_: *() = unsafe { mem::transmute(*other) };
let other_: *const () = unsafe { mem::transmute(*other) };
self_ == other_ self_ == other_
} }
} }
@ -491,9 +495,9 @@ mod externfnpointers {
// Comparison for pointers // Comparison for pointers
#[cfg(not(test))] #[cfg(not(test))]
impl<T> PartialOrd for *T { impl<T> PartialOrd for *const T {
#[inline] #[inline]
fn lt(&self, other: &*T) -> bool { *self < *other } fn lt(&self, other: &*const T) -> bool { *self < *other }
} }
#[cfg(not(test))] #[cfg(not(test))]
@ -587,7 +591,7 @@ pub mod test {
#[test] #[test]
fn test_is_null() { fn test_is_null() {
let p: *int = null(); let p: *const int = null();
assert!(p.is_null()); assert!(p.is_null());
assert!(!p.is_not_null()); assert!(!p.is_not_null());
@ -607,10 +611,10 @@ pub mod test {
#[test] #[test]
fn test_to_option() { fn test_to_option() {
unsafe { unsafe {
let p: *int = null(); let p: *const int = null();
assert_eq!(p.to_option(), None); assert_eq!(p.to_option(), None);
let q: *int = &2; let q: *const int = &2;
assert_eq!(q.to_option().unwrap(), &2); assert_eq!(q.to_option().unwrap(), &2);
let p: *mut int = mut_null(); let p: *mut int = mut_null();
@ -738,7 +742,7 @@ pub mod test {
#[should_fail] #[should_fail]
fn test_ptr_array_each_with_len_null_ptr() { fn test_ptr_array_each_with_len_null_ptr() {
unsafe { unsafe {
array_each_with_len(0 as **libc::c_char, 1, |e| { array_each_with_len(0 as *const *const libc::c_char, 1, |e| {
str::raw::from_c_str(e); str::raw::from_c_str(e);
}); });
} }
@ -747,7 +751,7 @@ pub mod test {
#[should_fail] #[should_fail]
fn test_ptr_array_each_null_ptr() { fn test_ptr_array_each_null_ptr() {
unsafe { unsafe {
array_each(0 as **libc::c_char, |e| { array_each(0 as *const *const libc::c_char, |e| {
str::raw::from_c_str(e); str::raw::from_c_str(e);
}); });
} }

View file

@ -31,20 +31,20 @@ pub struct Box<T> {
/// The representation of a Rust slice /// The representation of a Rust slice
pub struct Slice<T> { pub struct Slice<T> {
pub data: *T, pub data: *const T,
pub len: uint, pub len: uint,
} }
/// The representation of a Rust closure /// The representation of a Rust closure
pub struct Closure { pub struct Closure {
pub code: *(), pub code: *mut (),
pub env: *(), pub env: *mut (),
} }
/// The representation of a Rust procedure (`proc()`) /// The representation of a Rust procedure (`proc()`)
pub struct Procedure { pub struct Procedure {
pub code: *(), pub code: *mut (),
pub env: *(), pub env: *mut (),
} }
/// The representation of a Rust trait object. /// The representation of a Rust trait object.
@ -52,8 +52,8 @@ pub struct Procedure {
/// This struct does not have a `Repr` implementation /// This struct does not have a `Repr` implementation
/// because there is no way to refer to all trait objects generically. /// because there is no way to refer to all trait objects generically.
pub struct TraitObject { pub struct TraitObject {
pub vtable: *(), pub vtable: *mut (),
pub data: *(), pub data: *mut (),
} }
/// This trait is meant to map equivalences between raw structs and their /// This trait is meant to map equivalences between raw structs and their

View file

@ -44,7 +44,7 @@ pub fn ref_slice<'a, A>(s: &'a A) -> &'a [A] {
*/ */
pub fn mut_ref_slice<'a, A>(s: &'a mut A) -> &'a mut [A] { pub fn mut_ref_slice<'a, A>(s: &'a mut A) -> &'a mut [A] {
unsafe { unsafe {
let ptr: *A = transmute(s); let ptr: *const A = transmute(s);
transmute(Slice { data: ptr, len: 1 }) transmute(Slice { data: ptr, len: 1 })
} }
} }
@ -439,7 +439,7 @@ pub trait ImmutableVector<'a, T> {
* Modifying the vector may cause its buffer to be reallocated, which * Modifying the vector may cause its buffer to be reallocated, which
* would also make any pointers to it invalid. * would also make any pointers to it invalid.
*/ */
fn as_ptr(&self) -> *T; fn as_ptr(&self) -> *const T;
/** /**
* Binary search a sorted vector with a comparator function. * Binary search a sorted vector with a comparator function.
@ -520,7 +520,7 @@ impl<'a,T> ImmutableVector<'a, T> for &'a [T] {
let p = self.as_ptr(); let p = self.as_ptr();
if mem::size_of::<T>() == 0 { if mem::size_of::<T>() == 0 {
Items{ptr: p, Items{ptr: p,
end: (p as uint + self.len()) as *T, end: (p as uint + self.len()) as *const T,
marker: marker::ContravariantLifetime::<'a>} marker: marker::ContravariantLifetime::<'a>}
} else { } else {
Items{ptr: p, Items{ptr: p,
@ -606,7 +606,7 @@ impl<'a,T> ImmutableVector<'a, T> for &'a [T] {
} }
#[inline] #[inline]
fn as_ptr(&self) -> *T { fn as_ptr(&self) -> *const T {
self.repr().data self.repr().data
} }
@ -936,7 +936,7 @@ impl<'a,T> MutableVector<'a, T> for &'a mut [T] {
assert!(end <= self.len()); assert!(end <= self.len());
unsafe { unsafe {
transmute(Slice { transmute(Slice {
data: self.as_mut_ptr().offset(start as int) as *T, data: self.as_mut_ptr().offset(start as int) as *const T,
len: (end - start) len: (end - start)
}) })
} }
@ -1115,7 +1115,7 @@ pub mod raw {
* not bytes). * not bytes).
*/ */
#[inline] #[inline]
pub unsafe fn buf_as_slice<T,U>(p: *T, len: uint, f: |v: &[T]| -> U) pub unsafe fn buf_as_slice<T,U>(p: *const T, len: uint, f: |v: &[T]| -> U)
-> U { -> U {
f(transmute(Slice { f(transmute(Slice {
data: p, data: p,
@ -1135,7 +1135,7 @@ pub mod raw {
f: |v: &mut [T]| -> U) f: |v: &mut [T]| -> U)
-> U { -> U {
f(transmute(Slice { f(transmute(Slice {
data: p as *T, data: p as *const T,
len: len len: len
})) }))
} }
@ -1146,9 +1146,9 @@ pub mod raw {
* if the slice is empty. O(1). * if the slice is empty. O(1).
*/ */
#[inline] #[inline]
pub unsafe fn shift_ptr<T>(slice: &mut Slice<T>) -> Option<*T> { pub unsafe fn shift_ptr<T>(slice: &mut Slice<T>) -> Option<*const T> {
if slice.len == 0 { return None; } if slice.len == 0 { return None; }
let head: *T = slice.data; let head: *const T = slice.data;
slice.data = slice.data.offset(1); slice.data = slice.data.offset(1);
slice.len -= 1; slice.len -= 1;
Some(head) Some(head)
@ -1160,9 +1160,9 @@ pub mod raw {
* if the slice is empty. O(1). * if the slice is empty. O(1).
*/ */
#[inline] #[inline]
pub unsafe fn pop_ptr<T>(slice: &mut Slice<T>) -> Option<*T> { pub unsafe fn pop_ptr<T>(slice: &mut Slice<T>) -> Option<*const T> {
if slice.len == 0 { return None; } if slice.len == 0 { return None; }
let tail: *T = slice.data.offset((slice.len - 1) as int); let tail: *const T = slice.data.offset((slice.len - 1) as int);
slice.len -= 1; slice.len -= 1;
Some(tail) Some(tail)
} }
@ -1201,8 +1201,8 @@ pub mod bytes {
/// Immutable slice iterator /// Immutable slice iterator
pub struct Items<'a, T> { pub struct Items<'a, T> {
ptr: *T, ptr: *const T,
end: *T, end: *const T,
marker: marker::ContravariantLifetime<'a> marker: marker::ContravariantLifetime<'a>
} }
@ -1289,7 +1289,7 @@ impl<'a, T> RandomAccessIterator<&'a T> for Items<'a, T> {
} }
} }
iterator!{struct Items -> *T, &'a T} iterator!{struct Items -> *const T, &'a T}
impl<'a, T> ExactSize<&'a T> for Items<'a, T> {} impl<'a, T> ExactSize<&'a T> for Items<'a, T> {}
impl<'a, T> ExactSize<&'a mut T> for MutItems<'a, T> {} impl<'a, T> ExactSize<&'a mut T> for MutItems<'a, T> {}

View file

@ -568,10 +568,10 @@ Section: Comparing strings
#[inline] #[inline]
fn eq_slice_(a: &str, b: &str) -> bool { fn eq_slice_(a: &str, b: &str) -> bool {
#[allow(ctypes)] #[allow(ctypes)]
extern { fn memcmp(s1: *i8, s2: *i8, n: uint) -> i32; } extern { fn memcmp(s1: *const i8, s2: *const i8, n: uint) -> i32; }
a.len() == b.len() && unsafe { a.len() == b.len() && unsafe {
memcmp(a.as_ptr() as *i8, memcmp(a.as_ptr() as *const i8,
b.as_ptr() as *i8, b.as_ptr() as *const i8,
a.len()) == 0 a.len()) == 0
} }
} }
@ -888,8 +888,8 @@ pub mod raw {
/// Form a slice from a C string. Unsafe because the caller must ensure the /// Form a slice from a C string. Unsafe because the caller must ensure the
/// C string has the static lifetime, or else the return value may be /// C string has the static lifetime, or else the return value may be
/// invalidated later. /// invalidated later.
pub unsafe fn c_str_to_static_slice(s: *i8) -> &'static str { pub unsafe fn c_str_to_static_slice(s: *const i8) -> &'static str {
let s = s as *u8; let s = s as *const u8;
let mut curr = s; let mut curr = s;
let mut len = 0u; let mut len = 0u;
while *curr != 0u8 { while *curr != 0u8 {
@ -1618,7 +1618,7 @@ pub trait StrSlice<'a> {
/// The caller must ensure that the string outlives this pointer, /// The caller must ensure that the string outlives this pointer,
/// and that it is not reallocated (e.g. by pushing to the /// and that it is not reallocated (e.g. by pushing to the
/// string). /// string).
fn as_ptr(&self) -> *u8; fn as_ptr(&self) -> *const u8;
} }
impl<'a> StrSlice<'a> for &'a str { impl<'a> StrSlice<'a> for &'a str {
@ -1964,7 +1964,7 @@ impl<'a> StrSlice<'a> for &'a str {
} }
#[inline] #[inline]
fn as_ptr(&self) -> *u8 { fn as_ptr(&self) -> *const u8 {
self.repr().data self.repr().data
} }
} }

View file

@ -62,7 +62,7 @@ impl<T> Unsafe<T> {
/// Gets a mutable pointer to the wrapped value /// Gets a mutable pointer to the wrapped value
#[inline] #[inline]
pub unsafe fn get(&self) -> *mut T { &self.value as *T as *mut T } pub unsafe fn get(&self) -> *mut T { &self.value as *const T as *mut T }
/// Unwraps the value /// Unwraps the value
#[inline] #[inline]

View file

@ -28,7 +28,7 @@ use std::gc::Gc;
* as `TyVisitor`; then build a MovePtrAdaptor wrapped around your struct. * as `TyVisitor`; then build a MovePtrAdaptor wrapped around your struct.
*/ */
pub trait MovePtr { pub trait MovePtr {
fn move_ptr(&mut self, adjustment: |*u8| -> *u8); fn move_ptr(&mut self, adjustment: |*const u8| -> *const u8);
fn push_ptr(&mut self); fn push_ptr(&mut self);
fn pop_ptr(&mut self); fn pop_ptr(&mut self);
} }
@ -51,12 +51,12 @@ impl<V:TyVisitor + MovePtr> MovePtrAdaptor<V> {
#[inline] #[inline]
pub fn bump(&mut self, sz: uint) { pub fn bump(&mut self, sz: uint) {
self.inner.move_ptr(|p| ((p as uint) + sz) as *u8) self.inner.move_ptr(|p| ((p as uint) + sz) as *const u8)
} }
#[inline] #[inline]
pub fn align(&mut self, a: uint) { pub fn align(&mut self, a: uint) {
self.inner.move_ptr(|p| align(p as uint, a) as *u8) self.inner.move_ptr(|p| align(p as uint, a) as *const u8)
} }
#[inline] #[inline]
@ -202,35 +202,35 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
true true
} }
fn visit_box(&mut self, mtbl: uint, inner: *TyDesc) -> bool { fn visit_box(&mut self, mtbl: uint, inner: *const TyDesc) -> bool {
self.align_to::<Gc<u8>>(); self.align_to::<Gc<u8>>();
if ! self.inner.visit_box(mtbl, inner) { return false; } if ! self.inner.visit_box(mtbl, inner) { return false; }
self.bump_past::<Gc<u8>>(); self.bump_past::<Gc<u8>>();
true true
} }
fn visit_uniq(&mut self, mtbl: uint, inner: *TyDesc) -> bool { fn visit_uniq(&mut self, mtbl: uint, inner: *const TyDesc) -> bool {
self.align_to::<Box<u8>>(); self.align_to::<Box<u8>>();
if ! self.inner.visit_uniq(mtbl, inner) { return false; } if ! self.inner.visit_uniq(mtbl, inner) { return false; }
self.bump_past::<Box<u8>>(); self.bump_past::<Box<u8>>();
true true
} }
fn visit_ptr(&mut self, mtbl: uint, inner: *TyDesc) -> bool { fn visit_ptr(&mut self, mtbl: uint, inner: *const TyDesc) -> bool {
self.align_to::<*u8>(); self.align_to::<*const u8>();
if ! self.inner.visit_ptr(mtbl, inner) { return false; } if ! self.inner.visit_ptr(mtbl, inner) { return false; }
self.bump_past::<*u8>(); self.bump_past::<*const u8>();
true true
} }
fn visit_rptr(&mut self, mtbl: uint, inner: *TyDesc) -> bool { fn visit_rptr(&mut self, mtbl: uint, inner: *const TyDesc) -> bool {
self.align_to::<&'static u8>(); self.align_to::<&'static u8>();
if ! self.inner.visit_rptr(mtbl, inner) { return false; } if ! self.inner.visit_rptr(mtbl, inner) { return false; }
self.bump_past::<&'static u8>(); self.bump_past::<&'static u8>();
true true
} }
fn visit_evec_slice(&mut self, mtbl: uint, inner: *TyDesc) -> bool { fn visit_evec_slice(&mut self, mtbl: uint, inner: *const TyDesc) -> bool {
self.align_to::<&'static [u8]>(); self.align_to::<&'static [u8]>();
if ! self.inner.visit_evec_slice(mtbl, inner) { return false; } if ! self.inner.visit_evec_slice(mtbl, inner) { return false; }
self.bump_past::<&'static [u8]>(); self.bump_past::<&'static [u8]>();
@ -238,7 +238,7 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
} }
fn visit_evec_fixed(&mut self, n: uint, sz: uint, align: uint, fn visit_evec_fixed(&mut self, n: uint, sz: uint, align: uint,
mtbl: uint, inner: *TyDesc) -> bool { mtbl: uint, inner: *const TyDesc) -> bool {
self.align(align); self.align(align);
if ! self.inner.visit_evec_fixed(n, sz, align, mtbl, inner) { if ! self.inner.visit_evec_fixed(n, sz, align, mtbl, inner) {
return false; return false;
@ -254,7 +254,7 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
} }
fn visit_rec_field(&mut self, i: uint, name: &str, fn visit_rec_field(&mut self, i: uint, name: &str,
mtbl: uint, inner: *TyDesc) -> bool { mtbl: uint, inner: *const TyDesc) -> bool {
unsafe { self.align((*inner).align); } unsafe { self.align((*inner).align); }
if ! self.inner.visit_rec_field(i, name, mtbl, inner) { if ! self.inner.visit_rec_field(i, name, mtbl, inner) {
return false; return false;
@ -278,7 +278,7 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
} }
fn visit_class_field(&mut self, i: uint, name: &str, named: bool, mtbl: uint, fn visit_class_field(&mut self, i: uint, name: &str, named: bool, mtbl: uint,
inner: *TyDesc) -> bool { inner: *const TyDesc) -> bool {
unsafe { self.align((*inner).align); } unsafe { self.align((*inner).align); }
if ! self.inner.visit_class_field(i, name, named, mtbl, inner) { if ! self.inner.visit_class_field(i, name, named, mtbl, inner) {
return false; return false;
@ -301,7 +301,7 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
true true
} }
fn visit_tup_field(&mut self, i: uint, inner: *TyDesc) -> bool { fn visit_tup_field(&mut self, i: uint, inner: *const TyDesc) -> bool {
unsafe { self.align((*inner).align); } unsafe { self.align((*inner).align); }
if ! self.inner.visit_tup_field(i, inner) { return false; } if ! self.inner.visit_tup_field(i, inner) { return false; }
unsafe { self.bump((*inner).size); } unsafe { self.bump((*inner).size); }
@ -321,12 +321,14 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
true true
} }
fn visit_fn_input(&mut self, i: uint, mode: uint, inner: *TyDesc) -> bool { fn visit_fn_input(&mut self, i: uint, mode: uint,
inner: *const TyDesc) -> bool {
if ! self.inner.visit_fn_input(i, mode, inner) { return false; } if ! self.inner.visit_fn_input(i, mode, inner) { return false; }
true true
} }
fn visit_fn_output(&mut self, retstyle: uint, variadic: bool, inner: *TyDesc) -> bool { fn visit_fn_output(&mut self, retstyle: uint, variadic: bool,
inner: *const TyDesc) -> bool {
if ! self.inner.visit_fn_output(retstyle, variadic, inner) { return false; } if ! self.inner.visit_fn_output(retstyle, variadic, inner) { return false; }
true true
} }
@ -340,7 +342,7 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
} }
fn visit_enter_enum(&mut self, n_variants: uint, fn visit_enter_enum(&mut self, n_variants: uint,
get_disr: unsafe extern fn(ptr: *Opaque) -> Disr, get_disr: unsafe extern fn(ptr: *const Opaque) -> Disr,
sz: uint, align: uint) sz: uint, align: uint)
-> bool { -> bool {
self.align(align); self.align(align);
@ -361,7 +363,8 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
true true
} }
fn visit_enum_variant_field(&mut self, i: uint, offset: uint, inner: *TyDesc) -> bool { fn visit_enum_variant_field(&mut self, i: uint, offset: uint,
inner: *const TyDesc) -> bool {
self.inner.push_ptr(); self.inner.push_ptr();
self.bump(offset); self.bump(offset);
if ! self.inner.visit_enum_variant_field(i, offset, inner) { return false; } if ! self.inner.visit_enum_variant_field(i, offset, inner) { return false; }
@ -381,7 +384,7 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
} }
fn visit_leave_enum(&mut self, n_variants: uint, fn visit_leave_enum(&mut self, n_variants: uint,
get_disr: unsafe extern fn(ptr: *Opaque) -> Disr, get_disr: unsafe extern fn(ptr: *const Opaque) -> Disr,
sz: uint, align: uint) -> bool { sz: uint, align: uint) -> bool {
if ! self.inner.visit_leave_enum(n_variants, get_disr, sz, align) { if ! self.inner.visit_leave_enum(n_variants, get_disr, sz, align) {
return false; return false;

View file

@ -92,8 +92,8 @@ enum VariantState {
} }
pub struct ReprVisitor<'a> { pub struct ReprVisitor<'a> {
ptr: *u8, ptr: *const u8,
ptr_stk: Vec<*u8>, ptr_stk: Vec<*const u8>,
var_stk: Vec<VariantState>, var_stk: Vec<VariantState>,
writer: &'a mut io::Writer, writer: &'a mut io::Writer,
last_err: Option<io::IoError>, last_err: Option<io::IoError>,
@ -101,7 +101,7 @@ pub struct ReprVisitor<'a> {
impl<'a> MovePtr for ReprVisitor<'a> { impl<'a> MovePtr for ReprVisitor<'a> {
#[inline] #[inline]
fn move_ptr(&mut self, adjustment: |*u8| -> *u8) { fn move_ptr(&mut self, adjustment: |*const u8| -> *const u8) {
self.ptr = adjustment(self.ptr); self.ptr = adjustment(self.ptr);
} }
fn push_ptr(&mut self) { fn push_ptr(&mut self) {
@ -114,7 +114,7 @@ impl<'a> MovePtr for ReprVisitor<'a> {
impl<'a> ReprVisitor<'a> { impl<'a> ReprVisitor<'a> {
// Various helpers for the TyVisitor impl // Various helpers for the TyVisitor impl
pub fn new(ptr: *u8, writer: &'a mut io::Writer) -> ReprVisitor<'a> { pub fn new(ptr: *const u8, writer: &'a mut io::Writer) -> ReprVisitor<'a> {
ReprVisitor { ReprVisitor {
ptr: ptr, ptr: ptr,
ptr_stk: vec!(), ptr_stk: vec!(),
@ -128,18 +128,19 @@ impl<'a> ReprVisitor<'a> {
pub fn get<T>(&mut self, f: |&mut ReprVisitor, &T| -> bool) -> bool { pub fn get<T>(&mut self, f: |&mut ReprVisitor, &T| -> bool) -> bool {
unsafe { unsafe {
let ptr = self.ptr; let ptr = self.ptr;
f(self, mem::transmute::<*u8,&T>(ptr)) f(self, mem::transmute::<*const u8,&T>(ptr))
} }
} }
#[inline] #[inline]
pub fn visit_inner(&mut self, inner: *TyDesc) -> bool { pub fn visit_inner(&mut self, inner: *const TyDesc) -> bool {
let ptr = self.ptr; let ptr = self.ptr;
self.visit_ptr_inner(ptr, inner) self.visit_ptr_inner(ptr, inner)
} }
#[inline] #[inline]
pub fn visit_ptr_inner(&mut self, ptr: *u8, inner: *TyDesc) -> bool { pub fn visit_ptr_inner(&mut self, ptr: *const u8,
inner: *const TyDesc) -> bool {
unsafe { unsafe {
let u = ReprVisitor::new(ptr, mem::transmute_copy(&self.writer)); let u = ReprVisitor::new(ptr, mem::transmute_copy(&self.writer));
let mut v = reflect::MovePtrAdaptor::new(u); let mut v = reflect::MovePtrAdaptor::new(u);
@ -183,8 +184,9 @@ impl<'a> ReprVisitor<'a> {
true true
} }
pub fn write_vec_range(&mut self, ptr: *(), len: uint, inner: *TyDesc) -> bool { pub fn write_vec_range(&mut self, ptr: *const (), len: uint,
let mut p = ptr as *u8; inner: *const TyDesc) -> bool {
let mut p = ptr as *const u8;
let (sz, al) = unsafe { ((*inner).size, (*inner).align) }; let (sz, al) = unsafe { ((*inner).size, (*inner).align) };
try!(self, self.writer.write(['[' as u8])); try!(self, self.writer.write(['[' as u8]));
let mut first = true; let mut first = true;
@ -197,8 +199,8 @@ impl<'a> ReprVisitor<'a> {
} else { } else {
try!(self, self.writer.write(", ".as_bytes())); try!(self, self.writer.write(", ".as_bytes()));
} }
self.visit_ptr_inner(p as *u8, inner); self.visit_ptr_inner(p as *const u8, inner);
p = align(unsafe { p.offset(sz as int) as uint }, al) as *u8; p = align(unsafe { p.offset(sz as int) as uint }, al) as *const u8;
left -= dec; left -= dec;
} }
try!(self, self.writer.write([']' as u8])); try!(self, self.writer.write([']' as u8]));
@ -276,40 +278,46 @@ impl<'a> TyVisitor for ReprVisitor<'a> {
fn visit_estr_fixed(&mut self, _n: uint, _sz: uint, fn visit_estr_fixed(&mut self, _n: uint, _sz: uint,
_align: uint) -> bool { fail!(); } _align: uint) -> bool { fail!(); }
fn visit_box(&mut self, mtbl: uint, inner: *TyDesc) -> bool { fn visit_box(&mut self, mtbl: uint, inner: *const TyDesc) -> bool {
try!(self, self.writer.write("box(GC) ".as_bytes())); try!(self, self.writer.write("box(GC) ".as_bytes()));
self.write_mut_qualifier(mtbl); self.write_mut_qualifier(mtbl);
self.get::<&raw::Box<()>>(|this, b| { self.get::<&raw::Box<()>>(|this, b| {
let p = &b.data as *() as *u8; let p = &b.data as *const () as *const u8;
this.visit_ptr_inner(p, inner) this.visit_ptr_inner(p, inner)
}) })
} }
fn visit_uniq(&mut self, _mtbl: uint, inner: *TyDesc) -> bool { fn visit_uniq(&mut self, _mtbl: uint, inner: *const TyDesc) -> bool {
try!(self, self.writer.write("box ".as_bytes())); try!(self, self.writer.write("box ".as_bytes()));
self.get::<*u8>(|this, b| { self.get::<*const u8>(|this, b| {
this.visit_ptr_inner(*b, inner) this.visit_ptr_inner(*b, inner)
}) })
} }
fn visit_ptr(&mut self, mtbl: uint, _inner: *TyDesc) -> bool { fn visit_ptr(&mut self, mtbl: uint, _inner: *const TyDesc) -> bool {
self.get::<*u8>(|this, p| { self.get::<*const u8>(|this, p| {
try!(this, write!(this.writer, "({} as *", *p)); try!(this, write!(this.writer, "({} as *", *p));
this.write_mut_qualifier(mtbl); if mtbl == 0 {
try!(this, this.writer.write("mut ".as_bytes()));
} else if mtbl == 1 {
try!(this, this.writer.write("const ".as_bytes()));
} else {
fail!("invalid mutability value");
}
try!(this, this.writer.write("())".as_bytes())); try!(this, this.writer.write("())".as_bytes()));
true true
}) })
} }
fn visit_rptr(&mut self, mtbl: uint, inner: *TyDesc) -> bool { fn visit_rptr(&mut self, mtbl: uint, inner: *const TyDesc) -> bool {
try!(self, self.writer.write(['&' as u8])); try!(self, self.writer.write(['&' as u8]));
self.write_mut_qualifier(mtbl); self.write_mut_qualifier(mtbl);
self.get::<*u8>(|this, p| { self.get::<*const u8>(|this, p| {
this.visit_ptr_inner(*p, inner) this.visit_ptr_inner(*p, inner)
}) })
} }
fn visit_evec_slice(&mut self, mtbl: uint, inner: *TyDesc) -> bool { fn visit_evec_slice(&mut self, mtbl: uint, inner: *const TyDesc) -> bool {
self.get::<raw::Slice<()>>(|this, s| { self.get::<raw::Slice<()>>(|this, s| {
try!(this, this.writer.write(['&' as u8])); try!(this, this.writer.write(['&' as u8]));
this.write_mut_qualifier(mtbl); this.write_mut_qualifier(mtbl);
@ -321,7 +329,7 @@ impl<'a> TyVisitor for ReprVisitor<'a> {
} }
fn visit_evec_fixed(&mut self, n: uint, sz: uint, _align: uint, fn visit_evec_fixed(&mut self, n: uint, sz: uint, _align: uint,
_: uint, inner: *TyDesc) -> bool { _: uint, inner: *const TyDesc) -> bool {
let assumed_size = if sz == 0 { n } else { sz }; let assumed_size = if sz == 0 { n } else { sz };
self.get::<()>(|this, b| { self.get::<()>(|this, b| {
this.write_vec_range(b, assumed_size, inner) this.write_vec_range(b, assumed_size, inner)
@ -335,7 +343,7 @@ impl<'a> TyVisitor for ReprVisitor<'a> {
} }
fn visit_rec_field(&mut self, i: uint, name: &str, fn visit_rec_field(&mut self, i: uint, name: &str,
mtbl: uint, inner: *TyDesc) -> bool { mtbl: uint, inner: *const TyDesc) -> bool {
if i != 0 { if i != 0 {
try!(self, self.writer.write(", ".as_bytes())); try!(self, self.writer.write(", ".as_bytes()));
} }
@ -366,7 +374,7 @@ impl<'a> TyVisitor for ReprVisitor<'a> {
} }
fn visit_class_field(&mut self, i: uint, name: &str, named: bool, fn visit_class_field(&mut self, i: uint, name: &str, named: bool,
_mtbl: uint, inner: *TyDesc) -> bool { _mtbl: uint, inner: *const TyDesc) -> bool {
if i != 0 { if i != 0 {
try!(self, self.writer.write(", ".as_bytes())); try!(self, self.writer.write(", ".as_bytes()));
} }
@ -396,7 +404,7 @@ impl<'a> TyVisitor for ReprVisitor<'a> {
true true
} }
fn visit_tup_field(&mut self, i: uint, inner: *TyDesc) -> bool { fn visit_tup_field(&mut self, i: uint, inner: *const TyDesc) -> bool {
if i != 0 { if i != 0 {
try!(self, self.writer.write(", ".as_bytes())); try!(self, self.writer.write(", ".as_bytes()));
} }
@ -415,7 +423,7 @@ impl<'a> TyVisitor for ReprVisitor<'a> {
fn visit_enter_enum(&mut self, fn visit_enter_enum(&mut self,
_n_variants: uint, _n_variants: uint,
get_disr: unsafe extern fn(ptr: *Opaque) -> Disr, get_disr: unsafe extern fn(ptr: *const Opaque) -> Disr,
_sz: uint, _sz: uint,
_align: uint) -> bool { _align: uint) -> bool {
let disr = unsafe { let disr = unsafe {
@ -456,7 +464,7 @@ impl<'a> TyVisitor for ReprVisitor<'a> {
fn visit_enum_variant_field(&mut self, fn visit_enum_variant_field(&mut self,
i: uint, i: uint,
_offset: uint, _offset: uint,
inner: *TyDesc) inner: *const TyDesc)
-> bool { -> bool {
match *self.var_stk.get(self.var_stk.len() - 1) { match *self.var_stk.get(self.var_stk.len() - 1) {
Matched => { Matched => {
@ -489,7 +497,7 @@ impl<'a> TyVisitor for ReprVisitor<'a> {
fn visit_leave_enum(&mut self, fn visit_leave_enum(&mut self,
_n_variants: uint, _n_variants: uint,
_get_disr: unsafe extern fn(ptr: *Opaque) -> Disr, _get_disr: unsafe extern fn(ptr: *const Opaque) -> Disr,
_sz: uint, _sz: uint,
_align: uint) _align: uint)
-> bool { -> bool {
@ -505,7 +513,8 @@ impl<'a> TyVisitor for ReprVisitor<'a> {
true true
} }
fn visit_fn_input(&mut self, i: uint, _mode: uint, inner: *TyDesc) -> bool { fn visit_fn_input(&mut self, i: uint, _mode: uint,
inner: *const TyDesc) -> bool {
if i != 0 { if i != 0 {
try!(self, self.writer.write(", ".as_bytes())); try!(self, self.writer.write(", ".as_bytes()));
} }
@ -515,7 +524,7 @@ impl<'a> TyVisitor for ReprVisitor<'a> {
} }
fn visit_fn_output(&mut self, _retstyle: uint, variadic: bool, fn visit_fn_output(&mut self, _retstyle: uint, variadic: bool,
inner: *TyDesc) -> bool { inner: *const TyDesc) -> bool {
if variadic { if variadic {
try!(self, self.writer.write(", ...".as_bytes())); try!(self, self.writer.write(", ...".as_bytes()));
} }
@ -543,7 +552,7 @@ impl<'a> TyVisitor for ReprVisitor<'a> {
pub fn write_repr<T>(writer: &mut io::Writer, object: &T) -> io::IoResult<()> { pub fn write_repr<T>(writer: &mut io::Writer, object: &T) -> io::IoResult<()> {
unsafe { unsafe {
let ptr = object as *T as *u8; let ptr = object as *const T as *const u8;
let tydesc = get_tydesc::<T>(); let tydesc = get_tydesc::<T>();
let u = ReprVisitor::new(ptr, writer); let u = ReprVisitor::new(ptr, writer);
let mut v = reflect::MovePtrAdaptor::new(u); let mut v = reflect::MovePtrAdaptor::new(u);
@ -591,7 +600,7 @@ fn test_repr() {
let mut x = 10; let mut x = 10;
exact_test(&(&mut x), "&mut 10"); exact_test(&(&mut x), "&mut 10");
exact_test(&(0 as *()), "(0x0 as *())"); exact_test(&(0 as *const ()), "(0x0 as *const ())");
exact_test(&(0 as *mut ()), "(0x0 as *mut ())"); exact_test(&(0 as *mut ()), "(0x0 as *mut ())");
exact_test(&(1,), "(1,)"); exact_test(&(1,), "(1,)");

View file

@ -38,18 +38,18 @@ use libc::{c_void, size_t, c_int};
#[link(name = "miniz", kind = "static")] #[link(name = "miniz", kind = "static")]
extern { extern {
/// Raw miniz compression function. /// Raw miniz compression function.
fn tdefl_compress_mem_to_heap(psrc_buf: *c_void, fn tdefl_compress_mem_to_heap(psrc_buf: *const c_void,
src_buf_len: size_t, src_buf_len: size_t,
pout_len: *mut size_t, pout_len: *mut size_t,
flags: c_int) flags: c_int)
-> *mut c_void; -> *mut c_void;
/// Raw miniz decompression function. /// Raw miniz decompression function.
fn tinfl_decompress_mem_to_heap(psrc_buf: *c_void, fn tinfl_decompress_mem_to_heap(psrc_buf: *const c_void,
src_buf_len: size_t, src_buf_len: size_t,
pout_len: *mut size_t, pout_len: *mut size_t,
flags: c_int) flags: c_int)
-> *mut c_void; -> *mut c_void;
} }
static LZ_NORM : c_int = 0x80; // LZ with 128 probes, "normal" static LZ_NORM : c_int = 0x80; // LZ with 128 probes, "normal"
@ -59,10 +59,10 @@ static TDEFL_WRITE_ZLIB_HEADER : c_int = 0x01000; // write zlib header and adler
fn deflate_bytes_internal(bytes: &[u8], flags: c_int) -> Option<CVec<u8>> { fn deflate_bytes_internal(bytes: &[u8], flags: c_int) -> Option<CVec<u8>> {
unsafe { unsafe {
let mut outsz : size_t = 0; let mut outsz : size_t = 0;
let res = tdefl_compress_mem_to_heap(bytes.as_ptr() as *c_void, let res = tdefl_compress_mem_to_heap(bytes.as_ptr() as *const _,
bytes.len() as size_t, bytes.len() as size_t,
&mut outsz, &mut outsz,
flags); flags);
if !res.is_null() { if !res.is_null() {
Some(CVec::new_with_dtor(res as *mut u8, outsz as uint, proc() libc::free(res))) Some(CVec::new_with_dtor(res as *mut u8, outsz as uint, proc() libc::free(res)))
} else { } else {
@ -84,10 +84,10 @@ pub fn deflate_bytes_zlib(bytes: &[u8]) -> Option<CVec<u8>> {
fn inflate_bytes_internal(bytes: &[u8], flags: c_int) -> Option<CVec<u8>> { fn inflate_bytes_internal(bytes: &[u8], flags: c_int) -> Option<CVec<u8>> {
unsafe { unsafe {
let mut outsz : size_t = 0; let mut outsz : size_t = 0;
let res = tinfl_decompress_mem_to_heap(bytes.as_ptr() as *c_void, let res = tinfl_decompress_mem_to_heap(bytes.as_ptr() as *const _,
bytes.len() as size_t, bytes.len() as size_t,
&mut outsz, &mut outsz,
flags); flags);
if !res.is_null() { if !res.is_null() {
Some(CVec::new_with_dtor(res as *mut u8, outsz as uint, proc() libc::free(res))) Some(CVec::new_with_dtor(res as *mut u8, outsz as uint, proc() libc::free(res)))
} else { } else {

View file

@ -27,7 +27,7 @@ pub struct Context {
stack_bounds: Option<(uint, uint)>, stack_bounds: Option<(uint, uint)>,
} }
pub type InitFn = extern "C" fn(uint, *(), *()) -> !; pub type InitFn = extern "C" fn(uint, *mut (), *mut ()) -> !;
impl Context { impl Context {
pub fn empty() -> Context { pub fn empty() -> Context {
@ -49,7 +49,7 @@ impl Context {
pub fn new(init: InitFn, arg: uint, start: proc():Send, pub fn new(init: InitFn, arg: uint, start: proc():Send,
stack: &mut Stack) -> Context { stack: &mut Stack) -> Context {
let sp: *uint = stack.end(); let sp: *const uint = stack.end();
let sp: *mut uint = sp as *mut uint; let sp: *mut uint = sp as *mut uint;
// Save and then immediately load the current context, // Save and then immediately load the current context,
// which we will then modify to call the given function when restored // which we will then modify to call the given function when restored
@ -66,7 +66,7 @@ impl Context {
// them in terms of the code running on them (and hopefully they don't // them in terms of the code running on them (and hopefully they don't
// overflow). Additionally, their coroutine stacks are listed as being // overflow). Additionally, their coroutine stacks are listed as being
// zero-length, so that's how we detect what's what here. // zero-length, so that's how we detect what's what here.
let stack_base: *uint = stack.start(); let stack_base: *const uint = stack.start();
let bounds = if sp as uint == stack_base as uint { let bounds = if sp as uint == stack_base as uint {
None None
} else { } else {
@ -116,7 +116,7 @@ impl Context {
#[link(name = "context_switch", kind = "static")] #[link(name = "context_switch", kind = "static")]
extern { extern {
fn rust_swap_registers(out_regs: *mut Registers, in_regs: *Registers); fn rust_swap_registers(out_regs: *mut Registers, in_regs: *const Registers);
} }
// Register contexts used in various architectures // Register contexts used in various architectures

View file

@ -116,7 +116,7 @@
//! extern crate green; //! extern crate green;
//! //!
//! #[start] //! #[start]
//! fn start(argc: int, argv: **u8) -> int { //! fn start(argc: int, argv: *const *const u8) -> int {
//! green::start(argc, argv, green::basic::event_loop, main) //! green::start(argc, argv, green::basic::event_loop, main)
//! } //! }
//! //!
@ -135,7 +135,7 @@
//! extern crate rustuv; //! extern crate rustuv;
//! //!
//! #[start] //! #[start]
//! fn start(argc: int, argv: **u8) -> int { //! fn start(argc: int, argv: *const *const u8) -> int {
//! green::start(argc, argv, rustuv::event_loop, main) //! green::start(argc, argv, rustuv::event_loop, main)
//! } //! }
//! //!
@ -267,7 +267,7 @@ macro_rules! green_start( ($f:ident) => (
extern crate rustuv; extern crate rustuv;
#[start] #[start]
fn start(argc: int, argv: **u8) -> int { fn start(argc: int, argv: *const *const u8) -> int {
green::start(argc, argv, rustuv::event_loop, super::$f) green::start(argc, argv, rustuv::event_loop, super::$f)
} }
} }
@ -291,7 +291,7 @@ macro_rules! green_start( ($f:ident) => (
/// ///
/// The return value is used as the process return code. 0 on success, 101 on /// The return value is used as the process return code. 0 on success, 101 on
/// error. /// error.
pub fn start(argc: int, argv: **u8, pub fn start(argc: int, argv: *const *const u8,
event_loop_factory: fn() -> Box<rtio::EventLoop + Send>, event_loop_factory: fn() -> Box<rtio::EventLoop + Send>,
main: proc():Send) -> int { main: proc():Send) -> int {
rt::init(argc, argv); rt::init(argc, argv);

View file

@ -611,13 +611,13 @@ impl Scheduler {
// old task as inputs. // old task as inputs.
pub fn change_task_context(mut ~self, pub fn change_task_context(mut ~self,
current_task: Box<GreenTask>, mut current_task: Box<GreenTask>,
mut next_task: Box<GreenTask>, mut next_task: Box<GreenTask>,
f: |&mut Scheduler, Box<GreenTask>|) f: |&mut Scheduler, Box<GreenTask>|)
-> Box<GreenTask> { -> Box<GreenTask> {
let f_opaque = ClosureConverter::from_fn(f); let f_opaque = ClosureConverter::from_fn(f);
let current_task_dupe = &*current_task as *GreenTask; let current_task_dupe = &mut *current_task as *mut GreenTask;
// The current task is placed inside an enum with the cleanup // The current task is placed inside an enum with the cleanup
// function. This enum is then placed inside the scheduler. // function. This enum is then placed inside the scheduler.
@ -871,7 +871,7 @@ impl Scheduler {
// * Utility Functions // * Utility Functions
pub fn sched_id(&self) -> uint { self as *Scheduler as uint } pub fn sched_id(&self) -> uint { self as *const Scheduler as uint }
pub fn run_cleanup_job(&mut self) { pub fn run_cleanup_job(&mut self) {
let cleanup_job = self.cleanup_job.take_unwrap(); let cleanup_job = self.cleanup_job.take_unwrap();

View file

@ -32,7 +32,7 @@ impl Runtime for SimpleTask {
assert!(times == 1); assert!(times == 1);
let me = &mut *self as *mut SimpleTask; let me = &mut *self as *mut SimpleTask;
let cur_dupe = &*cur_task as *Task; let cur_dupe = &mut *cur_task as *mut Task;
cur_task.put_runtime(self); cur_task.put_runtime(self);
let task = BlockedTask::block(cur_task); let task = BlockedTask::block(cur_task);

View file

@ -78,14 +78,14 @@ impl Stack {
} }
/// Point to the low end of the allocated stack /// Point to the low end of the allocated stack
pub fn start(&self) -> *uint { pub fn start(&self) -> *const uint {
self.buf.data as *uint self.buf.data as *const uint
} }
/// Point one uint beyond the high end of the allocated stack /// Point one uint beyond the high end of the allocated stack
pub fn end(&self) -> *uint { pub fn end(&self) -> *const uint {
unsafe { unsafe {
self.buf.data.offset(self.buf.len as int) as *uint self.buf.data.offset(self.buf.len as int) as *const uint
} }
} }
} }
@ -168,8 +168,8 @@ fn max_cached_stacks() -> uint {
} }
extern { extern {
fn rust_valgrind_stack_register(start: *libc::uintptr_t, fn rust_valgrind_stack_register(start: *const libc::uintptr_t,
end: *libc::uintptr_t) -> libc::c_uint; end: *const libc::uintptr_t) -> libc::c_uint;
fn rust_valgrind_stack_deregister(id: libc::c_uint); fn rust_valgrind_stack_deregister(id: libc::c_uint);
} }

View file

@ -89,7 +89,7 @@ pub enum Home {
/// ///
/// The goal for having this weird-looking function is to reduce the number of /// The goal for having this weird-looking function is to reduce the number of
/// allocations done on a green-task startup as much as possible. /// allocations done on a green-task startup as much as possible.
extern fn bootstrap_green_task(task: uint, code: *(), env: *()) -> ! { extern fn bootstrap_green_task(task: uint, code: *mut (), env: *mut ()) -> ! {
// Acquire ownership of the `proc()` // Acquire ownership of the `proc()`
let start: proc() = unsafe { let start: proc() = unsafe {
mem::transmute(raw::Procedure { code: code, env: env }) mem::transmute(raw::Procedure { code: code, env: env })
@ -256,7 +256,7 @@ impl GreenTask {
// context switches // context switches
pub fn as_uint(&self) -> uint { pub fn as_uint(&self) -> uint {
self as *GreenTask as uint self as *const GreenTask as uint
} }
pub unsafe fn from_uint(val: uint) -> Box<GreenTask> { pub unsafe fn from_uint(val: uint) -> Box<GreenTask> {

View file

@ -365,14 +365,14 @@ pub mod types {
pub struct glob_t { pub struct glob_t {
pub gl_pathc: size_t, pub gl_pathc: size_t,
pub gl_pathv: **c_char, pub gl_pathv: *mut *mut c_char,
pub gl_offs: size_t, pub gl_offs: size_t,
pub __unused1: *c_void, pub __unused1: *mut c_void,
pub __unused2: *c_void, pub __unused2: *mut c_void,
pub __unused3: *c_void, pub __unused3: *mut c_void,
pub __unused4: *c_void, pub __unused4: *mut c_void,
pub __unused5: *c_void, pub __unused5: *mut c_void,
} }
pub struct timeval { pub struct timeval {
@ -440,18 +440,18 @@ pub mod types {
pub ai_addrlen: socklen_t, pub ai_addrlen: socklen_t,
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
pub ai_addr: *sockaddr, pub ai_addr: *mut sockaddr,
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
pub ai_canonname: *c_char, pub ai_canonname: *mut c_char,
#[cfg(target_os = "android")] #[cfg(target_os = "android")]
pub ai_canonname: *c_char, pub ai_canonname: *mut c_char,
#[cfg(target_os = "android")] #[cfg(target_os = "android")]
pub ai_addr: *sockaddr, pub ai_addr: *mut sockaddr,
pub ai_next: *addrinfo, pub ai_next: *mut addrinfo,
} }
pub struct sockaddr_un { pub struct sockaddr_un {
pub sun_family: sa_family_t, pub sun_family: sa_family_t,
@ -751,15 +751,15 @@ pub mod types {
pub __unused1: size_t, pub __unused1: size_t,
pub gl_offs: size_t, pub gl_offs: size_t,
pub __unused2: c_int, pub __unused2: c_int,
pub gl_pathv: **c_char, pub gl_pathv: *mut *mut c_char,
pub __unused3: *c_void, pub __unused3: *mut c_void,
pub __unused4: *c_void, pub __unused4: *mut c_void,
pub __unused5: *c_void, pub __unused5: *mut c_void,
pub __unused6: *c_void, pub __unused6: *mut c_void,
pub __unused7: *c_void, pub __unused7: *mut c_void,
pub __unused8: *c_void, pub __unused8: *mut c_void,
} }
pub struct timeval { pub struct timeval {
@ -830,9 +830,9 @@ pub mod types {
pub ai_socktype: c_int, pub ai_socktype: c_int,
pub ai_protocol: c_int, pub ai_protocol: c_int,
pub ai_addrlen: socklen_t, pub ai_addrlen: socklen_t,
pub ai_canonname: *c_char, pub ai_canonname: *mut c_char,
pub ai_addr: *sockaddr, pub ai_addr: *mut sockaddr,
pub ai_next: *addrinfo, pub ai_next: *mut addrinfo,
} }
pub struct sockaddr_un { pub struct sockaddr_un {
pub sun_len: u8, pub sun_len: u8,
@ -922,7 +922,7 @@ pub mod types {
pub modtime: time_t, pub modtime: time_t,
} }
pub type pthread_attr_t = *c_void; pub type pthread_attr_t = *mut c_void;
} }
pub mod posix08 { pub mod posix08 {
} }
@ -1028,9 +1028,9 @@ pub mod types {
pub ai_socktype: c_int, pub ai_socktype: c_int,
pub ai_protocol: c_int, pub ai_protocol: c_int,
pub ai_addrlen: size_t, pub ai_addrlen: size_t,
pub ai_canonname: *c_char, pub ai_canonname: *mut c_char,
pub ai_addr: *sockaddr, pub ai_addr: *mut sockaddr,
pub ai_next: *addrinfo, pub ai_next: *mut addrinfo,
} }
pub struct sockaddr_un { pub struct sockaddr_un {
pub sun_family: sa_family_t, pub sun_family: sa_family_t,
@ -1142,8 +1142,8 @@ pub mod types {
pub type LARGE_INTEGER = c_longlong; pub type LARGE_INTEGER = c_longlong;
pub type PLARGE_INTEGER = *mut c_longlong; pub type PLARGE_INTEGER = *mut c_longlong;
pub type LPCWSTR = *WCHAR; pub type LPCWSTR = *const WCHAR;
pub type LPCSTR = *CHAR; pub type LPCSTR = *const CHAR;
pub type LPWSTR = *mut WCHAR; pub type LPWSTR = *mut WCHAR;
pub type LPSTR = *mut CHAR; pub type LPSTR = *mut CHAR;
@ -1159,7 +1159,7 @@ pub mod types {
pub type LPSECURITY_ATTRIBUTES = *mut SECURITY_ATTRIBUTES; pub type LPSECURITY_ATTRIBUTES = *mut SECURITY_ATTRIBUTES;
pub type LPVOID = *mut c_void; pub type LPVOID = *mut c_void;
pub type LPCVOID = *c_void; pub type LPCVOID = *const c_void;
pub type LPBYTE = *mut BYTE; pub type LPBYTE = *mut BYTE;
pub type LPWORD = *mut WORD; pub type LPWORD = *mut WORD;
pub type LPDWORD = *mut DWORD; pub type LPDWORD = *mut DWORD;
@ -1231,8 +1231,8 @@ pub mod types {
pub type LPMEMORY_BASIC_INFORMATION = *mut MEMORY_BASIC_INFORMATION; pub type LPMEMORY_BASIC_INFORMATION = *mut MEMORY_BASIC_INFORMATION;
pub struct OVERLAPPED { pub struct OVERLAPPED {
pub Internal: *c_ulong, pub Internal: *mut c_ulong,
pub InternalHigh: *c_ulong, pub InternalHigh: *mut c_ulong,
pub Offset: DWORD, pub Offset: DWORD,
pub OffsetHigh: DWORD, pub OffsetHigh: DWORD,
pub hEvent: HANDLE, pub hEvent: HANDLE,
@ -1308,15 +1308,15 @@ pub mod types {
pub __unused1: c_int, pub __unused1: c_int,
pub gl_offs: size_t, pub gl_offs: size_t,
pub __unused2: c_int, pub __unused2: c_int,
pub gl_pathv: **c_char, pub gl_pathv: *mut *mut c_char,
pub __unused3: *c_void, pub __unused3: *mut c_void,
pub __unused4: *c_void, pub __unused4: *mut c_void,
pub __unused5: *c_void, pub __unused5: *mut c_void,
pub __unused6: *c_void, pub __unused6: *mut c_void,
pub __unused7: *c_void, pub __unused7: *mut c_void,
pub __unused8: *c_void, pub __unused8: *mut c_void,
} }
pub struct timeval { pub struct timeval {
@ -1388,9 +1388,9 @@ pub mod types {
pub ai_socktype: c_int, pub ai_socktype: c_int,
pub ai_protocol: c_int, pub ai_protocol: c_int,
pub ai_addrlen: socklen_t, pub ai_addrlen: socklen_t,
pub ai_canonname: *c_char, pub ai_canonname: *mut c_char,
pub ai_addr: *sockaddr, pub ai_addr: *mut sockaddr,
pub ai_next: *addrinfo, pub ai_next: *mut addrinfo,
} }
pub struct sockaddr_un { pub struct sockaddr_un {
pub sun_len: u8, pub sun_len: u8,
@ -3539,53 +3539,56 @@ pub mod funcs {
use types::os::arch::c95::{c_char, c_int, c_long, size_t}; use types::os::arch::c95::{c_char, c_int, c_long, size_t};
extern { extern {
pub fn fopen(filename: *c_char, mode: *c_char) -> *FILE; pub fn fopen(filename: *const c_char,
pub fn freopen(filename: *c_char, mode: *c_char, file: *FILE) mode: *const c_char) -> *mut FILE;
-> *FILE; pub fn freopen(filename: *const c_char, mode: *const c_char,
pub fn fflush(file: *FILE) -> c_int; file: *mut FILE)
pub fn fclose(file: *FILE) -> c_int; -> *mut FILE;
pub fn remove(filename: *c_char) -> c_int; pub fn fflush(file: *mut FILE) -> c_int;
pub fn rename(oldname: *c_char, newname: *c_char) -> c_int; pub fn fclose(file: *mut FILE) -> c_int;
pub fn tmpfile() -> *FILE; pub fn remove(filename: *const c_char) -> c_int;
pub fn setvbuf(stream: *FILE, pub fn rename(oldname: *const c_char,
buffer: *c_char, newname: *const c_char) -> c_int;
pub fn tmpfile() -> *mut FILE;
pub fn setvbuf(stream: *mut FILE,
buffer: *mut c_char,
mode: c_int, mode: c_int,
size: size_t) size: size_t)
-> c_int; -> c_int;
pub fn setbuf(stream: *FILE, buf: *c_char); pub fn setbuf(stream: *mut FILE, buf: *mut c_char);
// Omitted: printf and scanf variants. // Omitted: printf and scanf variants.
pub fn fgetc(stream: *FILE) -> c_int; pub fn fgetc(stream: *mut FILE) -> c_int;
pub fn fgets(buf: *mut c_char, n: c_int, stream: *FILE) pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE)
-> *c_char; -> *mut c_char;
pub fn fputc(c: c_int, stream: *FILE) -> c_int; pub fn fputc(c: c_int, stream: *mut FILE) -> c_int;
pub fn fputs(s: *c_char, stream: *FILE) -> *c_char; pub fn fputs(s: *const c_char, stream: *mut FILE)-> c_int;
// Omitted: getc, getchar (might be macros). // Omitted: getc, getchar (might be macros).
// Omitted: gets, so ridiculously unsafe that it should not // Omitted: gets, so ridiculously unsafe that it should not
// survive. // survive.
// Omitted: putc, putchar (might be macros). // Omitted: putc, putchar (might be macros).
pub fn puts(s: *c_char) -> c_int; pub fn puts(s: *const c_char) -> c_int;
pub fn ungetc(c: c_int, stream: *FILE) -> c_int; pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int;
pub fn fread(ptr: *mut c_void, pub fn fread(ptr: *mut c_void,
size: size_t, size: size_t,
nobj: size_t, nobj: size_t,
stream: *FILE) stream: *mut FILE)
-> size_t; -> size_t;
pub fn fwrite(ptr: *c_void, pub fn fwrite(ptr: *const c_void,
size: size_t, size: size_t,
nobj: size_t, nobj: size_t,
stream: *FILE) stream: *mut FILE)
-> size_t; -> size_t;
pub fn fseek(stream: *FILE, offset: c_long, whence: c_int) pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int)
-> c_int; -> c_int;
pub fn ftell(stream: *FILE) -> c_long; pub fn ftell(stream: *mut FILE) -> c_long;
pub fn rewind(stream: *FILE); pub fn rewind(stream: *mut FILE);
pub fn fgetpos(stream: *FILE, ptr: *fpos_t) -> c_int; pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int;
pub fn fsetpos(stream: *FILE, ptr: *fpos_t) -> c_int; pub fn fsetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int;
pub fn feof(stream: *FILE) -> c_int; pub fn feof(stream: *mut FILE) -> c_int;
pub fn ferror(stream: *FILE) -> c_int; pub fn ferror(stream: *mut FILE) -> c_int;
pub fn perror(s: *c_char); pub fn perror(s: *const c_char);
} }
} }
@ -3599,22 +3602,23 @@ pub mod funcs {
pub fn abs(i: c_int) -> c_int; pub fn abs(i: c_int) -> c_int;
pub fn labs(i: c_long) -> c_long; pub fn labs(i: c_long) -> c_long;
// Omitted: div, ldiv (return pub type incomplete). // Omitted: div, ldiv (return pub type incomplete).
pub fn atof(s: *c_char) -> c_double; pub fn atof(s: *const c_char) -> c_double;
pub fn atoi(s: *c_char) -> c_int; pub fn atoi(s: *const c_char) -> c_int;
pub fn strtod(s: *c_char, endp: **c_char) -> c_double; pub fn strtod(s: *const c_char,
pub fn strtol(s: *c_char, endp: **c_char, base: c_int) endp: *mut *mut c_char) -> c_double;
-> c_long; pub fn strtol(s: *const c_char,
pub fn strtoul(s: *c_char, endp: **c_char, base: c_int) endp: *mut *mut c_char, base: c_int) -> c_long;
-> c_ulong; pub fn strtoul(s: *const c_char, endp: *mut *mut c_char,
pub fn calloc(nobj: size_t, size: size_t) -> *c_void; base: c_int) -> c_ulong;
pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void;
pub fn malloc(size: size_t) -> *mut c_void; pub fn malloc(size: size_t) -> *mut c_void;
pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void;
pub fn free(p: *mut c_void); pub fn free(p: *mut c_void);
pub fn exit(status: c_int) -> !; pub fn exit(status: c_int) -> !;
pub fn _exit(status: c_int) -> !; pub fn _exit(status: c_int) -> !;
// Omitted: atexit. // Omitted: atexit.
pub fn system(s: *c_char) -> c_int; pub fn system(s: *const c_char) -> c_int;
pub fn getenv(s: *c_char) -> *c_char; pub fn getenv(s: *const c_char) -> *mut c_char;
// Omitted: bsearch, qsort // Omitted: bsearch, qsort
pub fn rand() -> c_int; pub fn rand() -> c_int;
pub fn srand(seed: c_uint); pub fn srand(seed: c_uint);
@ -3627,32 +3631,40 @@ pub mod funcs {
use types::os::arch::c95::{wchar_t}; use types::os::arch::c95::{wchar_t};
extern { extern {
pub fn strcpy(dst: *c_char, src: *c_char) -> *c_char; pub fn strcpy(dst: *mut c_char,
pub fn strncpy(dst: *c_char, src: *c_char, n: size_t) src: *const c_char) -> *mut c_char;
-> *c_char; pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t)
pub fn strcat(s: *c_char, ct: *c_char) -> *c_char; -> *mut c_char;
pub fn strncat(s: *c_char, ct: *c_char, n: size_t) -> *c_char; pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char;
pub fn strcmp(cs: *c_char, ct: *c_char) -> c_int; pub fn strncat(s: *mut c_char, ct: *const c_char,
pub fn strncmp(cs: *c_char, ct: *c_char, n: size_t) -> c_int; n: size_t) -> *mut c_char;
pub fn strcoll(cs: *c_char, ct: *c_char) -> c_int; pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int;
pub fn strchr(cs: *c_char, c: c_int) -> *c_char; pub fn strncmp(cs: *const c_char, ct: *const c_char,
pub fn strrchr(cs: *c_char, c: c_int) -> *c_char; n: size_t) -> c_int;
pub fn strspn(cs: *c_char, ct: *c_char) -> size_t; pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int;
pub fn strcspn(cs: *c_char, ct: *c_char) -> size_t; pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char;
pub fn strpbrk(cs: *c_char, ct: *c_char) -> *c_char; pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char;
pub fn strstr(cs: *c_char, ct: *c_char) -> *c_char; pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t;
pub fn strlen(cs: *c_char) -> size_t; pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t;
pub fn strerror(n: c_int) -> *c_char; pub fn strpbrk(cs: *const c_char,
pub fn strtok(s: *c_char, t: *c_char) -> *c_char; ct: *const c_char) -> *mut c_char;
pub fn strxfrm(s: *c_char, ct: *c_char, n: size_t) -> size_t; pub fn strstr(cs: *const c_char,
pub fn wcslen(buf: *wchar_t) -> size_t; ct: *const c_char) -> *mut c_char;
pub fn strlen(cs: *const c_char) -> size_t;
pub fn strerror(n: c_int) -> *mut c_char;
pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char;
pub fn strxfrm(s: *mut c_char, ct: *const c_char,
n: size_t) -> size_t;
pub fn wcslen(buf: *const wchar_t) -> size_t;
// Omitted: memcpy, memmove, memset (provided by LLVM) // Omitted: memcpy, memmove, memset (provided by LLVM)
// These are fine to execute on the Rust stack. They must be, // These are fine to execute on the Rust stack. They must be,
// in fact, because LLVM generates calls to them! // in fact, because LLVM generates calls to them!
pub fn memcmp(cx: *c_void, ct: *c_void, n: size_t) -> c_int; pub fn memcmp(cx: *const c_void, ct: *const c_void,
pub fn memchr(cx: *c_void, c: c_int, n: size_t) -> *c_void; n: size_t) -> c_int;
pub fn memchr(cx: *const c_void, c: c_int,
n: size_t) -> *mut c_void;
} }
} }
} }
@ -3671,21 +3683,21 @@ pub mod funcs {
extern { extern {
#[link_name = "_chmod"] #[link_name = "_chmod"]
pub fn chmod(path: *c_char, mode: c_int) -> c_int; pub fn chmod(path: *const c_char, mode: c_int) -> c_int;
#[link_name = "_wchmod"] #[link_name = "_wchmod"]
pub fn wchmod(path: *wchar_t, mode: c_int) -> c_int; pub fn wchmod(path: *const wchar_t, mode: c_int) -> c_int;
#[link_name = "_mkdir"] #[link_name = "_mkdir"]
pub fn mkdir(path: *c_char) -> c_int; pub fn mkdir(path: *const c_char) -> c_int;
#[link_name = "_wrmdir"] #[link_name = "_wrmdir"]
pub fn wrmdir(path: *wchar_t) -> c_int; pub fn wrmdir(path: *const wchar_t) -> c_int;
#[link_name = "_fstat64"] #[link_name = "_fstat64"]
pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int; pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int;
#[link_name = "_stat64"] #[link_name = "_stat64"]
pub fn stat(path: *c_char, buf: *mut stat) -> c_int; pub fn stat(path: *const c_char, buf: *mut stat) -> c_int;
#[link_name = "_wstat64"] #[link_name = "_wstat64"]
pub fn wstat(path: *wchar_t, buf: *mut stat) -> c_int; pub fn wstat(path: *const wchar_t, buf: *mut stat) -> c_int;
#[link_name = "_wutime64"] #[link_name = "_wutime64"]
pub fn wutime(file: *wchar_t, buf: *utimbuf) -> c_int; pub fn wutime(file: *const wchar_t, buf: *mut utimbuf) -> c_int;
} }
} }
@ -3695,13 +3707,14 @@ pub mod funcs {
extern { extern {
#[link_name = "_popen"] #[link_name = "_popen"]
pub fn popen(command: *c_char, mode: *c_char) -> *FILE; pub fn popen(command: *const c_char,
mode: *const c_char) -> *mut FILE;
#[link_name = "_pclose"] #[link_name = "_pclose"]
pub fn pclose(stream: *FILE) -> c_int; pub fn pclose(stream: *mut FILE) -> c_int;
#[link_name = "_fdopen"] #[link_name = "_fdopen"]
pub fn fdopen(fd: c_int, mode: *c_char) -> *FILE; pub fn fdopen(fd: c_int, mode: *const c_char) -> *mut FILE;
#[link_name = "_fileno"] #[link_name = "_fileno"]
pub fn fileno(stream: *FILE) -> c_int; pub fn fileno(stream: *mut FILE) -> c_int;
} }
} }
@ -3709,13 +3722,13 @@ pub mod funcs {
use types::os::arch::c95::{c_int, c_char, wchar_t}; use types::os::arch::c95::{c_int, c_char, wchar_t};
extern { extern {
#[link_name = "_open"] #[link_name = "_open"]
pub fn open(path: *c_char, oflag: c_int, mode: c_int) pub fn open(path: *const c_char, oflag: c_int, mode: c_int)
-> c_int; -> c_int;
#[link_name = "_wopen"] #[link_name = "_wopen"]
pub fn wopen(path: *wchar_t, oflag: c_int, mode: c_int) pub fn wopen(path: *const wchar_t, oflag: c_int, mode: c_int)
-> c_int; -> c_int;
#[link_name = "_creat"] #[link_name = "_creat"]
pub fn creat(path: *c_char, mode: c_int) -> c_int; pub fn creat(path: *const c_char, mode: c_int) -> c_int;
} }
} }
@ -3731,9 +3744,9 @@ pub mod funcs {
extern { extern {
#[link_name = "_access"] #[link_name = "_access"]
pub fn access(path: *c_char, amode: c_int) -> c_int; pub fn access(path: *const c_char, amode: c_int) -> c_int;
#[link_name = "_chdir"] #[link_name = "_chdir"]
pub fn chdir(dir: *c_char) -> c_int; pub fn chdir(dir: *const c_char) -> c_int;
#[link_name = "_close"] #[link_name = "_close"]
pub fn close(fd: c_int) -> c_int; pub fn close(fd: c_int) -> c_int;
#[link_name = "_dup"] #[link_name = "_dup"]
@ -3741,17 +3754,20 @@ pub mod funcs {
#[link_name = "_dup2"] #[link_name = "_dup2"]
pub fn dup2(src: c_int, dst: c_int) -> c_int; pub fn dup2(src: c_int, dst: c_int) -> c_int;
#[link_name = "_execv"] #[link_name = "_execv"]
pub fn execv(prog: *c_char, argv: **c_char) -> intptr_t; pub fn execv(prog: *const c_char,
argv: *mut *const c_char) -> intptr_t;
#[link_name = "_execve"] #[link_name = "_execve"]
pub fn execve(prog: *c_char, argv: **c_char, envp: **c_char) pub fn execve(prog: *const c_char, argv: *mut *const c_char,
envp: *mut *const c_char)
-> c_int; -> c_int;
#[link_name = "_execvp"] #[link_name = "_execvp"]
pub fn execvp(c: *c_char, argv: **c_char) -> c_int; pub fn execvp(c: *const c_char,
argv: *mut *const c_char) -> c_int;
#[link_name = "_execvpe"] #[link_name = "_execvpe"]
pub fn execvpe(c: *c_char, argv: **c_char, envp: **c_char) pub fn execvpe(c: *const c_char, argv: *mut *const c_char,
-> c_int; envp: *mut *const c_char) -> c_int;
#[link_name = "_getcwd"] #[link_name = "_getcwd"]
pub fn getcwd(buf: *mut c_char, size: size_t) -> *c_char; pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char;
#[link_name = "_getpid"] #[link_name = "_getpid"]
pub fn getpid() -> c_int; pub fn getpid() -> c_int;
#[link_name = "_isatty"] #[link_name = "_isatty"]
@ -3766,11 +3782,12 @@ pub mod funcs {
pub fn read(fd: c_int, buf: *mut c_void, count: c_uint) pub fn read(fd: c_int, buf: *mut c_void, count: c_uint)
-> c_int; -> c_int;
#[link_name = "_rmdir"] #[link_name = "_rmdir"]
pub fn rmdir(path: *c_char) -> c_int; pub fn rmdir(path: *const c_char) -> c_int;
#[link_name = "_unlink"] #[link_name = "_unlink"]
pub fn unlink(c: *c_char) -> c_int; pub fn unlink(c: *const c_char) -> c_int;
#[link_name = "_write"] #[link_name = "_write"]
pub fn write(fd: c_int, buf: *c_void, count: c_uint) -> c_int; pub fn write(fd: c_int, buf: *const c_void,
count: c_uint) -> c_int;
} }
} }
@ -3791,7 +3808,7 @@ pub mod funcs {
use types::os::arch::posix88::mode_t; use types::os::arch::posix88::mode_t;
extern { extern {
pub fn chmod(path: *c_char, mode: mode_t) -> c_int; pub fn chmod(path: *const c_char, mode: mode_t) -> c_int;
pub fn fchmod(fd: c_int, mode: mode_t) -> c_int; pub fn fchmod(fd: c_int, mode: mode_t) -> c_int;
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
@ -3804,18 +3821,18 @@ pub mod funcs {
#[link_name = "fstat64"] #[link_name = "fstat64"]
pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int; pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int;
pub fn mkdir(path: *c_char, mode: mode_t) -> c_int; pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int;
pub fn mkfifo(path: *c_char, mode: mode_t) -> c_int; pub fn mkfifo(path: *const c_char, mode: mode_t) -> c_int;
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
#[cfg(target_os = "freebsd")] #[cfg(target_os = "freebsd")]
#[cfg(target_os = "android")] #[cfg(target_os = "android")]
#[cfg(target_os = "ios")] #[cfg(target_os = "ios")]
pub fn stat(path: *c_char, buf: *mut stat) -> c_int; pub fn stat(path: *const c_char, buf: *mut stat) -> c_int;
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
#[link_name = "stat64"] #[link_name = "stat64"]
pub fn stat(path: *c_char, buf: *mut stat) -> c_int; pub fn stat(path: *const c_char, buf: *mut stat) -> c_int;
} }
} }
@ -3824,10 +3841,11 @@ pub mod funcs {
use types::os::arch::c95::{c_char, c_int}; use types::os::arch::c95::{c_char, c_int};
extern { extern {
pub fn popen(command: *c_char, mode: *c_char) -> *FILE; pub fn popen(command: *const c_char,
pub fn pclose(stream: *FILE) -> c_int; mode: *const c_char) -> *mut FILE;
pub fn fdopen(fd: c_int, mode: *c_char) -> *FILE; pub fn pclose(stream: *mut FILE) -> c_int;
pub fn fileno(stream: *FILE) -> c_int; pub fn fdopen(fd: c_int, mode: *const c_char) -> *mut FILE;
pub fn fileno(stream: *mut FILE) -> c_int;
} }
} }
@ -3836,9 +3854,9 @@ pub mod funcs {
use types::os::arch::posix88::mode_t; use types::os::arch::posix88::mode_t;
extern { extern {
pub fn open(path: *c_char, oflag: c_int, mode: c_int) pub fn open(path: *const c_char, oflag: c_int, mode: c_int)
-> c_int; -> c_int;
pub fn creat(path: *c_char, mode: mode_t) -> c_int; pub fn creat(path: *const c_char, mode: mode_t) -> c_int;
pub fn fcntl(fd: c_int, cmd: c_int, ...) -> c_int; pub fn fcntl(fd: c_int, cmd: c_int, ...) -> c_int;
} }
} }
@ -3856,17 +3874,17 @@ pub mod funcs {
extern { extern {
#[link_name="rust_opendir"] #[link_name="rust_opendir"]
pub fn opendir(dirname: *c_char) -> *DIR; pub fn opendir(dirname: *const c_char) -> *mut DIR;
#[link_name="rust_readdir_r"] #[link_name="rust_readdir_r"]
pub fn readdir_r(dirp: *DIR, entry: *mut dirent_t, pub fn readdir_r(dirp: *mut DIR, entry: *mut dirent_t,
result: *mut *mut dirent_t) -> c_int; result: *mut *mut dirent_t) -> c_int;
} }
extern { extern {
pub fn closedir(dirp: *DIR) -> c_int; pub fn closedir(dirp: *mut DIR) -> c_int;
pub fn rewinddir(dirp: *DIR); pub fn rewinddir(dirp: *mut DIR);
pub fn seekdir(dirp: *DIR, loc: c_long); pub fn seekdir(dirp: *mut DIR, loc: c_long);
pub fn telldir(dirp: *DIR) -> c_long; pub fn telldir(dirp: *mut DIR) -> c_long;
} }
} }
@ -3882,60 +3900,65 @@ pub mod funcs {
pub static _PC_NAME_MAX: c_int = 4; pub static _PC_NAME_MAX: c_int = 4;
extern { extern {
pub fn access(path: *c_char, amode: c_int) -> c_int; pub fn access(path: *const c_char, amode: c_int) -> c_int;
pub fn alarm(seconds: c_uint) -> c_uint; pub fn alarm(seconds: c_uint) -> c_uint;
pub fn chdir(dir: *c_char) -> c_int; pub fn chdir(dir: *const c_char) -> c_int;
pub fn chown(path: *c_char, uid: uid_t, gid: gid_t) -> c_int; pub fn chown(path: *const c_char, uid: uid_t,
gid: gid_t) -> c_int;
pub fn close(fd: c_int) -> c_int; pub fn close(fd: c_int) -> c_int;
pub fn dup(fd: c_int) -> c_int; pub fn dup(fd: c_int) -> c_int;
pub fn dup2(src: c_int, dst: c_int) -> c_int; pub fn dup2(src: c_int, dst: c_int) -> c_int;
pub fn execv(prog: *c_char, argv: **c_char) -> c_int; pub fn execv(prog: *const c_char,
pub fn execve(prog: *c_char, argv: **c_char, envp: **c_char) argv: *mut *const c_char) -> c_int;
pub fn execve(prog: *const c_char, argv: *mut *const c_char,
envp: *mut *const c_char)
-> c_int; -> c_int;
pub fn execvp(c: *c_char, argv: **c_char) -> c_int; pub fn execvp(c: *const c_char,
argv: *mut *const c_char) -> c_int;
pub fn fork() -> pid_t; pub fn fork() -> pid_t;
pub fn fpathconf(filedes: c_int, name: c_int) -> c_long; pub fn fpathconf(filedes: c_int, name: c_int) -> c_long;
pub fn getcwd(buf: *mut c_char, size: size_t) -> *c_char; pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char;
pub fn getegid() -> gid_t; pub fn getegid() -> gid_t;
pub fn geteuid() -> uid_t; pub fn geteuid() -> uid_t;
pub fn getgid() -> gid_t ; pub fn getgid() -> gid_t ;
pub fn getgroups(ngroups_max: c_int, groups: *mut gid_t) pub fn getgroups(ngroups_max: c_int, groups: *mut gid_t)
-> c_int; -> c_int;
pub fn getlogin() -> *c_char; pub fn getlogin() -> *mut c_char;
pub fn getopt(argc: c_int, argv: **c_char, optstr: *c_char) pub fn getopt(argc: c_int, argv: *mut *const c_char,
-> c_int; optstr: *const c_char) -> c_int;
pub fn getpgrp() -> pid_t; pub fn getpgrp() -> pid_t;
pub fn getpid() -> pid_t; pub fn getpid() -> pid_t;
pub fn getppid() -> pid_t; pub fn getppid() -> pid_t;
pub fn getuid() -> uid_t; pub fn getuid() -> uid_t;
pub fn isatty(fd: c_int) -> c_int; pub fn isatty(fd: c_int) -> c_int;
pub fn link(src: *c_char, dst: *c_char) -> c_int; pub fn link(src: *const c_char, dst: *const c_char) -> c_int;
pub fn lseek(fd: c_int, offset: off_t, whence: c_int) pub fn lseek(fd: c_int, offset: off_t, whence: c_int)
-> off_t; -> off_t;
pub fn pathconf(path: *c_char, name: c_int) -> c_long; pub fn pathconf(path: *mut c_char, name: c_int) -> c_long;
pub fn pause() -> c_int; pub fn pause() -> c_int;
pub fn pipe(fds: *mut c_int) -> c_int; pub fn pipe(fds: *mut c_int) -> c_int;
pub fn read(fd: c_int, buf: *mut c_void, count: size_t) pub fn read(fd: c_int, buf: *mut c_void, count: size_t)
-> ssize_t; -> ssize_t;
pub fn rmdir(path: *c_char) -> c_int; pub fn rmdir(path: *const c_char) -> c_int;
pub fn setgid(gid: gid_t) -> c_int; pub fn setgid(gid: gid_t) -> c_int;
pub fn setpgid(pid: pid_t, pgid: pid_t) -> c_int; pub fn setpgid(pid: pid_t, pgid: pid_t) -> c_int;
pub fn setsid() -> pid_t; pub fn setsid() -> pid_t;
pub fn setuid(uid: uid_t) -> c_int; pub fn setuid(uid: uid_t) -> c_int;
pub fn sleep(secs: c_uint) -> c_uint; pub fn sleep(secs: c_uint) -> c_uint;
pub fn usleep(secs: c_uint) -> c_int; pub fn usleep(secs: c_uint) -> c_int;
pub fn nanosleep(rqtp: *timespec, rmtp: *mut timespec) -> c_int; pub fn nanosleep(rqtp: *const timespec,
rmtp: *mut timespec) -> c_int;
pub fn sysconf(name: c_int) -> c_long; pub fn sysconf(name: c_int) -> c_long;
pub fn tcgetpgrp(fd: c_int) -> pid_t; pub fn tcgetpgrp(fd: c_int) -> pid_t;
pub fn ttyname(fd: c_int) -> *c_char; pub fn ttyname(fd: c_int) -> *mut c_char;
pub fn unlink(c: *c_char) -> c_int; pub fn unlink(c: *const c_char) -> c_int;
pub fn write(fd: c_int, buf: *c_void, count: size_t) pub fn write(fd: c_int, buf: *const c_void, count: size_t)
-> ssize_t; -> ssize_t;
pub fn pread(fd: c_int, buf: *c_void, count: size_t, pub fn pread(fd: c_int, buf: *mut c_void, count: size_t,
offset: off_t) -> ssize_t; offset: off_t) -> ssize_t;
pub fn pwrite(fd: c_int, buf: *c_void, count: size_t, pub fn pwrite(fd: c_int, buf: *const c_void, count: size_t,
offset: off_t) -> ssize_t; offset: off_t) -> ssize_t;
pub fn utime(file: *c_char, buf: *utimbuf) -> c_int; pub fn utime(file: *const c_char, buf: *const utimbuf) -> c_int;
} }
} }
@ -3954,8 +3977,8 @@ pub mod funcs {
use types::os::arch::posix88::{mode_t, off_t}; use types::os::arch::posix88::{mode_t, off_t};
extern { extern {
pub fn mlock(addr: *c_void, len: size_t) -> c_int; pub fn mlock(addr: *const c_void, len: size_t) -> c_int;
pub fn munlock(addr: *c_void, len: size_t) -> c_int; pub fn munlock(addr: *const c_void, len: size_t) -> c_int;
pub fn mlockall(flags: c_int) -> c_int; pub fn mlockall(flags: c_int) -> c_int;
pub fn munlockall() -> c_int; pub fn munlockall() -> c_int;
@ -3973,9 +3996,9 @@ pub mod funcs {
pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) pub fn msync(addr: *mut c_void, len: size_t, flags: c_int)
-> c_int; -> c_int;
pub fn shm_open(name: *c_char, oflag: c_int, mode: mode_t) pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t)
-> c_int; -> c_int;
pub fn shm_unlink(name: *c_char) -> c_int; pub fn shm_unlink(name: *const c_char) -> c_int;
} }
} }
} }
@ -3995,11 +4018,11 @@ pub mod funcs {
#[cfg(target_os = "freebsd")] #[cfg(target_os = "freebsd")]
#[cfg(target_os = "android")] #[cfg(target_os = "android")]
#[cfg(target_os = "ios")] #[cfg(target_os = "ios")]
pub fn lstat(path: *c_char, buf: *mut stat) -> c_int; pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int;
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
#[link_name = "lstat64"] #[link_name = "lstat64"]
pub fn lstat(path: *c_char, buf: *mut stat) -> c_int; pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int;
} }
} }
@ -4008,7 +4031,7 @@ pub mod funcs {
use types::os::arch::posix88::{ssize_t, off_t}; use types::os::arch::posix88::{ssize_t, off_t};
extern { extern {
pub fn readlink(path: *c_char, pub fn readlink(path: *const c_char,
buf: *mut c_char, buf: *mut c_char,
bufsz: size_t) bufsz: size_t)
-> ssize_t; -> ssize_t;
@ -4019,12 +4042,13 @@ pub mod funcs {
#[cfg(target_os = "android")] #[cfg(target_os = "android")]
pub fn fdatasync(fd: c_int) -> c_int; pub fn fdatasync(fd: c_int) -> c_int;
pub fn setenv(name: *c_char, val: *c_char, overwrite: c_int) pub fn setenv(name: *const c_char, val: *const c_char,
-> c_int; overwrite: c_int) -> c_int;
pub fn unsetenv(name: *c_char) -> c_int; pub fn unsetenv(name: *const c_char) -> c_int;
pub fn putenv(string: *c_char) -> c_int; pub fn putenv(string: *mut c_char) -> c_int;
pub fn symlink(path1: *c_char, path2: *c_char) -> c_int; pub fn symlink(path1: *const c_char,
path2: *const c_char) -> c_int;
pub fn ftruncate(fd: c_int, length: off_t) -> c_int; pub fn ftruncate(fd: c_int, length: off_t) -> c_int;
} }
@ -4053,9 +4077,10 @@ pub mod funcs {
use types::os::common::posix01::{glob_t}; use types::os::common::posix01::{glob_t};
extern { extern {
pub fn glob(pattern: *c_char, pub fn glob(pattern: *const c_char,
flags: c_int, flags: c_int,
errfunc: ::Nullable<extern "C" fn(epath: *c_char, errno: int) -> int>, errfunc: ::Nullable<extern "C" fn(epath: *const c_char,
errno: int) -> int>,
pglob: *mut glob_t); pglob: *mut glob_t);
pub fn globfree(pglob: *mut glob_t); pub fn globfree(pglob: *mut glob_t);
} }
@ -4066,7 +4091,7 @@ pub mod funcs {
use types::os::arch::c95::{c_int, size_t}; use types::os::arch::c95::{c_int, size_t};
extern { extern {
pub fn posix_madvise(addr: *c_void, pub fn posix_madvise(addr: *mut c_void,
len: size_t, len: size_t,
advice: c_int) advice: c_int)
-> c_int; -> c_int;
@ -4110,9 +4135,9 @@ pub mod funcs {
extern "system" { extern "system" {
pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> c_int; pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> c_int;
pub fn connect(socket: c_int, address: *sockaddr, pub fn connect(socket: c_int, address: *const sockaddr,
len: socklen_t) -> c_int; len: socklen_t) -> c_int;
pub fn bind(socket: c_int, address: *sockaddr, pub fn bind(socket: c_int, address: *const sockaddr,
address_len: socklen_t) -> c_int; address_len: socklen_t) -> c_int;
pub fn listen(socket: c_int, backlog: c_int) -> c_int; pub fn listen(socket: c_int, backlog: c_int) -> c_int;
pub fn accept(socket: c_int, address: *mut sockaddr, pub fn accept(socket: c_int, address: *mut sockaddr,
@ -4122,7 +4147,8 @@ pub mod funcs {
pub fn getsockname(socket: c_int, address: *mut sockaddr, pub fn getsockname(socket: c_int, address: *mut sockaddr,
address_len: *mut socklen_t) -> c_int; address_len: *mut socklen_t) -> c_int;
pub fn setsockopt(socket: c_int, level: c_int, name: c_int, pub fn setsockopt(socket: c_int, level: c_int, name: c_int,
value: *c_void, option_len: socklen_t) -> c_int; value: *const c_void,
option_len: socklen_t) -> c_int;
pub fn recv(socket: c_int, buf: *mut c_void, len: size_t, pub fn recv(socket: c_int, buf: *mut c_void, len: size_t,
flags: c_int) -> ssize_t; flags: c_int) -> ssize_t;
pub fn send(socket: c_int, buf: *mut c_void, len: size_t, pub fn send(socket: c_int, buf: *mut c_void, len: size_t,
@ -4130,8 +4156,8 @@ pub mod funcs {
pub fn recvfrom(socket: c_int, buf: *mut c_void, len: size_t, pub fn recvfrom(socket: c_int, buf: *mut c_void, len: size_t,
flags: c_int, addr: *mut sockaddr, flags: c_int, addr: *mut sockaddr,
addrlen: *mut socklen_t) -> ssize_t; addrlen: *mut socklen_t) -> ssize_t;
pub fn sendto(socket: c_int, buf: *c_void, len: size_t, pub fn sendto(socket: c_int, buf: *const c_void, len: size_t,
flags: c_int, addr: *sockaddr, flags: c_int, addr: *const sockaddr,
addrlen: socklen_t) -> ssize_t; addrlen: socklen_t) -> ssize_t;
pub fn shutdown(socket: c_int, how: c_int) -> c_int; pub fn shutdown(socket: c_int, how: c_int) -> c_int;
} }
@ -4146,9 +4172,9 @@ pub mod funcs {
extern "system" { extern "system" {
pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> SOCKET; pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> SOCKET;
pub fn connect(socket: SOCKET, address: *sockaddr, pub fn connect(socket: SOCKET, address: *const sockaddr,
len: socklen_t) -> c_int; len: socklen_t) -> c_int;
pub fn bind(socket: SOCKET, address: *sockaddr, pub fn bind(socket: SOCKET, address: *const sockaddr,
address_len: socklen_t) -> c_int; address_len: socklen_t) -> c_int;
pub fn listen(socket: SOCKET, backlog: c_int) -> c_int; pub fn listen(socket: SOCKET, backlog: c_int) -> c_int;
pub fn accept(socket: SOCKET, address: *mut sockaddr, pub fn accept(socket: SOCKET, address: *mut sockaddr,
@ -4158,7 +4184,8 @@ pub mod funcs {
pub fn getsockname(socket: SOCKET, address: *mut sockaddr, pub fn getsockname(socket: SOCKET, address: *mut sockaddr,
address_len: *mut socklen_t) -> c_int; address_len: *mut socklen_t) -> c_int;
pub fn setsockopt(socket: SOCKET, level: c_int, name: c_int, pub fn setsockopt(socket: SOCKET, level: c_int, name: c_int,
value: *c_void, option_len: socklen_t) -> c_int; value: *const c_void,
option_len: socklen_t) -> c_int;
pub fn closesocket(socket: SOCKET) -> c_int; pub fn closesocket(socket: SOCKET) -> c_int;
pub fn recv(socket: SOCKET, buf: *mut c_void, len: c_int, pub fn recv(socket: SOCKET, buf: *mut c_void, len: c_int,
flags: c_int) -> c_int; flags: c_int) -> c_int;
@ -4167,8 +4194,8 @@ pub mod funcs {
pub fn recvfrom(socket: SOCKET, buf: *mut c_void, len: c_int, pub fn recvfrom(socket: SOCKET, buf: *mut c_void, len: c_int,
flags: c_int, addr: *mut sockaddr, flags: c_int, addr: *mut sockaddr,
addrlen: *mut c_int) -> ssize_t; addrlen: *mut c_int) -> ssize_t;
pub fn sendto(socket: SOCKET, buf: *c_void, len: c_int, pub fn sendto(socket: SOCKET, buf: *const c_void, len: c_int,
flags: c_int, addr: *sockaddr, flags: c_int, addr: *const sockaddr,
addrlen: c_int) -> c_int; addrlen: c_int) -> c_int;
pub fn shutdown(socket: SOCKET, how: c_int) -> c_int; pub fn shutdown(socket: SOCKET, how: c_int) -> c_int;
} }
@ -4182,27 +4209,27 @@ pub mod funcs {
use types::os::arch::c95::{c_char, c_uchar, c_int, c_uint, size_t}; use types::os::arch::c95::{c_char, c_uchar, c_int, c_uint, size_t};
extern { extern {
pub fn sysctl(name: *c_int, pub fn sysctl(name: *mut c_int,
namelen: c_uint, namelen: c_uint,
oldp: *mut c_void, oldp: *mut c_void,
oldlenp: *mut size_t, oldlenp: *mut size_t,
newp: *c_void, newp: *mut c_void,
newlen: size_t) newlen: size_t)
-> c_int; -> c_int;
pub fn sysctlbyname(name: *c_char, pub fn sysctlbyname(name: *const c_char,
oldp: *mut c_void, oldp: *mut c_void,
oldlenp: *mut size_t, oldlenp: *mut size_t,
newp: *c_void, newp: *mut c_void,
newlen: size_t) newlen: size_t)
-> c_int; -> c_int;
pub fn sysctlnametomib(name: *c_char, pub fn sysctlnametomib(name: *const c_char,
mibp: *mut c_int, mibp: *mut c_int,
sizep: *mut size_t) sizep: *mut size_t)
-> c_int; -> c_int;
pub fn getdtablesize() -> c_int; pub fn getdtablesize() -> c_int;
pub fn madvise(addr: *c_void, len: size_t, advice: c_int) pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int)
-> c_int; -> c_int;
pub fn mincore(addr: *c_void, len: size_t, vec: *c_uchar) pub fn mincore(addr: *mut c_void, len: size_t, vec: *mut c_uchar)
-> c_int; -> c_int;
} }
} }
@ -4294,7 +4321,7 @@ pub mod funcs {
-> DWORD; -> DWORD;
pub fn SetCurrentDirectoryW(lpPathName: LPCWSTR) -> BOOL; pub fn SetCurrentDirectoryW(lpPathName: LPCWSTR) -> BOOL;
pub fn GetLastError() -> DWORD; pub fn GetLastError() -> DWORD;
pub fn FindFirstFileW(fileName: *u16, findFileData: HANDLE) pub fn FindFirstFileW(fileName: LPCWSTR, findFileData: HANDLE)
-> HANDLE; -> HANDLE;
pub fn FindNextFileW(findFile: HANDLE, findFileData: HANDLE) pub fn FindNextFileW(findFile: HANDLE, findFileData: HANDLE)
-> BOOL; -> BOOL;

View file

@ -144,8 +144,8 @@ static DEFAULT_LOG_LEVEL: u32 = 1;
/// logging statement should be run. /// logging statement should be run.
static mut LOG_LEVEL: u32 = MAX_LOG_LEVEL; static mut LOG_LEVEL: u32 = MAX_LOG_LEVEL;
static mut DIRECTIVES: *Vec<directive::LogDirective> = static mut DIRECTIVES: *const Vec<directive::LogDirective> =
0 as *Vec<directive::LogDirective>; 0 as *const Vec<directive::LogDirective>;
/// Debug log level /// Debug log level
pub static DEBUG: u32 = 4; pub static DEBUG: u32 = 4;
@ -351,7 +351,7 @@ fn init() {
assert!(!DIRECTIVES.is_null()); assert!(!DIRECTIVES.is_null());
let _directives: Box<Vec<directive::LogDirective>> = let _directives: Box<Vec<directive::LogDirective>> =
mem::transmute(DIRECTIVES); mem::transmute(DIRECTIVES);
DIRECTIVES = 0 as *Vec<directive::LogDirective>; DIRECTIVES = 0 as *const Vec<directive::LogDirective>;
}); });
} }
} }

View file

@ -37,13 +37,15 @@ impl GetAddrInfoRequest {
ai_socktype: 0, ai_socktype: 0,
ai_protocol: 0, ai_protocol: 0,
ai_addrlen: 0, ai_addrlen: 0,
ai_canonname: null(), ai_canonname: mut_null(),
ai_addr: null(), ai_addr: mut_null(),
ai_next: null() ai_next: mut_null()
} }
}); });
let hint_ptr = hint.as_ref().map_or(null(), |x| x as *libc::addrinfo); let hint_ptr = hint.as_ref().map_or(null(), |x| {
x as *const libc::addrinfo
});
let mut res = mut_null(); let mut res = mut_null();
// Make the call // Make the call
@ -87,11 +89,12 @@ impl GetAddrInfoRequest {
} }
extern "system" { extern "system" {
fn getaddrinfo(node: *c_char, service: *c_char, fn getaddrinfo(node: *const c_char, service: *const c_char,
hints: *libc::addrinfo, res: *mut *mut libc::addrinfo) -> c_int; hints: *const libc::addrinfo,
res: *mut *mut libc::addrinfo) -> c_int;
fn freeaddrinfo(res: *mut libc::addrinfo); fn freeaddrinfo(res: *mut libc::addrinfo);
#[cfg(not(windows))] #[cfg(not(windows))]
fn gai_strerror(errcode: c_int) -> *c_char; fn gai_strerror(errcode: c_int) -> *const c_char;
} }
#[cfg(windows)] #[cfg(windows)]

View file

@ -57,12 +57,12 @@ pub static WNOHANG: libc::c_int = 1;
extern { extern {
pub fn gettimeofday(timeval: *mut libc::timeval, pub fn gettimeofday(timeval: *mut libc::timeval,
tzp: *libc::c_void) -> libc::c_int; tzp: *mut libc::c_void) -> libc::c_int;
pub fn select(nfds: libc::c_int, pub fn select(nfds: libc::c_int,
readfds: *fd_set, readfds: *mut fd_set,
writefds: *fd_set, writefds: *mut fd_set,
errorfds: *fd_set, errorfds: *mut fd_set,
timeout: *libc::timeval) -> libc::c_int; timeout: *mut libc::timeval) -> libc::c_int;
pub fn getsockopt(sockfd: libc::c_int, pub fn getsockopt(sockfd: libc::c_int,
level: libc::c_int, level: libc::c_int,
optname: libc::c_int, optname: libc::c_int,
@ -75,7 +75,7 @@ extern {
options: libc::c_int) -> libc::pid_t; options: libc::c_int) -> libc::pid_t;
pub fn sigaction(signum: libc::c_int, pub fn sigaction(signum: libc::c_int,
act: *sigaction, act: *const sigaction,
oldact: *mut sigaction) -> libc::c_int; oldact: *mut sigaction) -> libc::c_int;
pub fn sigaddset(set: *mut sigset_t, signum: libc::c_int) -> libc::c_int; pub fn sigaddset(set: *mut sigset_t, signum: libc::c_int) -> libc::c_int;

View file

@ -28,7 +28,7 @@ pub struct WSADATA {
pub szSystemStatus: [u8, ..WSASYS_STATUS_LEN + 1], pub szSystemStatus: [u8, ..WSASYS_STATUS_LEN + 1],
pub iMaxSockets: u16, pub iMaxSockets: u16,
pub iMaxUdpDg: u16, pub iMaxUdpDg: u16,
pub lpVendorInfo: *u8, pub lpVendorInfo: *mut u8,
} }
pub type LPWSADATA = *mut WSADATA; pub type LPWSADATA = *mut WSADATA;
@ -53,10 +53,10 @@ extern "system" {
pub fn ioctlsocket(s: libc::SOCKET, cmd: libc::c_long, pub fn ioctlsocket(s: libc::SOCKET, cmd: libc::c_long,
argp: *mut libc::c_ulong) -> libc::c_int; argp: *mut libc::c_ulong) -> libc::c_int;
pub fn select(nfds: libc::c_int, pub fn select(nfds: libc::c_int,
readfds: *fd_set, readfds: *mut fd_set,
writefds: *fd_set, writefds: *mut fd_set,
exceptfds: *fd_set, exceptfds: *mut fd_set,
timeout: *libc::timeval) -> libc::c_int; timeout: *mut libc::timeval) -> libc::c_int;
pub fn getsockopt(sockfd: libc::SOCKET, pub fn getsockopt(sockfd: libc::SOCKET,
level: libc::c_int, level: libc::c_int,
optname: libc::c_int, optname: libc::c_int,

View file

@ -68,7 +68,7 @@ impl FileDesc {
pub fn inner_write(&mut self, buf: &[u8]) -> IoResult<()> { pub fn inner_write(&mut self, buf: &[u8]) -> IoResult<()> {
let ret = keep_going(buf, |buf, len| { let ret = keep_going(buf, |buf, len| {
unsafe { unsafe {
libc::write(self.fd(), buf as *libc::c_void, libc::write(self.fd(), buf as *const libc::c_void,
len as libc::size_t) as i64 len as libc::size_t) as i64
} }
}); });
@ -91,7 +91,7 @@ impl rtio::RtioFileStream for FileDesc {
} }
fn pread(&mut self, buf: &mut [u8], offset: u64) -> IoResult<int> { fn pread(&mut self, buf: &mut [u8], offset: u64) -> IoResult<int> {
match retry(|| unsafe { match retry(|| unsafe {
libc::pread(self.fd(), buf.as_ptr() as *libc::c_void, libc::pread(self.fd(), buf.as_ptr() as *mut _,
buf.len() as libc::size_t, buf.len() as libc::size_t,
offset as libc::off_t) as libc::c_int offset as libc::off_t) as libc::c_int
}) { }) {
@ -101,7 +101,7 @@ impl rtio::RtioFileStream for FileDesc {
} }
fn pwrite(&mut self, buf: &[u8], offset: u64) -> IoResult<()> { fn pwrite(&mut self, buf: &[u8], offset: u64) -> IoResult<()> {
super::mkerr_libc(retry(|| unsafe { super::mkerr_libc(retry(|| unsafe {
libc::pwrite(self.fd(), buf.as_ptr() as *libc::c_void, libc::pwrite(self.fd(), buf.as_ptr() as *const _,
buf.len() as libc::size_t, offset as libc::off_t) buf.len() as libc::size_t, offset as libc::off_t)
} as c_int)) } as c_int))
} }
@ -222,7 +222,7 @@ impl Drop for Inner {
} }
pub struct CFile { pub struct CFile {
file: *libc::FILE, file: *mut libc::FILE,
fd: FileDesc, fd: FileDesc,
} }
@ -231,7 +231,7 @@ impl CFile {
/// ///
/// The `CFile` takes ownership of the `FILE` pointer and will close it upon /// The `CFile` takes ownership of the `FILE` pointer and will close it upon
/// destruction. /// destruction.
pub fn new(file: *libc::FILE) -> CFile { pub fn new(file: *mut libc::FILE) -> CFile {
CFile { CFile {
file: file, file: file,
fd: FileDesc::new(unsafe { libc::fileno(file) }, false) fd: FileDesc::new(unsafe { libc::fileno(file) }, false)
@ -263,7 +263,7 @@ impl rtio::RtioFileStream for CFile {
fn write(&mut self, buf: &[u8]) -> IoResult<()> { fn write(&mut self, buf: &[u8]) -> IoResult<()> {
let ret = keep_going(buf, |buf, len| { let ret = keep_going(buf, |buf, len| {
unsafe { unsafe {
libc::fwrite(buf as *libc::c_void, 1, len as libc::size_t, libc::fwrite(buf as *const libc::c_void, 1, len as libc::size_t,
self.file) as i64 self.file) as i64
} }
}); });
@ -366,7 +366,7 @@ pub fn readdir(p: &CString) -> IoResult<Vec<CString>> {
extern { extern {
fn rust_dirent_t_size() -> libc::c_int; fn rust_dirent_t_size() -> libc::c_int;
fn rust_list_dir_val(ptr: *mut dirent_t) -> *libc::c_char; fn rust_list_dir_val(ptr: *mut dirent_t) -> *const libc::c_char;
} }
let size = unsafe { rust_dirent_t_size() }; let size = unsafe { rust_dirent_t_size() };
@ -423,7 +423,7 @@ pub fn chown(p: &CString, uid: int, gid: int) -> IoResult<()> {
pub fn readlink(p: &CString) -> IoResult<CString> { pub fn readlink(p: &CString) -> IoResult<CString> {
let p = p.with_ref(|p| p); let p = p.with_ref(|p| p);
let mut len = unsafe { libc::pathconf(p, libc::_PC_NAME_MAX) }; let mut len = unsafe { libc::pathconf(p as *mut _, libc::_PC_NAME_MAX) };
if len == -1 { if len == -1 {
len = 1024; // FIXME: read PATH_MAX from C ffi? len = 1024; // FIXME: read PATH_MAX from C ffi?
} }

View file

@ -357,7 +357,7 @@ pub fn readdir(p: &CString) -> IoResult<Vec<CString>> {
extern { extern {
fn rust_list_dir_wfd_size() -> libc::size_t; fn rust_list_dir_wfd_size() -> libc::size_t;
fn rust_list_dir_wfd_fp_buf(wfd: *libc::c_void) -> *u16; fn rust_list_dir_wfd_fp_buf(wfd: *mut libc::c_void) -> *const u16;
} }
let star = Path::new(unsafe { let star = Path::new(unsafe {
CString::new(p.with_ref(|p| p), false) CString::new(p.with_ref(|p| p), false)
@ -366,12 +366,13 @@ pub fn readdir(p: &CString) -> IoResult<Vec<CString>> {
unsafe { unsafe {
let wfd_ptr = malloc_raw(rust_list_dir_wfd_size() as uint); let wfd_ptr = malloc_raw(rust_list_dir_wfd_size() as uint);
let find_handle = libc::FindFirstFileW(path.as_ptr(), wfd_ptr as libc::HANDLE); let find_handle = libc::FindFirstFileW(path.as_ptr(),
wfd_ptr as libc::HANDLE);
if find_handle as libc::c_int != libc::INVALID_HANDLE_VALUE { if find_handle as libc::c_int != libc::INVALID_HANDLE_VALUE {
let mut paths = vec!(); let mut paths = vec!();
let mut more_files = 1 as libc::c_int; let mut more_files = 1 as libc::c_int;
while more_files != 0 { while more_files != 0 {
let fp_buf = rust_list_dir_wfd_fp_buf(wfd_ptr as *c_void); let fp_buf = rust_list_dir_wfd_fp_buf(wfd_ptr as *mut c_void);
if fp_buf as uint == 0 { if fp_buf as uint == 0 {
fail!("os::list_dir() failure: got null ptr from wfd"); fail!("os::list_dir() failure: got null ptr from wfd");
} else { } else {
@ -446,7 +447,7 @@ pub fn readlink(p: &CString) -> IoResult<CString> {
// without the null pointer // without the null pointer
let ret = fill_utf16_buf_and_decode(|buf, sz| unsafe { let ret = fill_utf16_buf_and_decode(|buf, sz| unsafe {
GetFinalPathNameByHandleW(handle, GetFinalPathNameByHandleW(handle,
buf as *u16, buf as *const u16,
sz - 1, sz - 1,
libc::VOLUME_NAME_DOS) libc::VOLUME_NAME_DOS)
}); });
@ -514,12 +515,12 @@ pub fn lstat(_p: &CString) -> IoResult<rtio::FileStat> {
} }
pub fn utime(p: &CString, atime: u64, mtime: u64) -> IoResult<()> { pub fn utime(p: &CString, atime: u64, mtime: u64) -> IoResult<()> {
let buf = libc::utimbuf { let mut buf = libc::utimbuf {
actime: (atime / 1000) as libc::time64_t, actime: (atime / 1000) as libc::time64_t,
modtime: (mtime / 1000) as libc::time64_t, modtime: (mtime / 1000) as libc::time64_t,
}; };
let p = try!(to_utf16(p)); let p = try!(to_utf16(p));
super::mkerr_libc(unsafe { super::mkerr_libc(unsafe {
libc::wutime(p.as_ptr(), &buf) libc::wutime(p.as_ptr(), &mut buf)
}) })
} }

View file

@ -132,7 +132,7 @@ fn retry(f: || -> libc::c_int) -> libc::c_int {
} }
} }
fn keep_going(data: &[u8], f: |*u8, uint| -> i64) -> i64 { fn keep_going(data: &[u8], f: |*const u8, uint| -> i64) -> i64 {
let origamt = data.len(); let origamt = data.len();
let mut data = data.as_ptr(); let mut data = data.as_ptr();
let mut amt = origamt; let mut amt = origamt;

View file

@ -105,7 +105,7 @@ fn socket(addr: rtio::SocketAddr, ty: libc::c_int) -> IoResult<sock_t> {
fn setsockopt<T>(fd: sock_t, opt: libc::c_int, val: libc::c_int, fn setsockopt<T>(fd: sock_t, opt: libc::c_int, val: libc::c_int,
payload: T) -> IoResult<()> { payload: T) -> IoResult<()> {
unsafe { unsafe {
let payload = &payload as *T as *libc::c_void; let payload = &payload as *const T as *const libc::c_void;
let ret = libc::setsockopt(fd, opt, val, let ret = libc::setsockopt(fd, opt, val,
payload, payload,
mem::size_of::<T>() as libc::socklen_t); mem::size_of::<T>() as libc::socklen_t);
@ -278,7 +278,7 @@ impl TcpStream {
let ret = TcpStream::new(Inner::new(fd)); let ret = TcpStream::new(Inner::new(fd));
let (addr, len) = addr_to_sockaddr(addr); let (addr, len) = addr_to_sockaddr(addr);
let addrp = &addr as *_ as *libc::sockaddr; let addrp = &addr as *const _ as *const libc::sockaddr;
let len = len as libc::socklen_t; let len = len as libc::socklen_t;
match timeout { match timeout {
@ -369,7 +369,7 @@ impl rtio::RtioTcpStream for TcpStream {
fn write(&mut self, buf: &[u8]) -> IoResult<()> { fn write(&mut self, buf: &[u8]) -> IoResult<()> {
let fd = self.fd(); let fd = self.fd();
let dolock = || self.lock_nonblocking(); let dolock = || self.lock_nonblocking();
let dowrite = |nb: bool, buf: *u8, len: uint| unsafe { let dowrite = |nb: bool, buf: *const u8, len: uint| unsafe {
let flags = if nb {c::MSG_DONTWAIT} else {0}; let flags = if nb {c::MSG_DONTWAIT} else {0};
libc::send(fd, libc::send(fd,
buf as *mut libc::c_void, buf as *mut libc::c_void,
@ -456,7 +456,7 @@ impl TcpListener {
let ret = TcpListener { inner: Inner::new(fd) }; let ret = TcpListener { inner: Inner::new(fd) };
let (addr, len) = addr_to_sockaddr(addr); let (addr, len) = addr_to_sockaddr(addr);
let addrp = &addr as *_ as *libc::sockaddr; let addrp = &addr as *const _ as *const libc::sockaddr;
let len = len as libc::socklen_t; let len = len as libc::socklen_t;
// On platforms with Berkeley-derived sockets, this allows // On platforms with Berkeley-derived sockets, this allows
@ -564,7 +564,7 @@ impl UdpSocket {
}; };
let (addr, len) = addr_to_sockaddr(addr); let (addr, len) = addr_to_sockaddr(addr);
let addrp = &addr as *_ as *libc::sockaddr; let addrp = &addr as *const _ as *const libc::sockaddr;
let len = len as libc::socklen_t; let len = len as libc::socklen_t;
match unsafe { libc::bind(fd, addrp, len) } { match unsafe { libc::bind(fd, addrp, len) } {
@ -654,15 +654,15 @@ impl rtio::RtioUdpSocket for UdpSocket {
fn sendto(&mut self, buf: &[u8], dst: rtio::SocketAddr) -> IoResult<()> { fn sendto(&mut self, buf: &[u8], dst: rtio::SocketAddr) -> IoResult<()> {
let (dst, dstlen) = addr_to_sockaddr(dst); let (dst, dstlen) = addr_to_sockaddr(dst);
let dstp = &dst as *_ as *libc::sockaddr; let dstp = &dst as *const _ as *const libc::sockaddr;
let dstlen = dstlen as libc::socklen_t; let dstlen = dstlen as libc::socklen_t;
let fd = self.fd(); let fd = self.fd();
let dolock = || self.lock_nonblocking(); let dolock = || self.lock_nonblocking();
let dowrite = |nb, buf: *u8, len: uint| unsafe { let dowrite = |nb, buf: *const u8, len: uint| unsafe {
let flags = if nb {c::MSG_DONTWAIT} else {0}; let flags = if nb {c::MSG_DONTWAIT} else {0};
libc::sendto(fd, libc::sendto(fd,
buf as *libc::c_void, buf as *const libc::c_void,
len as msglen_t, len as msglen_t,
flags, flags,
dstp, dstp,
@ -842,7 +842,7 @@ pub fn write<T>(fd: sock_t,
buf: &[u8], buf: &[u8],
write_everything: bool, write_everything: bool,
lock: || -> T, lock: || -> T,
write: |bool, *u8, uint| -> i64) -> IoResult<uint> { write: |bool, *const u8, uint| -> i64) -> IoResult<uint> {
let mut ret = -1; let mut ret = -1;
let mut written = 0; let mut written = 0;
if deadline == 0 { if deadline == 0 {

View file

@ -78,7 +78,7 @@ fn connect(addr: &CString, ty: libc::c_int,
timeout: Option<u64>) -> IoResult<Inner> { timeout: Option<u64>) -> IoResult<Inner> {
let (addr, len) = try!(addr_to_sockaddr_un(addr)); let (addr, len) = try!(addr_to_sockaddr_un(addr));
let inner = Inner::new(try!(unix_socket(ty))); let inner = Inner::new(try!(unix_socket(ty)));
let addrp = &addr as *_ as *libc::sockaddr; let addrp = &addr as *const _ as *const libc::sockaddr;
let len = len as libc::socklen_t; let len = len as libc::socklen_t;
match timeout { match timeout {
@ -98,9 +98,9 @@ fn connect(addr: &CString, ty: libc::c_int,
fn bind(addr: &CString, ty: libc::c_int) -> IoResult<Inner> { fn bind(addr: &CString, ty: libc::c_int) -> IoResult<Inner> {
let (addr, len) = try!(addr_to_sockaddr_un(addr)); let (addr, len) = try!(addr_to_sockaddr_un(addr));
let inner = Inner::new(try!(unix_socket(ty))); let inner = Inner::new(try!(unix_socket(ty)));
let addrp = &addr as *libc::sockaddr_storage; let addrp = &addr as *const _;
match unsafe { match unsafe {
libc::bind(inner.fd, addrp as *libc::sockaddr, len as libc::socklen_t) libc::bind(inner.fd, addrp as *const _, len as libc::socklen_t)
} { } {
-1 => Err(super::last_error()), -1 => Err(super::last_error()),
_ => Ok(inner) _ => Ok(inner)
@ -166,7 +166,7 @@ impl rtio::RtioPipe for UnixStream {
fn write(&mut self, buf: &[u8]) -> IoResult<()> { fn write(&mut self, buf: &[u8]) -> IoResult<()> {
let fd = self.fd(); let fd = self.fd();
let dolock = || self.lock_nonblocking(); let dolock = || self.lock_nonblocking();
let dowrite = |nb: bool, buf: *u8, len: uint| unsafe { let dowrite = |nb: bool, buf: *const u8, len: uint| unsafe {
let flags = if nb {c::MSG_DONTWAIT} else {0}; let flags = if nb {c::MSG_DONTWAIT} else {0};
libc::send(fd, libc::send(fd,
buf as *mut libc::c_void, buf as *mut libc::c_void,

View file

@ -152,7 +152,7 @@ impl Drop for Inner {
} }
} }
unsafe fn pipe(name: *u16, init: bool) -> libc::HANDLE { unsafe fn pipe(name: *const u16, init: bool) -> libc::HANDLE {
libc::CreateNamedPipeW( libc::CreateNamedPipeW(
name, name,
libc::PIPE_ACCESS_DUPLEX | libc::PIPE_ACCESS_DUPLEX |
@ -210,7 +210,7 @@ pub struct UnixStream {
} }
impl UnixStream { impl UnixStream {
fn try_connect(p: *u16) -> Option<libc::HANDLE> { fn try_connect(p: *const u16) -> Option<libc::HANDLE> {
// Note that most of this is lifted from the libuv implementation. // Note that most of this is lifted from the libuv implementation.
// The idea is that if we fail to open a pipe in read/write mode // The idea is that if we fail to open a pipe in read/write mode
// that we try afterwards in just read or just write // that we try afterwards in just read or just write

View file

@ -43,7 +43,7 @@ pub struct Process {
/// A handle to the process - on unix this will always be NULL, but on /// A handle to the process - on unix this will always be NULL, but on
/// windows it will be a HANDLE to the process, which will prevent the /// windows it will be a HANDLE to the process, which will prevent the
/// pid being re-used until the handle is closed. /// pid being re-used until the handle is closed.
handle: *(), handle: *mut (),
/// None until finish() is called. /// None until finish() is called.
exit_code: Option<rtio::ProcessExit>, exit_code: Option<rtio::ProcessExit>,
@ -269,7 +269,7 @@ unsafe fn killpid(pid: pid_t, signal: int) -> IoResult<()> {
struct SpawnProcessResult { struct SpawnProcessResult {
pid: pid_t, pid: pid_t,
handle: *(), handle: *mut (),
} }
#[cfg(windows)] #[cfg(windows)]
@ -403,7 +403,7 @@ fn spawn_process_os(cfg: ProcessConfig,
Ok(SpawnProcessResult { Ok(SpawnProcessResult {
pid: pi.dwProcessId as pid_t, pid: pi.dwProcessId as pid_t,
handle: pi.hProcess as *() handle: pi.hProcess as *mut ()
}) })
} }
} }
@ -515,14 +515,14 @@ fn spawn_process_os(cfg: ProcessConfig,
} }
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
unsafe fn set_environ(envp: *c_void) { unsafe fn set_environ(envp: *const c_void) {
extern { fn _NSGetEnviron() -> *mut *c_void; } extern { fn _NSGetEnviron() -> *mut *const c_void; }
*_NSGetEnviron() = envp; *_NSGetEnviron() = envp;
} }
#[cfg(not(target_os = "macos"))] #[cfg(not(target_os = "macos"))]
unsafe fn set_environ(envp: *c_void) { unsafe fn set_environ(envp: *const c_void) {
extern { static mut environ: *c_void; } extern { static mut environ: *const c_void; }
environ = envp; environ = envp;
} }
@ -564,7 +564,7 @@ fn spawn_process_os(cfg: ProcessConfig,
Err(..) => { Err(..) => {
Ok(SpawnProcessResult { Ok(SpawnProcessResult {
pid: pid, pid: pid,
handle: ptr::null() handle: ptr::mut_null()
}) })
} }
Ok(..) => fail!("short read on the cloexec pipe"), Ok(..) => fail!("short read on the cloexec pipe"),
@ -664,17 +664,18 @@ fn spawn_process_os(cfg: ProcessConfig,
} }
match cfg.uid { match cfg.uid {
Some(u) => { Some(u) => {
// When dropping privileges from root, the `setgroups` call will // When dropping privileges from root, the `setgroups` call
// remove any extraneous groups. If we don't call this, then // will remove any extraneous groups. If we don't call this,
// even though our uid has dropped, we may still have groups // then even though our uid has dropped, we may still have
// that enable us to do super-user things. This will fail if we // groups that enable us to do super-user things. This will
// aren't root, so don't bother checking the return value, this // fail if we aren't root, so don't bother checking the
// is just done as an optimistic privilege dropping function. // return value, this is just done as an optimistic
// privilege dropping function.
extern { extern {
fn setgroups(ngroups: libc::c_int, fn setgroups(ngroups: libc::c_int,
ptr: *libc::c_void) -> libc::c_int; ptr: *const libc::c_void) -> libc::c_int;
} }
let _ = setgroups(0, 0 as *libc::c_void); let _ = setgroups(0, 0 as *const libc::c_void);
if libc::setuid(u as libc::uid_t) != 0 { if libc::setuid(u as libc::uid_t) != 0 {
fail(&mut output); fail(&mut output);
@ -694,15 +695,16 @@ fn spawn_process_os(cfg: ProcessConfig,
if !envp.is_null() { if !envp.is_null() {
set_environ(envp); set_environ(envp);
} }
let _ = execvp(*argv, argv); let _ = execvp(*argv, argv as *mut _);
fail(&mut output); fail(&mut output);
}) })
}) })
} }
#[cfg(unix)] #[cfg(unix)]
fn with_argv<T>(prog: &CString, args: &[CString], cb: proc(**libc::c_char) -> T) -> T { fn with_argv<T>(prog: &CString, args: &[CString],
let mut ptrs: Vec<*libc::c_char> = Vec::with_capacity(args.len()+1); cb: proc(*const *const libc::c_char) -> T) -> T {
let mut ptrs: Vec<*const libc::c_char> = Vec::with_capacity(args.len()+1);
// Convert the CStrings into an array of pointers. Note: the // Convert the CStrings into an array of pointers. Note: the
// lifetime of the various CStrings involved is guaranteed to be // lifetime of the various CStrings involved is guaranteed to be
@ -719,7 +721,8 @@ fn with_argv<T>(prog: &CString, args: &[CString], cb: proc(**libc::c_char) -> T)
} }
#[cfg(unix)] #[cfg(unix)]
fn with_envp<T>(env: Option<&[(CString, CString)]>, cb: proc(*c_void) -> T) -> T { fn with_envp<T>(env: Option<&[(CString, CString)]>,
cb: proc(*const c_void) -> T) -> T {
// On posixy systems we can pass a char** for envp, which is a // On posixy systems we can pass a char** for envp, which is a
// null-terminated array of "k=v\0" strings. Since we must create // null-terminated array of "k=v\0" strings. Since we must create
// these strings locally, yet expose a raw pointer to them, we // these strings locally, yet expose a raw pointer to them, we
@ -738,13 +741,13 @@ fn with_envp<T>(env: Option<&[(CString, CString)]>, cb: proc(*c_void) -> T) -> T
} }
// As with `with_argv`, this is unsafe, since cb could leak the pointers. // As with `with_argv`, this is unsafe, since cb could leak the pointers.
let mut ptrs: Vec<*libc::c_char> = let mut ptrs: Vec<*const libc::c_char> =
tmps.iter() tmps.iter()
.map(|tmp| tmp.as_ptr() as *libc::c_char) .map(|tmp| tmp.as_ptr() as *const libc::c_char)
.collect(); .collect();
ptrs.push(ptr::null()); ptrs.push(ptr::null());
cb(ptrs.as_ptr() as *c_void) cb(ptrs.as_ptr() as *const c_void)
} }
_ => cb(ptr::null()) _ => cb(ptr::null())
} }
@ -776,7 +779,7 @@ fn with_envp<T>(env: Option<&[(CString, CString)]>, cb: |*mut c_void| -> T) -> T
} }
#[cfg(windows)] #[cfg(windows)]
fn with_dirp<T>(d: Option<&CString>, cb: |*u16| -> T) -> T { fn with_dirp<T>(d: Option<&CString>, cb: |*const u16| -> T) -> T {
match d { match d {
Some(dir) => { Some(dir) => {
let dir_str = dir.as_str() let dir_str = dir.as_str()
@ -789,14 +792,14 @@ fn with_dirp<T>(d: Option<&CString>, cb: |*u16| -> T) -> T {
} }
#[cfg(windows)] #[cfg(windows)]
fn free_handle(handle: *()) { fn free_handle(handle: *mut ()) {
assert!(unsafe { assert!(unsafe {
libc::CloseHandle(mem::transmute(handle)) != 0 libc::CloseHandle(mem::transmute(handle)) != 0
}) })
} }
#[cfg(unix)] #[cfg(unix)]
fn free_handle(_handle: *()) { fn free_handle(_handle: *mut ()) {
// unix has no process handle object, just a pid // unix has no process handle object, just a pid
} }
@ -1010,15 +1013,16 @@ fn waitpid(pid: pid_t, deadline: u64) -> IoResult<rtio::ProcessExit> {
let now = ::io::timer::now(); let now = ::io::timer::now();
let ms = if now < deadline {deadline - now} else {0}; let ms = if now < deadline {deadline - now} else {0};
tv = util::ms_to_timeval(ms); tv = util::ms_to_timeval(ms);
(&tv as *_, idx) (&mut tv as *mut _, idx)
} }
None => (ptr::null(), -1), None => (ptr::mut_null(), -1),
}; };
// Wait for something to happen // Wait for something to happen
c::fd_set(&mut set, input); c::fd_set(&mut set, input);
c::fd_set(&mut set, read_fd); c::fd_set(&mut set, read_fd);
match unsafe { c::select(max, &set, ptr::null(), ptr::null(), p) } { match unsafe { c::select(max, &mut set, ptr::mut_null(),
ptr::mut_null(), p) } {
// interrupted, retry // interrupted, retry
-1 if os::errno() == libc::EINTR as int => continue, -1 if os::errno() == libc::EINTR as int => continue,
@ -1128,9 +1132,9 @@ fn waitpid(pid: pid_t, deadline: u64) -> IoResult<rtio::ProcessExit> {
// which will wake up the other end at some point, so we just allow this // which will wake up the other end at some point, so we just allow this
// signal to be coalesced with the pending signals on the pipe. // signal to be coalesced with the pending signals on the pipe.
extern fn sigchld_handler(_signum: libc::c_int) { extern fn sigchld_handler(_signum: libc::c_int) {
let mut msg = 1; let msg = 1;
match unsafe { match unsafe {
libc::write(WRITE_FD, &mut msg as *mut _ as *libc::c_void, 1) libc::write(WRITE_FD, &msg as *const _ as *const libc::c_void, 1)
} { } {
1 => {} 1 => {}
-1 if util::wouldblock() => {} // see above comments -1 if util::wouldblock() => {} // see above comments

View file

@ -88,7 +88,7 @@ pub enum Req {
pub fn now() -> u64 { pub fn now() -> u64 {
unsafe { unsafe {
let mut now: libc::timeval = mem::zeroed(); let mut now: libc::timeval = mem::zeroed();
assert_eq!(c::gettimeofday(&mut now, ptr::null()), 0); assert_eq!(c::gettimeofday(&mut now, ptr::mut_null()), 0);
return (now.tv_sec as u64) * 1000 + (now.tv_usec as u64) / 1000; return (now.tv_sec as u64) * 1000 + (now.tv_usec as u64) / 1000;
} }
} }
@ -146,7 +146,7 @@ fn helper(input: libc::c_int, messages: Receiver<Req>, _: int) {
'outer: loop { 'outer: loop {
let timeout = if active.len() == 0 { let timeout = if active.len() == 0 {
// Empty array? no timeout (wait forever for the next request) // Empty array? no timeout (wait forever for the next request)
ptr::null() ptr::mut_null()
} else { } else {
let now = now(); let now = now();
// If this request has already expired, then signal it and go // If this request has already expired, then signal it and go
@ -162,12 +162,13 @@ fn helper(input: libc::c_int, messages: Receiver<Req>, _: int) {
let tm = active.get(0).target - now; let tm = active.get(0).target - now;
timeout.tv_sec = (tm / 1000) as libc::time_t; timeout.tv_sec = (tm / 1000) as libc::time_t;
timeout.tv_usec = ((tm % 1000) * 1000) as libc::suseconds_t; timeout.tv_usec = ((tm % 1000) * 1000) as libc::suseconds_t;
&timeout as *libc::timeval &mut timeout as *mut libc::timeval
}; };
c::fd_set(&mut set, input); c::fd_set(&mut set, input);
match unsafe { match unsafe {
c::select(input + 1, &set, ptr::null(), ptr::null(), timeout) c::select(input + 1, &mut set, ptr::mut_null(),
ptr::mut_null(), timeout)
} { } {
// timed out // timed out
0 => signal(&mut active, &mut dead), 0 => signal(&mut active, &mut dead),

View file

@ -141,7 +141,7 @@ impl rtio::RtioTimer for Timer {
// 100ns intervals, so we multiply by 10^4. // 100ns intervals, so we multiply by 10^4.
let due = -(msecs as i64 * 10000) as libc::LARGE_INTEGER; let due = -(msecs as i64 * 10000) as libc::LARGE_INTEGER;
assert_eq!(unsafe { assert_eq!(unsafe {
imp::SetWaitableTimer(self.obj, &due, 0, ptr::null(), imp::SetWaitableTimer(self.obj, &due, 0, ptr::mut_null(),
ptr::mut_null(), 0) ptr::mut_null(), 0)
}, 1); }, 1);
@ -154,7 +154,7 @@ impl rtio::RtioTimer for Timer {
// see above for the calculation // see above for the calculation
let due = -(msecs as i64 * 10000) as libc::LARGE_INTEGER; let due = -(msecs as i64 * 10000) as libc::LARGE_INTEGER;
assert_eq!(unsafe { assert_eq!(unsafe {
imp::SetWaitableTimer(self.obj, &due, 0, ptr::null(), imp::SetWaitableTimer(self.obj, &due, 0, ptr::mut_null(),
ptr::mut_null(), 0) ptr::mut_null(), 0)
}, 1); }, 1);
@ -169,7 +169,7 @@ impl rtio::RtioTimer for Timer {
let due = -(msecs as i64 * 10000) as libc::LARGE_INTEGER; let due = -(msecs as i64 * 10000) as libc::LARGE_INTEGER;
assert_eq!(unsafe { assert_eq!(unsafe {
imp::SetWaitableTimer(self.obj, &due, msecs as libc::LONG, imp::SetWaitableTimer(self.obj, &due, msecs as libc::LONG,
ptr::null(), ptr::mut_null(), 0) ptr::mut_null(), ptr::mut_null(), 0)
}, 1); }, 1);
unsafe { HELPER.send(NewTimer(self.obj, cb, false)) } unsafe { HELPER.send(NewTimer(self.obj, cb, false)) }
@ -188,20 +188,20 @@ mod imp {
use libc::{LPSECURITY_ATTRIBUTES, BOOL, LPCSTR, HANDLE, LARGE_INTEGER, use libc::{LPSECURITY_ATTRIBUTES, BOOL, LPCSTR, HANDLE, LARGE_INTEGER,
LONG, LPVOID, DWORD, c_void}; LONG, LPVOID, DWORD, c_void};
pub type PTIMERAPCROUTINE = *c_void; pub type PTIMERAPCROUTINE = *mut c_void;
extern "system" { extern "system" {
pub fn CreateWaitableTimerA(lpTimerAttributes: LPSECURITY_ATTRIBUTES, pub fn CreateWaitableTimerA(lpTimerAttributes: LPSECURITY_ATTRIBUTES,
bManualReset: BOOL, bManualReset: BOOL,
lpTimerName: LPCSTR) -> HANDLE; lpTimerName: LPCSTR) -> HANDLE;
pub fn SetWaitableTimer(hTimer: HANDLE, pub fn SetWaitableTimer(hTimer: HANDLE,
pDueTime: *LARGE_INTEGER, pDueTime: *const LARGE_INTEGER,
lPeriod: LONG, lPeriod: LONG,
pfnCompletionRoutine: PTIMERAPCROUTINE, pfnCompletionRoutine: PTIMERAPCROUTINE,
lpArgToCompletionRoutine: LPVOID, lpArgToCompletionRoutine: LPVOID,
fResume: BOOL) -> BOOL; fResume: BOOL) -> BOOL;
pub fn WaitForMultipleObjects(nCount: DWORD, pub fn WaitForMultipleObjects(nCount: DWORD,
lpHandles: *HANDLE, lpHandles: *const HANDLE,
bWaitAll: BOOL, bWaitAll: BOOL,
dwMilliseconds: DWORD) -> DWORD; dwMilliseconds: DWORD) -> DWORD;
pub fn WaitForSingleObject(hHandle: HANDLE, pub fn WaitForSingleObject(hHandle: HANDLE,

View file

@ -90,7 +90,7 @@ pub fn set_nonblocking(fd: net::sock_t, nb: bool) -> IoResult<()> {
// See http://developerweb.net/viewtopic.php?id=3196 for where this is // See http://developerweb.net/viewtopic.php?id=3196 for where this is
// derived from. // derived from.
pub fn connect_timeout(fd: net::sock_t, pub fn connect_timeout(fd: net::sock_t,
addrp: *libc::sockaddr, addrp: *const libc::sockaddr,
len: libc::socklen_t, len: libc::socklen_t,
timeout_ms: u64) -> IoResult<()> { timeout_ms: u64) -> IoResult<()> {
use std::os; use std::os;
@ -145,16 +145,16 @@ pub fn connect_timeout(fd: net::sock_t,
// Recalculate the timeout each iteration (it is generally // Recalculate the timeout each iteration (it is generally
// undefined what the value of the 'tv' is after select // undefined what the value of the 'tv' is after select
// returns EINTR). // returns EINTR).
let tv = ms_to_timeval(timeout - (::io::timer::now() - start)); let mut tv = ms_to_timeval(timeout - (::io::timer::now() - start));
c::select(fd + 1, ptr::null(), set as *mut _ as *_, c::select(fd + 1, ptr::mut_null(), set as *mut _,
ptr::null(), &tv) ptr::mut_null(), &mut tv)
}) })
} }
#[cfg(windows)] #[cfg(windows)]
fn await(_fd: net::sock_t, set: &mut c::fd_set, fn await(_fd: net::sock_t, set: &mut c::fd_set,
timeout: u64) -> libc::c_int { timeout: u64) -> libc::c_int {
let tv = ms_to_timeval(timeout); let mut tv = ms_to_timeval(timeout);
unsafe { c::select(1, ptr::null(), &*set, ptr::null(), &tv) } unsafe { c::select(1, ptr::mut_null(), set, ptr::mut_null(), &mut tv) }
} }
} }
@ -163,25 +163,25 @@ pub fn await(fd: net::sock_t, deadline: Option<u64>,
let mut set: c::fd_set = unsafe { mem::zeroed() }; let mut set: c::fd_set = unsafe { mem::zeroed() };
c::fd_set(&mut set, fd); c::fd_set(&mut set, fd);
let (read, write) = match status { let (read, write) = match status {
Readable => (&set as *_, ptr::null()), Readable => (&mut set as *mut _, ptr::mut_null()),
Writable => (ptr::null(), &set as *_), Writable => (ptr::mut_null(), &mut set as *mut _),
}; };
let mut tv: libc::timeval = unsafe { mem::zeroed() }; let mut tv: libc::timeval = unsafe { mem::zeroed() };
match retry(|| { match retry(|| {
let now = ::io::timer::now(); let now = ::io::timer::now();
let tvp = match deadline { let tvp = match deadline {
None => ptr::null(), None => ptr::mut_null(),
Some(deadline) => { Some(deadline) => {
// If we're past the deadline, then pass a 0 timeout to // If we're past the deadline, then pass a 0 timeout to
// select() so we can poll the status // select() so we can poll the status
let ms = if deadline < now {0} else {deadline - now}; let ms = if deadline < now {0} else {deadline - now};
tv = ms_to_timeval(ms); tv = ms_to_timeval(ms);
&tv as *_ &mut tv as *mut _
} }
}; };
let n = if cfg!(windows) {1} else {fd as libc::c_int + 1}; let n = if cfg!(windows) {1} else {fd as libc::c_int + 1};
let r = unsafe { c::select(n, read, write, ptr::null(), tvp) }; let r = unsafe { c::select(n, read, write, ptr::mut_null(), tvp) };
r r
}) { }) {
-1 => Err(last_error()), -1 => Err(last_error()),

View file

@ -20,7 +20,9 @@
//! extern crate native; //! extern crate native;
//! //!
//! #[start] //! #[start]
//! fn start(argc: int, argv: **u8) -> int { native::start(argc, argv, main) } //! fn start(argc: int, argv: *const *const u8) -> int {
//! native::start(argc, argv, main)
//! }
//! //!
//! fn main() { //! fn main() {
//! // this code is running on the main OS thread //! // this code is running on the main OS thread
@ -83,7 +85,7 @@ static OS_DEFAULT_STACK_ESTIMATE: uint = 2 * (1 << 20);
#[lang = "start"] #[lang = "start"]
#[cfg(not(test))] #[cfg(not(test))]
pub fn lang_start(main: *u8, argc: int, argv: **u8) -> int { pub fn lang_start(main: *const u8, argc: int, argv: *const *const u8) -> int {
use std::mem; use std::mem;
start(argc, argv, proc() { start(argc, argv, proc() {
let main: extern "Rust" fn() = unsafe { mem::transmute(main) }; let main: extern "Rust" fn() = unsafe { mem::transmute(main) };
@ -100,9 +102,9 @@ pub fn lang_start(main: *u8, argc: int, argv: **u8) -> int {
/// ///
/// This function will only return once *all* native threads in the system have /// This function will only return once *all* native threads in the system have
/// exited. /// exited.
pub fn start(argc: int, argv: **u8, main: proc()) -> int { pub fn start(argc: int, argv: *const *const u8, main: proc()) -> int {
let something_around_the_top_of_the_stack = 1; let something_around_the_top_of_the_stack = 1;
let addr = &something_around_the_top_of_the_stack as *int; let addr = &something_around_the_top_of_the_stack as *const int;
let my_stack_top = addr as uint; let my_stack_top = addr as uint;
// FIXME #11359 we just assume that this thread has a stack of a // FIXME #11359 we just assume that this thread has a stack of a

View file

@ -81,7 +81,7 @@ pub fn spawn_opts(opts: TaskOpts, f: proc():Send) {
// which our stack started). // which our stack started).
Thread::spawn_stack(stack, proc() { Thread::spawn_stack(stack, proc() {
let something_around_the_top_of_the_stack = 1; let something_around_the_top_of_the_stack = 1;
let addr = &something_around_the_top_of_the_stack as *int; let addr = &something_around_the_top_of_the_stack as *const int;
let my_stack = addr as uint; let my_stack = addr as uint;
unsafe { unsafe {
stack::record_stack_bounds(my_stack - stack + 1024, my_stack); stack::record_stack_bounds(my_stack - stack + 1024, my_stack);
@ -199,7 +199,7 @@ impl rt::Runtime for Ops {
cur_task.put_runtime(self); cur_task.put_runtime(self);
unsafe { unsafe {
let cur_task_dupe = &*cur_task as *Task; let cur_task_dupe = &mut *cur_task as *mut Task;
let task = BlockedTask::block(cur_task); let task = BlockedTask::block(cur_task);
if times == 1 { if times == 1 {

View file

@ -42,31 +42,36 @@
// implementations below. If pointer arithmetic is done through integers the // implementations below. If pointer arithmetic is done through integers the
// optimizations start to break down. // optimizations start to break down.
extern "rust-intrinsic" { extern "rust-intrinsic" {
fn offset<T>(dst: *T, offset: int) -> *T; fn offset<T>(dst: *const T, offset: int) -> *const T;
} }
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn memcpy(dest: *mut u8, src: *u8, n: uint) -> *mut u8 { pub unsafe extern "C" fn memcpy(dest: *mut u8, src: *const u8,
n: uint) -> *mut u8 {
let mut i = 0; let mut i = 0;
while i < n { while i < n {
*(offset(dest as *u8, i as int) as *mut u8) = *offset(src, i as int); *(offset(dest as *const u8, i as int) as *mut u8) =
*offset(src, i as int);
i += 1; i += 1;
} }
return dest; return dest;
} }
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn memmove(dest: *mut u8, src: *u8, n: uint) -> *mut u8 { pub unsafe extern "C" fn memmove(dest: *mut u8, src: *const u8,
if src < dest as *u8 { // copy from end n: uint) -> *mut u8 {
if src < dest as *const u8 { // copy from end
let mut i = n; let mut i = n;
while i != 0 { while i != 0 {
i -= 1; i -= 1;
*(offset(dest as *u8, i as int) as *mut u8) = *offset(src, i as int); *(offset(dest as *const u8, i as int) as *mut u8) =
*offset(src, i as int);
} }
} else { // copy from beginning } else { // copy from beginning
let mut i = 0; let mut i = 0;
while i < n { while i < n {
*(offset(dest as *u8, i as int) as *mut u8) = *offset(src, i as int); *(offset(dest as *const u8, i as int) as *mut u8) =
*offset(src, i as int);
i += 1; i += 1;
} }
} }
@ -77,14 +82,14 @@ pub unsafe extern "C" fn memmove(dest: *mut u8, src: *u8, n: uint) -> *mut u8 {
pub unsafe extern "C" fn memset(s: *mut u8, c: i32, n: uint) -> *mut u8 { pub unsafe extern "C" fn memset(s: *mut u8, c: i32, n: uint) -> *mut u8 {
let mut i = 0; let mut i = 0;
while i < n { while i < n {
*(offset(s as *u8, i as int) as *mut u8) = c as u8; *(offset(s as *const u8, i as int) as *mut u8) = c as u8;
i += 1; i += 1;
} }
return s; return s;
} }
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn memcmp(s1: *u8, s2: *u8, n: uint) -> i32 { pub unsafe extern "C" fn memcmp(s1: *const u8, s2: *const u8, n: uint) -> i32 {
let mut i = 0; let mut i = 0;
while i < n { while i < n {
let a = *offset(s1, i as int); let a = *offset(s1, i as int);

View file

@ -82,7 +82,7 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
(), (),
|()| unsafe { |()| unsafe {
if !llvm::LLVMRustLinkInExternalBitcode(llmod, if !llvm::LLVMRustLinkInExternalBitcode(llmod,
ptr as *libc::c_char, ptr as *const libc::c_char,
bc.len() as libc::size_t) { bc.len() as libc::size_t) {
link::llvm_err(sess, link::llvm_err(sess,
format!("failed to load bc of `{}`", format!("failed to load bc of `{}`",
@ -94,10 +94,11 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
// Internalize everything but the reachable symbols of the current module // Internalize everything but the reachable symbols of the current module
let cstrs: Vec<::std::c_str::CString> = let cstrs: Vec<::std::c_str::CString> =
reachable.iter().map(|s| s.as_slice().to_c_str()).collect(); reachable.iter().map(|s| s.as_slice().to_c_str()).collect();
let arr: Vec<*i8> = cstrs.iter().map(|c| c.with_ref(|p| p)).collect(); let arr: Vec<*const i8> = cstrs.iter().map(|c| c.with_ref(|p| p)).collect();
let ptr = arr.as_ptr(); let ptr = arr.as_ptr();
unsafe { unsafe {
llvm::LLVMRustRunRestrictionPass(llmod, ptr as **libc::c_char, llvm::LLVMRustRunRestrictionPass(llmod,
ptr as *const *const libc::c_char,
arr.len() as libc::size_t); arr.len() as libc::size_t);
} }

File diff suppressed because it is too large Load diff

View file

@ -176,7 +176,7 @@ pub struct LintId {
impl PartialEq for LintId { impl PartialEq for LintId {
fn eq(&self, other: &LintId) -> bool { fn eq(&self, other: &LintId) -> bool {
(self.lint as *Lint) == (other.lint as *Lint) (self.lint as *const Lint) == (other.lint as *const Lint)
} }
} }
@ -184,7 +184,7 @@ impl Eq for LintId { }
impl<S: hash::Writer> hash::Hash<S> for LintId { impl<S: hash::Writer> hash::Hash<S> for LintId {
fn hash(&self, state: &mut S) { fn hash(&self, state: &mut S) {
let ptr = self.lint as *Lint; let ptr = self.lint as *const Lint;
ptr.hash(state); ptr.hash(state);
} }
} }

View file

@ -1308,7 +1308,7 @@ fn my_visit_expr(_e: &Expr) { }
fn my_visit_item(i: &Item, fn my_visit_item(i: &Item,
ebml_w: &mut Encoder, ebml_w: &mut Encoder,
ecx_ptr: *int, ecx_ptr: *const int,
index: &mut Vec<entry<i64>>) { index: &mut Vec<entry<i64>>) {
let mut ebml_w = unsafe { ebml_w.unsafe_clone() }; let mut ebml_w = unsafe { ebml_w.unsafe_clone() };
// See above // See above
@ -1320,7 +1320,7 @@ fn my_visit_item(i: &Item,
fn my_visit_foreign_item(ni: &ForeignItem, fn my_visit_foreign_item(ni: &ForeignItem,
ebml_w: &mut Encoder, ebml_w: &mut Encoder,
ecx_ptr:*int, ecx_ptr:*const int,
index: &mut Vec<entry<i64>>) { index: &mut Vec<entry<i64>>) {
// See above // See above
let ecx: &EncodeContext = unsafe { mem::transmute(ecx_ptr) }; let ecx: &EncodeContext = unsafe { mem::transmute(ecx_ptr) };
@ -1341,7 +1341,7 @@ fn my_visit_foreign_item(ni: &ForeignItem,
struct EncodeVisitor<'a,'b> { struct EncodeVisitor<'a,'b> {
ebml_w_for_visit_item: &'a mut Encoder<'b>, ebml_w_for_visit_item: &'a mut Encoder<'b>,
ecx_ptr:*int, ecx_ptr:*const int,
index: &'a mut Vec<entry<i64>>, index: &'a mut Vec<entry<i64>>,
} }
@ -1386,7 +1386,7 @@ fn encode_info_for_items(ecx: &EncodeContext,
Public); Public);
// See comment in `encode_side_tables_for_ii` in astencode // See comment in `encode_side_tables_for_ii` in astencode
let ecx_ptr: *int = unsafe { mem::transmute(ecx) }; let ecx_ptr: *const int = unsafe { mem::transmute(ecx) };
visit::walk_crate(&mut EncodeVisitor { visit::walk_crate(&mut EncodeVisitor {
index: &mut index, index: &mut index,
ecx_ptr: ecx_ptr, ecx_ptr: ecx_ptr,

View file

@ -545,14 +545,15 @@ fn get_metadata_section_imp(os: abi::Os, filename: &Path) -> Result<MetadataBlob
while llvm::LLVMIsSectionIteratorAtEnd(of.llof, si.llsi) == False { while llvm::LLVMIsSectionIteratorAtEnd(of.llof, si.llsi) == False {
let mut name_buf = ptr::null(); let mut name_buf = ptr::null();
let name_len = llvm::LLVMRustGetSectionName(si.llsi, &mut name_buf); let name_len = llvm::LLVMRustGetSectionName(si.llsi, &mut name_buf);
let name = str::raw::from_buf_len(name_buf as *u8, name_len as uint); let name = str::raw::from_buf_len(name_buf as *const u8,
name_len as uint);
debug!("get_metadata_section: name {}", name); debug!("get_metadata_section: name {}", name);
if read_meta_section_name(os).as_slice() == name.as_slice() { if read_meta_section_name(os).as_slice() == name.as_slice() {
let cbuf = llvm::LLVMGetSectionContents(si.llsi); let cbuf = llvm::LLVMGetSectionContents(si.llsi);
let csz = llvm::LLVMGetSectionSize(si.llsi) as uint; let csz = llvm::LLVMGetSectionSize(si.llsi) as uint;
let mut found = let mut found =
Err(format!("metadata not found: '{}'", filename.display())); Err(format!("metadata not found: '{}'", filename.display()));
let cvbuf: *u8 = mem::transmute(cbuf); let cvbuf: *const u8 = mem::transmute(cbuf);
let vlen = encoder::metadata_encoding_version.len(); let vlen = encoder::metadata_encoding_version.len();
debug!("checking {} bytes of metadata-version stamp", debug!("checking {} bytes of metadata-version stamp",
vlen); vlen);

View file

@ -943,7 +943,7 @@ impl<'a> write_tag_and_id for Encoder<'a> {
} }
struct SideTableEncodingIdVisitor<'a,'b> { struct SideTableEncodingIdVisitor<'a,'b> {
ecx_ptr: *libc::c_void, ecx_ptr: *const libc::c_void,
new_ebml_w: &'a mut Encoder<'b>, new_ebml_w: &'a mut Encoder<'b>,
} }

View file

@ -360,7 +360,8 @@ fn visit_fn(ir: &mut IrMaps,
let mut fn_maps = IrMaps::new(ir.tcx); let mut fn_maps = IrMaps::new(ir.tcx);
unsafe { unsafe {
debug!("creating fn_maps: {}", transmute::<&IrMaps, *IrMaps>(&fn_maps)); debug!("creating fn_maps: {}",
transmute::<&IrMaps, *const IrMaps>(&fn_maps));
} }
for arg in decl.inputs.iter() { for arg in decl.inputs.iter() {

View file

@ -44,7 +44,7 @@ impl<T> HomogeneousTuple3<T> for (T, T, T) {
fn as_slice<'a>(&'a self) -> &'a [T] { fn as_slice<'a>(&'a self) -> &'a [T] {
unsafe { unsafe {
let ptr: *T = mem::transmute(self); let ptr: *const T = mem::transmute(self);
let slice = raw::Slice { data: ptr, len: 3 }; let slice = raw::Slice { data: ptr, len: 3 };
mem::transmute(slice) mem::transmute(slice)
} }
@ -52,7 +52,7 @@ impl<T> HomogeneousTuple3<T> for (T, T, T) {
fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T] { fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T] {
unsafe { unsafe {
let ptr: *T = mem::transmute(self); let ptr: *const T = mem::transmute(self);
let slice = raw::Slice { data: ptr, len: 3 }; let slice = raw::Slice { data: ptr, len: 3 };
mem::transmute(slice) mem::transmute(slice)
} }

View file

@ -453,7 +453,7 @@ pub fn StructGEP(cx: &Block, pointer: ValueRef, idx: uint) -> ValueRef {
} }
} }
pub fn GlobalString(cx: &Block, _str: *c_char) -> ValueRef { pub fn GlobalString(cx: &Block, _str: *const c_char) -> ValueRef {
unsafe { unsafe {
if cx.unreachable.get() { if cx.unreachable.get() {
return llvm::LLVMGetUndef(Type::i8p(cx.ccx()).to_ref()); return llvm::LLVMGetUndef(Type::i8p(cx.ccx()).to_ref());
@ -462,7 +462,7 @@ pub fn GlobalString(cx: &Block, _str: *c_char) -> ValueRef {
} }
} }
pub fn GlobalStringPtr(cx: &Block, _str: *c_char) -> ValueRef { pub fn GlobalStringPtr(cx: &Block, _str: *const c_char) -> ValueRef {
unsafe { unsafe {
if cx.unreachable.get() { if cx.unreachable.get() {
return llvm::LLVMGetUndef(Type::i8p(cx.ccx()).to_ref()); return llvm::LLVMGetUndef(Type::i8p(cx.ccx()).to_ref());
@ -577,7 +577,8 @@ pub fn TruncOrBitCast(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef {
} }
} }
pub fn Cast(cx: &Block, op: Opcode, val: ValueRef, dest_ty: Type, _: *u8) pub fn Cast(cx: &Block, op: Opcode, val: ValueRef, dest_ty: Type,
_: *const u8)
-> ValueRef { -> ValueRef {
unsafe { unsafe {
if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); } if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); }
@ -636,7 +637,8 @@ pub fn EmptyPhi(cx: &Block, ty: Type) -> ValueRef {
} }
} }
pub fn Phi(cx: &Block, ty: Type, vals: &[ValueRef], bbs: &[BasicBlockRef]) -> ValueRef { pub fn Phi(cx: &Block, ty: Type, vals: &[ValueRef],
bbs: &[BasicBlockRef]) -> ValueRef {
unsafe { unsafe {
if cx.unreachable.get() { return llvm::LLVMGetUndef(ty.to_ref()); } if cx.unreachable.get() { return llvm::LLVMGetUndef(ty.to_ref()); }
B(cx).phi(ty, vals, bbs) B(cx).phi(ty, vals, bbs)
@ -672,7 +674,7 @@ pub fn add_comment(cx: &Block, text: &str) {
B(cx).add_comment(text) B(cx).add_comment(text)
} }
pub fn InlineAsmCall(cx: &Block, asm: *c_char, cons: *c_char, pub fn InlineAsmCall(cx: &Block, asm: *const c_char, cons: *const c_char,
inputs: &[ValueRef], output: Type, inputs: &[ValueRef], output: Type,
volatile: bool, alignstack: bool, volatile: bool, alignstack: bool,
dia: AsmDialect) -> ValueRef { dia: AsmDialect) -> ValueRef {

View file

@ -31,9 +31,9 @@ pub struct Builder<'a> {
// This is a really awful way to get a zero-length c-string, but better (and a // This is a really awful way to get a zero-length c-string, but better (and a
// lot more efficient) than doing str::as_c_str("", ...) every time. // lot more efficient) than doing str::as_c_str("", ...) every time.
pub fn noname() -> *c_char { pub fn noname() -> *const c_char {
static cnull: c_char = 0; static cnull: c_char = 0;
&cnull as *c_char &cnull as *const c_char
} }
impl<'a> Builder<'a> { impl<'a> Builder<'a> {
@ -564,14 +564,14 @@ impl<'a> Builder<'a> {
} }
} }
pub fn global_string(&self, _str: *c_char) -> ValueRef { pub fn global_string(&self, _str: *const c_char) -> ValueRef {
self.count_insn("globalstring"); self.count_insn("globalstring");
unsafe { unsafe {
llvm::LLVMBuildGlobalString(self.llbuilder, _str, noname()) llvm::LLVMBuildGlobalString(self.llbuilder, _str, noname())
} }
} }
pub fn global_string_ptr(&self, _str: *c_char) -> ValueRef { pub fn global_string_ptr(&self, _str: *const c_char) -> ValueRef {
self.count_insn("globalstringptr"); self.count_insn("globalstringptr");
unsafe { unsafe {
llvm::LLVMBuildGlobalStringPtr(self.llbuilder, _str, noname()) llvm::LLVMBuildGlobalStringPtr(self.llbuilder, _str, noname())
@ -774,7 +774,7 @@ impl<'a> Builder<'a> {
} }
} }
pub fn inline_asm_call(&self, asm: *c_char, cons: *c_char, pub fn inline_asm_call(&self, asm: *const c_char, cons: *const c_char,
inputs: &[ValueRef], output: Type, inputs: &[ValueRef], output: Type,
volatile: bool, alignstack: bool, volatile: bool, alignstack: bool,
dia: AsmDialect) -> ValueRef { dia: AsmDialect) -> ValueRef {

View file

@ -471,7 +471,7 @@ impl<'a> Block<'a> {
} }
pub fn to_str(&self) -> String { pub fn to_str(&self) -> String {
let blk: *Block = self; let blk: *const Block = self;
format!("[block {}]", blk) format!("[block {}]", blk)
} }
} }
@ -568,7 +568,7 @@ pub fn C_cstr(cx: &CrateContext, s: InternedString, null_terminated: bool) -> Va
} }
let sc = llvm::LLVMConstStringInContext(cx.llcx, let sc = llvm::LLVMConstStringInContext(cx.llcx,
s.get().as_ptr() as *c_char, s.get().as_ptr() as *const c_char,
s.get().len() as c_uint, s.get().len() as c_uint,
!null_terminated as Bool); !null_terminated as Bool);
@ -636,7 +636,7 @@ pub fn C_array(ty: Type, elts: &[ValueRef]) -> ValueRef {
pub fn C_bytes(ccx: &CrateContext, bytes: &[u8]) -> ValueRef { pub fn C_bytes(ccx: &CrateContext, bytes: &[u8]) -> ValueRef {
unsafe { unsafe {
let ptr = bytes.as_ptr() as *c_char; let ptr = bytes.as_ptr() as *const c_char;
return llvm::LLVMConstStringInContext(ccx.llcx, ptr, bytes.len() as c_uint, True); return llvm::LLVMConstStringInContext(ccx.llcx, ptr, bytes.len() as c_uint, True);
} }
} }

View file

@ -221,8 +221,8 @@ impl CrateContext {
llvm_insns: RefCell::new(HashMap::new()), llvm_insns: RefCell::new(HashMap::new()),
fn_stats: RefCell::new(Vec::new()), fn_stats: RefCell::new(Vec::new()),
}, },
int_type: Type::from_ref(ptr::null()), int_type: Type::from_ref(ptr::mut_null()),
opaque_vec_type: Type::from_ref(ptr::null()), opaque_vec_type: Type::from_ref(ptr::mut_null()),
builder: BuilderRef_res(llvm::LLVMCreateBuilderInContext(llcx)), builder: BuilderRef_res(llvm::LLVMCreateBuilderInContext(llcx)),
uses_gc: false, uses_gc: false,
dbg_cx: dbg_cx, dbg_cx: dbg_cx,

View file

@ -805,7 +805,7 @@ pub fn create_global_var_metadata(cx: &CrateContext,
type_metadata, type_metadata,
is_local_to_unit, is_local_to_unit,
global, global,
ptr::null()); ptr::mut_null());
} }
}) })
}); });
@ -980,7 +980,7 @@ pub fn create_argument_metadata(bcx: &Block, arg: &ast::Arg) {
} }
}; };
if unsafe { llvm::LLVMIsAAllocaInst(llarg.val) } == ptr::null() { if unsafe { llvm::LLVMIsAAllocaInst(llarg.val) } == ptr::mut_null() {
cx.sess().span_bug(span, "debuginfo::create_argument_metadata() - \ cx.sess().span_bug(span, "debuginfo::create_argument_metadata() - \
Referenced variable location is not an alloca!"); Referenced variable location is not an alloca!");
} }
@ -1221,7 +1221,7 @@ pub fn create_function_debug_context(cx: &CrateContext,
cx.sess().opts.optimize != config::No, cx.sess().opts.optimize != config::No,
llfn, llfn,
template_parameters, template_parameters,
ptr::null()) ptr::mut_null())
} }
}) })
}); });
@ -1257,7 +1257,7 @@ pub fn create_function_debug_context(cx: &CrateContext,
// Return type -- llvm::DIBuilder wants this at index 0 // Return type -- llvm::DIBuilder wants this at index 0
match fn_decl.output.node { match fn_decl.output.node {
ast::TyNil => { ast::TyNil => {
signature.push(ptr::null()); signature.push(ptr::mut_null());
} }
_ => { _ => {
assert_type_for_node_id(cx, fn_ast_id, error_span); assert_type_for_node_id(cx, fn_ast_id, error_span);
@ -1328,7 +1328,7 @@ pub fn create_function_debug_context(cx: &CrateContext,
file_metadata, file_metadata,
name, name,
actual_self_type_metadata, actual_self_type_metadata,
ptr::null(), ptr::mut_null(),
0, 0,
0) 0)
} }
@ -1361,7 +1361,7 @@ pub fn create_function_debug_context(cx: &CrateContext,
file_metadata, file_metadata,
name, name,
actual_type_metadata, actual_type_metadata,
ptr::null(), ptr::mut_null(),
0, 0,
0) 0)
} }
@ -2374,7 +2374,7 @@ fn prepare_enum_metadata(cx: &CrateContext,
bytes_to_bits(enum_type_size), bytes_to_bits(enum_type_size),
bytes_to_bits(enum_type_align), bytes_to_bits(enum_type_align),
0, // Flags 0, // Flags
ptr::null(), ptr::mut_null(),
0, // RuntimeLang 0, // RuntimeLang
unique_type_id_str) unique_type_id_str)
} }
@ -2554,10 +2554,10 @@ fn create_struct_stub(cx: &CrateContext,
bytes_to_bits(struct_size), bytes_to_bits(struct_size),
bytes_to_bits(struct_align), bytes_to_bits(struct_align),
0, 0,
ptr::null(), ptr::mut_null(),
empty_array, empty_array,
0, 0,
ptr::null(), ptr::mut_null(),
unique_type_id) unique_type_id)
}) })
}) })
@ -2855,7 +2855,7 @@ fn subroutine_type_metadata(cx: &CrateContext,
// return type // return type
signature_metadata.push(match ty::get(signature.output).sty { signature_metadata.push(match ty::get(signature.output).sty {
ty::ty_nil => ptr::null(), ty::ty_nil => ptr::mut_null(),
_ => type_metadata(cx, signature.output, span) _ => type_metadata(cx, signature.output, span)
}); });
@ -3153,7 +3153,8 @@ fn set_debug_location(cx: &CrateContext, debug_location: DebugLocation) {
KnownLocation { scope, line, .. } => { KnownLocation { scope, line, .. } => {
let col = 0u; // Always set the column to zero like Clang and GCC let col = 0u; // Always set the column to zero like Clang and GCC
debug!("setting debug location to {} {}", line, col); debug!("setting debug location to {} {}", line, col);
let elements = [C_i32(cx, line as i32), C_i32(cx, col as i32), scope, ptr::null()]; let elements = [C_i32(cx, line as i32), C_i32(cx, col as i32),
scope, ptr::mut_null()];
unsafe { unsafe {
metadata_node = llvm::LLVMMDNodeInContext(debug_context(cx).llcontext, metadata_node = llvm::LLVMMDNodeInContext(debug_context(cx).llcontext,
elements.as_ptr(), elements.as_ptr(),
@ -3162,7 +3163,7 @@ fn set_debug_location(cx: &CrateContext, debug_location: DebugLocation) {
} }
UnknownLocation => { UnknownLocation => {
debug!("clearing debug location "); debug!("clearing debug location ");
metadata_node = ptr::null(); metadata_node = ptr::mut_null();
} }
}; };
@ -3771,7 +3772,7 @@ fn namespace_for_item(cx: &CrateContext, def_id: ast::DefId) -> Rc<NamespaceTree
// create and insert // create and insert
let parent_scope = match parent_node { let parent_scope = match parent_node {
Some(ref node) => node.scope, Some(ref node) => node.scope,
None => ptr::null() None => ptr::mut_null()
}; };
let namespace_name = token::get_name(name); let namespace_name = token::get_name(name);
let scope = namespace_name.get().with_c_str(|namespace_name| { let scope = namespace_name.get().with_c_str(|namespace_name| {
@ -3781,7 +3782,7 @@ fn namespace_for_item(cx: &CrateContext, def_id: ast::DefId) -> Rc<NamespaceTree
parent_scope, parent_scope,
namespace_name, namespace_name,
// cannot reconstruct file ... // cannot reconstruct file ...
ptr::null(), ptr::mut_null(),
// ... or line information, but that's not so important. // ... or line information, but that's not so important.
0) 0)
} }

View file

@ -158,7 +158,7 @@ pub struct creader_cache_key {
pub type creader_cache = RefCell<HashMap<creader_cache_key, t>>; pub type creader_cache = RefCell<HashMap<creader_cache_key, t>>;
pub struct intern_key { pub struct intern_key {
sty: *sty, sty: *const sty,
} }
// NB: Do not replace this with #[deriving(PartialEq)]. The automatically-derived // NB: Do not replace this with #[deriving(PartialEq)]. The automatically-derived
@ -409,7 +409,7 @@ enum t_opaque {}
#[allow(raw_pointer_deriving)] #[allow(raw_pointer_deriving)]
#[deriving(Clone, PartialEq, Eq, Hash)] #[deriving(Clone, PartialEq, Eq, Hash)]
pub struct t { inner: *t_opaque } pub struct t { inner: *const t_opaque }
impl fmt::Show for t { impl fmt::Show for t {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@ -1216,7 +1216,7 @@ pub fn mk_t(cx: &ctxt, st: sty) -> t {
flags: flags, flags: flags,
}; };
let sty_ptr = &t.sty as *sty; let sty_ptr = &t.sty as *const sty;
let key = intern_key { let key = intern_key {
sty: sty_ptr, sty: sty_ptr,
@ -1227,7 +1227,7 @@ pub fn mk_t(cx: &ctxt, st: sty) -> t {
cx.next_id.set(cx.next_id.get() + 1); cx.next_id.set(cx.next_id.get() + 1);
unsafe { unsafe {
mem::transmute::<*sty, t>(sty_ptr) mem::transmute::<*const sty, t>(sty_ptr)
} }
} }

View file

@ -1262,7 +1262,7 @@ impl<'a> RegionScope for infer::InferCtxt<'a> {
impl<'a> FnCtxt<'a> { impl<'a> FnCtxt<'a> {
pub fn tag(&self) -> String { pub fn tag(&self) -> String {
format!("{}", self as *FnCtxt) format!("{}", self as *const FnCtxt)
} }
pub fn local_ty(&self, span: Span, nid: ast::NodeId) -> ty::t { pub fn local_ty(&self, span: Span, nid: ast::NodeId) -> ty::t {

View file

@ -129,7 +129,7 @@ impl<'a> PluginLoader<'a> {
let registrar = let registrar =
match lib.symbol(symbol.as_slice()) { match lib.symbol(symbol.as_slice()) {
Ok(registrar) => { Ok(registrar) => {
mem::transmute::<*u8,PluginRegistrarFun>(registrar) mem::transmute::<*mut u8,PluginRegistrarFun>(registrar)
} }
// again fatal if we can't register macros // again fatal if we can't register macros
Err(err) => self.sess.span_fatal(vi.span, err.as_slice()) Err(err) => self.sess.span_fatal(vi.span, err.as_slice())

View file

@ -355,7 +355,12 @@ pub fn ty_to_str(cx: &ctxt, typ: t) -> String {
ty_float(t) => ast_util::float_ty_to_str(t).to_string(), ty_float(t) => ast_util::float_ty_to_str(t).to_string(),
ty_box(typ) => format!("Gc<{}>", ty_to_str(cx, typ)), ty_box(typ) => format!("Gc<{}>", ty_to_str(cx, typ)),
ty_uniq(typ) => format!("Box<{}>", ty_to_str(cx, typ)), ty_uniq(typ) => format!("Box<{}>", ty_to_str(cx, typ)),
ty_ptr(ref tm) => format!("*{}", mt_to_str(cx, tm)), ty_ptr(ref tm) => {
format!("*{} {}", match tm.mutbl {
ast::MutMutable => "mut",
ast::MutImmutable => "const",
}, ty_to_str(cx, tm.ty))
}
ty_rptr(r, ref tm) => { ty_rptr(r, ref tm) => {
let mut buf = region_ptr_to_str(cx, r); let mut buf = region_ptr_to_str(cx, r);
buf.push_str(mt_to_str(cx, tm).as_slice()); buf.push_str(mt_to_str(cx, tm).as_slice());

View file

@ -34,7 +34,7 @@ fn read_u32v_be(dst: &mut[u32], input: &[u8]) {
assert!(dst.len() * 4 == input.len()); assert!(dst.len() * 4 == input.len());
unsafe { unsafe {
let mut x = dst.unsafe_mut_ref(0) as *mut _ as *mut u32; let mut x = dst.unsafe_mut_ref(0) as *mut _ as *mut u32;
let mut y = input.unsafe_ref(0) as *_ as *u32; let mut y = input.unsafe_ref(0) as *const _ as *const u32;
for _ in range(0, dst.len()) { for _ in range(0, dst.len()) {
*x = to_be32(*y); *x = to_be32(*y);
x = x.offset(1); x = x.offset(1);

View file

@ -104,7 +104,7 @@ mod imp {
l_sysid: 0, l_sysid: 0,
}; };
let ret = unsafe { let ret = unsafe {
libc::fcntl(fd, os::F_SETLKW, &flock as *os::flock) libc::fcntl(fd, os::F_SETLKW, &flock as *const os::flock)
}; };
if ret == -1 { if ret == -1 {
unsafe { libc::close(fd); } unsafe { libc::close(fd); }
@ -125,7 +125,7 @@ mod imp {
l_sysid: 0, l_sysid: 0,
}; };
unsafe { unsafe {
libc::fcntl(self.fd, os::F_SETLK, &flock as *os::flock); libc::fcntl(self.fd, os::F_SETLK, &flock as *const os::flock);
libc::close(self.fd); libc::close(self.fd);
} }
} }

View file

@ -66,13 +66,13 @@ type hoedown_document = libc::c_void; // this is opaque to us
struct hoedown_renderer { struct hoedown_renderer {
opaque: *mut hoedown_html_renderer_state, opaque: *mut hoedown_html_renderer_state,
blockcode: Option<extern "C" fn(*mut hoedown_buffer, *hoedown_buffer, blockcode: Option<extern "C" fn(*mut hoedown_buffer, *const hoedown_buffer,
*hoedown_buffer, *mut libc::c_void)>, *const hoedown_buffer, *mut libc::c_void)>,
blockquote: Option<extern "C" fn(*mut hoedown_buffer, *hoedown_buffer, blockquote: Option<extern "C" fn(*mut hoedown_buffer, *const hoedown_buffer,
*mut libc::c_void)>, *mut libc::c_void)>,
blockhtml: Option<extern "C" fn(*mut hoedown_buffer, *hoedown_buffer, blockhtml: Option<extern "C" fn(*mut hoedown_buffer, *const hoedown_buffer,
*mut libc::c_void)>, *mut libc::c_void)>,
header: Option<extern "C" fn(*mut hoedown_buffer, *hoedown_buffer, header: Option<extern "C" fn(*mut hoedown_buffer, *const hoedown_buffer,
libc::c_int, *mut libc::c_void)>, libc::c_int, *mut libc::c_void)>,
other: [libc::size_t, ..28], other: [libc::size_t, ..28],
} }
@ -81,7 +81,8 @@ struct hoedown_html_renderer_state {
opaque: *mut libc::c_void, opaque: *mut libc::c_void,
toc_data: html_toc_data, toc_data: html_toc_data,
flags: libc::c_uint, flags: libc::c_uint,
link_attributes: Option<extern "C" fn(*mut hoedown_buffer, *hoedown_buffer, link_attributes: Option<extern "C" fn(*mut hoedown_buffer,
*const hoedown_buffer,
*mut libc::c_void)>, *mut libc::c_void)>,
} }
@ -93,13 +94,13 @@ struct html_toc_data {
} }
struct MyOpaque { struct MyOpaque {
dfltblk: extern "C" fn(*mut hoedown_buffer, *hoedown_buffer, dfltblk: extern "C" fn(*mut hoedown_buffer, *const hoedown_buffer,
*hoedown_buffer, *mut libc::c_void), *const hoedown_buffer, *mut libc::c_void),
toc_builder: Option<TocBuilder>, toc_builder: Option<TocBuilder>,
} }
struct hoedown_buffer { struct hoedown_buffer {
data: *u8, data: *const u8,
size: libc::size_t, size: libc::size_t,
asize: libc::size_t, asize: libc::size_t,
unit: libc::size_t, unit: libc::size_t,
@ -118,12 +119,12 @@ extern {
max_nesting: libc::size_t) -> *mut hoedown_document; max_nesting: libc::size_t) -> *mut hoedown_document;
fn hoedown_document_render(doc: *mut hoedown_document, fn hoedown_document_render(doc: *mut hoedown_document,
ob: *mut hoedown_buffer, ob: *mut hoedown_buffer,
document: *u8, document: *const u8,
doc_size: libc::size_t); doc_size: libc::size_t);
fn hoedown_document_free(md: *mut hoedown_document); fn hoedown_document_free(md: *mut hoedown_document);
fn hoedown_buffer_new(unit: libc::size_t) -> *mut hoedown_buffer; fn hoedown_buffer_new(unit: libc::size_t) -> *mut hoedown_buffer;
fn hoedown_buffer_puts(b: *mut hoedown_buffer, c: *libc::c_char); fn hoedown_buffer_puts(b: *mut hoedown_buffer, c: *const libc::c_char);
fn hoedown_buffer_free(b: *mut hoedown_buffer); fn hoedown_buffer_free(b: *mut hoedown_buffer);
} }
@ -147,13 +148,13 @@ local_data_key!(test_idx: Cell<uint>)
local_data_key!(pub playground_krate: Option<String>) local_data_key!(pub playground_krate: Option<String>)
pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result { pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
extern fn block(ob: *mut hoedown_buffer, text: *hoedown_buffer, extern fn block(ob: *mut hoedown_buffer, text: *const hoedown_buffer,
lang: *hoedown_buffer, opaque: *mut libc::c_void) { lang: *const hoedown_buffer, opaque: *mut libc::c_void) {
unsafe { unsafe {
if text.is_null() { return } if text.is_null() { return }
let opaque = opaque as *mut hoedown_html_renderer_state; let opaque = opaque as *mut hoedown_html_renderer_state;
let my_opaque: &MyOpaque = &*((*opaque).opaque as *MyOpaque); let my_opaque: &MyOpaque = &*((*opaque).opaque as *const MyOpaque);
slice::raw::buf_as_slice((*text).data, (*text).size as uint, |text| { slice::raw::buf_as_slice((*text).data, (*text).size as uint, |text| {
let origtext = str::from_utf8(text).unwrap(); let origtext = str::from_utf8(text).unwrap();
debug!("docblock: ==============\n{}\n=======", text); debug!("docblock: ==============\n{}\n=======", text);
@ -213,7 +214,7 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
} }
} }
extern fn header(ob: *mut hoedown_buffer, text: *hoedown_buffer, extern fn header(ob: *mut hoedown_buffer, text: *const hoedown_buffer,
level: libc::c_int, opaque: *mut libc::c_void) { level: libc::c_int, opaque: *mut libc::c_void) {
// hoedown does this, we may as well too // hoedown does this, we may as well too
"\n".with_c_str(|p| unsafe { hoedown_buffer_puts(ob, p) }); "\n".with_c_str(|p| unsafe { hoedown_buffer_puts(ob, p) });
@ -304,8 +305,10 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
} }
pub fn find_testable_code(doc: &str, tests: &mut ::test::Collector) { pub fn find_testable_code(doc: &str, tests: &mut ::test::Collector) {
extern fn block(_ob: *mut hoedown_buffer, text: *hoedown_buffer, extern fn block(_ob: *mut hoedown_buffer,
lang: *hoedown_buffer, opaque: *mut libc::c_void) { text: *const hoedown_buffer,
lang: *const hoedown_buffer,
opaque: *mut libc::c_void) {
unsafe { unsafe {
if text.is_null() { return } if text.is_null() { return }
let block_info = if lang.is_null() { let block_info = if lang.is_null() {
@ -333,7 +336,8 @@ pub fn find_testable_code(doc: &str, tests: &mut ::test::Collector) {
} }
} }
extern fn header(_ob: *mut hoedown_buffer, text: *hoedown_buffer, extern fn header(_ob: *mut hoedown_buffer,
text: *const hoedown_buffer,
level: libc::c_int, opaque: *mut libc::c_void) { level: libc::c_int, opaque: *mut libc::c_void) {
unsafe { unsafe {
let opaque = opaque as *mut hoedown_html_renderer_state; let opaque = opaque as *mut hoedown_html_renderer_state;

View file

@ -48,7 +48,7 @@ impl PluginManager {
let lib = lib_result.unwrap(); let lib = lib_result.unwrap();
unsafe { unsafe {
let plugin = lib.symbol("rustdoc_plugin_entrypoint").unwrap(); let plugin = lib.symbol("rustdoc_plugin_entrypoint").unwrap();
self.callbacks.push(mem::transmute::<*u8,PluginCallback>(plugin)); self.callbacks.push(mem::transmute::<*mut u8,PluginCallback>(plugin));
} }
self.dylibs.push(lib); self.dylibs.push(lib);
} }

View file

@ -23,7 +23,7 @@ use core::prelude::*;
use collections::vec::Vec; use collections::vec::Vec;
/// One-time global initialization. /// One-time global initialization.
pub unsafe fn init(argc: int, argv: **u8) { imp::init(argc, argv) } pub unsafe fn init(argc: int, argv: *const *const u8) { imp::init(argc, argv) }
/// One-time global cleanup. /// One-time global cleanup.
pub unsafe fn cleanup() { imp::cleanup() } pub unsafe fn cleanup() { imp::cleanup() }
@ -55,7 +55,7 @@ mod imp {
static mut global_args_ptr: uint = 0; static mut global_args_ptr: uint = 0;
static mut lock: StaticNativeMutex = NATIVE_MUTEX_INIT; static mut lock: StaticNativeMutex = NATIVE_MUTEX_INIT;
pub unsafe fn init(argc: int, argv: **u8) { pub unsafe fn init(argc: int, argv: *const *const u8) {
let args = load_argc_and_argv(argc, argv); let args = load_argc_and_argv(argc, argv);
put(args); put(args);
} }
@ -99,7 +99,7 @@ mod imp {
unsafe { mem::transmute(&global_args_ptr) } unsafe { mem::transmute(&global_args_ptr) }
} }
unsafe fn load_argc_and_argv(argc: int, argv: **u8) -> Vec<Vec<u8>> { unsafe fn load_argc_and_argv(argc: int, argv: *const *const u8) -> Vec<Vec<u8>> {
Vec::from_fn(argc as uint, |i| { Vec::from_fn(argc as uint, |i| {
let base = *argv.offset(i as int); let base = *argv.offset(i as int);
let mut len = 0; let mut len = 0;
@ -151,7 +151,7 @@ mod imp {
use core::prelude::*; use core::prelude::*;
use collections::vec::Vec; use collections::vec::Vec;
pub unsafe fn init(_argc: int, _argv: **u8) { pub unsafe fn init(_argc: int, _argv: *const *const u8) {
} }
pub fn cleanup() { pub fn cleanup() {

View file

@ -43,7 +43,7 @@ pub fn push(f: proc():Send) {
rtassert!(!RUNNING.load(atomics::SeqCst)); rtassert!(!RUNNING.load(atomics::SeqCst));
let queue = QUEUE.load(atomics::SeqCst); let queue = QUEUE.load(atomics::SeqCst);
rtassert!(queue != 0); rtassert!(queue != 0);
(*(queue as *Queue)).lock().push(f); (*(queue as *const Queue)).lock().push(f);
} }
} }

View file

@ -42,7 +42,7 @@ An example of creating and using a C string would be:
extern crate libc; extern crate libc;
extern { extern {
fn puts(s: *libc::c_char); fn puts(s: *const libc::c_char);
} }
fn main() { fn main() {
@ -82,7 +82,7 @@ use libc;
/// This structure wraps a `*libc::c_char`, and will automatically free the /// This structure wraps a `*libc::c_char`, and will automatically free the
/// memory it is pointing to when it goes out of scope. /// memory it is pointing to when it goes out of scope.
pub struct CString { pub struct CString {
buf: *libc::c_char, buf: *const libc::c_char,
owns_buffer_: bool, owns_buffer_: bool,
} }
@ -97,7 +97,7 @@ impl Clone for CString {
let len = self.len() + 1; let len = self.len() + 1;
let buf = unsafe { malloc_raw(len) } as *mut libc::c_char; let buf = unsafe { malloc_raw(len) } as *mut libc::c_char;
unsafe { ptr::copy_nonoverlapping_memory(buf, self.buf, len); } unsafe { ptr::copy_nonoverlapping_memory(buf, self.buf, len); }
CString { buf: buf as *libc::c_char, owns_buffer_: true } CString { buf: buf as *const libc::c_char, owns_buffer_: true }
} }
} }
} }
@ -118,7 +118,7 @@ impl PartialEq for CString {
impl CString { impl CString {
/// Create a C String from a pointer. /// Create a C String from a pointer.
pub unsafe fn new(buf: *libc::c_char, owns_buffer: bool) -> CString { pub unsafe fn new(buf: *const libc::c_char, owns_buffer: bool) -> CString {
CString { buf: buf, owns_buffer_: owns_buffer } CString { buf: buf, owns_buffer_: owns_buffer }
} }
@ -127,7 +127,7 @@ impl CString {
/// The original object is destructed after this method is called, and if /// The original object is destructed after this method is called, and if
/// the underlying pointer was previously allocated, care must be taken to /// the underlying pointer was previously allocated, care must be taken to
/// ensure that it is deallocated properly. /// ensure that it is deallocated properly.
pub unsafe fn unwrap(self) -> *libc::c_char { pub unsafe fn unwrap(self) -> *const libc::c_char {
let mut c_str = self; let mut c_str = self;
c_str.owns_buffer_ = false; c_str.owns_buffer_ = false;
c_str.buf c_str.buf
@ -138,7 +138,7 @@ impl CString {
/// # Failure /// # Failure
/// ///
/// Fails if the CString is null. /// Fails if the CString is null.
pub fn with_ref<T>(&self, f: |*libc::c_char| -> T) -> T { pub fn with_ref<T>(&self, f: |*const libc::c_char| -> T) -> T {
if self.buf.is_null() { fail!("CString is null!"); } if self.buf.is_null() { fail!("CString is null!"); }
f(self.buf) f(self.buf)
} }
@ -284,13 +284,13 @@ pub trait ToCStr {
/// ///
/// Fails the task if the receiver has an interior null. /// Fails the task if the receiver has an interior null.
#[inline] #[inline]
fn with_c_str<T>(&self, f: |*libc::c_char| -> T) -> T { fn with_c_str<T>(&self, f: |*const libc::c_char| -> T) -> T {
self.to_c_str().with_ref(f) self.to_c_str().with_ref(f)
} }
/// Unsafe variant of `with_c_str()` that doesn't check for nulls. /// Unsafe variant of `with_c_str()` that doesn't check for nulls.
#[inline] #[inline]
unsafe fn with_c_str_unchecked<T>(&self, f: |*libc::c_char| -> T) -> T { unsafe fn with_c_str_unchecked<T>(&self, f: |*const libc::c_char| -> T) -> T {
self.to_c_str_unchecked().with_ref(f) self.to_c_str_unchecked().with_ref(f)
} }
} }
@ -315,12 +315,12 @@ impl<'a> ToCStr for &'a str {
} }
#[inline] #[inline]
fn with_c_str<T>(&self, f: |*libc::c_char| -> T) -> T { fn with_c_str<T>(&self, f: |*const libc::c_char| -> T) -> T {
self.as_bytes().with_c_str(f) self.as_bytes().with_c_str(f)
} }
#[inline] #[inline]
unsafe fn with_c_str_unchecked<T>(&self, f: |*libc::c_char| -> T) -> T { unsafe fn with_c_str_unchecked<T>(&self, f: |*const libc::c_char| -> T) -> T {
self.as_bytes().with_c_str_unchecked(f) self.as_bytes().with_c_str_unchecked(f)
} }
} }
@ -337,12 +337,12 @@ impl ToCStr for String {
} }
#[inline] #[inline]
fn with_c_str<T>(&self, f: |*libc::c_char| -> T) -> T { fn with_c_str<T>(&self, f: |*const libc::c_char| -> T) -> T {
self.as_bytes().with_c_str(f) self.as_bytes().with_c_str(f)
} }
#[inline] #[inline]
unsafe fn with_c_str_unchecked<T>(&self, f: |*libc::c_char| -> T) -> T { unsafe fn with_c_str_unchecked<T>(&self, f: |*const libc::c_char| -> T) -> T {
self.as_bytes().with_c_str_unchecked(f) self.as_bytes().with_c_str_unchecked(f)
} }
} }
@ -364,20 +364,21 @@ impl<'a> ToCStr for &'a [u8] {
ptr::copy_memory(buf, self.as_ptr(), self_len); ptr::copy_memory(buf, self.as_ptr(), self_len);
*buf.offset(self_len as int) = 0; *buf.offset(self_len as int) = 0;
CString::new(buf as *libc::c_char, true) CString::new(buf as *const libc::c_char, true)
} }
fn with_c_str<T>(&self, f: |*libc::c_char| -> T) -> T { fn with_c_str<T>(&self, f: |*const libc::c_char| -> T) -> T {
unsafe { with_c_str(*self, true, f) } unsafe { with_c_str(*self, true, f) }
} }
unsafe fn with_c_str_unchecked<T>(&self, f: |*libc::c_char| -> T) -> T { unsafe fn with_c_str_unchecked<T>(&self, f: |*const libc::c_char| -> T) -> T {
with_c_str(*self, false, f) with_c_str(*self, false, f)
} }
} }
// Unsafe function that handles possibly copying the &[u8] into a stack array. // Unsafe function that handles possibly copying the &[u8] into a stack array.
unsafe fn with_c_str<T>(v: &[u8], checked: bool, f: |*libc::c_char| -> T) -> T { unsafe fn with_c_str<T>(v: &[u8], checked: bool,
f: |*const libc::c_char| -> T) -> T {
if v.len() < BUF_LEN { if v.len() < BUF_LEN {
let mut buf: [u8, .. BUF_LEN] = mem::uninitialized(); let mut buf: [u8, .. BUF_LEN] = mem::uninitialized();
slice::bytes::copy_memory(buf, v); slice::bytes::copy_memory(buf, v);
@ -388,7 +389,7 @@ unsafe fn with_c_str<T>(v: &[u8], checked: bool, f: |*libc::c_char| -> T) -> T {
check_for_null(v, buf as *mut libc::c_char); check_for_null(v, buf as *mut libc::c_char);
} }
f(buf as *libc::c_char) f(buf as *const libc::c_char)
} else if checked { } else if checked {
v.to_c_str().with_ref(f) v.to_c_str().with_ref(f)
} else { } else {
@ -410,7 +411,7 @@ fn check_for_null(v: &[u8], buf: *mut libc::c_char) {
/// ///
/// Use with the `std::iter` module. /// Use with the `std::iter` module.
pub struct CChars<'a> { pub struct CChars<'a> {
ptr: *libc::c_char, ptr: *const libc::c_char,
marker: marker::ContravariantLifetime<'a>, marker: marker::ContravariantLifetime<'a>,
} }
@ -434,7 +435,7 @@ impl<'a> Iterator<libc::c_char> for CChars<'a> {
/// ///
/// The specified closure is invoked with each string that /// The specified closure is invoked with each string that
/// is found, and the number of strings found is returned. /// is found, and the number of strings found is returned.
pub unsafe fn from_c_multistring(buf: *libc::c_char, pub unsafe fn from_c_multistring(buf: *const libc::c_char,
count: Option<uint>, count: Option<uint>,
f: |&CString|) -> uint { f: |&CString|) -> uint {
@ -445,8 +446,8 @@ pub unsafe fn from_c_multistring(buf: *libc::c_char,
None => (false, 0) None => (false, 0)
}; };
while ((limited_count && ctr < limit) || !limited_count) while ((limited_count && ctr < limit) || !limited_count)
&& *(curr_ptr as *libc::c_char) != 0 as libc::c_char { && *(curr_ptr as *const libc::c_char) != 0 as libc::c_char {
let cstr = CString::new(curr_ptr as *libc::c_char, false); let cstr = CString::new(curr_ptr as *const libc::c_char, false);
f(&cstr); f(&cstr);
curr_ptr += cstr.len() + 1; curr_ptr += cstr.len() + 1;
ctr += 1; ctr += 1;
@ -470,7 +471,7 @@ mod tests {
let ptr = input.as_ptr(); let ptr = input.as_ptr();
let expected = ["zero", "one"]; let expected = ["zero", "one"];
let mut it = expected.iter(); let mut it = expected.iter();
let result = from_c_multistring(ptr as *libc::c_char, None, |c| { let result = from_c_multistring(ptr as *const libc::c_char, None, |c| {
let cbytes = c.as_bytes_no_nul(); let cbytes = c.as_bytes_no_nul();
assert_eq!(cbytes, it.next().unwrap().as_bytes()); assert_eq!(cbytes, it.next().unwrap().as_bytes());
}); });
@ -707,7 +708,7 @@ mod bench {
use std::prelude::*; use std::prelude::*;
#[inline] #[inline]
fn check(s: &str, c_str: *libc::c_char) { fn check(s: &str, c_str: *const libc::c_char) {
let s_buf = s.as_ptr(); let s_buf = s.as_ptr();
for i in range(0, s.len()) { for i in range(0, s.len()) {
unsafe { unsafe {

View file

@ -104,7 +104,7 @@ pub static DEFAULT_ERROR_CODE: int = 101;
/// Initializes global state, including frobbing /// Initializes global state, including frobbing
/// the crate's logging flags, registering GC /// the crate's logging flags, registering GC
/// metadata, and storing the process arguments. /// metadata, and storing the process arguments.
pub fn init(argc: int, argv: **u8) { pub fn init(argc: int, argv: *const *const u8) {
// FIXME: Derefing these pointers is not safe. // FIXME: Derefing these pointers is not safe.
// Need to propagate the unsafety to `start`. // Need to propagate the unsafety to `start`.
unsafe { unsafe {

View file

@ -82,7 +82,7 @@ pub enum _Unwind_Context {}
pub type _Unwind_Exception_Cleanup_Fn = pub type _Unwind_Exception_Cleanup_Fn =
extern "C" fn(unwind_code: _Unwind_Reason_Code, extern "C" fn(unwind_code: _Unwind_Reason_Code,
exception: *_Unwind_Exception); exception: *mut _Unwind_Exception);
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
#[cfg(target_os = "freebsd")] #[cfg(target_os = "freebsd")]
@ -99,14 +99,14 @@ extern "C" {
// iOS on armv7 uses SjLj exceptions and requires to link // iOS on armv7 uses SjLj exceptions and requires to link
// agains corresponding routine (..._SjLj_...) // agains corresponding routine (..._SjLj_...)
#[cfg(not(target_os = "ios", target_arch = "arm"))] #[cfg(not(target_os = "ios", target_arch = "arm"))]
pub fn _Unwind_RaiseException(exception: *_Unwind_Exception) pub fn _Unwind_RaiseException(exception: *mut _Unwind_Exception)
-> _Unwind_Reason_Code; -> _Unwind_Reason_Code;
#[cfg(target_os = "ios", target_arch = "arm")] #[cfg(target_os = "ios", target_arch = "arm")]
fn _Unwind_SjLj_RaiseException(e: *_Unwind_Exception) fn _Unwind_SjLj_RaiseException(e: *mut _Unwind_Exception)
-> _Unwind_Reason_Code; -> _Unwind_Reason_Code;
pub fn _Unwind_DeleteException(exception: *_Unwind_Exception); pub fn _Unwind_DeleteException(exception: *mut _Unwind_Exception);
} }
// ... and now we just providing access to SjLj counterspart // ... and now we just providing access to SjLj counterspart
@ -114,7 +114,7 @@ extern "C" {
// (see also comment above regarding _Unwind_RaiseException) // (see also comment above regarding _Unwind_RaiseException)
#[cfg(target_os = "ios", target_arch = "arm")] #[cfg(target_os = "ios", target_arch = "arm")]
#[inline(always)] #[inline(always)]
pub unsafe fn _Unwind_RaiseException(exc: *_Unwind_Exception) pub unsafe fn _Unwind_RaiseException(exc: *mut _Unwind_Exception)
-> _Unwind_Reason_Code { -> _Unwind_Reason_Code {
_Unwind_SjLj_RaiseException(exc) _Unwind_SjLj_RaiseException(exc)
} }

View file

@ -90,7 +90,7 @@ impl<T: 'static> LocalData for T {}
// n.b. If TLS is used heavily in future, this could be made more efficient with // n.b. If TLS is used heavily in future, this could be made more efficient with
// a proper map. // a proper map.
#[doc(hidden)] #[doc(hidden)]
pub type Map = Vec<Option<(*u8, TLSValue, uint)>>; pub type Map = Vec<Option<(*const u8, TLSValue, uint)>>;
type TLSValue = Box<LocalData + Send>; type TLSValue = Box<LocalData + Send>;
// Gets the map from the runtime. Lazily initialises if not done so already. // Gets the map from the runtime. Lazily initialises if not done so already.
@ -116,8 +116,8 @@ unsafe fn get_local_map() -> Option<&mut Map> {
} }
} }
fn key_to_key_value<T: 'static>(key: Key<T>) -> *u8 { fn key_to_key_value<T: 'static>(key: Key<T>) -> *const u8 {
key as *KeyValue<T> as *u8 key as *const KeyValue<T> as *const u8
} }
/// An RAII immutable reference to a task-local value. /// An RAII immutable reference to a task-local value.
@ -236,7 +236,8 @@ impl<T: 'static> KeyValue<T> {
// pointer part of the trait, (as ~T), and then use // pointer part of the trait, (as ~T), and then use
// compiler coercions to achieve a '&' pointer. // compiler coercions to achieve a '&' pointer.
let ptr = unsafe { let ptr = unsafe {
let data = data as *Box<LocalData + Send> as *raw::TraitObject; let data = data as *const Box<LocalData + Send>
as *const raw::TraitObject;
&mut *((*data).data as *mut T) &mut *((*data).data as *mut T)
}; };
Ref { _ptr: ptr, _index: pos, _nosend: marker::NoSend, _key: self } Ref { _ptr: ptr, _index: pos, _nosend: marker::NoSend, _key: self }

View file

@ -213,8 +213,8 @@ impl MemoryRegion {
#[inline] #[inline]
fn malloc(&mut self, size: uint) -> *mut Box { fn malloc(&mut self, size: uint) -> *mut Box {
let total_size = size + AllocHeader::size(); let total_size = size + AllocHeader::size();
let alloc: *AllocHeader = unsafe { let alloc: *mut AllocHeader = unsafe {
libc_heap::malloc_raw(total_size) as *AllocHeader libc_heap::malloc_raw(total_size) as *mut AllocHeader
}; };
let alloc: &mut AllocHeader = unsafe { mem::transmute(alloc) }; let alloc: &mut AllocHeader = unsafe { mem::transmute(alloc) };
@ -232,14 +232,14 @@ impl MemoryRegion {
unsafe { (*orig_alloc).assert_sane(); } unsafe { (*orig_alloc).assert_sane(); }
let total_size = size + AllocHeader::size(); let total_size = size + AllocHeader::size();
let alloc: *AllocHeader = unsafe { let alloc: *mut AllocHeader = unsafe {
libc_heap::realloc_raw(orig_alloc as *mut u8, total_size) as *AllocHeader libc_heap::realloc_raw(orig_alloc as *mut u8, total_size) as *mut AllocHeader
}; };
let alloc: &mut AllocHeader = unsafe { mem::transmute(alloc) }; let alloc: &mut AllocHeader = unsafe { mem::transmute(alloc) };
alloc.assert_sane(); alloc.assert_sane();
alloc.update_size(size as u32); alloc.update_size(size as u32);
self.update(alloc, orig_alloc as *AllocHeader); self.update(alloc, orig_alloc as *mut AllocHeader);
return alloc.as_box(); return alloc.as_box();
} }
@ -261,7 +261,7 @@ impl MemoryRegion {
#[inline] #[inline]
fn release(&mut self, _alloc: &AllocHeader) {} fn release(&mut self, _alloc: &AllocHeader) {}
#[inline] #[inline]
fn update(&mut self, _alloc: &mut AllocHeader, _orig: *AllocHeader) {} fn update(&mut self, _alloc: &mut AllocHeader, _orig: *mut AllocHeader) {}
} }
impl Drop for MemoryRegion { impl Drop for MemoryRegion {
@ -275,17 +275,19 @@ impl Drop for MemoryRegion {
#[cfg(not(test))] #[cfg(not(test))]
#[lang="malloc"] #[lang="malloc"]
#[inline] #[inline]
pub unsafe fn local_malloc_(drop_glue: fn(*mut u8), size: uint, align: uint) -> *u8 { pub unsafe fn local_malloc_(drop_glue: fn(*mut u8), size: uint,
align: uint) -> *mut u8 {
local_malloc(drop_glue, size, align) local_malloc(drop_glue, size, align)
} }
#[inline] #[inline]
pub unsafe fn local_malloc(drop_glue: fn(*mut u8), size: uint, align: uint) -> *u8 { pub unsafe fn local_malloc(drop_glue: fn(*mut u8), size: uint,
align: uint) -> *mut u8 {
// FIXME: Unsafe borrow for speed. Lame. // FIXME: Unsafe borrow for speed. Lame.
let task: Option<*mut Task> = Local::try_unsafe_borrow(); let task: Option<*mut Task> = Local::try_unsafe_borrow();
match task { match task {
Some(task) => { Some(task) => {
(*task).heap.alloc(drop_glue, size, align) as *u8 (*task).heap.alloc(drop_glue, size, align) as *mut u8
} }
None => rtabort!("local malloc outside of task") None => rtabort!("local malloc outside of task")
} }
@ -294,7 +296,7 @@ pub unsafe fn local_malloc(drop_glue: fn(*mut u8), size: uint, align: uint) -> *
#[cfg(not(test))] #[cfg(not(test))]
#[lang="free"] #[lang="free"]
#[inline] #[inline]
pub unsafe fn local_free_(ptr: *u8) { pub unsafe fn local_free_(ptr: *mut u8) {
local_free(ptr) local_free(ptr)
} }
@ -302,7 +304,7 @@ pub unsafe fn local_free_(ptr: *u8) {
// inside a landing pad may corrupt the state of the exception handler. If a // inside a landing pad may corrupt the state of the exception handler. If a
// problem occurs, call exit instead. // problem occurs, call exit instead.
#[inline] #[inline]
pub unsafe fn local_free(ptr: *u8) { pub unsafe fn local_free(ptr: *mut u8) {
// FIXME: Unsafe borrow for speed. Lame. // FIXME: Unsafe borrow for speed. Lame.
let task_ptr: Option<*mut Task> = Local::try_unsafe_borrow(); let task_ptr: Option<*mut Task> = Local::try_unsafe_borrow();
match task_ptr { match task_ptr {

View file

@ -35,7 +35,7 @@ pub use self::compiled::{init, cleanup, put, take, try_take, unsafe_take, exists
/// Encapsulates a borrowed value. When this value goes out of scope, the /// Encapsulates a borrowed value. When this value goes out of scope, the
/// pointer is returned. /// pointer is returned.
pub struct Borrowed<T> { pub struct Borrowed<T> {
val: *(), val: *const (),
} }
#[unsafe_destructor] #[unsafe_destructor]
@ -54,7 +54,7 @@ impl<T> Drop for Borrowed<T> {
impl<T> Deref<T> for Borrowed<T> { impl<T> Deref<T> for Borrowed<T> {
fn deref<'a>(&'a self) -> &'a T { fn deref<'a>(&'a self) -> &'a T {
unsafe { &*(self.val as *T) } unsafe { &*(self.val as *const T) }
} }
} }
@ -72,7 +72,7 @@ impl<T> DerefMut<T> for Borrowed<T> {
/// Does not validate the pointer type. /// Does not validate the pointer type.
#[inline] #[inline]
pub unsafe fn borrow<T>() -> Borrowed<T> { pub unsafe fn borrow<T>() -> Borrowed<T> {
let val: *() = mem::transmute(take::<T>()); let val: *const () = mem::transmute(take::<T>());
Borrowed { Borrowed {
val: val, val: val,
} }

View file

@ -351,8 +351,8 @@ mod imp {
mod os { mod os {
use libc; use libc;
pub type pthread_mutex_t = *libc::c_void; pub type pthread_mutex_t = *mut libc::c_void;
pub type pthread_cond_t = *libc::c_void; pub type pthread_cond_t = *mut libc::c_void;
pub static PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pub static PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t =
0 as pthread_mutex_t; 0 as pthread_mutex_t;

View file

@ -221,9 +221,9 @@ pub unsafe fn record_sp_limit(limit: uint) {
#[cfg(target_arch = "arm", not(target_os = "ios"))] #[inline(always)] #[cfg(target_arch = "arm", not(target_os = "ios"))] #[inline(always)]
unsafe fn target_record_sp_limit(limit: uint) { unsafe fn target_record_sp_limit(limit: uint) {
use libc::c_void; use libc::c_void;
return record_sp_limit(limit as *c_void); return record_sp_limit(limit as *const c_void);
extern { extern {
fn record_sp_limit(limit: *c_void); fn record_sp_limit(limit: *const c_void);
} }
} }
@ -305,7 +305,7 @@ pub unsafe fn get_sp_limit() -> uint {
use libc::c_void; use libc::c_void;
return get_sp_limit() as uint; return get_sp_limit() as uint;
extern { extern {
fn get_sp_limit() -> *c_void; fn get_sp_limit() -> *const c_void;
} }
} }

View file

@ -25,7 +25,7 @@ use libc;
use stack; use stack;
type StartFn = extern "C" fn(*libc::c_void) -> imp::rust_thread_return; type StartFn = extern "C" fn(*mut libc::c_void) -> imp::rust_thread_return;
/// This struct represents a native thread's state. This is used to join on an /// This struct represents a native thread's state. This is used to join on an
/// existing thread created in the join-able state. /// existing thread created in the join-able state.
@ -42,7 +42,7 @@ static DEFAULT_STACK_SIZE: uint = 1024 * 1024;
// no_split_stack annotation), and then we extract the main function // no_split_stack annotation), and then we extract the main function
// and invoke it. // and invoke it.
#[no_split_stack] #[no_split_stack]
extern fn thread_start(main: *libc::c_void) -> imp::rust_thread_return { extern fn thread_start(main: *mut libc::c_void) -> imp::rust_thread_return {
unsafe { unsafe {
stack::record_stack_bounds(0, uint::MAX); stack::record_stack_bounds(0, uint::MAX);
let f: Box<proc()> = mem::transmute(main); let f: Box<proc()> = mem::transmute(main);
@ -82,7 +82,7 @@ impl Thread<()> {
// so. // so.
let packet = box None; let packet = box None;
let packet2: *mut Option<T> = unsafe { let packet2: *mut Option<T> = unsafe {
*mem::transmute::<&Box<Option<T>>, **mut Option<T>>(&packet) *mem::transmute::<&Box<Option<T>>, *const *mut Option<T>>(&packet)
}; };
let main = proc() unsafe { *packet2 = Some(main()); }; let main = proc() unsafe { *packet2 = Some(main()); };
let native = unsafe { imp::create(stack, box main) }; let native = unsafe { imp::create(stack, box main) };
@ -225,7 +225,7 @@ mod imp {
use stack::RED_ZONE; use stack::RED_ZONE;
pub type rust_thread = libc::pthread_t; pub type rust_thread = libc::pthread_t;
pub type rust_thread_return = *u8; pub type rust_thread_return = *mut u8;
pub unsafe fn create(stack: uint, p: Box<proc():Send>) -> rust_thread { pub unsafe fn create(stack: uint, p: Box<proc():Send>) -> rust_thread {
let mut native: libc::pthread_t = mem::zeroed(); let mut native: libc::pthread_t = mem::zeroed();
@ -255,7 +255,7 @@ mod imp {
}, },
}; };
let arg: *libc::c_void = mem::transmute(p); let arg: *mut libc::c_void = mem::transmute(p);
let ret = pthread_create(&mut native, &attr, super::thread_start, arg); let ret = pthread_create(&mut native, &attr, super::thread_start, arg);
assert_eq!(pthread_attr_destroy(&mut attr), 0); assert_eq!(pthread_attr_destroy(&mut attr), 0);
@ -268,7 +268,7 @@ mod imp {
} }
pub unsafe fn join(native: rust_thread) { pub unsafe fn join(native: rust_thread) {
assert_eq!(pthread_join(native, ptr::null()), 0); assert_eq!(pthread_join(native, ptr::mut_null()), 0);
} }
pub unsafe fn detach(native: rust_thread) { pub unsafe fn detach(native: rust_thread) {
@ -287,33 +287,33 @@ mod imp {
// currently always the case. Note that you need to check that the symbol // currently always the case. Note that you need to check that the symbol
// is non-null before calling it! // is non-null before calling it!
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
fn min_stack_size(attr: *libc::pthread_attr_t) -> libc::size_t { fn min_stack_size(attr: *const libc::pthread_attr_t) -> libc::size_t {
type F = unsafe extern "C" fn(*libc::pthread_attr_t) -> libc::size_t; type F = unsafe extern "C" fn(*const libc::pthread_attr_t) -> libc::size_t;
extern { extern {
#[linkage = "extern_weak"] #[linkage = "extern_weak"]
static __pthread_get_minstack: *(); static __pthread_get_minstack: *const ();
} }
if __pthread_get_minstack.is_null() { if __pthread_get_minstack.is_null() {
PTHREAD_STACK_MIN PTHREAD_STACK_MIN
} else { } else {
unsafe { mem::transmute::<*(), F>(__pthread_get_minstack)(attr) } unsafe { mem::transmute::<*const (), F>(__pthread_get_minstack)(attr) }
} }
} }
// __pthread_get_minstack() is marked as weak but extern_weak linkage is // __pthread_get_minstack() is marked as weak but extern_weak linkage is
// not supported on OS X, hence this kludge... // not supported on OS X, hence this kludge...
#[cfg(not(target_os = "linux"))] #[cfg(not(target_os = "linux"))]
fn min_stack_size(_: *libc::pthread_attr_t) -> libc::size_t { fn min_stack_size(_: *const libc::pthread_attr_t) -> libc::size_t {
PTHREAD_STACK_MIN PTHREAD_STACK_MIN
} }
extern { extern {
fn pthread_create(native: *mut libc::pthread_t, fn pthread_create(native: *mut libc::pthread_t,
attr: *libc::pthread_attr_t, attr: *const libc::pthread_attr_t,
f: super::StartFn, f: super::StartFn,
value: *libc::c_void) -> libc::c_int; value: *mut libc::c_void) -> libc::c_int;
fn pthread_join(native: libc::pthread_t, fn pthread_join(native: libc::pthread_t,
value: **libc::c_void) -> libc::c_int; value: *mut *mut libc::c_void) -> libc::c_int;
fn pthread_attr_init(attr: *mut libc::pthread_attr_t) -> libc::c_int; fn pthread_attr_init(attr: *mut libc::pthread_attr_t) -> libc::c_int;
fn pthread_attr_destroy(attr: *mut libc::pthread_attr_t) -> libc::c_int; fn pthread_attr_destroy(attr: *mut libc::pthread_attr_t) -> libc::c_int;
fn pthread_attr_setstacksize(attr: *mut libc::pthread_attr_t, fn pthread_attr_setstacksize(attr: *mut libc::pthread_attr_t,

View file

@ -50,7 +50,7 @@ type pthread_key_t = ::libc::c_uint;
#[cfg(unix)] #[cfg(unix)]
extern { extern {
fn pthread_key_create(key: *mut pthread_key_t, dtor: *u8) -> c_int; fn pthread_key_create(key: *mut pthread_key_t, dtor: *const u8) -> c_int;
fn pthread_key_delete(key: pthread_key_t) -> c_int; fn pthread_key_delete(key: pthread_key_t) -> c_int;
fn pthread_getspecific(key: pthread_key_t) -> *mut u8; fn pthread_getspecific(key: pthread_key_t) -> *mut u8;
fn pthread_setspecific(key: pthread_key_t, value: *mut u8) -> c_int; fn pthread_setspecific(key: pthread_key_t, value: *mut u8) -> c_int;

View file

@ -150,8 +150,8 @@ impl Unwinder {
/// run. /// run.
pub unsafe fn try(f: ||) -> ::core::result::Result<(), Box<Any + Send>> { pub unsafe fn try(f: ||) -> ::core::result::Result<(), Box<Any + Send>> {
let closure: Closure = mem::transmute(f); let closure: Closure = mem::transmute(f);
let ep = rust_try(try_fn, closure.code as *c_void, let ep = rust_try(try_fn, closure.code as *mut c_void,
closure.env as *c_void); closure.env as *mut c_void);
return if ep.is_null() { return if ep.is_null() {
Ok(()) Ok(())
} else { } else {
@ -162,11 +162,11 @@ pub unsafe fn try(f: ||) -> ::core::result::Result<(), Box<Any + Send>> {
Err(cause.unwrap()) Err(cause.unwrap())
}; };
extern fn try_fn(code: *c_void, env: *c_void) { extern fn try_fn(code: *mut c_void, env: *mut c_void) {
unsafe { unsafe {
let closure: || = mem::transmute(Closure { let closure: || = mem::transmute(Closure {
code: code as *(), code: code as *mut (),
env: env as *(), env: env as *mut (),
}); });
closure(); closure();
} }
@ -178,9 +178,9 @@ pub unsafe fn try(f: ||) -> ::core::result::Result<(), Box<Any + Send>> {
// When f(...) returns normally, the return value is null. // When f(...) returns normally, the return value is null.
// When f(...) throws, the return value is a pointer to the caught // When f(...) throws, the return value is a pointer to the caught
// exception object. // exception object.
fn rust_try(f: extern "C" fn(*c_void, *c_void), fn rust_try(f: extern "C" fn(*mut c_void, *mut c_void),
code: *c_void, code: *mut c_void,
data: *c_void) -> *uw::_Unwind_Exception; data: *mut c_void) -> *mut uw::_Unwind_Exception;
} }
} }
@ -204,7 +204,7 @@ fn rust_fail(cause: Box<Any + Send>) -> ! {
} }
extern fn exception_cleanup(_unwind_code: uw::_Unwind_Reason_Code, extern fn exception_cleanup(_unwind_code: uw::_Unwind_Reason_Code,
exception: *uw::_Unwind_Exception) { exception: *mut uw::_Unwind_Exception) {
rtdebug!("exception_cleanup()"); rtdebug!("exception_cleanup()");
unsafe { unsafe {
let _: Box<Exception> = mem::transmute(exception); let _: Box<Exception> = mem::transmute(exception);
@ -249,8 +249,8 @@ pub mod eabi {
fn __gcc_personality_v0(version: c_int, fn __gcc_personality_v0(version: c_int,
actions: uw::_Unwind_Action, actions: uw::_Unwind_Action,
exception_class: uw::_Unwind_Exception_Class, exception_class: uw::_Unwind_Exception_Class,
ue_header: *uw::_Unwind_Exception, ue_header: *mut uw::_Unwind_Exception,
context: *uw::_Unwind_Context) context: *mut uw::_Unwind_Context)
-> uw::_Unwind_Reason_Code; -> uw::_Unwind_Reason_Code;
} }
@ -259,8 +259,8 @@ pub mod eabi {
version: c_int, version: c_int,
actions: uw::_Unwind_Action, actions: uw::_Unwind_Action,
exception_class: uw::_Unwind_Exception_Class, exception_class: uw::_Unwind_Exception_Class,
ue_header: *uw::_Unwind_Exception, ue_header: *mut uw::_Unwind_Exception,
context: *uw::_Unwind_Context context: *mut uw::_Unwind_Context
) -> uw::_Unwind_Reason_Code ) -> uw::_Unwind_Reason_Code
{ {
unsafe { unsafe {
@ -274,8 +274,8 @@ pub mod eabi {
version: c_int, version: c_int,
actions: uw::_Unwind_Action, actions: uw::_Unwind_Action,
exception_class: uw::_Unwind_Exception_Class, exception_class: uw::_Unwind_Exception_Class,
ue_header: *uw::_Unwind_Exception, ue_header: *mut uw::_Unwind_Exception,
context: *uw::_Unwind_Context context: *mut uw::_Unwind_Context
) -> uw::_Unwind_Reason_Code ) -> uw::_Unwind_Reason_Code
{ {
if (actions as c_int & uw::_UA_SEARCH_PHASE as c_int) != 0 { // search phase if (actions as c_int & uw::_UA_SEARCH_PHASE as c_int) != 0 { // search phase
@ -304,8 +304,8 @@ pub mod eabi {
fn __gcc_personality_sj0(version: c_int, fn __gcc_personality_sj0(version: c_int,
actions: uw::_Unwind_Action, actions: uw::_Unwind_Action,
exception_class: uw::_Unwind_Exception_Class, exception_class: uw::_Unwind_Exception_Class,
ue_header: *uw::_Unwind_Exception, ue_header: *mut uw::_Unwind_Exception,
context: *uw::_Unwind_Context) context: *mut uw::_Unwind_Context)
-> uw::_Unwind_Reason_Code; -> uw::_Unwind_Reason_Code;
} }
@ -315,8 +315,8 @@ pub mod eabi {
version: c_int, version: c_int,
actions: uw::_Unwind_Action, actions: uw::_Unwind_Action,
exception_class: uw::_Unwind_Exception_Class, exception_class: uw::_Unwind_Exception_Class,
ue_header: *uw::_Unwind_Exception, ue_header: *mut uw::_Unwind_Exception,
context: *uw::_Unwind_Context context: *mut uw::_Unwind_Context
) -> uw::_Unwind_Reason_Code ) -> uw::_Unwind_Reason_Code
{ {
unsafe { unsafe {
@ -330,8 +330,8 @@ pub mod eabi {
version: c_int, version: c_int,
actions: uw::_Unwind_Action, actions: uw::_Unwind_Action,
exception_class: uw::_Unwind_Exception_Class, exception_class: uw::_Unwind_Exception_Class,
ue_header: *uw::_Unwind_Exception, ue_header: *mut uw::_Unwind_Exception,
context: *uw::_Unwind_Context context: *mut uw::_Unwind_Context
) -> uw::_Unwind_Reason_Code ) -> uw::_Unwind_Reason_Code
{ {
if (actions as c_int & uw::_UA_SEARCH_PHASE as c_int) != 0 { // search phase if (actions as c_int & uw::_UA_SEARCH_PHASE as c_int) != 0 { // search phase
@ -357,16 +357,16 @@ pub mod eabi {
extern "C" { extern "C" {
fn __gcc_personality_v0(state: uw::_Unwind_State, fn __gcc_personality_v0(state: uw::_Unwind_State,
ue_header: *uw::_Unwind_Exception, ue_header: *mut uw::_Unwind_Exception,
context: *uw::_Unwind_Context) context: *mut uw::_Unwind_Context)
-> uw::_Unwind_Reason_Code; -> uw::_Unwind_Reason_Code;
} }
#[lang="eh_personality"] #[lang="eh_personality"]
extern "C" fn eh_personality( extern "C" fn eh_personality(
state: uw::_Unwind_State, state: uw::_Unwind_State,
ue_header: *uw::_Unwind_Exception, ue_header: *mut uw::_Unwind_Exception,
context: *uw::_Unwind_Context context: *mut uw::_Unwind_Context
) -> uw::_Unwind_Reason_Code ) -> uw::_Unwind_Reason_Code
{ {
unsafe { unsafe {
@ -377,8 +377,8 @@ pub mod eabi {
#[no_mangle] // referenced from rust_try.ll #[no_mangle] // referenced from rust_try.ll
pub extern "C" fn rust_eh_personality_catch( pub extern "C" fn rust_eh_personality_catch(
state: uw::_Unwind_State, state: uw::_Unwind_State,
ue_header: *uw::_Unwind_Exception, ue_header: *mut uw::_Unwind_Exception,
context: *uw::_Unwind_Context context: *mut uw::_Unwind_Context
) -> uw::_Unwind_Reason_Code ) -> uw::_Unwind_Reason_Code
{ {
if (state as c_int & uw::_US_ACTION_MASK as c_int) if (state as c_int & uw::_US_ACTION_MASK as c_int)

View file

@ -38,7 +38,7 @@ impl fmt::FormatWriter for Stdio {
unsafe { unsafe {
let Stdio(fd) = *self; let Stdio(fd) = *self;
libc::write(fd, libc::write(fd,
data.as_ptr() as *libc::c_void, data.as_ptr() as *const libc::c_void,
data.len() as WriteLen); data.len() as WriteLen);
} }
Ok(()) // yes, we're lying Ok(()) // yes, we're lying

View file

@ -11,7 +11,7 @@
use libc::c_int; use libc::c_int;
use libc; use libc;
use std::mem; use std::mem;
use std::ptr::null; use std::ptr::{null, mut_null};
use std::rt::task::BlockedTask; use std::rt::task::BlockedTask;
use std::rt::rtio; use std::rt::rtio;
@ -20,7 +20,7 @@ use super::{Loop, UvError, Request, wait_until_woken_after, wakeup};
use uvll; use uvll;
struct Addrinfo { struct Addrinfo {
handle: *libc::addrinfo, handle: *const libc::addrinfo,
} }
struct Ctx { struct Ctx {
@ -62,12 +62,14 @@ impl GetAddrInfoRequest {
ai_socktype: 0, ai_socktype: 0,
ai_protocol: 0, ai_protocol: 0,
ai_addrlen: 0, ai_addrlen: 0,
ai_canonname: null(), ai_canonname: mut_null(),
ai_addr: null(), ai_addr: mut_null(),
ai_next: null(), ai_next: mut_null(),
} }
}); });
let hint_ptr = hint.as_ref().map_or(null(), |x| x as *libc::addrinfo); let hint_ptr = hint.as_ref().map_or(null(), |x| {
x as *const libc::addrinfo
});
let mut req = Request::new(uvll::UV_GETADDRINFO); let mut req = Request::new(uvll::UV_GETADDRINFO);
return match unsafe { return match unsafe {
@ -80,7 +82,7 @@ impl GetAddrInfoRequest {
let mut cx = Ctx { slot: None, status: 0, addrinfo: None }; let mut cx = Ctx { slot: None, status: 0, addrinfo: None };
wait_until_woken_after(&mut cx.slot, loop_, || { wait_until_woken_after(&mut cx.slot, loop_, || {
req.set_data(&cx); req.set_data(&mut cx);
}); });
match cx.status { match cx.status {
@ -92,9 +94,9 @@ impl GetAddrInfoRequest {
}; };
extern fn getaddrinfo_cb(req: *uvll::uv_getaddrinfo_t, extern fn getaddrinfo_cb(req: *mut uvll::uv_getaddrinfo_t,
status: c_int, status: c_int,
res: *libc::addrinfo) { res: *const libc::addrinfo) {
let req = Request::wrap(req); let req = Request::wrap(req);
assert!(status != uvll::ECANCELED); assert!(status != uvll::ECANCELED);
let cx: &mut Ctx = unsafe { req.get_data() }; let cx: &mut Ctx = unsafe { req.get_data() };
@ -108,7 +110,7 @@ impl GetAddrInfoRequest {
impl Drop for Addrinfo { impl Drop for Addrinfo {
fn drop(&mut self) { fn drop(&mut self) {
unsafe { uvll::uv_freeaddrinfo(self.handle) } unsafe { uvll::uv_freeaddrinfo(self.handle as *mut _) }
} }
} }
@ -130,7 +132,7 @@ pub fn accum_addrinfo(addr: &Addrinfo) -> Vec<rtio::AddrinfoInfo> {
flags: 0, flags: 0,
}); });
if (*addr).ai_next.is_not_null() { if (*addr).ai_next.is_not_null() {
addr = (*addr).ai_next; addr = (*addr).ai_next as *const _;
} else { } else {
break; break;
} }

View file

@ -19,7 +19,7 @@ use super::{Loop, UvHandle};
// The entire point of async is to call into a loop from other threads so it // The entire point of async is to call into a loop from other threads so it
// does not need to home. // does not need to home.
pub struct AsyncWatcher { pub struct AsyncWatcher {
handle: *uvll::uv_async_t, handle: *mut uvll::uv_async_t,
// A flag to tell the callback to exit, set from the dtor. This is // A flag to tell the callback to exit, set from the dtor. This is
// almost never contested - only in rare races with the dtor. // almost never contested - only in rare races with the dtor.
@ -40,7 +40,7 @@ impl AsyncWatcher {
let flag = Arc::new(Exclusive::new(false)); let flag = Arc::new(Exclusive::new(false));
let payload = box Payload { callback: cb, exit_flag: flag.clone() }; let payload = box Payload { callback: cb, exit_flag: flag.clone() };
unsafe { unsafe {
let payload: *u8 = mem::transmute(payload); let payload: *mut u8 = mem::transmute(payload);
uvll::set_data_for_uv_handle(handle, payload); uvll::set_data_for_uv_handle(handle, payload);
} }
return AsyncWatcher { handle: handle, exit_flag: flag, }; return AsyncWatcher { handle: handle, exit_flag: flag, };
@ -48,13 +48,13 @@ impl AsyncWatcher {
} }
impl UvHandle<uvll::uv_async_t> for AsyncWatcher { impl UvHandle<uvll::uv_async_t> for AsyncWatcher {
fn uv_handle(&self) -> *uvll::uv_async_t { self.handle } fn uv_handle(&self) -> *mut uvll::uv_async_t { self.handle }
unsafe fn from_uv_handle<'a>(_: &'a *uvll::uv_async_t) -> &'a mut AsyncWatcher { unsafe fn from_uv_handle<'a>(_: &'a *mut uvll::uv_async_t) -> &'a mut AsyncWatcher {
fail!("async watchers can't be built from their handles"); fail!("async watchers can't be built from their handles");
} }
} }
extern fn async_cb(handle: *uvll::uv_async_t) { extern fn async_cb(handle: *mut uvll::uv_async_t) {
let payload: &mut Payload = unsafe { let payload: &mut Payload = unsafe {
mem::transmute(uvll::get_data_for_uv_handle(handle)) mem::transmute(uvll::get_data_for_uv_handle(handle))
}; };
@ -90,7 +90,7 @@ extern fn async_cb(handle: *uvll::uv_async_t) {
} }
} }
extern fn close_cb(handle: *uvll::uv_handle_t) { extern fn close_cb(handle: *mut uvll::uv_handle_t) {
// drop the payload // drop the payload
let _payload: Box<Payload> = unsafe { let _payload: Box<Payload> = unsafe {
mem::transmute(uvll::get_data_for_uv_handle(handle)) mem::transmute(uvll::get_data_for_uv_handle(handle))

View file

@ -24,7 +24,7 @@ use uvio::UvIoFactory;
use uvll; use uvll;
pub struct FsRequest { pub struct FsRequest {
req: *uvll::uv_fs_t, req: *mut uvll::uv_fs_t,
fired: bool, fired: bool,
} }
@ -94,7 +94,7 @@ impl FsRequest {
offset + written as i64 offset + written as i64
}; };
let uvbuf = uvll::uv_buf_t { let uvbuf = uvll::uv_buf_t {
base: buf.slice_from(written as uint).as_ptr(), base: buf.slice_from(written as uint).as_ptr() as *mut _,
len: (buf.len() - written) as uvll::uv_buf_len_t, len: (buf.len() - written) as uvll::uv_buf_len_t,
}; };
match execute(|req, cb| unsafe { match execute(|req, cb| unsafe {
@ -111,11 +111,11 @@ impl FsRequest {
-> Result<int, UvError> -> Result<int, UvError>
{ {
execute(|req, cb| unsafe { execute(|req, cb| unsafe {
let uvbuf = uvll::uv_buf_t { let mut uvbuf = uvll::uv_buf_t {
base: buf.as_ptr(), base: buf.as_mut_ptr(),
len: buf.len() as uvll::uv_buf_len_t, len: buf.len() as uvll::uv_buf_len_t,
}; };
uvll::uv_fs_read(loop_.handle, req, fd, &uvbuf, 1, offset, cb) uvll::uv_fs_read(loop_.handle, req, fd, &mut uvbuf, 1, offset, cb)
}).map(|req| { }).map(|req| {
req.get_result() as int req.get_result() as int
}) })
@ -168,7 +168,7 @@ impl FsRequest {
let mut paths = vec!(); let mut paths = vec!();
let path = CString::new(path.with_ref(|p| p), false); let path = CString::new(path.with_ref(|p| p), false);
let parent = Path::new(path); let parent = Path::new(path);
let _ = c_str::from_c_multistring(req.get_ptr() as *libc::c_char, let _ = c_str::from_c_multistring(req.get_ptr() as *const libc::c_char,
Some(req.get_result() as uint), Some(req.get_result() as uint),
|rel| { |rel| {
let p = rel.as_bytes(); let p = rel.as_bytes();
@ -186,7 +186,7 @@ impl FsRequest {
// Be sure to clone the cstring so we get an independently owned // Be sure to clone the cstring so we get an independently owned
// allocation to work with and return. // allocation to work with and return.
unsafe { unsafe {
CString::new(req.get_ptr() as *libc::c_char, false).clone() CString::new(req.get_ptr() as *const libc::c_char, false).clone()
} }
}) })
} }
@ -262,12 +262,12 @@ impl FsRequest {
} }
pub fn get_stat(&self) -> uvll::uv_stat_t { pub fn get_stat(&self) -> uvll::uv_stat_t {
let stat = uvll::uv_stat_t::new(); let mut stat = uvll::uv_stat_t::new();
unsafe { uvll::populate_stat(self.req, &stat); } unsafe { uvll::populate_stat(self.req, &mut stat); }
stat stat
} }
pub fn get_ptr(&self) -> *libc::c_void { pub fn get_ptr(&self) -> *mut libc::c_void {
unsafe { uvll::get_ptr_from_fs_req(self.req) } unsafe { uvll::get_ptr_from_fs_req(self.req) }
} }
@ -310,7 +310,7 @@ impl Drop for FsRequest {
} }
} }
fn execute(f: |*uvll::uv_fs_t, uvll::uv_fs_cb| -> c_int) fn execute(f: |*mut uvll::uv_fs_t, uvll::uv_fs_cb| -> c_int)
-> Result<FsRequest, UvError> -> Result<FsRequest, UvError>
{ {
let mut req = FsRequest { let mut req = FsRequest {
@ -323,7 +323,7 @@ fn execute(f: |*uvll::uv_fs_t, uvll::uv_fs_cb| -> c_int)
let mut slot = None; let mut slot = None;
let loop_ = unsafe { uvll::get_loop_from_fs_req(req.req) }; let loop_ = unsafe { uvll::get_loop_from_fs_req(req.req) };
wait_until_woken_after(&mut slot, &Loop::wrap(loop_), || { wait_until_woken_after(&mut slot, &Loop::wrap(loop_), || {
unsafe { uvll::set_data_for_req(req.req, &slot) } unsafe { uvll::set_data_for_req(req.req, &mut slot) }
}); });
match req.get_result() { match req.get_result() {
n if n < 0 => Err(UvError(n as i32)), n if n < 0 => Err(UvError(n as i32)),
@ -333,7 +333,7 @@ fn execute(f: |*uvll::uv_fs_t, uvll::uv_fs_cb| -> c_int)
n => Err(UvError(n)) n => Err(UvError(n))
}; };
extern fn fs_cb(req: *uvll::uv_fs_t) { extern fn fs_cb(req: *mut uvll::uv_fs_t) {
let slot: &mut Option<BlockedTask> = unsafe { let slot: &mut Option<BlockedTask> = unsafe {
mem::transmute(uvll::get_data_for_req(req)) mem::transmute(uvll::get_data_for_req(req))
}; };
@ -341,7 +341,7 @@ fn execute(f: |*uvll::uv_fs_t, uvll::uv_fs_cb| -> c_int)
} }
} }
fn execute_nop(f: |*uvll::uv_fs_t, uvll::uv_fs_cb| -> c_int) fn execute_nop(f: |*mut uvll::uv_fs_t, uvll::uv_fs_cb| -> c_int)
-> Result<(), UvError> { -> Result<(), UvError> {
execute(f).map(|_| {}) execute(f).map(|_| {})
} }
@ -397,7 +397,7 @@ impl Drop for FileWatcher {
self.fd, close_cb), 0); self.fd, close_cb), 0);
} }
extern fn close_cb(req: *uvll::uv_fs_t) { extern fn close_cb(req: *mut uvll::uv_fs_t) {
unsafe { unsafe {
uvll::uv_fs_req_cleanup(req); uvll::uv_fs_req_cleanup(req);
uvll::free_req(req); uvll::free_req(req);

View file

@ -16,7 +16,7 @@ use super::{Loop, UvHandle};
use std::rt::rtio::{Callback, PausableIdleCallback}; use std::rt::rtio::{Callback, PausableIdleCallback};
pub struct IdleWatcher { pub struct IdleWatcher {
handle: *uvll::uv_idle_t, handle: *mut uvll::uv_idle_t,
idle_flag: bool, idle_flag: bool,
callback: Box<Callback + Send>, callback: Box<Callback + Send>,
} }
@ -39,12 +39,12 @@ impl IdleWatcher {
let handle = UvHandle::alloc(None::<IdleWatcher>, uvll::UV_IDLE); let handle = UvHandle::alloc(None::<IdleWatcher>, uvll::UV_IDLE);
unsafe { unsafe {
assert_eq!(uvll::uv_idle_init(loop_.handle, handle), 0); assert_eq!(uvll::uv_idle_init(loop_.handle, handle), 0);
let data: *c_void = mem::transmute(box f); let data: *mut c_void = mem::transmute(box f);
uvll::set_data_for_uv_handle(handle, data); uvll::set_data_for_uv_handle(handle, data);
assert_eq!(uvll::uv_idle_start(handle, onetime_cb), 0) assert_eq!(uvll::uv_idle_start(handle, onetime_cb), 0)
} }
extern fn onetime_cb(handle: *uvll::uv_idle_t) { extern fn onetime_cb(handle: *mut uvll::uv_idle_t) {
unsafe { unsafe {
let data = uvll::get_data_for_uv_handle(handle); let data = uvll::get_data_for_uv_handle(handle);
let f: Box<proc()> = mem::transmute(data); let f: Box<proc()> = mem::transmute(data);
@ -54,7 +54,7 @@ impl IdleWatcher {
} }
} }
extern fn close_cb(handle: *uvll::uv_handle_t) { extern fn close_cb(handle: *mut uvll::uv_handle_t) {
unsafe { uvll::free_handle(handle) } unsafe { uvll::free_handle(handle) }
} }
} }
@ -76,10 +76,10 @@ impl PausableIdleCallback for IdleWatcher {
} }
impl UvHandle<uvll::uv_idle_t> for IdleWatcher { impl UvHandle<uvll::uv_idle_t> for IdleWatcher {
fn uv_handle(&self) -> *uvll::uv_idle_t { self.handle } fn uv_handle(&self) -> *mut uvll::uv_idle_t { self.handle }
} }
extern fn idle_cb(handle: *uvll::uv_idle_t) { extern fn idle_cb(handle: *mut uvll::uv_idle_t) {
let idle: &mut IdleWatcher = unsafe { UvHandle::from_uv_handle(&handle) }; let idle: &mut IdleWatcher = unsafe { UvHandle::from_uv_handle(&handle) };
idle.callback.call(); idle.callback.call();
} }

View file

@ -53,7 +53,6 @@ extern crate alloc;
use libc::{c_int, c_void}; use libc::{c_int, c_void};
use std::fmt; use std::fmt;
use std::mem; use std::mem;
use std::ptr::null;
use std::ptr; use std::ptr;
use std::rt::local::Local; use std::rt::local::Local;
use std::rt::rtio; use std::rt::rtio;
@ -78,7 +77,7 @@ pub use self::tty::TtyWatcher;
// threading mode than the default by reaching into the auto-generated // threading mode than the default by reaching into the auto-generated
// '__test' module. // '__test' module.
#[cfg(test)] #[start] #[cfg(test)] #[start]
fn start(argc: int, argv: **u8) -> int { fn start(argc: int, argv: *const *const u8) -> int {
green::start(argc, argv, event_loop, __test::main) green::start(argc, argv, event_loop, __test::main)
} }
@ -118,7 +117,7 @@ pub mod stream;
/// extern crate green; /// extern crate green;
/// ///
/// #[start] /// #[start]
/// fn start(argc: int, argv: **u8) -> int { /// fn start(argc: int, argv: *const *const u8) -> int {
/// green::start(argc, argv, rustuv::event_loop, main) /// green::start(argc, argv, rustuv::event_loop, main)
/// } /// }
/// ///
@ -132,28 +131,28 @@ pub fn event_loop() -> Box<rtio::EventLoop + Send> {
/// A type that wraps a uv handle /// A type that wraps a uv handle
pub trait UvHandle<T> { pub trait UvHandle<T> {
fn uv_handle(&self) -> *T; fn uv_handle(&self) -> *mut T;
fn uv_loop(&self) -> Loop { fn uv_loop(&self) -> Loop {
Loop::wrap(unsafe { uvll::get_loop_for_uv_handle(self.uv_handle()) }) Loop::wrap(unsafe { uvll::get_loop_for_uv_handle(self.uv_handle()) })
} }
// FIXME(#8888) dummy self // FIXME(#8888) dummy self
fn alloc(_: Option<Self>, ty: uvll::uv_handle_type) -> *T { fn alloc(_: Option<Self>, ty: uvll::uv_handle_type) -> *mut T {
unsafe { unsafe {
let handle = uvll::malloc_handle(ty); let handle = uvll::malloc_handle(ty);
assert!(!handle.is_null()); assert!(!handle.is_null());
handle as *T handle as *mut T
} }
} }
unsafe fn from_uv_handle<'a>(h: &'a *T) -> &'a mut Self { unsafe fn from_uv_handle<'a>(h: &'a *mut T) -> &'a mut Self {
mem::transmute(uvll::get_data_for_uv_handle(*h)) mem::transmute(uvll::get_data_for_uv_handle(*h))
} }
fn install(~self) -> Box<Self> { fn install(~self) -> Box<Self> {
unsafe { unsafe {
let myptr = mem::transmute::<&Box<Self>, &*u8>(&self); let myptr = mem::transmute::<&Box<Self>, &*mut u8>(&self);
uvll::set_data_for_uv_handle(self.uv_handle(), *myptr); uvll::set_data_for_uv_handle(self.uv_handle(), *myptr);
} }
self self
@ -162,13 +161,13 @@ pub trait UvHandle<T> {
fn close_async_(&mut self) { fn close_async_(&mut self) {
// we used malloc to allocate all handles, so we must always have at // we used malloc to allocate all handles, so we must always have at
// least a callback to free all the handles we allocated. // least a callback to free all the handles we allocated.
extern fn close_cb(handle: *uvll::uv_handle_t) { extern fn close_cb(handle: *mut uvll::uv_handle_t) {
unsafe { uvll::free_handle(handle) } unsafe { uvll::free_handle(handle) }
} }
unsafe { unsafe {
uvll::set_data_for_uv_handle(self.uv_handle(), null::<()>()); uvll::set_data_for_uv_handle(self.uv_handle(), ptr::mut_null::<()>());
uvll::uv_close(self.uv_handle() as *uvll::uv_handle_t, close_cb) uvll::uv_close(self.uv_handle() as *mut uvll::uv_handle_t, close_cb)
} }
} }
@ -176,19 +175,20 @@ pub trait UvHandle<T> {
let mut slot = None; let mut slot = None;
unsafe { unsafe {
uvll::uv_close(self.uv_handle() as *uvll::uv_handle_t, close_cb); uvll::uv_close(self.uv_handle() as *mut uvll::uv_handle_t, close_cb);
uvll::set_data_for_uv_handle(self.uv_handle(), ptr::null::<()>()); uvll::set_data_for_uv_handle(self.uv_handle(),
ptr::mut_null::<()>());
wait_until_woken_after(&mut slot, &self.uv_loop(), || { wait_until_woken_after(&mut slot, &self.uv_loop(), || {
uvll::set_data_for_uv_handle(self.uv_handle(), &slot); uvll::set_data_for_uv_handle(self.uv_handle(), &mut slot);
}) })
} }
extern fn close_cb(handle: *uvll::uv_handle_t) { extern fn close_cb(handle: *mut uvll::uv_handle_t) {
unsafe { unsafe {
let data = uvll::get_data_for_uv_handle(handle); let data = uvll::get_data_for_uv_handle(handle);
uvll::free_handle(handle); uvll::free_handle(handle);
if data == ptr::null() { return } if data == ptr::mut_null() { return }
let slot: &mut Option<BlockedTask> = mem::transmute(data); let slot: &mut Option<BlockedTask> = mem::transmute(data);
wakeup(slot); wakeup(slot);
} }
@ -261,7 +261,7 @@ fn wakeup(slot: &mut Option<BlockedTask>) {
} }
pub struct Request { pub struct Request {
pub handle: *uvll::uv_req_t, pub handle: *mut uvll::uv_req_t,
defused: bool, defused: bool,
} }
@ -269,22 +269,22 @@ impl Request {
pub fn new(ty: uvll::uv_req_type) -> Request { pub fn new(ty: uvll::uv_req_type) -> Request {
unsafe { unsafe {
let handle = uvll::malloc_req(ty); let handle = uvll::malloc_req(ty);
uvll::set_data_for_req(handle, null::<()>()); uvll::set_data_for_req(handle, ptr::mut_null::<()>());
Request::wrap(handle) Request::wrap(handle)
} }
} }
pub fn wrap(handle: *uvll::uv_req_t) -> Request { pub fn wrap(handle: *mut uvll::uv_req_t) -> Request {
Request { handle: handle, defused: false } Request { handle: handle, defused: false }
} }
pub fn set_data<T>(&self, t: *T) { pub fn set_data<T>(&self, t: *mut T) {
unsafe { uvll::set_data_for_req(self.handle, t) } unsafe { uvll::set_data_for_req(self.handle, t) }
} }
pub unsafe fn get_data<T>(&self) -> &'static mut T { pub unsafe fn get_data<T>(&self) -> &'static mut T {
let data = uvll::get_data_for_req(self.handle); let data = uvll::get_data_for_req(self.handle);
assert!(data != null()); assert!(data != ptr::mut_null());
mem::transmute(data) mem::transmute(data)
} }
@ -313,18 +313,18 @@ impl Drop for Request {
/// with dtors may not be destructured, but tuple structs can, /// with dtors may not be destructured, but tuple structs can,
/// but the results are not correct. /// but the results are not correct.
pub struct Loop { pub struct Loop {
handle: *uvll::uv_loop_t handle: *mut uvll::uv_loop_t
} }
impl Loop { impl Loop {
pub fn new() -> Loop { pub fn new() -> Loop {
let handle = unsafe { uvll::loop_new() }; let handle = unsafe { uvll::loop_new() };
assert!(handle.is_not_null()); assert!(handle.is_not_null());
unsafe { uvll::set_data_for_uv_loop(handle, 0 as *c_void) } unsafe { uvll::set_data_for_uv_loop(handle, 0 as *mut c_void) }
Loop::wrap(handle) Loop::wrap(handle)
} }
pub fn wrap(handle: *uvll::uv_loop_t) -> Loop { Loop { handle: handle } } pub fn wrap(handle: *mut uvll::uv_loop_t) -> Loop { Loop { handle: handle } }
pub fn run(&mut self) { pub fn run(&mut self) {
assert_eq!(unsafe { uvll::uv_run(self.handle, uvll::RUN_DEFAULT) }, 0); assert_eq!(unsafe { uvll::uv_run(self.handle, uvll::RUN_DEFAULT) }, 0);
@ -339,7 +339,7 @@ impl Loop {
fn modify_blockers(&self, amt: uint) { fn modify_blockers(&self, amt: uint) {
unsafe { unsafe {
let cur = uvll::get_data_for_uv_loop(self.handle) as uint; let cur = uvll::get_data_for_uv_loop(self.handle) as uint;
uvll::set_data_for_uv_loop(self.handle, (cur + amt) as *c_void) uvll::set_data_for_uv_loop(self.handle, (cur + amt) as *mut c_void)
} }
} }
@ -445,7 +445,7 @@ pub type Buf = uvll::uv_buf_t;
pub fn empty_buf() -> Buf { pub fn empty_buf() -> Buf {
uvll::uv_buf_t { uvll::uv_buf_t {
base: null(), base: ptr::mut_null(),
len: 0, len: 0,
} }
} }
@ -453,7 +453,7 @@ pub fn empty_buf() -> Buf {
/// Borrow a slice to a Buf /// Borrow a slice to a Buf
pub fn slice_to_uv_buf(v: &[u8]) -> Buf { pub fn slice_to_uv_buf(v: &[u8]) -> Buf {
let data = v.as_ptr(); let data = v.as_ptr();
uvll::uv_buf_t { base: data, len: v.len() as uvll::uv_buf_len_t } uvll::uv_buf_t { base: data as *mut u8, len: v.len() as uvll::uv_buf_len_t }
} }
// This function is full of lies! // This function is full of lies!
@ -512,7 +512,7 @@ mod test {
assert_eq!(buf.len, 20); assert_eq!(buf.len, 20);
unsafe { unsafe {
let base = transmute::<*u8, *mut u8>(buf.base); let base = transmute::<*mut u8, *mut u8>(buf.base);
(*base) = 1; (*base) = 1;
(*base.offset(1)) = 2; (*base.offset(1)) = 2;
} }

View file

@ -125,7 +125,7 @@ enum SocketNameKind {
} }
fn socket_name(sk: SocketNameKind, fn socket_name(sk: SocketNameKind,
handle: *c_void) -> Result<rtio::SocketAddr, IoError> { handle: *mut c_void) -> Result<rtio::SocketAddr, IoError> {
let getsockname = match sk { let getsockname = match sk {
TcpPeer => uvll::uv_tcp_getpeername, TcpPeer => uvll::uv_tcp_getpeername,
Tcp => uvll::uv_tcp_getsockname, Tcp => uvll::uv_tcp_getsockname,
@ -150,7 +150,7 @@ fn socket_name(sk: SocketNameKind,
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
pub struct TcpWatcher { pub struct TcpWatcher {
handle: *uvll::uv_tcp_t, handle: *mut uvll::uv_tcp_t,
stream: StreamWatcher, stream: StreamWatcher,
home: HomeHandle, home: HomeHandle,
refcount: Refcount, refcount: Refcount,
@ -165,7 +165,7 @@ pub struct TcpWatcher {
pub struct TcpListener { pub struct TcpListener {
home: HomeHandle, home: HomeHandle,
handle: *uvll::uv_pipe_t, handle: *mut uvll::uv_pipe_t,
outgoing: Sender<Result<Box<rtio::RtioTcpStream + Send>, IoError>>, outgoing: Sender<Result<Box<rtio::RtioTcpStream + Send>, IoError>>,
incoming: Receiver<Result<Box<rtio::RtioTcpStream + Send>, IoError>>, incoming: Receiver<Result<Box<rtio::RtioTcpStream + Send>, IoError>>,
} }
@ -204,7 +204,7 @@ impl TcpWatcher {
let tcp = TcpWatcher::new(io); let tcp = TcpWatcher::new(io);
let cx = ConnectCtx { status: -1, task: None, timer: None }; let cx = ConnectCtx { status: -1, task: None, timer: None };
let (addr, _len) = addr_to_sockaddr(address); let (addr, _len) = addr_to_sockaddr(address);
let addr_p = &addr as *_ as *libc::sockaddr; let addr_p = &addr as *const _ as *const libc::sockaddr;
cx.connect(tcp, timeout, io, |req, tcp, cb| { cx.connect(tcp, timeout, io, |req, tcp, cb| {
unsafe { uvll::uv_tcp_connect(req.handle, tcp.handle, addr_p, cb) } unsafe { uvll::uv_tcp_connect(req.handle, tcp.handle, addr_p, cb) }
}) })
@ -311,7 +311,7 @@ impl rtio::RtioTcpStream for TcpWatcher {
let _m = self.fire_homing_missile(); let _m = self.fire_homing_missile();
let loop_ = self.uv_loop(); let loop_ = self.uv_loop();
self.read_access.set_timeout(ms, &self.home, &loop_, cancel_read, self.read_access.set_timeout(ms, &self.home, &loop_, cancel_read,
&self.stream as *_ as uint); &self.stream as *const _ as uint);
fn cancel_read(stream: uint) -> Option<BlockedTask> { fn cancel_read(stream: uint) -> Option<BlockedTask> {
let stream: &mut StreamWatcher = unsafe { mem::transmute(stream) }; let stream: &mut StreamWatcher = unsafe { mem::transmute(stream) };
@ -323,7 +323,7 @@ impl rtio::RtioTcpStream for TcpWatcher {
let _m = self.fire_homing_missile(); let _m = self.fire_homing_missile();
let loop_ = self.uv_loop(); let loop_ = self.uv_loop();
self.write_access.set_timeout(ms, &self.home, &loop_, cancel_write, self.write_access.set_timeout(ms, &self.home, &loop_, cancel_write,
&self.stream as *_ as uint); &self.stream as *const _ as uint);
fn cancel_write(stream: uint) -> Option<BlockedTask> { fn cancel_write(stream: uint) -> Option<BlockedTask> {
let stream: &mut StreamWatcher = unsafe { mem::transmute(stream) }; let stream: &mut StreamWatcher = unsafe { mem::transmute(stream) };
@ -333,7 +333,7 @@ impl rtio::RtioTcpStream for TcpWatcher {
} }
impl UvHandle<uvll::uv_tcp_t> for TcpWatcher { impl UvHandle<uvll::uv_tcp_t> for TcpWatcher {
fn uv_handle(&self) -> *uvll::uv_tcp_t { self.stream.handle } fn uv_handle(&self) -> *mut uvll::uv_tcp_t { self.stream.handle }
} }
impl Drop for TcpWatcher { impl Drop for TcpWatcher {
@ -363,8 +363,8 @@ impl TcpListener {
}; };
let (addr, _len) = addr_to_sockaddr(address); let (addr, _len) = addr_to_sockaddr(address);
let res = unsafe { let res = unsafe {
let addr_p = &addr as *libc::sockaddr_storage; let addr_p = &addr as *const libc::sockaddr_storage;
uvll::uv_tcp_bind(l.handle, addr_p as *libc::sockaddr) uvll::uv_tcp_bind(l.handle, addr_p as *const libc::sockaddr)
}; };
return match res { return match res {
0 => Ok(l.install()), 0 => Ok(l.install()),
@ -378,7 +378,7 @@ impl HomingIO for TcpListener {
} }
impl UvHandle<uvll::uv_tcp_t> for TcpListener { impl UvHandle<uvll::uv_tcp_t> for TcpListener {
fn uv_handle(&self) -> *uvll::uv_tcp_t { self.handle } fn uv_handle(&self) -> *mut uvll::uv_tcp_t { self.handle }
} }
impl rtio::RtioSocket for TcpListener { impl rtio::RtioSocket for TcpListener {
@ -405,7 +405,7 @@ impl rtio::RtioTcpListener for TcpListener {
} }
} }
extern fn listen_cb(server: *uvll::uv_stream_t, status: c_int) { extern fn listen_cb(server: *mut uvll::uv_stream_t, status: c_int) {
assert!(status != uvll::ECANCELED); assert!(status != uvll::ECANCELED);
let tcp: &mut TcpListener = unsafe { UvHandle::from_uv_handle(&server) }; let tcp: &mut TcpListener = unsafe { UvHandle::from_uv_handle(&server) };
let msg = match status { let msg = match status {
@ -475,7 +475,7 @@ impl rtio::RtioTcpAcceptor for TcpAcceptor {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
pub struct UdpWatcher { pub struct UdpWatcher {
handle: *uvll::uv_udp_t, handle: *mut uvll::uv_udp_t,
home: HomeHandle, home: HomeHandle,
// See above for what these fields are // See above for what these fields are
@ -514,8 +514,8 @@ impl UdpWatcher {
}, 0); }, 0);
let (addr, _len) = addr_to_sockaddr(address); let (addr, _len) = addr_to_sockaddr(address);
let result = unsafe { let result = unsafe {
let addr_p = &addr as *libc::sockaddr_storage; let addr_p = &addr as *const libc::sockaddr_storage;
uvll::uv_udp_bind(udp.handle, addr_p as *libc::sockaddr, 0u32) uvll::uv_udp_bind(udp.handle, addr_p as *const libc::sockaddr, 0u32)
}; };
return match result { return match result {
0 => Ok(udp), 0 => Ok(udp),
@ -525,7 +525,7 @@ impl UdpWatcher {
} }
impl UvHandle<uvll::uv_udp_t> for UdpWatcher { impl UvHandle<uvll::uv_udp_t> for UdpWatcher {
fn uv_handle(&self) -> *uvll::uv_udp_t { self.handle } fn uv_handle(&self) -> *mut uvll::uv_udp_t { self.handle }
} }
impl HomingIO for UdpWatcher { impl HomingIO for UdpWatcher {
@ -558,7 +558,7 @@ impl rtio::RtioUdpSocket for UdpWatcher {
}; };
let handle = self.handle; let handle = self.handle;
wait_until_woken_after(&mut cx.task, &loop_, || { wait_until_woken_after(&mut cx.task, &loop_, || {
unsafe { uvll::set_data_for_uv_handle(handle, &cx) } unsafe { uvll::set_data_for_uv_handle(handle, &mut cx) }
}); });
match cx.result.take_unwrap() { match cx.result.take_unwrap() {
(n, _) if n < 0 => (n, _) if n < 0 =>
@ -569,7 +569,7 @@ impl rtio::RtioUdpSocket for UdpWatcher {
n => Err(uv_error_to_io_error(UvError(n))) n => Err(uv_error_to_io_error(UvError(n)))
}; };
extern fn alloc_cb(handle: *uvll::uv_udp_t, extern fn alloc_cb(handle: *mut uvll::uv_udp_t,
_suggested_size: size_t, _suggested_size: size_t,
buf: *mut Buf) { buf: *mut Buf) {
unsafe { unsafe {
@ -579,8 +579,9 @@ impl rtio::RtioUdpSocket for UdpWatcher {
} }
} }
extern fn recv_cb(handle: *uvll::uv_udp_t, nread: ssize_t, buf: *Buf, extern fn recv_cb(handle: *mut uvll::uv_udp_t, nread: ssize_t,
addr: *libc::sockaddr, _flags: c_uint) { buf: *const Buf,
addr: *const libc::sockaddr, _flags: c_uint) {
assert!(nread != uvll::ECANCELED as ssize_t); assert!(nread != uvll::ECANCELED as ssize_t);
let cx = unsafe { let cx = unsafe {
&mut *(uvll::get_data_for_uv_handle(handle) as *mut UdpRecvCtx) &mut *(uvll::get_data_for_uv_handle(handle) as *mut UdpRecvCtx)
@ -613,7 +614,7 @@ impl rtio::RtioUdpSocket for UdpWatcher {
let mut req = Request::new(uvll::UV_UDP_SEND); let mut req = Request::new(uvll::UV_UDP_SEND);
let (addr, _len) = addr_to_sockaddr(dst); let (addr, _len) = addr_to_sockaddr(dst);
let addr_p = &addr as *_ as *libc::sockaddr; let addr_p = &addr as *const _ as *const libc::sockaddr;
// see comments in StreamWatcher::write for why we may allocate a buffer // see comments in StreamWatcher::write for why we may allocate a buffer
// here. // here.
@ -633,7 +634,7 @@ impl rtio::RtioUdpSocket for UdpWatcher {
result: uvll::ECANCELED, data: data, udp: self as *mut _ result: uvll::ECANCELED, data: data, udp: self as *mut _
}; };
wait_until_woken_after(&mut self.blocked_sender, &loop_, || { wait_until_woken_after(&mut self.blocked_sender, &loop_, || {
req.set_data(&cx); req.set_data(&mut cx);
}); });
if cx.result != uvll::ECANCELED { if cx.result != uvll::ECANCELED {
@ -642,13 +643,13 @@ impl rtio::RtioUdpSocket for UdpWatcher {
n => Err(uv_error_to_io_error(UvError(n))) n => Err(uv_error_to_io_error(UvError(n)))
} }
} }
let new_cx = box UdpSendCtx { let mut new_cx = box UdpSendCtx {
result: 0, result: 0,
udp: 0 as *mut UdpWatcher, udp: 0 as *mut UdpWatcher,
data: cx.data.take(), data: cx.data.take(),
}; };
unsafe { unsafe {
req.set_data(&*new_cx); req.set_data(&mut *new_cx);
mem::forget(new_cx); mem::forget(new_cx);
} }
Err(uv_error_to_io_error(UvError(cx.result))) Err(uv_error_to_io_error(UvError(cx.result)))
@ -658,7 +659,7 @@ impl rtio::RtioUdpSocket for UdpWatcher {
// This function is the same as stream::write_cb, but adapted for udp // This function is the same as stream::write_cb, but adapted for udp
// instead of streams. // instead of streams.
extern fn send_cb(req: *uvll::uv_udp_send_t, status: c_int) { extern fn send_cb(req: *mut uvll::uv_udp_send_t, status: c_int) {
let req = Request::wrap(req); let req = Request::wrap(req);
let cx: &mut UdpSendCtx = unsafe { req.get_data() }; let cx: &mut UdpSendCtx = unsafe { req.get_data() };
cx.result = status; cx.result = status;
@ -766,12 +767,12 @@ impl rtio::RtioUdpSocket for UdpWatcher {
fn cancel_read(stream: uint) -> Option<BlockedTask> { fn cancel_read(stream: uint) -> Option<BlockedTask> {
// This method is quite similar to StreamWatcher::cancel_read, see // This method is quite similar to StreamWatcher::cancel_read, see
// there for more information // there for more information
let handle = stream as *uvll::uv_udp_t; let handle = stream as *mut uvll::uv_udp_t;
assert_eq!(unsafe { uvll::uv_udp_recv_stop(handle) }, 0); assert_eq!(unsafe { uvll::uv_udp_recv_stop(handle) }, 0);
let data = unsafe { let data = unsafe {
let data = uvll::get_data_for_uv_handle(handle); let data = uvll::get_data_for_uv_handle(handle);
if data.is_null() { return None } if data.is_null() { return None }
uvll::set_data_for_uv_handle(handle, 0 as *int); uvll::set_data_for_uv_handle(handle, 0 as *mut int);
&mut *(data as *mut UdpRecvCtx) &mut *(data as *mut UdpRecvCtx)
}; };
data.result = Some((uvll::ECANCELED as ssize_t, None)); data.result = Some((uvll::ECANCELED as ssize_t, None));
@ -806,7 +807,7 @@ impl Drop for UdpWatcher {
// Shutdown helper // Shutdown helper
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
pub fn shutdown(handle: *uvll::uv_stream_t, loop_: &Loop) -> Result<(), IoError> { pub fn shutdown(handle: *mut uvll::uv_stream_t, loop_: &Loop) -> Result<(), IoError> {
struct Ctx { struct Ctx {
slot: Option<BlockedTask>, slot: Option<BlockedTask>,
status: c_int, status: c_int,
@ -819,7 +820,7 @@ pub fn shutdown(handle: *uvll::uv_stream_t, loop_: &Loop) -> Result<(), IoError>
let mut cx = Ctx { slot: None, status: 0 }; let mut cx = Ctx { slot: None, status: 0 };
wait_until_woken_after(&mut cx.slot, loop_, || { wait_until_woken_after(&mut cx.slot, loop_, || {
req.set_data(&cx); req.set_data(&mut cx);
}); });
status_to_io_result(cx.status) status_to_io_result(cx.status)
@ -827,7 +828,7 @@ pub fn shutdown(handle: *uvll::uv_stream_t, loop_: &Loop) -> Result<(), IoError>
n => Err(uv_error_to_io_error(UvError(n))) n => Err(uv_error_to_io_error(UvError(n)))
}; };
extern fn shutdown_cb(req: *uvll::uv_shutdown_t, status: libc::c_int) { extern fn shutdown_cb(req: *mut uvll::uv_shutdown_t, status: libc::c_int) {
let req = Request::wrap(req); let req = Request::wrap(req);
assert!(status != uvll::ECANCELED); assert!(status != uvll::ECANCELED);
let cx: &mut Ctx = unsafe { req.get_data() }; let cx: &mut Ctx = unsafe { req.get_data() };

View file

@ -37,7 +37,7 @@ pub struct PipeWatcher {
pub struct PipeListener { pub struct PipeListener {
home: HomeHandle, home: HomeHandle,
pipe: *uvll::uv_pipe_t, pipe: *mut uvll::uv_pipe_t,
outgoing: Sender<IoResult<Box<rtio::RtioPipe + Send>>>, outgoing: Sender<IoResult<Box<rtio::RtioPipe + Send>>>,
incoming: Receiver<IoResult<Box<rtio::RtioPipe + Send>>>, incoming: Receiver<IoResult<Box<rtio::RtioPipe + Send>>>,
} }
@ -100,11 +100,11 @@ impl PipeWatcher {
}) })
} }
pub fn handle(&self) -> *uvll::uv_pipe_t { self.stream.handle } pub fn handle(&self) -> *mut uvll::uv_pipe_t { self.stream.handle }
// Unwraps the underlying uv pipe. This cancels destruction of the pipe and // Unwraps the underlying uv pipe. This cancels destruction of the pipe and
// allows the pipe to get moved elsewhere // allows the pipe to get moved elsewhere
fn unwrap(mut self) -> *uvll::uv_pipe_t { fn unwrap(mut self) -> *mut uvll::uv_pipe_t {
self.defused = true; self.defused = true;
return self.stream.handle; return self.stream.handle;
} }
@ -181,7 +181,7 @@ impl rtio::RtioPipe for PipeWatcher {
let _m = self.fire_homing_missile(); let _m = self.fire_homing_missile();
let loop_ = self.uv_loop(); let loop_ = self.uv_loop();
self.read_access.set_timeout(ms, &self.home, &loop_, cancel_read, self.read_access.set_timeout(ms, &self.home, &loop_, cancel_read,
&self.stream as *_ as uint); &self.stream as *const _ as uint);
fn cancel_read(stream: uint) -> Option<BlockedTask> { fn cancel_read(stream: uint) -> Option<BlockedTask> {
let stream: &mut StreamWatcher = unsafe { mem::transmute(stream) }; let stream: &mut StreamWatcher = unsafe { mem::transmute(stream) };
@ -193,7 +193,7 @@ impl rtio::RtioPipe for PipeWatcher {
let _m = self.fire_homing_missile(); let _m = self.fire_homing_missile();
let loop_ = self.uv_loop(); let loop_ = self.uv_loop();
self.write_access.set_timeout(ms, &self.home, &loop_, cancel_write, self.write_access.set_timeout(ms, &self.home, &loop_, cancel_write,
&self.stream as *_ as uint); &self.stream as *const _ as uint);
fn cancel_write(stream: uint) -> Option<BlockedTask> { fn cancel_write(stream: uint) -> Option<BlockedTask> {
let stream: &mut StreamWatcher = unsafe { mem::transmute(stream) }; let stream: &mut StreamWatcher = unsafe { mem::transmute(stream) };
@ -207,7 +207,7 @@ impl HomingIO for PipeWatcher {
} }
impl UvHandle<uvll::uv_pipe_t> for PipeWatcher { impl UvHandle<uvll::uv_pipe_t> for PipeWatcher {
fn uv_handle(&self) -> *uvll::uv_pipe_t { self.stream.handle } fn uv_handle(&self) -> *mut uvll::uv_pipe_t { self.stream.handle }
} }
impl Drop for PipeWatcher { impl Drop for PipeWatcher {
@ -269,10 +269,10 @@ impl HomingIO for PipeListener {
} }
impl UvHandle<uvll::uv_pipe_t> for PipeListener { impl UvHandle<uvll::uv_pipe_t> for PipeListener {
fn uv_handle(&self) -> *uvll::uv_pipe_t { self.pipe } fn uv_handle(&self) -> *mut uvll::uv_pipe_t { self.pipe }
} }
extern fn listen_cb(server: *uvll::uv_stream_t, status: libc::c_int) { extern fn listen_cb(server: *mut uvll::uv_stream_t, status: libc::c_int) {
assert!(status != uvll::ECANCELED); assert!(status != uvll::ECANCELED);
let pipe: &mut PipeListener = unsafe { UvHandle::from_uv_handle(&server) }; let pipe: &mut PipeListener = unsafe { UvHandle::from_uv_handle(&server) };

View file

@ -25,7 +25,7 @@ use uvio::UvIoFactory;
use uvll; use uvll;
pub struct Process { pub struct Process {
handle: *uvll::uv_process_t, handle: *mut uvll::uv_process_t,
home: HomeHandle, home: HomeHandle,
/// Task to wake up (may be null) for when the process exits /// Task to wake up (may be null) for when the process exits
@ -60,8 +60,8 @@ impl Process {
let mut ret_io = Vec::with_capacity(io.len()); let mut ret_io = Vec::with_capacity(io.len());
unsafe { unsafe {
stdio.set_len(io.len()); stdio.set_len(io.len());
for (slot, other) in stdio.iter().zip(io.iter()) { for (slot, other) in stdio.mut_iter().zip(io.iter()) {
let io = set_stdio(slot as *uvll::uv_stdio_container_t, other, let io = set_stdio(slot as *mut uvll::uv_stdio_container_t, other,
io_loop); io_loop);
ret_io.push(io); ret_io.push(io);
} }
@ -79,7 +79,7 @@ impl Process {
if cfg.detach { if cfg.detach {
flags |= uvll::PROCESS_DETACHED; flags |= uvll::PROCESS_DETACHED;
} }
let options = uvll::uv_process_options_t { let mut options = uvll::uv_process_options_t {
exit_cb: on_exit, exit_cb: on_exit,
file: unsafe { *argv }, file: unsafe { *argv },
args: argv, args: argv,
@ -90,7 +90,7 @@ impl Process {
}, },
flags: flags as libc::c_uint, flags: flags as libc::c_uint,
stdio_count: stdio.len() as libc::c_int, stdio_count: stdio.len() as libc::c_int,
stdio: stdio.as_ptr(), stdio: stdio.as_mut_ptr(),
uid: cfg.uid.unwrap_or(0) as uvll::uv_uid_t, uid: cfg.uid.unwrap_or(0) as uvll::uv_uid_t,
gid: cfg.gid.unwrap_or(0) as uvll::uv_gid_t, gid: cfg.gid.unwrap_or(0) as uvll::uv_gid_t,
}; };
@ -105,7 +105,7 @@ impl Process {
timeout_state: NoTimeout, timeout_state: NoTimeout,
}; };
match unsafe { match unsafe {
uvll::uv_spawn(io_loop.uv_loop(), handle, &options) uvll::uv_spawn(io_loop.uv_loop(), handle, &mut options)
} { } {
0 => Ok(process.install()), 0 => Ok(process.install()),
err => Err(UvError(err)), err => Err(UvError(err)),
@ -129,7 +129,7 @@ impl Process {
} }
} }
extern fn on_exit(handle: *uvll::uv_process_t, extern fn on_exit(handle: *mut uvll::uv_process_t,
exit_status: i64, exit_status: i64,
term_signal: libc::c_int) { term_signal: libc::c_int) {
let p: &mut Process = unsafe { UvHandle::from_uv_handle(&handle) }; let p: &mut Process = unsafe { UvHandle::from_uv_handle(&handle) };
@ -144,7 +144,7 @@ extern fn on_exit(handle: *uvll::uv_process_t,
wakeup(&mut p.to_wake); wakeup(&mut p.to_wake);
} }
unsafe fn set_stdio(dst: *uvll::uv_stdio_container_t, unsafe fn set_stdio(dst: *mut uvll::uv_stdio_container_t,
io: &rtio::StdioContainer, io: &rtio::StdioContainer,
io_loop: &mut UvIoFactory) -> Option<PipeWatcher> { io_loop: &mut UvIoFactory) -> Option<PipeWatcher> {
match *io { match *io {
@ -174,8 +174,9 @@ unsafe fn set_stdio(dst: *uvll::uv_stdio_container_t,
} }
/// Converts the program and arguments to the argv array expected by libuv. /// Converts the program and arguments to the argv array expected by libuv.
fn with_argv<T>(prog: &CString, args: &[CString], cb: |**libc::c_char| -> T) -> T { fn with_argv<T>(prog: &CString, args: &[CString],
let mut ptrs: Vec<*libc::c_char> = Vec::with_capacity(args.len()+1); cb: |*const *const libc::c_char| -> T) -> T {
let mut ptrs: Vec<*const libc::c_char> = Vec::with_capacity(args.len()+1);
// Convert the CStrings into an array of pointers. Note: the // Convert the CStrings into an array of pointers. Note: the
// lifetime of the various CStrings involved is guaranteed to be // lifetime of the various CStrings involved is guaranteed to be
@ -192,7 +193,8 @@ fn with_argv<T>(prog: &CString, args: &[CString], cb: |**libc::c_char| -> T) ->
} }
/// Converts the environment to the env array expected by libuv /// Converts the environment to the env array expected by libuv
fn with_env<T>(env: Option<&[(CString, CString)]>, cb: |**libc::c_char| -> T) -> T { fn with_env<T>(env: Option<&[(CString, CString)]>,
cb: |*const *const libc::c_char| -> T) -> T {
// We can pass a char** for envp, which is a null-terminated array // We can pass a char** for envp, which is a null-terminated array
// of "k=v\0" strings. Since we must create these strings locally, // of "k=v\0" strings. Since we must create these strings locally,
// yet expose a raw pointer to them, we create a temporary vector // yet expose a raw pointer to them, we create a temporary vector
@ -210,9 +212,9 @@ fn with_env<T>(env: Option<&[(CString, CString)]>, cb: |**libc::c_char| -> T) ->
} }
// As with `with_argv`, this is unsafe, since cb could leak the pointers. // As with `with_argv`, this is unsafe, since cb could leak the pointers.
let mut ptrs: Vec<*libc::c_char> = let mut ptrs: Vec<*const libc::c_char> =
tmps.iter() tmps.iter()
.map(|tmp| tmp.as_ptr() as *libc::c_char) .map(|tmp| tmp.as_ptr() as *const libc::c_char)
.collect(); .collect();
ptrs.push(ptr::null()); ptrs.push(ptr::null());
@ -227,7 +229,7 @@ impl HomingIO for Process {
} }
impl UvHandle<uvll::uv_process_t> for Process { impl UvHandle<uvll::uv_process_t> for Process {
fn uv_handle(&self) -> *uvll::uv_process_t { self.handle } fn uv_handle(&self) -> *mut uvll::uv_process_t { self.handle }
} }
impl rtio::RtioProcess for Process { impl rtio::RtioProcess for Process {
@ -290,7 +292,7 @@ impl rtio::RtioProcess for Process {
}); });
let mut timer = box TimerWatcher::new_home(&loop_, self.home().clone()); let mut timer = box TimerWatcher::new_home(&loop_, self.home().clone());
unsafe { unsafe {
timer.set_data(self as *mut _ as *Process); timer.set_data(self as *mut _);
} }
self.timer = Some(timer); self.timer = Some(timer);
} }
@ -300,7 +302,7 @@ impl rtio::RtioProcess for Process {
timer.start(timer_cb, ms, 0); timer.start(timer_cb, ms, 0);
self.timeout_state = TimeoutPending; self.timeout_state = TimeoutPending;
extern fn timer_cb(timer: *uvll::uv_timer_t) { extern fn timer_cb(timer: *mut uvll::uv_timer_t) {
let p: &mut Process = unsafe { let p: &mut Process = unsafe {
&mut *(uvll::get_data_for_uv_handle(timer) as *mut Process) &mut *(uvll::get_data_for_uv_handle(timer) as *mut Process)
}; };

View file

@ -38,7 +38,7 @@ enum Message {
} }
struct State { struct State {
handle: *uvll::uv_async_t, handle: *mut uvll::uv_async_t,
lock: NativeMutex, // see comments in async_cb for why this is needed lock: NativeMutex, // see comments in async_cb for why this is needed
queue: mpsc::Queue<Message>, queue: mpsc::Queue<Message>,
} }
@ -55,7 +55,7 @@ pub struct Queue {
queue: Arc<State>, queue: Arc<State>,
} }
extern fn async_cb(handle: *uvll::uv_async_t) { extern fn async_cb(handle: *mut uvll::uv_async_t) {
let pool: &mut QueuePool = unsafe { let pool: &mut QueuePool = unsafe {
mem::transmute(uvll::get_data_for_uv_handle(handle)) mem::transmute(uvll::get_data_for_uv_handle(handle))
}; };
@ -114,7 +114,7 @@ impl QueuePool {
lock: unsafe {NativeMutex::new()}, lock: unsafe {NativeMutex::new()},
queue: mpsc::Queue::new(), queue: mpsc::Queue::new(),
}); });
let q = box QueuePool { let mut q = box QueuePool {
refcnt: 0, refcnt: 0,
queue: state, queue: state,
}; };
@ -122,7 +122,7 @@ impl QueuePool {
unsafe { unsafe {
assert_eq!(uvll::uv_async_init(loop_.handle, handle, async_cb), 0); assert_eq!(uvll::uv_async_init(loop_.handle, handle, async_cb), 0);
uvll::uv_unref(handle); uvll::uv_unref(handle);
let data = &*q as *QueuePool as *c_void; let data = &mut *q as *mut QueuePool as *mut c_void;
uvll::set_data_for_uv_handle(handle, data); uvll::set_data_for_uv_handle(handle, data);
} }
@ -139,7 +139,7 @@ impl QueuePool {
Queue { queue: self.queue.clone() } Queue { queue: self.queue.clone() }
} }
pub fn handle(&self) -> *uvll::uv_async_t { self.queue.handle } pub fn handle(&self) -> *mut uvll::uv_async_t { self.queue.handle }
} }
impl Queue { impl Queue {

View file

@ -17,7 +17,7 @@ use uvll;
use uvio::UvIoFactory; use uvio::UvIoFactory;
pub struct SignalWatcher { pub struct SignalWatcher {
handle: *uvll::uv_signal_t, handle: *mut uvll::uv_signal_t,
home: HomeHandle, home: HomeHandle,
cb: Box<Callback + Send>, cb: Box<Callback + Send>,
@ -45,7 +45,7 @@ impl SignalWatcher {
} }
} }
extern fn signal_cb(handle: *uvll::uv_signal_t, _signum: c_int) { extern fn signal_cb(handle: *mut uvll::uv_signal_t, _signum: c_int) {
let s: &mut SignalWatcher = unsafe { UvHandle::from_uv_handle(&handle) }; let s: &mut SignalWatcher = unsafe { UvHandle::from_uv_handle(&handle) };
let _ = s.cb.call(); let _ = s.cb.call();
} }
@ -55,7 +55,7 @@ impl HomingIO for SignalWatcher {
} }
impl UvHandle<uvll::uv_signal_t> for SignalWatcher { impl UvHandle<uvll::uv_signal_t> for SignalWatcher {
fn uv_handle(&self) -> *uvll::uv_signal_t { self.handle } fn uv_handle(&self) -> *mut uvll::uv_signal_t { self.handle }
} }
impl RtioSignal for SignalWatcher {} impl RtioSignal for SignalWatcher {}

View file

@ -23,7 +23,7 @@ use uvll;
// uv_stream_t instance, and all I/O operations assume that it's already located // uv_stream_t instance, and all I/O operations assume that it's already located
// on the appropriate scheduler. // on the appropriate scheduler.
pub struct StreamWatcher { pub struct StreamWatcher {
pub handle: *uvll::uv_stream_t, pub handle: *mut uvll::uv_stream_t,
// Cache the last used uv_write_t so we don't have to allocate a new one on // Cache the last used uv_write_t so we don't have to allocate a new one on
// every call to uv_write(). Ideally this would be a stack-allocated // every call to uv_write(). Ideally this would be a stack-allocated
@ -59,8 +59,8 @@ impl StreamWatcher {
// will be manipulated on each of the methods called on this watcher. // will be manipulated on each of the methods called on this watcher.
// Wrappers should ensure to always reset the field to an appropriate value // Wrappers should ensure to always reset the field to an appropriate value
// if they rely on the field to perform an action. // if they rely on the field to perform an action.
pub fn new(stream: *uvll::uv_stream_t) -> StreamWatcher { pub fn new(stream: *mut uvll::uv_stream_t) -> StreamWatcher {
unsafe { uvll::set_data_for_uv_handle(stream, 0 as *int) } unsafe { uvll::set_data_for_uv_handle(stream, 0 as *mut int) }
StreamWatcher { StreamWatcher {
handle: stream, handle: stream,
last_write_req: None, last_write_req: None,
@ -85,7 +85,7 @@ impl StreamWatcher {
// we must be ready for this to happen (by setting the data in the uv // we must be ready for this to happen (by setting the data in the uv
// handle). In theory this otherwise doesn't need to happen until after // handle). In theory this otherwise doesn't need to happen until after
// the read is succesfully started. // the read is succesfully started.
unsafe { uvll::set_data_for_uv_handle(self.handle, &rcx) } unsafe { uvll::set_data_for_uv_handle(self.handle, &mut rcx) }
// Send off the read request, but don't block until we're sure that the // Send off the read request, but don't block until we're sure that the
// read request is queued. // read request is queued.
@ -103,7 +103,7 @@ impl StreamWatcher {
n => Err(UvError(n)) n => Err(UvError(n))
}; };
// Make sure a read cancellation sees that there's no pending read // Make sure a read cancellation sees that there's no pending read
unsafe { uvll::set_data_for_uv_handle(self.handle, 0 as *int) } unsafe { uvll::set_data_for_uv_handle(self.handle, 0 as *mut int) }
return ret; return ret;
} }
@ -115,7 +115,7 @@ impl StreamWatcher {
let data = unsafe { let data = unsafe {
let data = uvll::get_data_for_uv_handle(self.handle); let data = uvll::get_data_for_uv_handle(self.handle);
if data.is_null() { return None } if data.is_null() { return None }
uvll::set_data_for_uv_handle(self.handle, 0 as *int); uvll::set_data_for_uv_handle(self.handle, 0 as *mut int);
&mut *(data as *mut ReadContext) &mut *(data as *mut ReadContext)
}; };
data.result = reason; data.result = reason;
@ -133,7 +133,7 @@ impl StreamWatcher {
let mut req = match self.last_write_req.take() { let mut req = match self.last_write_req.take() {
Some(req) => req, None => Request::new(uvll::UV_WRITE), Some(req) => req, None => Request::new(uvll::UV_WRITE),
}; };
req.set_data(ptr::null::<()>()); req.set_data(ptr::mut_null::<()>());
// And here's where timeouts get a little interesting. Currently, libuv // And here's where timeouts get a little interesting. Currently, libuv
// does not support canceling an in-flight write request. Consequently, // does not support canceling an in-flight write request. Consequently,
@ -180,7 +180,7 @@ impl StreamWatcher {
let loop_ = unsafe { uvll::get_loop_for_uv_handle(self.handle) }; let loop_ = unsafe { uvll::get_loop_for_uv_handle(self.handle) };
wait_until_woken_after(&mut self.blocked_writer, wait_until_woken_after(&mut self.blocked_writer,
&Loop::wrap(loop_), || { &Loop::wrap(loop_), || {
req.set_data(&wcx); req.set_data(&mut wcx);
}); });
if wcx.result != uvll::ECANCELED { if wcx.result != uvll::ECANCELED {
@ -205,13 +205,13 @@ impl StreamWatcher {
// Note that we don't cache this write request back in the // Note that we don't cache this write request back in the
// stream watcher because we no longer have ownership of it, and // stream watcher because we no longer have ownership of it, and
// we never will. // we never will.
let new_wcx = box WriteContext { let mut new_wcx = box WriteContext {
result: 0, result: 0,
stream: 0 as *mut StreamWatcher, stream: 0 as *mut StreamWatcher,
data: wcx.data.take(), data: wcx.data.take(),
}; };
unsafe { unsafe {
req.set_data(&*new_wcx); req.set_data(&mut *new_wcx);
mem::forget(new_wcx); mem::forget(new_wcx);
} }
Err(UvError(wcx.result)) Err(UvError(wcx.result))
@ -228,7 +228,7 @@ impl StreamWatcher {
// This allocation callback expects to be invoked once and only once. It will // This allocation callback expects to be invoked once and only once. It will
// unwrap the buffer in the ReadContext stored in the stream and return it. This // unwrap the buffer in the ReadContext stored in the stream and return it. This
// will fail if it is called more than once. // will fail if it is called more than once.
extern fn alloc_cb(stream: *uvll::uv_stream_t, _hint: size_t, buf: *mut Buf) { extern fn alloc_cb(stream: *mut uvll::uv_stream_t, _hint: size_t, buf: *mut Buf) {
uvdebug!("alloc_cb"); uvdebug!("alloc_cb");
unsafe { unsafe {
let rcx: &mut ReadContext = let rcx: &mut ReadContext =
@ -239,7 +239,8 @@ extern fn alloc_cb(stream: *uvll::uv_stream_t, _hint: size_t, buf: *mut Buf) {
// When a stream has read some data, we will always forcibly stop reading and // When a stream has read some data, we will always forcibly stop reading and
// return all the data read (even if it didn't fill the whole buffer). // return all the data read (even if it didn't fill the whole buffer).
extern fn read_cb(handle: *uvll::uv_stream_t, nread: ssize_t, _buf: *Buf) { extern fn read_cb(handle: *mut uvll::uv_stream_t, nread: ssize_t,
_buf: *const Buf) {
uvdebug!("read_cb {}", nread); uvdebug!("read_cb {}", nread);
assert!(nread != uvll::ECANCELED as ssize_t); assert!(nread != uvll::ECANCELED as ssize_t);
let rcx: &mut ReadContext = unsafe { let rcx: &mut ReadContext = unsafe {
@ -258,7 +259,7 @@ extern fn read_cb(handle: *uvll::uv_stream_t, nread: ssize_t, _buf: *Buf) {
// Unlike reading, the WriteContext is stored in the uv_write_t request. Like // Unlike reading, the WriteContext is stored in the uv_write_t request. Like
// reading, however, all this does is wake up the blocked task after squirreling // reading, however, all this does is wake up the blocked task after squirreling
// away the error code as a result. // away the error code as a result.
extern fn write_cb(req: *uvll::uv_write_t, status: c_int) { extern fn write_cb(req: *mut uvll::uv_write_t, status: c_int) {
let mut req = Request::wrap(req); let mut req = Request::wrap(req);
// Remember to not free the request because it is re-used between writes on // Remember to not free the request because it is re-used between writes on
// the same stream. // the same stream.

View file

@ -119,13 +119,13 @@ impl AccessTimeout {
// to fire when the timeout runs out. // to fire when the timeout runs out.
if self.timer.is_none() { if self.timer.is_none() {
let mut timer = box TimerWatcher::new_home(loop_, home.clone()); let mut timer = box TimerWatcher::new_home(loop_, home.clone());
let cx = box TimerContext { let mut cx = box TimerContext {
timeout: self as *mut _, timeout: self as *mut _,
callback: cb, callback: cb,
payload: data, payload: data,
}; };
unsafe { unsafe {
timer.set_data(&*cx); timer.set_data(&mut *cx);
mem::forget(cx); mem::forget(cx);
} }
self.timer = Some(timer); self.timer = Some(timer);
@ -142,9 +142,9 @@ impl AccessTimeout {
timer.start(timer_cb, ms, 0); timer.start(timer_cb, ms, 0);
self.state = TimeoutPending(NoWaiter); self.state = TimeoutPending(NoWaiter);
extern fn timer_cb(timer: *uvll::uv_timer_t) { extern fn timer_cb(timer: *mut uvll::uv_timer_t) {
let cx: &TimerContext = unsafe { let cx: &TimerContext = unsafe {
&*(uvll::get_data_for_uv_handle(timer) as *TimerContext) &*(uvll::get_data_for_uv_handle(timer) as *const TimerContext)
}; };
let me = unsafe { &mut *cx.timeout }; let me = unsafe { &mut *cx.timeout };
@ -240,7 +240,7 @@ impl ConnectCtx {
None => {} None => {}
} }
wait_until_woken_after(&mut self.task, &io.loop_, || { wait_until_woken_after(&mut self.task, &io.loop_, || {
let data = &self as *_; let data = &self as *const _ as *mut ConnectCtx;
match self.timer { match self.timer {
Some(ref mut timer) => unsafe { timer.set_data(data) }, Some(ref mut timer) => unsafe { timer.set_data(data) },
None => {} None => {}
@ -249,7 +249,7 @@ impl ConnectCtx {
}); });
// Make sure an erroneously fired callback doesn't have access // Make sure an erroneously fired callback doesn't have access
// to the context any more. // to the context any more.
req.set_data(0 as *int); req.set_data(0 as *mut int);
// If we failed because of a timeout, drop the TcpWatcher as // If we failed because of a timeout, drop the TcpWatcher as
// soon as possible because it's data is now set to null and we // soon as possible because it's data is now set to null and we
@ -262,7 +262,7 @@ impl ConnectCtx {
n => Err(UvError(n)) n => Err(UvError(n))
}; };
extern fn timer_cb(handle: *uvll::uv_timer_t) { extern fn timer_cb(handle: *mut uvll::uv_timer_t) {
// Don't close the corresponding tcp request, just wake up the task // Don't close the corresponding tcp request, just wake up the task
// and let RAII take care of the pending watcher. // and let RAII take care of the pending watcher.
let cx: &mut ConnectCtx = unsafe { let cx: &mut ConnectCtx = unsafe {
@ -272,7 +272,7 @@ impl ConnectCtx {
wakeup(&mut cx.task); wakeup(&mut cx.task);
} }
extern fn connect_cb(req: *uvll::uv_connect_t, status: c_int) { extern fn connect_cb(req: *mut uvll::uv_connect_t, status: c_int) {
// This callback can be invoked with ECANCELED if the watcher is // This callback can be invoked with ECANCELED if the watcher is
// closed by the timeout callback. In that case we just want to free // closed by the timeout callback. In that case we just want to free
// the request and be along our merry way. // the request and be along our merry way.
@ -367,7 +367,7 @@ impl AcceptTimeout {
}); });
let mut timer = TimerWatcher::new_home(&loop_, t.home().clone()); let mut timer = TimerWatcher::new_home(&loop_, t.home().clone());
unsafe { unsafe {
timer.set_data(self as *mut _ as *AcceptTimeout); timer.set_data(self as *mut _);
} }
self.timer = Some(timer); self.timer = Some(timer);
} }
@ -381,7 +381,7 @@ impl AcceptTimeout {
self.timeout_tx = Some(tx); self.timeout_tx = Some(tx);
self.timeout_rx = Some(rx); self.timeout_rx = Some(rx);
extern fn timer_cb(timer: *uvll::uv_timer_t) { extern fn timer_cb(timer: *mut uvll::uv_timer_t) {
let acceptor: &mut AcceptTimeout = unsafe { let acceptor: &mut AcceptTimeout = unsafe {
&mut *(uvll::get_data_for_uv_handle(timer) as *mut AcceptTimeout) &mut *(uvll::get_data_for_uv_handle(timer) as *mut AcceptTimeout)
}; };

Some files were not shown because too many files have changed in this diff Show more