Skip to content

Commit cb4965e

Browse files
committed
complete openbsd support for std::env
- add `std::env:consts` - deprecating `std::os::consts` - refactoring errno_location()
1 parent 5ad3488 commit cb4965e

File tree

3 files changed

+37
-7
lines changed

3 files changed

+37
-7
lines changed

src/libstd/env.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,38 @@ pub mod consts {
562562
pub const EXE_EXTENSION: &'static str = "";
563563
}
564564

565+
/// Constants associated with the current target
566+
#[cfg(target_os = "openbsd")]
567+
pub mod consts {
568+
pub use super::arch_consts::ARCH;
569+
570+
pub const FAMILY: &'static str = "unix";
571+
572+
/// A string describing the specific operating system in use: in this
573+
/// case, `dragonfly`.
574+
pub const OS: &'static str = "openbsd";
575+
576+
/// Specifies the filename prefix used for shared libraries on this
577+
/// platform: in this case, `lib`.
578+
pub const DLL_PREFIX: &'static str = "lib";
579+
580+
/// Specifies the filename suffix used for shared libraries on this
581+
/// platform: in this case, `.so`.
582+
pub const DLL_SUFFIX: &'static str = ".so";
583+
584+
/// Specifies the file extension used for shared libraries on this
585+
/// platform that goes after the dot: in this case, `so`.
586+
pub const DLL_EXTENSION: &'static str = "so";
587+
588+
/// Specifies the filename suffix used for executable binaries on this
589+
/// platform: in this case, the empty string.
590+
pub const EXE_SUFFIX: &'static str = "";
591+
592+
/// Specifies the file extension, if any, used for executable binaries
593+
/// on this platform: in this case, the empty string.
594+
pub const EXE_EXTENSION: &'static str = "";
595+
}
596+
565597
/// Constants associated with the current target
566598
#[cfg(target_os = "android")]
567599
pub mod consts {

src/libstd/os.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,8 @@ pub mod consts {
12891289
}
12901290

12911291
#[cfg(target_os = "openbsd")]
1292+
#[deprecated(since = "1.0.0", reason = "renamed to env::consts")]
1293+
#[unstable(feature = "os")]
12921294
pub mod consts {
12931295
pub use os::arch_consts::ARCH;
12941296

src/libstd/sys/unix/os.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,9 @@ pub fn errno() -> i32 {
4747
}
4848

4949
#[cfg(target_os = "openbsd")]
50-
fn errno_location() -> *const c_int {
51-
extern {
52-
fn __errno() -> *const c_int;
53-
}
54-
unsafe {
55-
__errno()
56-
}
50+
unsafe fn errno_location() -> *const c_int {
51+
extern { fn __errno() -> *const c_int; }
52+
__errno()
5753
}
5854

5955
#[cfg(any(target_os = "linux", target_os = "android"))]

0 commit comments

Comments
 (0)