auto merge of #15208 : alexcrichton/rust/snapshots, r=pcwalton

This change registers new snapshots, allowing `*T` to be removed from the language. This is a large breaking change, and it is recommended that if compiler errors are seen that any FFI calls are audited to determine whether they should be actually taking `*mut T`.
This commit is contained in:
bors 2014-06-28 20:11:34 +00:00
commit fe8bc17801
228 changed files with 1813 additions and 1685 deletions

View file

@ -23,7 +23,7 @@ use core::prelude::*;
use collections::vec::Vec;
/// 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.
pub unsafe fn cleanup() { imp::cleanup() }
@ -55,7 +55,7 @@ mod imp {
static mut global_args_ptr: uint = 0;
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);
put(args);
}
@ -99,7 +99,7 @@ mod imp {
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| {
let base = *argv.offset(i as int);
let mut len = 0;
@ -151,7 +151,7 @@ mod imp {
use core::prelude::*;
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() {

View file

@ -43,7 +43,7 @@ pub fn push(f: proc():Send) {
rtassert!(!RUNNING.load(atomics::SeqCst));
let queue = QUEUE.load(atomics::SeqCst);
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 {
fn puts(s: *libc::c_char);
fn puts(s: *const libc::c_char);
}
fn main() {
@ -82,7 +82,7 @@ use libc;
/// This structure wraps a `*libc::c_char`, and will automatically free the
/// memory it is pointing to when it goes out of scope.
pub struct CString {
buf: *libc::c_char,
buf: *const libc::c_char,
owns_buffer_: bool,
}
@ -97,7 +97,7 @@ impl Clone for CString {
let len = self.len() + 1;
let buf = unsafe { malloc_raw(len) } as *mut libc::c_char;
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 {
/// 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 }
}
@ -127,7 +127,7 @@ impl CString {
/// The original object is destructed after this method is called, and if
/// the underlying pointer was previously allocated, care must be taken to
/// 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;
c_str.owns_buffer_ = false;
c_str.buf
@ -138,7 +138,7 @@ impl CString {
/// # Failure
///
/// 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!"); }
f(self.buf)
}
@ -284,13 +284,13 @@ pub trait ToCStr {
///
/// Fails the task if the receiver has an interior null.
#[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)
}
/// Unsafe variant of `with_c_str()` that doesn't check for nulls.
#[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)
}
}
@ -315,12 +315,12 @@ impl<'a> ToCStr for &'a str {
}
#[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)
}
#[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)
}
}
@ -337,12 +337,12 @@ impl ToCStr for String {
}
#[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)
}
#[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)
}
}
@ -364,20 +364,21 @@ impl<'a> ToCStr for &'a [u8] {
ptr::copy_memory(buf, self.as_ptr(), self_len);
*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 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)
}
}
// 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 {
let mut buf: [u8, .. BUF_LEN] = mem::uninitialized();
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);
}
f(buf as *libc::c_char)
f(buf as *const libc::c_char)
} else if checked {
v.to_c_str().with_ref(f)
} else {
@ -410,7 +411,7 @@ fn check_for_null(v: &[u8], buf: *mut libc::c_char) {
///
/// Use with the `std::iter` module.
pub struct CChars<'a> {
ptr: *libc::c_char,
ptr: *const libc::c_char,
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
/// 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>,
f: |&CString|) -> uint {
@ -445,8 +446,8 @@ pub unsafe fn from_c_multistring(buf: *libc::c_char,
None => (false, 0)
};
while ((limited_count && ctr < limit) || !limited_count)
&& *(curr_ptr as *libc::c_char) != 0 as libc::c_char {
let cstr = CString::new(curr_ptr as *libc::c_char, false);
&& *(curr_ptr as *const libc::c_char) != 0 as libc::c_char {
let cstr = CString::new(curr_ptr as *const libc::c_char, false);
f(&cstr);
curr_ptr += cstr.len() + 1;
ctr += 1;
@ -470,7 +471,7 @@ mod tests {
let ptr = input.as_ptr();
let expected = ["zero", "one"];
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();
assert_eq!(cbytes, it.next().unwrap().as_bytes());
});
@ -707,7 +708,7 @@ mod bench {
use std::prelude::*;
#[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();
for i in range(0, s.len()) {
unsafe {

View file

@ -18,7 +18,6 @@
#![feature(macro_rules, phase, globs, thread_local, managed_boxes, asm)]
#![feature(linkage, lang_items, unsafe_destructor)]
#![allow(unknown_features)] // NOTE: remove after stage0 snapshot
#![no_std]
#![experimental]
@ -105,7 +104,7 @@ pub static DEFAULT_ERROR_CODE: int = 101;
/// Initializes global state, including frobbing
/// the crate's logging flags, registering GC
/// 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.
// Need to propagate the unsafety to `start`.
unsafe {

View file

@ -82,7 +82,7 @@ pub enum _Unwind_Context {}
pub type _Unwind_Exception_Cleanup_Fn =
extern "C" fn(unwind_code: _Unwind_Reason_Code,
exception: *_Unwind_Exception);
exception: *mut _Unwind_Exception);
#[cfg(target_os = "linux")]
#[cfg(target_os = "freebsd")]
@ -99,14 +99,14 @@ extern "C" {
// iOS on armv7 uses SjLj exceptions and requires to link
// agains corresponding routine (..._SjLj_...)
#[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;
#[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;
pub fn _Unwind_DeleteException(exception: *_Unwind_Exception);
pub fn _Unwind_DeleteException(exception: *mut _Unwind_Exception);
}
// ... and now we just providing access to SjLj counterspart
@ -114,7 +114,7 @@ extern "C" {
// (see also comment above regarding _Unwind_RaiseException)
#[cfg(target_os = "ios", target_arch = "arm")]
#[inline(always)]
pub unsafe fn _Unwind_RaiseException(exc: *_Unwind_Exception)
pub unsafe fn _Unwind_RaiseException(exc: *mut _Unwind_Exception)
-> _Unwind_Reason_Code {
_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
// a proper map.
#[doc(hidden)]
pub type Map = Vec<Option<(*u8, TLSValue, uint)>>;
pub type Map = Vec<Option<(*const u8, TLSValue, uint)>>;
type TLSValue = Box<LocalData + Send>;
// 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 {
key as *KeyValue<T> as *u8
fn key_to_key_value<T: 'static>(key: Key<T>) -> *const u8 {
key as *const KeyValue<T> as *const u8
}
/// 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
// compiler coercions to achieve a '&' pointer.
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)
};
Ref { _ptr: ptr, _index: pos, _nosend: marker::NoSend, _key: self }

View file

@ -225,8 +225,8 @@ impl MemoryRegion {
#[inline]
fn malloc(&mut self, size: uint) -> *mut Box {
let total_size = size + AllocHeader::size();
let alloc: *AllocHeader = unsafe {
libc_heap::malloc_raw(total_size) as *AllocHeader
let alloc: *mut AllocHeader = unsafe {
libc_heap::malloc_raw(total_size) as *mut AllocHeader
};
let alloc: &mut AllocHeader = unsafe { mem::transmute(alloc) };
@ -244,14 +244,14 @@ impl MemoryRegion {
unsafe { (*orig_alloc).assert_sane(); }
let total_size = size + AllocHeader::size();
let alloc: *AllocHeader = unsafe {
libc_heap::realloc_raw(orig_alloc as *mut u8, total_size) as *AllocHeader
let alloc: *mut AllocHeader = unsafe {
libc_heap::realloc_raw(orig_alloc as *mut u8, total_size) as *mut AllocHeader
};
let alloc: &mut AllocHeader = unsafe { mem::transmute(alloc) };
alloc.assert_sane();
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();
}
@ -273,7 +273,7 @@ impl MemoryRegion {
#[inline]
fn release(&mut self, _alloc: &AllocHeader) {}
#[inline]
fn update(&mut self, _alloc: &mut AllocHeader, _orig: *AllocHeader) {}
fn update(&mut self, _alloc: &mut AllocHeader, _orig: *mut AllocHeader) {}
}
impl Drop for MemoryRegion {
@ -287,17 +287,19 @@ impl Drop for MemoryRegion {
#[cfg(not(test))]
#[lang="malloc"]
#[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)
}
#[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.
let task: Option<*mut Task> = Local::try_unsafe_borrow();
match 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")
}
@ -306,7 +308,7 @@ pub unsafe fn local_malloc(drop_glue: fn(*mut u8), size: uint, align: uint) -> *
#[cfg(not(test))]
#[lang="free"]
#[inline]
pub unsafe fn local_free_(ptr: *u8) {
pub unsafe fn local_free_(ptr: *mut u8) {
local_free(ptr)
}
@ -314,7 +316,7 @@ pub unsafe fn local_free_(ptr: *u8) {
// inside a landing pad may corrupt the state of the exception handler. If a
// problem occurs, call exit instead.
#[inline]
pub unsafe fn local_free(ptr: *u8) {
pub unsafe fn local_free(ptr: *mut u8) {
// FIXME: Unsafe borrow for speed. Lame.
let task_ptr: Option<*mut Task> = Local::try_unsafe_borrow();
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
/// pointer is returned.
pub struct Borrowed<T> {
val: *(),
val: *const (),
}
#[unsafe_destructor]
@ -54,7 +54,7 @@ impl<T> Drop for Borrowed<T> {
impl<T> Deref<T> for Borrowed<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.
#[inline]
pub unsafe fn borrow<T>() -> Borrowed<T> {
let val: *() = mem::transmute(take::<T>());
let val: *const () = mem::transmute(take::<T>());
Borrowed {
val: val,
}

View file

@ -351,8 +351,8 @@ mod imp {
mod os {
use libc;
pub type pthread_mutex_t = *libc::c_void;
pub type pthread_cond_t = *libc::c_void;
pub type pthread_mutex_t = *mut libc::c_void;
pub type pthread_cond_t = *mut libc::c_void;
pub static PTHREAD_MUTEX_INITIALIZER: 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)]
unsafe fn target_record_sp_limit(limit: uint) {
use libc::c_void;
return record_sp_limit(limit as *c_void);
return record_sp_limit(limit as *const c_void);
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;
return get_sp_limit() as uint;
extern {
fn get_sp_limit() -> *c_void;
fn get_sp_limit() -> *const c_void;
}
}

View file

@ -25,7 +25,7 @@ use libc;
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
/// 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
// and invoke it.
#[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 {
stack::record_stack_bounds(0, uint::MAX);
let f: Box<proc()> = mem::transmute(main);
@ -82,7 +82,7 @@ impl Thread<()> {
// so.
let packet = box None;
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 native = unsafe { imp::create(stack, box main) };
@ -225,7 +225,7 @@ mod imp {
use stack::RED_ZONE;
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 {
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);
assert_eq!(pthread_attr_destroy(&mut attr), 0);
@ -268,7 +268,7 @@ mod imp {
}
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) {
@ -287,33 +287,33 @@ mod imp {
// currently always the case. Note that you need to check that the symbol
// is non-null before calling it!
#[cfg(target_os = "linux")]
fn min_stack_size(attr: *libc::pthread_attr_t) -> libc::size_t {
type F = unsafe extern "C" fn(*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(*const libc::pthread_attr_t) -> libc::size_t;
extern {
#[linkage = "extern_weak"]
static __pthread_get_minstack: *();
static __pthread_get_minstack: *const ();
}
if __pthread_get_minstack.is_null() {
PTHREAD_STACK_MIN
} 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
// not supported on OS X, hence this kludge...
#[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
}
extern {
fn pthread_create(native: *mut libc::pthread_t,
attr: *libc::pthread_attr_t,
attr: *const libc::pthread_attr_t,
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,
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_destroy(attr: *mut libc::pthread_attr_t) -> libc::c_int;
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)]
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_getspecific(key: pthread_key_t) -> *mut u8;
fn pthread_setspecific(key: pthread_key_t, value: *mut u8) -> c_int;

View file

@ -136,8 +136,8 @@ impl Unwinder {
/// run.
pub unsafe fn try(f: ||) -> ::core::result::Result<(), Box<Any + Send>> {
let closure: Closure = mem::transmute(f);
let ep = rust_try(try_fn, closure.code as *c_void,
closure.env as *c_void);
let ep = rust_try(try_fn, closure.code as *mut c_void,
closure.env as *mut c_void);
return if ep.is_null() {
Ok(())
} else {
@ -148,11 +148,11 @@ pub unsafe fn try(f: ||) -> ::core::result::Result<(), Box<Any + Send>> {
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 {
let closure: || = mem::transmute(Closure {
code: code as *(),
env: env as *(),
code: code as *mut (),
env: env as *mut (),
});
closure();
}
@ -164,9 +164,9 @@ pub unsafe fn try(f: ||) -> ::core::result::Result<(), Box<Any + Send>> {
// When f(...) returns normally, the return value is null.
// When f(...) throws, the return value is a pointer to the caught
// exception object.
fn rust_try(f: extern "C" fn(*c_void, *c_void),
code: *c_void,
data: *c_void) -> *uw::_Unwind_Exception;
fn rust_try(f: extern "C" fn(*mut c_void, *mut c_void),
code: *mut c_void,
data: *mut c_void) -> *mut uw::_Unwind_Exception;
}
}
@ -190,7 +190,7 @@ fn rust_fail(cause: Box<Any + Send>) -> ! {
}
extern fn exception_cleanup(_unwind_code: uw::_Unwind_Reason_Code,
exception: *uw::_Unwind_Exception) {
exception: *mut uw::_Unwind_Exception) {
rtdebug!("exception_cleanup()");
unsafe {
let _: Box<Exception> = mem::transmute(exception);
@ -235,8 +235,8 @@ pub mod eabi {
fn __gcc_personality_v0(version: c_int,
actions: uw::_Unwind_Action,
exception_class: uw::_Unwind_Exception_Class,
ue_header: *uw::_Unwind_Exception,
context: *uw::_Unwind_Context)
ue_header: *mut uw::_Unwind_Exception,
context: *mut uw::_Unwind_Context)
-> uw::_Unwind_Reason_Code;
}
@ -245,8 +245,8 @@ pub mod eabi {
version: c_int,
actions: uw::_Unwind_Action,
exception_class: uw::_Unwind_Exception_Class,
ue_header: *uw::_Unwind_Exception,
context: *uw::_Unwind_Context
ue_header: *mut uw::_Unwind_Exception,
context: *mut uw::_Unwind_Context
) -> uw::_Unwind_Reason_Code
{
unsafe {
@ -260,8 +260,8 @@ pub mod eabi {
version: c_int,
actions: uw::_Unwind_Action,
exception_class: uw::_Unwind_Exception_Class,
ue_header: *uw::_Unwind_Exception,
context: *uw::_Unwind_Context
ue_header: *mut uw::_Unwind_Exception,
context: *mut uw::_Unwind_Context
) -> uw::_Unwind_Reason_Code
{
if (actions as c_int & uw::_UA_SEARCH_PHASE as c_int) != 0 { // search phase
@ -290,8 +290,8 @@ pub mod eabi {
fn __gcc_personality_sj0(version: c_int,
actions: uw::_Unwind_Action,
exception_class: uw::_Unwind_Exception_Class,
ue_header: *uw::_Unwind_Exception,
context: *uw::_Unwind_Context)
ue_header: *mut uw::_Unwind_Exception,
context: *mut uw::_Unwind_Context)
-> uw::_Unwind_Reason_Code;
}
@ -301,8 +301,8 @@ pub mod eabi {
version: c_int,
actions: uw::_Unwind_Action,
exception_class: uw::_Unwind_Exception_Class,
ue_header: *uw::_Unwind_Exception,
context: *uw::_Unwind_Context
ue_header: *mut uw::_Unwind_Exception,
context: *mut uw::_Unwind_Context
) -> uw::_Unwind_Reason_Code
{
unsafe {
@ -316,8 +316,8 @@ pub mod eabi {
version: c_int,
actions: uw::_Unwind_Action,
exception_class: uw::_Unwind_Exception_Class,
ue_header: *uw::_Unwind_Exception,
context: *uw::_Unwind_Context
ue_header: *mut uw::_Unwind_Exception,
context: *mut uw::_Unwind_Context
) -> uw::_Unwind_Reason_Code
{
if (actions as c_int & uw::_UA_SEARCH_PHASE as c_int) != 0 { // search phase
@ -343,16 +343,16 @@ pub mod eabi {
extern "C" {
fn __gcc_personality_v0(state: uw::_Unwind_State,
ue_header: *uw::_Unwind_Exception,
context: *uw::_Unwind_Context)
ue_header: *mut uw::_Unwind_Exception,
context: *mut uw::_Unwind_Context)
-> uw::_Unwind_Reason_Code;
}
#[lang="eh_personality"]
extern "C" fn eh_personality(
state: uw::_Unwind_State,
ue_header: *uw::_Unwind_Exception,
context: *uw::_Unwind_Context
ue_header: *mut uw::_Unwind_Exception,
context: *mut uw::_Unwind_Context
) -> uw::_Unwind_Reason_Code
{
unsafe {
@ -363,8 +363,8 @@ pub mod eabi {
#[no_mangle] // referenced from rust_try.ll
pub extern "C" fn rust_eh_personality_catch(
state: uw::_Unwind_State,
ue_header: *uw::_Unwind_Exception,
context: *uw::_Unwind_Context
ue_header: *mut uw::_Unwind_Exception,
context: *mut uw::_Unwind_Context
) -> uw::_Unwind_Reason_Code
{
if (state as c_int & uw::_US_ACTION_MASK as c_int)

View file

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