diff options
| author | Michael Neumann <mneumann@ntecs.de> | 2014-07-29 16:44:39 +0200 |
|---|---|---|
| committer | Michael Neumann <mneumann@ntecs.de> | 2014-07-29 16:44:39 +0200 |
| commit | 2e2f53fad210543be39f6997991abcd403533676 (patch) | |
| tree | 2f20ba5f45c3e60332b2cc5509659002862b6160 /src/libstd | |
| parent | 72e2c7dec34bd87fab6bb15bb7d3d97269d4afd3 (diff) | |
| download | rust-2e2f53fad210543be39f6997991abcd403533676.tar.gz rust-2e2f53fad210543be39f6997991abcd403533676.zip | |
Port Rust to DragonFlyBSD
Not included are two required patches: * LLVM: segmented stack support for DragonFly [1] * jemalloc: simple configure patches [1]: http://reviews.llvm.org/D4705
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/dynamic_lib.rs | 2 | ||||
| -rw-r--r-- | src/libstd/os.rs | 44 | ||||
| -rw-r--r-- | src/libstd/rt/backtrace.rs | 6 | ||||
| -rw-r--r-- | src/libstd/rtdeps.rs | 4 |
4 files changed, 55 insertions, 1 deletions
diff --git a/src/libstd/dynamic_lib.rs b/src/libstd/dynamic_lib.rs index 5980245fa79..2c4e0ea6701 100644 --- a/src/libstd/dynamic_lib.rs +++ b/src/libstd/dynamic_lib.rs @@ -193,6 +193,7 @@ mod test { #[cfg(target_os = "linux")] #[cfg(target_os = "macos")] #[cfg(target_os = "freebsd")] + #[cfg(target_os = "dragonfly")] fn test_errors_do_not_crash() { // Open /dev/null as a library to get an error, and make sure // that only causes an error, and not a crash. @@ -209,6 +210,7 @@ mod test { #[cfg(target_os = "macos")] #[cfg(target_os = "ios")] #[cfg(target_os = "freebsd")] +#[cfg(target_os = "dragonfly")] pub mod dl { use c_str::{CString, ToCStr}; diff --git a/src/libstd/os.rs b/src/libstd/os.rs index ebcb60253f5..7fff510a60a 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -651,6 +651,7 @@ pub fn dll_filename(base: &str) -> String { pub fn self_exe_name() -> Option<Path> { #[cfg(target_os = "freebsd")] + #[cfg(target_os = "dragonfly")] fn load_self() -> Option<Vec<u8>> { unsafe { use libc::funcs::bsd44::*; @@ -913,6 +914,16 @@ pub fn errno() -> int { } } + #[cfg(target_os = "dragonfly")] + fn errno_location() -> *const c_int { + extern { + fn __dfly_error() -> *const c_int; + } + unsafe { + __dfly_error() + } + } + #[cfg(target_os = "linux")] #[cfg(target_os = "android")] fn errno_location() -> *const c_int { @@ -961,6 +972,7 @@ pub fn error_string(errnum: uint) -> String { #[cfg(target_os = "ios")] #[cfg(target_os = "android")] #[cfg(target_os = "freebsd")] + #[cfg(target_os = "dragonfly")] fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: libc::size_t) -> c_int { extern { @@ -1167,6 +1179,7 @@ fn real_args_as_bytes() -> Vec<Vec<u8>> { #[cfg(target_os = "linux")] #[cfg(target_os = "android")] #[cfg(target_os = "freebsd")] +#[cfg(target_os = "dragonfly")] fn real_args_as_bytes() -> Vec<Vec<u8>> { use rt; @@ -1767,6 +1780,37 @@ pub mod consts { pub static EXE_EXTENSION: &'static str = ""; } +#[cfg(target_os = "dragonfly")] +pub mod consts { + pub use os::arch_consts::ARCH; + + pub static FAMILY: &'static str = "unix"; + + /// A string describing the specific operating system in use: in this + /// case, `dragonfly`. + pub static SYSNAME: &'static str = "dragonfly"; + + /// Specifies the filename prefix used for shared libraries on this + /// platform: in this case, `lib`. + pub static DLL_PREFIX: &'static str = "lib"; + + /// Specifies the filename suffix used for shared libraries on this + /// platform: in this case, `.so`. + pub static 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 static DLL_EXTENSION: &'static str = "so"; + + /// Specifies the filename suffix used for executable binaries on this + /// platform: in this case, the empty string. + pub static EXE_SUFFIX: &'static str = ""; + + /// Specifies the file extension, if any, used for executable binaries + /// on this platform: in this case, the empty string. + pub static EXE_EXTENSION: &'static str = ""; +} + #[cfg(target_os = "android")] pub mod consts { pub use os::arch_consts::ARCH; diff --git a/src/libstd/rt/backtrace.rs b/src/libstd/rt/backtrace.rs index d075f9a1205..00477f8e119 100644 --- a/src/libstd/rt/backtrace.rs +++ b/src/libstd/rt/backtrace.rs @@ -464,11 +464,15 @@ mod imp { // the symbols. The libbacktrace API also states that the filename must // be in "permanent memory", so we copy it to a static and then use the // static as the pointer. + // + // FIXME: We also call self_exe_name() on DragonFly BSD. I haven't + // tested if this is required or not. unsafe fn init_state() -> *mut backtrace_state { static mut STATE: *mut backtrace_state = 0 as *mut backtrace_state; static mut LAST_FILENAME: [libc::c_char, ..256] = [0, ..256]; if !STATE.is_null() { return STATE } - let selfname = if cfg!(target_os = "freebsd") { + let selfname = if cfg!(target_os = "freebsd") || + cfg!(target_os = "dragonfly") { os::self_exe_name() } else { None diff --git a/src/libstd/rtdeps.rs b/src/libstd/rtdeps.rs index 0ffac99775c..1717aeb8430 100644 --- a/src/libstd/rtdeps.rs +++ b/src/libstd/rtdeps.rs @@ -38,6 +38,10 @@ extern {} #[link(name = "pthread")] extern {} +#[cfg(target_os = "dragonfly")] +#[link(name = "pthread")] +extern {} + #[cfg(target_os = "macos")] #[link(name = "System")] extern {} |
