Tidy up asm! usage in libstd
This commit is contained in:
parent
ece5028a8b
commit
e6d8f06cad
@ -391,36 +391,32 @@ pub unsafe fn record_sp_limit(limit: uint) {
|
|||||||
/// As with the setter, this function does not have a __morestack header and can
|
/// As with the setter, this function does not have a __morestack header and can
|
||||||
/// therefore be called in a "we're out of stack" situation.
|
/// therefore be called in a "we're out of stack" situation.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
// NOTE: after the next snapshot, can remove the initialization before inline
|
|
||||||
// assembly due to an improvement in how it's handled, then this specific
|
|
||||||
// allow directive should get removed.
|
|
||||||
#[allow(dead_assignment)]
|
|
||||||
pub unsafe fn get_sp_limit() -> uint {
|
pub unsafe fn get_sp_limit() -> uint {
|
||||||
return target_get_sp_limit();
|
return target_get_sp_limit();
|
||||||
|
|
||||||
// x86-64
|
// x86-64
|
||||||
#[cfg(target_arch = "x86_64", target_os = "macos")] #[inline(always)]
|
#[cfg(target_arch = "x86_64", target_os = "macos")] #[inline(always)]
|
||||||
unsafe fn target_get_sp_limit() -> uint {
|
unsafe fn target_get_sp_limit() -> uint {
|
||||||
let mut limit: uint = 0;
|
let limit;
|
||||||
asm!("movq $$0x60+90*8, %rsi
|
asm!("movq $$0x60+90*8, %rsi
|
||||||
movq %gs:(%rsi), $0" : "=r"(limit) :: "rsi" : "volatile");
|
movq %gs:(%rsi), $0" : "=r"(limit) :: "rsi" : "volatile");
|
||||||
return limit;
|
return limit;
|
||||||
}
|
}
|
||||||
#[cfg(target_arch = "x86_64", target_os = "linux")] #[inline(always)]
|
#[cfg(target_arch = "x86_64", target_os = "linux")] #[inline(always)]
|
||||||
unsafe fn target_get_sp_limit() -> uint {
|
unsafe fn target_get_sp_limit() -> uint {
|
||||||
let mut limit: uint = 0;
|
let limit;
|
||||||
asm!("movq %fs:112, $0" : "=r"(limit) ::: "volatile");
|
asm!("movq %fs:112, $0" : "=r"(limit) ::: "volatile");
|
||||||
return limit;
|
return limit;
|
||||||
}
|
}
|
||||||
#[cfg(target_arch = "x86_64", target_os = "win32")] #[inline(always)]
|
#[cfg(target_arch = "x86_64", target_os = "win32")] #[inline(always)]
|
||||||
unsafe fn target_get_sp_limit() -> uint {
|
unsafe fn target_get_sp_limit() -> uint {
|
||||||
let mut limit: uint = 0;
|
let limit;
|
||||||
asm!("movq %gs:0x28, $0" : "=r"(limit) ::: "volatile");
|
asm!("movq %gs:0x28, $0" : "=r"(limit) ::: "volatile");
|
||||||
return limit;
|
return limit;
|
||||||
}
|
}
|
||||||
#[cfg(target_arch = "x86_64", target_os = "freebsd")] #[inline(always)]
|
#[cfg(target_arch = "x86_64", target_os = "freebsd")] #[inline(always)]
|
||||||
unsafe fn target_get_sp_limit() -> uint {
|
unsafe fn target_get_sp_limit() -> uint {
|
||||||
let mut limit: uint = 0;
|
let limit;
|
||||||
asm!("movq %fs:24, $0" : "=r"(limit) ::: "volatile");
|
asm!("movq %fs:24, $0" : "=r"(limit) ::: "volatile");
|
||||||
return limit;
|
return limit;
|
||||||
}
|
}
|
||||||
@ -428,7 +424,7 @@ pub unsafe fn get_sp_limit() -> uint {
|
|||||||
// x86
|
// x86
|
||||||
#[cfg(target_arch = "x86", target_os = "macos")] #[inline(always)]
|
#[cfg(target_arch = "x86", target_os = "macos")] #[inline(always)]
|
||||||
unsafe fn target_get_sp_limit() -> uint {
|
unsafe fn target_get_sp_limit() -> uint {
|
||||||
let mut limit: uint = 0;
|
let limit;
|
||||||
asm!("movl $$0x48+90*4, %eax
|
asm!("movl $$0x48+90*4, %eax
|
||||||
movl %gs:(%eax), $0" : "=r"(limit) :: "eax" : "volatile");
|
movl %gs:(%eax), $0" : "=r"(limit) :: "eax" : "volatile");
|
||||||
return limit;
|
return limit;
|
||||||
@ -436,13 +432,13 @@ pub unsafe fn get_sp_limit() -> uint {
|
|||||||
#[cfg(target_arch = "x86", target_os = "linux")]
|
#[cfg(target_arch = "x86", target_os = "linux")]
|
||||||
#[cfg(target_arch = "x86", target_os = "freebsd")] #[inline(always)]
|
#[cfg(target_arch = "x86", target_os = "freebsd")] #[inline(always)]
|
||||||
unsafe fn target_get_sp_limit() -> uint {
|
unsafe fn target_get_sp_limit() -> uint {
|
||||||
let mut limit: uint = 0;
|
let limit;
|
||||||
asm!("movl %gs:48, $0" : "=r"(limit) ::: "volatile");
|
asm!("movl %gs:48, $0" : "=r"(limit) ::: "volatile");
|
||||||
return limit;
|
return limit;
|
||||||
}
|
}
|
||||||
#[cfg(target_arch = "x86", target_os = "win32")] #[inline(always)]
|
#[cfg(target_arch = "x86", target_os = "win32")] #[inline(always)]
|
||||||
unsafe fn target_get_sp_limit() -> uint {
|
unsafe fn target_get_sp_limit() -> uint {
|
||||||
let mut limit: uint = 0;
|
let limit;
|
||||||
asm!("movl %fs:0x14, $0" : "=r"(limit) ::: "volatile");
|
asm!("movl %fs:0x14, $0" : "=r"(limit) ::: "volatile");
|
||||||
return limit;
|
return limit;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user