From cb4965ef3a826af8150ef863e98709b4ffa83767 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Marie?= Date: Thu, 5 Feb 2015 18:56:10 +0100 Subject: [PATCH] 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(-) diff --git a/src/libstd/env.rs b/src/libstd/env.rs index 559a68542efc..c3aacf6f6b0c 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 64f9e16aee4f..72a8ac049117 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 be52c7dc6929..b191eda583c9 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"))]