From fcb30a0b67b1bd4acbc3422ff74fac5d031ae1ae Mon Sep 17 00:00:00 2001 From: Sébastien Marie Date: Thu, 29 Jan 2015 08:19:28 +0100 Subject: openbsd support --- src/libstd/sys/common/stack.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/libstd/sys/common/stack.rs') diff --git a/src/libstd/sys/common/stack.rs b/src/libstd/sys/common/stack.rs index 88bb9395cf1..cd5458a2109 100644 --- a/src/libstd/sys/common/stack.rs +++ b/src/libstd/sys/common/stack.rs @@ -241,6 +241,11 @@ pub unsafe fn record_sp_limit(limit: uint) { #[cfg(all(target_arch = "arm", target_os = "ios"))] #[inline(always)] unsafe fn target_record_sp_limit(_: uint) { } + + #[cfg(target_os = "openbsd")] #[inline(always)] + unsafe fn target_record_sp_limit(_: uint) { + // segmented stack is disabled + } } /// The counterpart of the function above, this function will fetch the current @@ -345,4 +350,10 @@ pub unsafe fn get_sp_limit() -> uint { unsafe fn target_get_sp_limit() -> uint { 1024 } + + #[cfg(target_os = "openbsd")] #[inline(always)] + unsafe fn target_get_sp_limit() -> uint { + // segmented stack is disabled + 1024 + } } -- cgit 1.4.1-3-g733a5 From 568a451a90a14b101ed357235a5055de2940f16b Mon Sep 17 00:00:00 2001 From: Sébastien Marie Date: Fri, 30 Jan 2015 08:15:28 +0100 Subject: openbsd: incoporate remarks - consolidate target_record_sp_limit and target_get_sp_limit functions for aarch64, powerpc, arm-ios and openbsd as there are all without segmented stacks (no need to duplicate functions). - rename __load_self function to rust_load_self - use a mutex inner load_self() as underline implementation is not thread-safe --- src/libstd/sys/common/stack.rs | 54 +++++++++++++----------------------------- src/libstd/sys/unix/os.rs | 11 +++++++-- src/rt/rust_builtin.c | 2 +- 3 files changed, 27 insertions(+), 40 deletions(-) (limited to 'src/libstd/sys/common/stack.rs') diff --git a/src/libstd/sys/common/stack.rs b/src/libstd/sys/common/stack.rs index cd5458a2109..8dd2f154fa8 100644 --- a/src/libstd/sys/common/stack.rs +++ b/src/libstd/sys/common/stack.rs @@ -227,24 +227,14 @@ pub unsafe fn record_sp_limit(limit: uint) { } // aarch64 - FIXME(AARCH64): missing... - #[cfg(target_arch = "aarch64")] - 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) { - } - - #[cfg(target_os = "openbsd")] #[inline(always)] + // arm-ios - iOS segmented stack is disabled for now, see related notes + // openbsd - segmented stack is disabled + #[cfg(any(target_arch = "aarch64", + target_arch = "powerpc", + all(target_arch = "arm", target_os = "ios"), + target_os = "openbsd"))] unsafe fn target_record_sp_limit(_: uint) { - // segmented stack is disabled } } @@ -332,28 +322,18 @@ pub unsafe fn get_sp_limit() -> uint { } // aarch64 - FIXME(AARCH64): missing... - #[cfg(target_arch = "aarch64")] - unsafe fn target_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. - #[cfg(all(target_arch = "arm", target_os = "ios"))] #[inline(always)] - unsafe fn target_get_sp_limit() -> uint { - 1024 - } - - #[cfg(target_os = "openbsd")] #[inline(always)] + // powerpc - FIXME(POWERPC): missing... + // arm-ios - iOS doesn't support segmented stacks yet. + // openbsd - OpenBSD doesn't support segmented stacks. + // + // This function might be called by runtime though + // so it is unsafe to unreachable, let's return a fixed constant. + #[cfg(any(target_arch = "aarch64", + target_arch = "powerpc", + all(target_arch = "arm", target_os = "ios"), + target_os = "openbsd"))] + #[inline(always)] unsafe fn target_get_sp_limit() -> uint { - // segmented stack is disabled 1024 } } diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index dd39501a7cb..9faa4a038ba 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -217,11 +217,18 @@ pub fn load_self() -> Option> { #[cfg(target_os = "openbsd")] pub fn load_self() -> Option> { + use sync::{StaticMutex, MUTEX_INIT}; + + static LOCK: StaticMutex = MUTEX_INIT; + extern { - fn __load_self() -> *const c_char; + fn rust_load_self() -> *const c_char; } + + let _guard = LOCK.lock(); + unsafe { - let v = __load_self(); + let v = rust_load_self(); if v.is_null() { None } else { diff --git a/src/rt/rust_builtin.c b/src/rt/rust_builtin.c index 372ff0f2147..382cbf0d5d1 100644 --- a/src/rt/rust_builtin.c +++ b/src/rt/rust_builtin.c @@ -204,7 +204,7 @@ int *__dfly_error(void) { return __error(); } #include #include -const char * __load_self() { +const char * rust_load_self() { static char *self = NULL; if (self == NULL) { -- cgit 1.4.1-3-g733a5