Fix librustrt
This commit is contained in:
parent
d5647a8ea3
commit
ad83352618
@ -39,10 +39,10 @@ pub fn put(args: Vec<Vec<u8>>) { imp::put(args) }
|
||||
/// Make a clone of the global arguments.
|
||||
pub fn clone() -> Option<Vec<Vec<u8>>> { imp::clone() }
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(target_os = "android")]
|
||||
#[cfg(target_os = "freebsd")]
|
||||
#[cfg(target_os = "dragonfly")]
|
||||
#[cfg(any(target_os = "linux",
|
||||
target_os = "android",
|
||||
target_os = "freebsd",
|
||||
target_os = "dragonfly"))]
|
||||
mod imp {
|
||||
use core::prelude::*;
|
||||
|
||||
@ -146,9 +146,9 @@ mod imp {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg(target_os = "ios")]
|
||||
#[cfg(target_os = "windows")]
|
||||
#[cfg(any(target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "windows"))]
|
||||
mod imp {
|
||||
use core::prelude::*;
|
||||
use collections::vec::Vec;
|
||||
|
@ -160,7 +160,7 @@ pub unsafe fn cleanup() {
|
||||
pub mod shouldnt_be_public {
|
||||
#[cfg(not(test))]
|
||||
pub use super::local_ptr::native::maybe_tls_key;
|
||||
#[cfg(not(windows), not(target_os = "android"), not(target_os = "ios"))]
|
||||
#[cfg(all(not(windows), not(target_os = "android"), not(target_os = "ios")))]
|
||||
pub use super::local_ptr::compiled::RT_TLS_PTR;
|
||||
}
|
||||
|
||||
|
@ -16,8 +16,7 @@
|
||||
|
||||
use libc;
|
||||
|
||||
#[cfg(not(target_arch = "arm"))]
|
||||
#[cfg(target_os = "ios")]
|
||||
#[cfg(any(not(target_arch = "arm"), target_os = "ios"))]
|
||||
#[repr(C)]
|
||||
pub enum _Unwind_Action {
|
||||
_UA_SEARCH_PHASE = 1,
|
||||
@ -62,14 +61,13 @@ pub static unwinder_private_data_size: uint = 5;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
pub static unwinder_private_data_size: uint = 6;
|
||||
|
||||
#[cfg(target_arch = "arm", not(target_os = "ios"))]
|
||||
#[cfg(all(target_arch = "arm", not(target_os = "ios")))]
|
||||
pub static unwinder_private_data_size: uint = 20;
|
||||
|
||||
#[cfg(target_arch = "arm", target_os = "ios")]
|
||||
#[cfg(all(target_arch = "arm", target_os = "ios"))]
|
||||
pub static unwinder_private_data_size: uint = 5;
|
||||
|
||||
#[cfg(target_arch = "mips")]
|
||||
#[cfg(target_arch = "mipsel")]
|
||||
#[cfg(any(target_arch = "mips", target_arch = "mipsel"))]
|
||||
pub static unwinder_private_data_size: uint = 2;
|
||||
|
||||
#[repr(C)]
|
||||
@ -85,8 +83,7 @@ pub type _Unwind_Exception_Cleanup_Fn =
|
||||
extern "C" fn(unwind_code: _Unwind_Reason_Code,
|
||||
exception: *mut _Unwind_Exception);
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(target_os = "freebsd")]
|
||||
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
|
||||
#[link(name = "gcc_s")]
|
||||
extern {}
|
||||
|
||||
@ -101,11 +98,11 @@ extern {}
|
||||
extern "C" {
|
||||
// iOS on armv7 uses SjLj exceptions and requires to link
|
||||
// against corresponding routine (..._SjLj_...)
|
||||
#[cfg(not(target_os = "ios", target_arch = "arm"))]
|
||||
#[cfg(not(all(target_os = "ios", target_arch = "arm")))]
|
||||
pub fn _Unwind_RaiseException(exception: *mut _Unwind_Exception)
|
||||
-> _Unwind_Reason_Code;
|
||||
|
||||
#[cfg(target_os = "ios", target_arch = "arm")]
|
||||
#[cfg(all(target_os = "ios", target_arch = "arm"))]
|
||||
fn _Unwind_SjLj_RaiseException(e: *mut _Unwind_Exception)
|
||||
-> _Unwind_Reason_Code;
|
||||
|
||||
@ -115,7 +112,7 @@ extern "C" {
|
||||
// ... and now we just providing access to SjLj counterspart
|
||||
// through a standard name to hide those details from others
|
||||
// (see also comment above regarding _Unwind_RaiseException)
|
||||
#[cfg(target_os = "ios", target_arch = "arm")]
|
||||
#[cfg(all(target_os = "ios", target_arch = "arm"))]
|
||||
#[inline(always)]
|
||||
pub unsafe fn _Unwind_RaiseException(exc: *mut _Unwind_Exception)
|
||||
-> _Unwind_Reason_Code {
|
||||
|
@ -22,13 +22,13 @@ use core::prelude::*;
|
||||
use core::mem;
|
||||
use alloc::boxed::Box;
|
||||
|
||||
#[cfg(windows)] // mingw-w32 doesn't like thread_local things
|
||||
#[cfg(target_os = "android")] // see #10686
|
||||
#[cfg(target_os = "ios")]
|
||||
#[cfg(any(windows, // mingw-w32 doesn't like thread_local things
|
||||
target_os = "android", // see #10686
|
||||
target_os = "ios"))]
|
||||
pub use self::native::{init, cleanup, put, take, try_take, unsafe_take, exists,
|
||||
unsafe_borrow, try_unsafe_borrow};
|
||||
|
||||
#[cfg(not(windows), not(target_os = "android"), not(target_os = "ios"))]
|
||||
#[cfg(not(any(windows, target_os = "android", target_os = "ios")))]
|
||||
pub use self::compiled::{init, cleanup, put, take, try_take, unsafe_take, exists,
|
||||
unsafe_borrow, try_unsafe_borrow};
|
||||
|
||||
@ -82,7 +82,7 @@ pub unsafe fn borrow<T>() -> Borrowed<T> {
|
||||
/// implemented using LLVM's thread_local attribute which isn't necessarily
|
||||
/// working on all platforms. This implementation is faster, however, so we use
|
||||
/// it wherever possible.
|
||||
#[cfg(not(windows), not(target_os = "android"), not(target_os = "ios"))]
|
||||
#[cfg(not(any(windows, target_os = "android", target_os = "ios")))]
|
||||
pub mod compiled {
|
||||
use core::prelude::*;
|
||||
|
||||
|
@ -346,8 +346,7 @@ mod imp {
|
||||
type pthread_mutexattr_t = libc::c_void;
|
||||
type pthread_condattr_t = libc::c_void;
|
||||
|
||||
#[cfg(target_os = "freebsd")]
|
||||
#[cfg(target_os = "dragonfly")]
|
||||
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
|
||||
mod os {
|
||||
use libc;
|
||||
|
||||
@ -360,8 +359,7 @@ mod imp {
|
||||
0 as pthread_cond_t;
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg(target_os = "ios")]
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
mod os {
|
||||
use libc;
|
||||
|
||||
|
@ -156,13 +156,13 @@ pub unsafe fn record_rust_managed_stack_bounds(stack_lo: uint, stack_hi: uint) {
|
||||
#[cfg(not(windows))] #[inline(always)]
|
||||
unsafe fn target_record_stack_bounds(_stack_lo: uint, _stack_hi: uint) {}
|
||||
|
||||
#[cfg(windows, target_arch = "x86")] #[inline(always)]
|
||||
#[cfg(all(windows, target_arch = "x86"))] #[inline(always)]
|
||||
unsafe fn target_record_stack_bounds(stack_lo: uint, stack_hi: uint) {
|
||||
// stack range is at TIB: %fs:0x04 (top) and %fs:0x08 (bottom)
|
||||
asm!("mov $0, %fs:0x04" :: "r"(stack_hi) :: "volatile");
|
||||
asm!("mov $0, %fs:0x08" :: "r"(stack_lo) :: "volatile");
|
||||
}
|
||||
#[cfg(windows, target_arch = "x86_64")] #[inline(always)]
|
||||
#[cfg(all(windows, target_arch = "x86_64"))] #[inline(always)]
|
||||
unsafe fn target_record_stack_bounds(stack_lo: uint, stack_hi: uint) {
|
||||
// stack range is at TIB: %gs:0x08 (top) and %gs:0x10 (bottom)
|
||||
asm!("mov $0, %gs:0x08" :: "r"(stack_hi) :: "volatile");
|
||||
@ -189,49 +189,53 @@ pub unsafe fn record_sp_limit(limit: uint) {
|
||||
return target_record_sp_limit(limit);
|
||||
|
||||
// x86-64
|
||||
#[cfg(target_arch = "x86_64", target_os = "macos")]
|
||||
#[cfg(target_arch = "x86_64", target_os = "ios")] #[inline(always)]
|
||||
#[cfg(all(target_arch = "x86_64",
|
||||
any(target_os = "macos", target_os = "ios")))]
|
||||
#[inline(always)]
|
||||
unsafe fn target_record_sp_limit(limit: uint) {
|
||||
asm!("movq $$0x60+90*8, %rsi
|
||||
movq $0, %gs:(%rsi)" :: "r"(limit) : "rsi" : "volatile")
|
||||
}
|
||||
#[cfg(target_arch = "x86_64", target_os = "linux")] #[inline(always)]
|
||||
#[cfg(all(target_arch = "x86_64", target_os = "linux"))] #[inline(always)]
|
||||
unsafe fn target_record_sp_limit(limit: uint) {
|
||||
asm!("movq $0, %fs:112" :: "r"(limit) :: "volatile")
|
||||
}
|
||||
#[cfg(target_arch = "x86_64", target_os = "windows")] #[inline(always)]
|
||||
#[cfg(all(target_arch = "x86_64", target_os = "windows"))] #[inline(always)]
|
||||
unsafe fn target_record_sp_limit(_: uint) {
|
||||
}
|
||||
#[cfg(target_arch = "x86_64", target_os = "freebsd")] #[inline(always)]
|
||||
#[cfg(all(target_arch = "x86_64", target_os = "freebsd"))] #[inline(always)]
|
||||
unsafe fn target_record_sp_limit(limit: uint) {
|
||||
asm!("movq $0, %fs:24" :: "r"(limit) :: "volatile")
|
||||
}
|
||||
#[cfg(target_arch = "x86_64", target_os = "dragonfly")] #[inline(always)]
|
||||
#[cfg(all(target_arch = "x86_64", target_os = "dragonfly"))] #[inline(always)]
|
||||
unsafe fn target_record_sp_limit(limit: uint) {
|
||||
asm!("movq $0, %fs:32" :: "r"(limit) :: "volatile")
|
||||
}
|
||||
|
||||
// x86
|
||||
#[cfg(target_arch = "x86", target_os = "macos")]
|
||||
#[cfg(target_arch = "x86", target_os = "ios")] #[inline(always)]
|
||||
#[cfg(all(target_arch = "x86",
|
||||
any(target_os = "macos", target_os = "ios")))]
|
||||
#[inline(always)]
|
||||
unsafe fn target_record_sp_limit(limit: uint) {
|
||||
asm!("movl $$0x48+90*4, %eax
|
||||
movl $0, %gs:(%eax)" :: "r"(limit) : "eax" : "volatile")
|
||||
}
|
||||
#[cfg(target_arch = "x86", target_os = "linux")]
|
||||
#[cfg(target_arch = "x86", target_os = "freebsd")] #[inline(always)]
|
||||
#[cfg(all(target_arch = "x86",
|
||||
any(target_os = "linux", target_os = "freebsd")))]
|
||||
#[inline(always)]
|
||||
unsafe fn target_record_sp_limit(limit: uint) {
|
||||
asm!("movl $0, %gs:48" :: "r"(limit) :: "volatile")
|
||||
}
|
||||
#[cfg(target_arch = "x86", target_os = "windows")] #[inline(always)]
|
||||
#[cfg(all(target_arch = "x86", target_os = "windows"))] #[inline(always)]
|
||||
unsafe fn target_record_sp_limit(_: uint) {
|
||||
}
|
||||
|
||||
// mips, arm - Some brave soul can port these to inline asm, but it's over
|
||||
// my head personally
|
||||
#[cfg(target_arch = "mips")]
|
||||
#[cfg(target_arch = "mipsel")]
|
||||
#[cfg(target_arch = "arm", not(target_os = "ios"))] #[inline(always)]
|
||||
#[cfg(any(target_arch = "mips",
|
||||
target_arch = "mipsel",
|
||||
all(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 *const c_void);
|
||||
@ -241,7 +245,7 @@ pub unsafe fn record_sp_limit(limit: uint) {
|
||||
}
|
||||
|
||||
// iOS segmented stack is disabled for now, see related notes
|
||||
#[cfg(target_arch = "arm", target_os = "ios")] #[inline(always)]
|
||||
#[cfg(all(target_arch = "arm", target_os = "ios"))] #[inline(always)]
|
||||
unsafe fn target_record_sp_limit(_: uint) {
|
||||
}
|
||||
}
|
||||
@ -259,31 +263,32 @@ pub unsafe fn get_sp_limit() -> uint {
|
||||
return target_get_sp_limit();
|
||||
|
||||
// x86-64
|
||||
#[cfg(target_arch = "x86_64", target_os = "macos")]
|
||||
#[cfg(target_arch = "x86_64", target_os = "ios")] #[inline(always)]
|
||||
#[cfg(all(target_arch = "x86_64",
|
||||
any(target_os = "macos", target_os = "ios")))]
|
||||
#[inline(always)]
|
||||
unsafe fn target_get_sp_limit() -> uint {
|
||||
let limit;
|
||||
asm!("movq $$0x60+90*8, %rsi
|
||||
movq %gs:(%rsi), $0" : "=r"(limit) :: "rsi" : "volatile");
|
||||
return limit;
|
||||
}
|
||||
#[cfg(target_arch = "x86_64", target_os = "linux")] #[inline(always)]
|
||||
#[cfg(all(target_arch = "x86_64", target_os = "linux"))] #[inline(always)]
|
||||
unsafe fn target_get_sp_limit() -> uint {
|
||||
let limit;
|
||||
asm!("movq %fs:112, $0" : "=r"(limit) ::: "volatile");
|
||||
return limit;
|
||||
}
|
||||
#[cfg(target_arch = "x86_64", target_os = "windows")] #[inline(always)]
|
||||
#[cfg(all(target_arch = "x86_64", target_os = "windows"))] #[inline(always)]
|
||||
unsafe fn target_get_sp_limit() -> uint {
|
||||
return 1024;
|
||||
}
|
||||
#[cfg(target_arch = "x86_64", target_os = "freebsd")] #[inline(always)]
|
||||
#[cfg(all(target_arch = "x86_64", target_os = "freebsd"))] #[inline(always)]
|
||||
unsafe fn target_get_sp_limit() -> uint {
|
||||
let limit;
|
||||
asm!("movq %fs:24, $0" : "=r"(limit) ::: "volatile");
|
||||
return limit;
|
||||
}
|
||||
#[cfg(target_arch = "x86_64", target_os = "dragonfly")] #[inline(always)]
|
||||
#[cfg(all(target_arch = "x86_64", target_os = "dragonfly"))] #[inline(always)]
|
||||
unsafe fn target_get_sp_limit() -> uint {
|
||||
let limit;
|
||||
asm!("movq %fs:32, $0" : "=r"(limit) ::: "volatile");
|
||||
@ -292,31 +297,34 @@ pub unsafe fn get_sp_limit() -> uint {
|
||||
|
||||
|
||||
// x86
|
||||
#[cfg(target_arch = "x86", target_os = "macos")]
|
||||
#[cfg(target_arch = "x86", target_os = "ios")] #[inline(always)]
|
||||
#[cfg(all(target_arch = "x86",
|
||||
any(target_os = "macos", target_os = "ios")))]
|
||||
#[inline(always)]
|
||||
unsafe fn target_get_sp_limit() -> uint {
|
||||
let limit;
|
||||
asm!("movl $$0x48+90*4, %eax
|
||||
movl %gs:(%eax), $0" : "=r"(limit) :: "eax" : "volatile");
|
||||
return limit;
|
||||
}
|
||||
#[cfg(target_arch = "x86", target_os = "linux")]
|
||||
#[cfg(target_arch = "x86", target_os = "freebsd")] #[inline(always)]
|
||||
#[cfg(all(target_arch = "x86",
|
||||
any(target_os = "linux", target_os = "freebsd")))]
|
||||
#[inline(always)]
|
||||
unsafe fn target_get_sp_limit() -> uint {
|
||||
let limit;
|
||||
asm!("movl %gs:48, $0" : "=r"(limit) ::: "volatile");
|
||||
return limit;
|
||||
}
|
||||
#[cfg(target_arch = "x86", target_os = "windows")] #[inline(always)]
|
||||
#[cfg(all(target_arch = "x86", target_os = "windows"))] #[inline(always)]
|
||||
unsafe fn target_get_sp_limit() -> uint {
|
||||
return 1024;
|
||||
}
|
||||
|
||||
// mips, arm - Some brave soul can port these to inline asm, but it's over
|
||||
// my head personally
|
||||
#[cfg(target_arch = "mips")]
|
||||
#[cfg(target_arch = "mipsel")]
|
||||
#[cfg(target_arch = "arm", not(target_os = "ios"))] #[inline(always)]
|
||||
#[cfg(any(target_arch = "mips",
|
||||
target_arch = "mipsel",
|
||||
all(target_arch = "arm", not(target_os = "ios"))))]
|
||||
#[inline(always)]
|
||||
unsafe fn target_get_sp_limit() -> uint {
|
||||
use libc::c_void;
|
||||
return get_sp_limit() as uint;
|
||||
@ -328,7 +336,7 @@ pub unsafe fn get_sp_limit() -> uint {
|
||||
// iOS doesn't support segmented stacks yet. This function might
|
||||
// be called by runtime though so it is unsafe to mark it as
|
||||
// unreachable, let's return a fixed constant.
|
||||
#[cfg(target_arch = "arm", target_os = "ios")] #[inline(always)]
|
||||
#[cfg(all(target_arch = "arm", target_os = "ios"))] #[inline(always)]
|
||||
unsafe fn target_get_sp_limit() -> uint {
|
||||
1024
|
||||
}
|
||||
|
@ -41,11 +41,11 @@ pub unsafe fn destroy(key: Key) {
|
||||
#[allow(non_camel_case_types)] // foreign type
|
||||
type pthread_key_t = ::libc::c_ulong;
|
||||
|
||||
#[cfg(target_os="linux")]
|
||||
#[cfg(target_os="freebsd")]
|
||||
#[cfg(target_os="dragonfly")]
|
||||
#[cfg(target_os="android")]
|
||||
#[cfg(target_os = "ios")]
|
||||
#[cfg(any(target_os="linux",
|
||||
target_os="freebsd",
|
||||
target_os="dragonfly",
|
||||
target_os="android",
|
||||
target_os = "ios"))]
|
||||
#[allow(non_camel_case_types)] // foreign type
|
||||
type pthread_key_t = ::libc::c_uint;
|
||||
|
||||
|
@ -235,7 +235,9 @@ fn rust_exception_class() -> uw::_Unwind_Exception_Class {
|
||||
//
|
||||
// See also: rt/rust_try.ll
|
||||
|
||||
#[cfg(not(target_arch = "arm"), not(windows, target_arch = "x86_64"), not(test))]
|
||||
#[cfg(all(not(target_arch = "arm"),
|
||||
not(all(windows, target_arch = "x86_64")),
|
||||
not(test)))]
|
||||
#[doc(hidden)]
|
||||
pub mod eabi {
|
||||
use libunwind as uw;
|
||||
@ -288,7 +290,7 @@ pub mod eabi {
|
||||
// iOS on armv7 is using SjLj exceptions and therefore requires to use
|
||||
// a specialized personality routine: __gcc_personality_sj0
|
||||
|
||||
#[cfg(target_os = "ios", target_arch = "arm", not(test))]
|
||||
#[cfg(all(target_os = "ios", target_arch = "arm", not(test)))]
|
||||
#[doc(hidden)]
|
||||
pub mod eabi {
|
||||
use libunwind as uw;
|
||||
@ -343,7 +345,7 @@ pub mod eabi {
|
||||
|
||||
// ARM EHABI uses a slightly different personality routine signature,
|
||||
// but otherwise works the same.
|
||||
#[cfg(target_arch = "arm", not(target_os = "ios"), not(test))]
|
||||
#[cfg(all(target_arch = "arm", not(target_os = "ios"), not(test)))]
|
||||
#[doc(hidden)]
|
||||
pub mod eabi {
|
||||
use libunwind as uw;
|
||||
@ -392,7 +394,7 @@ pub mod eabi {
|
||||
// GCC reuses the same personality routine as for the other architectures by wrapping it
|
||||
// with an "API translator" layer (_GCC_specific_handler).
|
||||
|
||||
#[cfg(windows, target_arch = "x86_64", not(test))]
|
||||
#[cfg(all(windows, target_arch = "x86_64", not(test)))]
|
||||
#[doc(hidden)]
|
||||
#[allow(non_camel_case_types, non_snake_case)]
|
||||
pub mod eabi {
|
||||
|
Loading…
x
Reference in New Issue
Block a user