From dc2e444e506c31e8f4a4331c7f6264ca6c107bb6 Mon Sep 17 00:00:00 2001 From: Joseph Crail Date: Wed, 4 Feb 2015 23:00:02 -0500 Subject: Fix for misspelled comments. The spelling corrections were made in both documentation comments and regular comments. --- src/libstd/sys/common/wtf8.rs | 2 +- src/libstd/sys/windows/thread_local.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libstd/sys') diff --git a/src/libstd/sys/common/wtf8.rs b/src/libstd/sys/common/wtf8.rs index b30af10986b..158c491aeae 100644 --- a/src/libstd/sys/common/wtf8.rs +++ b/src/libstd/sys/common/wtf8.rs @@ -84,7 +84,7 @@ impl CodePoint { /// Create a new `CodePoint` from a `char`. /// - /// Since all Unicode scalar values are code points, this always succeds. + /// Since all Unicode scalar values are code points, this always succeeds. #[inline] pub fn from_char(value: char) -> CodePoint { CodePoint { value: value as u32 } diff --git a/src/libstd/sys/windows/thread_local.rs b/src/libstd/sys/windows/thread_local.rs index 54a32e43daf..0c24ab1fa09 100644 --- a/src/libstd/sys/windows/thread_local.rs +++ b/src/libstd/sys/windows/thread_local.rs @@ -191,7 +191,7 @@ unsafe fn unregister_dtor(key: Key) -> bool { // # What's up with this callback? // // The callback specified receives a number of parameters from... someone! -// (the kernel? the runtime? I'm not qute sure!) There are a few events that +// (the kernel? the runtime? I'm not quite sure!) There are a few events that // this gets invoked for, but we're currently only interested on when a // thread or a process "detaches" (exits). The process part happens for the // last thread and the thread part happens for any normal thread. -- cgit 1.4.1-3-g733a5 From 5ad3488f29bbccfcee074bb0f3971acec97cfc45 Mon Sep 17 00:00:00 2001 From: Sébastien Marie Date: Thu, 5 Feb 2015 15:24:17 +0100 Subject: unbreak tree for openbsd after #21787 - add `_SC_GETPW_R_SIZE_MAX` constant - declare `struct passwd` - convert `load_self` to `current_exe` Note: OpenBSD don't provide system function to return a valuable Path for `env::current_exe`. The implementation is currently based on the value of `argv[0]`, which couldn't be used when executable is called via PATH. --- src/libstd/sys/unix/c.rs | 5 ++++- src/libstd/sys/unix/os.rs | 13 +++++++------ src/rt/rust_builtin.c | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) (limited to 'src/libstd/sys') diff --git a/src/libstd/sys/unix/c.rs b/src/libstd/sys/unix/c.rs index 50a8e6b73e3..22194145252 100644 --- a/src/libstd/sys/unix/c.rs +++ b/src/libstd/sys/unix/c.rs @@ -74,6 +74,8 @@ pub const _SC_GETPW_R_SIZE_MAX: libc::c_int = 70; #[cfg(any(target_os = "macos", target_os = "freebsd"))] pub const _SC_GETPW_R_SIZE_MAX: libc::c_int = 71; +#[cfg(target_os = "openbsd")] +pub const _SC_GETPW_R_SIZE_MAX: libc::c_int = 101; #[cfg(target_os = "android")] pub const _SC_GETPW_R_SIZE_MAX: libc::c_int = 0x0048; @@ -91,7 +93,8 @@ pub struct passwd { #[repr(C)] #[cfg(any(target_os = "macos", - target_os = "freebsd"))] + target_os = "freebsd", + target_os = "openbsd"))] pub struct passwd { pub pw_name: *mut libc::c_char, pub pw_passwd: *mut libc::c_char, diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index 5004ff713c4..be52c7dc692 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -197,23 +197,23 @@ pub fn current_exe() -> IoResult { } #[cfg(target_os = "openbsd")] -pub fn load_self() -> Option> { +pub fn current_exe() -> IoResult { use sync::{StaticMutex, MUTEX_INIT}; static LOCK: StaticMutex = MUTEX_INIT; extern { - fn rust_load_self() -> *const c_char; + fn rust_current_exe() -> *const c_char; } let _guard = LOCK.lock(); unsafe { - let v = rust_load_self(); + let v = rust_current_exe(); if v.is_null() { - None + Err(IoError::last_error()) } else { - Some(ffi::c_str_to_bytes(&v).to_vec()) + Ok(Path::new(ffi::c_str_to_bytes(&v).to_vec())) } } } @@ -333,7 +333,8 @@ pub fn args() -> Args { #[cfg(any(target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "dragonfly"))] + target_os = "dragonfly", + target_os = "openbsd"))] pub fn args() -> Args { use rt; let bytes = rt::args::clone().unwrap_or(Vec::new()); diff --git a/src/rt/rust_builtin.c b/src/rt/rust_builtin.c index 382cbf0d5d1..255fbdcbfcf 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 * rust_load_self() { +const char * rust_current_exe() { static char *self = NULL; if (self == NULL) { -- cgit 1.4.1-3-g733a5 From cb4965ef3a826af8150ef863e98709b4ffa83767 Mon Sep 17 00:00:00 2001 From: Sébastien Marie Date: Thu, 5 Feb 2015 18:56:10 +0100 Subject: complete openbsd support for `std::env` - add `std::env:consts` - deprecating `std::os::consts` - refactoring errno_location() --- src/libstd/env.rs | 32 ++++++++++++++++++++++++++++++++ src/libstd/os.rs | 2 ++ src/libstd/sys/unix/os.rs | 10 +++------- 3 files changed, 37 insertions(+), 7 deletions(-) (limited to 'src/libstd/sys') diff --git a/src/libstd/env.rs b/src/libstd/env.rs index 559a68542ef..c3aacf6f6b0 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -562,6 +562,38 @@ pub mod consts { pub const EXE_EXTENSION: &'static str = ""; } +/// Constants associated with the current target +#[cfg(target_os = "openbsd")] +pub mod consts { + pub use super::arch_consts::ARCH; + + pub const FAMILY: &'static str = "unix"; + + /// A string describing the specific operating system in use: in this + /// case, `dragonfly`. + pub const OS: &'static str = "openbsd"; + + /// Specifies the filename prefix used for shared libraries on this + /// platform: in this case, `lib`. + pub const DLL_PREFIX: &'static str = "lib"; + + /// Specifies the filename suffix used for shared libraries on this + /// platform: in this case, `.so`. + pub const DLL_SUFFIX: &'static str = ".so"; + + /// Specifies the file extension used for shared libraries on this + /// platform that goes after the dot: in this case, `so`. + pub const DLL_EXTENSION: &'static str = "so"; + + /// Specifies the filename suffix used for executable binaries on this + /// platform: in this case, the empty string. + pub const EXE_SUFFIX: &'static str = ""; + + /// Specifies the file extension, if any, used for executable binaries + /// on this platform: in this case, the empty string. + pub const EXE_EXTENSION: &'static str = ""; +} + /// Constants associated with the current target #[cfg(target_os = "android")] pub mod consts { diff --git a/src/libstd/os.rs b/src/libstd/os.rs index 64f9e16aee4..72a8ac04911 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -1289,6 +1289,8 @@ pub mod consts { } #[cfg(target_os = "openbsd")] +#[deprecated(since = "1.0.0", reason = "renamed to env::consts")] +#[unstable(feature = "os")] pub mod consts { pub use os::arch_consts::ARCH; diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index be52c7dc692..b191eda583c 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -47,13 +47,9 @@ pub fn errno() -> i32 { } #[cfg(target_os = "openbsd")] - fn errno_location() -> *const c_int { - extern { - fn __errno() -> *const c_int; - } - unsafe { - __errno() - } + unsafe fn errno_location() -> *const c_int { + extern { fn __errno() -> *const c_int; } + __errno() } #[cfg(any(target_os = "linux", target_os = "android"))] -- cgit 1.4.1-3-g733a5