Skip to content

Commit

Permalink
complete openbsd support for std::env
Browse files Browse the repository at this point in the history
- add `std::env:consts`
- deprecating `std::os::consts`
- refactoring errno_location()
  • Loading branch information
semarie committed Feb 5, 2015
1 parent 5ad3488 commit cb4965e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
32 changes: 32 additions & 0 deletions src/libstd/env.rs
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions src/libstd/os.rs
Expand Up @@ -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;

Expand Down
10 changes: 3 additions & 7 deletions src/libstd/sys/unix/os.rs
Expand Up @@ -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"))]
Expand Down

0 comments on commit cb4965e

Please sign in to comment.