From a2e3993111d40308bc492c5683a08ecd335dbe95 Mon Sep 17 00:00:00 2001 From: Richo Healey Date: Fri, 9 Jan 2015 20:20:15 -0800 Subject: powerpc: Add libstd utils --- src/libstd/os.rs | 5 +++++ src/libstd/rand/os.rs | 14 ++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/os.rs b/src/libstd/os.rs index 6e3949b9e22..9f7b9668bce 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -1422,6 +1422,11 @@ mod arch_consts { pub const ARCH: &'static str = "mipsel"; } +#[cfg(target_arch = "powerpc")] +mod arch_consts { + pub const ARCH: &'static str = "powerpc"; +} + #[cfg(test)] mod tests { use prelude::v1::*; diff --git a/src/libstd/rand/os.rs b/src/libstd/rand/os.rs index 18d40ecd3eb..68ba7e1dd29 100644 --- a/src/libstd/rand/os.rs +++ b/src/libstd/rand/os.rs @@ -32,7 +32,8 @@ mod imp { any(target_arch = "x86_64", target_arch = "x86", target_arch = "arm", - target_arch = "aarch64")))] + target_arch = "aarch64", + target_arch = "powerpc")))] fn getrandom(buf: &mut [u8]) -> libc::c_long { extern "C" { fn syscall(number: libc::c_long, ...) -> libc::c_long; @@ -44,6 +45,8 @@ mod imp { const NR_GETRANDOM: libc::c_long = 355; #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] const NR_GETRANDOM: libc::c_long = 384; + #[cfg(target_arch = "powerpc")] + const NR_GETRANDOM: libc::c_long = 384; unsafe { syscall(NR_GETRANDOM, buf.as_mut_ptr(), buf.len(), 0u) @@ -54,7 +57,8 @@ mod imp { any(target_arch = "x86_64", target_arch = "x86", target_arch = "arm", - target_arch = "aarch64"))))] + target_arch = "aarch64", + target_arch = "powerpc"))))] fn getrandom(_buf: &mut [u8]) -> libc::c_long { -1 } fn getrandom_fill_bytes(v: &mut [u8]) { @@ -91,7 +95,8 @@ mod imp { any(target_arch = "x86_64", target_arch = "x86", target_arch = "arm", - target_arch = "aarch64")))] + target_arch = "aarch64", + target_arch = "powerpc")))] fn is_getrandom_available() -> bool { use sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering}; @@ -119,7 +124,8 @@ mod imp { any(target_arch = "x86_64", target_arch = "x86", target_arch = "arm", - target_arch = "aarch64"))))] + target_arch = "aarch64", + target_arch = "powerpc"))))] fn is_getrandom_available() -> bool { false } /// A random number generator that retrieves randomness straight from -- cgit 1.4.1-3-g733a5 From f0d6eee499e898fc0336c72069ab7bac47125c4b Mon Sep 17 00:00:00 2001 From: Richo Healey Date: Fri, 9 Jan 2015 20:20:57 -0800 Subject: powerpc: Add unwinder size REVISIT --- src/libstd/rt/libunwind.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/libstd') diff --git a/src/libstd/rt/libunwind.rs b/src/libstd/rt/libunwind.rs index 7cc39d7d972..dd9923307d6 100644 --- a/src/libstd/rt/libunwind.rs +++ b/src/libstd/rt/libunwind.rs @@ -81,6 +81,9 @@ pub const unwinder_private_data_size: uint = 2; #[cfg(any(target_arch = "mips", target_arch = "mipsel"))] pub const unwinder_private_data_size: uint = 2; +#[cfg(target_arch = "powerpc")] +pub const unwinder_private_data_size: uint = 2; + #[repr(C)] pub struct _Unwind_Exception { pub exception_class: _Unwind_Exception_Class, -- cgit 1.4.1-3-g733a5 From 164981042d6afd38c6635ab10ef8ed3c0daffe8b Mon Sep 17 00:00:00 2001 From: Richo Healey Date: Fri, 9 Jan 2015 20:26:10 -0800 Subject: powerpc: Janky segmented stack support --- src/libstd/sys/common/stack.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/libstd') diff --git a/src/libstd/sys/common/stack.rs b/src/libstd/sys/common/stack.rs index ce5ab67ae61..88bb9395cf1 100644 --- a/src/libstd/sys/common/stack.rs +++ b/src/libstd/sys/common/stack.rs @@ -231,6 +231,12 @@ pub unsafe fn record_sp_limit(limit: uint) { unsafe fn target_record_sp_limit(_: uint) { } + // powerpc - FIXME(POWERPC): missing... + #[cfg(target_arch = "powerpc")] + unsafe fn target_record_sp_limit(_: uint) { + } + + // iOS segmented stack is disabled for now, see related notes #[cfg(all(target_arch = "arm", target_os = "ios"))] #[inline(always)] unsafe fn target_record_sp_limit(_: uint) { @@ -326,6 +332,12 @@ pub unsafe fn get_sp_limit() -> uint { 1024 } + // powepc - FIXME(POWERPC): missing... + #[cfg(target_arch = "powerpc")] + unsafe fn target_get_sp_limit() -> uint { + 1024 + } + // 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. -- cgit 1.4.1-3-g733a5 From d48fa78694a4403837a9e0b5df3f1f6c0abf1e84 Mon Sep 17 00:00:00 2001 From: Richo Healey Date: Fri, 9 Jan 2015 20:27:46 -0800 Subject: powerpc: add cdefs for linux This borrowed entirely from the mips definitions, and should be revisited after it lands while testing. --- src/libstd/sys/unix/c.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/sys/unix/c.rs b/src/libstd/sys/unix/c.rs index 1d523ed6edd..fed700cc9d5 100644 --- a/src/libstd/sys/unix/c.rs +++ b/src/libstd/sys/unix/c.rs @@ -33,7 +33,9 @@ pub const FIONBIO: libc::c_ulong = 0x8004667e; target_os = "android"))] pub const FIONBIO: libc::c_ulong = 0x5421; #[cfg(all(target_os = "linux", - any(target_arch = "mips", target_arch = "mipsel")))] + any(target_arch = "mips", + target_arch = "mipsel", + target_arch = "powerpc")))] pub const FIONBIO: libc::c_ulong = 0x667e; #[cfg(any(target_os = "macos", @@ -49,7 +51,9 @@ pub const FIOCLEX: libc::c_ulong = 0x20006601; target_os = "android"))] pub const FIOCLEX: libc::c_ulong = 0x5451; #[cfg(all(target_os = "linux", - any(target_arch = "mips", target_arch = "mipsel")))] + any(target_arch = "mips", + target_arch = "mipsel", + target_arch = "powerpc")))] pub const FIOCLEX: libc::c_ulong = 0x6601; #[cfg(any(target_os = "macos", @@ -182,7 +186,9 @@ mod signal { } #[cfg(all(target_os = "linux", - any(target_arch = "mips", target_arch = "mipsel")))] + any(target_arch = "mips", + target_arch = "mipsel", + target_arch = "powerpc")))] mod signal { use libc; -- cgit 1.4.1-3-g733a5 From e9908da0d7cf881391c37ff10bb5573f2d8a4198 Mon Sep 17 00:00:00 2001 From: Richo Healey Date: Fri, 9 Jan 2015 20:28:48 -0800 Subject: powerpc: Fixup more stack work --- src/libstd/sys/unix/stack_overflow.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/libstd') diff --git a/src/libstd/sys/unix/stack_overflow.rs b/src/libstd/sys/unix/stack_overflow.rs index 48a51813ba4..45680f52e73 100644 --- a/src/libstd/sys/unix/stack_overflow.rs +++ b/src/libstd/sys/unix/stack_overflow.rs @@ -150,6 +150,7 @@ mod imp { all(target_os = "linux", target_arch = "aarch64"), all(target_os = "linux", target_arch = "mips"), // may not match all(target_os = "linux", target_arch = "mipsel"), // may not match + all(target_os = "linux", target_arch = "powerpc"), // may not match target_os = "android"))] // may not match mod signal { use libc; -- cgit 1.4.1-3-g733a5 From 7a05dc273dc193c747853e35231e165b2665e3f0 Mon Sep 17 00:00:00 2001 From: Richo Healey Date: Fri, 9 Jan 2015 20:33:29 -0800 Subject: powerpc: pthread support --- src/libstd/sys/unix/sync.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/sys/unix/sync.rs b/src/libstd/sys/unix/sync.rs index fbbdee1009d..c1e3fc88794 100644 --- a/src/libstd/sys/unix/sync.rs +++ b/src/libstd/sys/unix/sync.rs @@ -126,7 +126,8 @@ mod os { #[cfg(any(target_arch = "x86", target_arch = "arm", target_arch = "mips", - target_arch = "mipsel"))] + target_arch = "mipsel", + target_arch = "powerpc"))] const __SIZEOF_PTHREAD_MUTEX_T: uint = 24 - 8; #[cfg(target_arch = "aarch64")] const __SIZEOF_PTHREAD_MUTEX_T: uint = 48 - 8; @@ -136,7 +137,8 @@ mod os { target_arch = "arm", target_arch = "aarch64", target_arch = "mips", - target_arch = "mipsel"))] + target_arch = "mipsel", + target_arch = "powerpc"))] const __SIZEOF_PTHREAD_COND_T: uint = 48 - 8; #[cfg(any(target_arch = "x86_64", @@ -146,7 +148,8 @@ mod os { #[cfg(any(target_arch = "x86", target_arch = "arm", target_arch = "mips", - target_arch = "mipsel"))] + target_arch = "mipsel", + target_arch = "powerpc"))] const __SIZEOF_PTHREAD_RWLOCK_T: uint = 32 - 8; #[repr(C)] -- cgit 1.4.1-3-g733a5