mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Apply several fixes for Illumos support
This commit is contained in:
parent
f189d7a693
commit
ebab24059a
6
configure
vendored
6
configure
vendored
@ -1,12 +1,12 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# /bin/sh on Solaris is not a POSIX compatible shell, but /usr/bin/ksh is.
|
# /bin/sh on Solaris is not a POSIX compatible shell, but /usr/bin/bash is.
|
||||||
if [ `uname -s` = 'SunOS' -a "${POSIX_SHELL}" != "true" ]; then
|
if [ `uname -s` = 'SunOS' -a "${POSIX_SHELL}" != "true" ]; then
|
||||||
POSIX_SHELL="true"
|
POSIX_SHELL="true"
|
||||||
export POSIX_SHELL
|
export POSIX_SHELL
|
||||||
exec /usr/bin/bash $0 "$@"
|
exec /usr/bin/env bash $0 "$@"
|
||||||
fi
|
fi
|
||||||
unset POSIX_SHELL # clear it so if we invoke other scripts, they run as ksh as well
|
unset POSIX_SHELL # clear it so if we invoke other scripts, they run as bash as well
|
||||||
|
|
||||||
msg() {
|
msg() {
|
||||||
echo "configure: $*"
|
echo "configure: $*"
|
||||||
|
@ -13,8 +13,6 @@ use target::Target;
|
|||||||
pub fn target() -> Target {
|
pub fn target() -> Target {
|
||||||
let mut base = super::sunos_base::opts();
|
let mut base = super::sunos_base::opts();
|
||||||
base.pre_link_args.push("-m64".to_string());
|
base.pre_link_args.push("-m64".to_string());
|
||||||
base.pre_link_args.push("-lsocket".to_string());
|
|
||||||
base.pre_link_args.push("-lposix4".to_string());
|
|
||||||
|
|
||||||
Target {
|
Target {
|
||||||
llvm_target: "x86_64-pc-solaris2.11".to_string(),
|
llvm_target: "x86_64-pc-solaris2.11".to_string(),
|
||||||
|
@ -84,38 +84,6 @@ mod cmath {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_os = "sunos"))]
|
|
||||||
macro_rules! log_wrapper {
|
|
||||||
($num:ident, $f:ident) => (
|
|
||||||
unsafe { intrinsics::$f($num) }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Illumos requires a wrapper around log, log2, and log10 functions
|
|
||||||
// because of non-standard behavior (e.g. log(-n) returns -Inf instead
|
|
||||||
// of expected NaN).
|
|
||||||
#[cfg(target_os = "sunos")]
|
|
||||||
macro_rules! log_wrapper {
|
|
||||||
($num:ident, $f:ident) => (
|
|
||||||
if $num.is_finite() {
|
|
||||||
if $num > 0.0 {
|
|
||||||
return unsafe { intrinsics::$f($num) }
|
|
||||||
}
|
|
||||||
return if $num == 0.0 {
|
|
||||||
NEG_INFINITY // log(0) = -Inf
|
|
||||||
} else {
|
|
||||||
NAN // log(-ve) = NaN
|
|
||||||
}
|
|
||||||
} else if $num.is_nan() {
|
|
||||||
$num // log(NaN) = NaN
|
|
||||||
} else if $num > 0.0 {
|
|
||||||
$num // log(Inf) = Inf
|
|
||||||
} else {
|
|
||||||
return NAN // log(-Inf) = NaN
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
#[lang = "f64"]
|
#[lang = "f64"]
|
||||||
impl f64 {
|
impl f64 {
|
||||||
@ -543,7 +511,28 @@ impl f64 {
|
|||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ln(self) -> f64 {
|
pub fn ln(self) -> f64 {
|
||||||
log_wrapper!(self, logf64)
|
if !cfg!(target_os = "sunos") {
|
||||||
|
unsafe { intrinsics::logf64(self) }
|
||||||
|
} else {
|
||||||
|
// Illumos requires a wrapper around log, log2, and log10 functions
|
||||||
|
// because of their non-standard behavior (e.g. log(-n) returns -Inf instead
|
||||||
|
// of expected NaN).
|
||||||
|
if self.is_finite() {
|
||||||
|
if self > 0.0 {
|
||||||
|
unsafe { intrinsics::logf64(self) }
|
||||||
|
} else if self == 0.0 {
|
||||||
|
NEG_INFINITY // log(0) = -Inf
|
||||||
|
} else {
|
||||||
|
NAN // log(-n) = NaN
|
||||||
|
}
|
||||||
|
} else if self.is_nan() {
|
||||||
|
self // log(NaN) = NaN
|
||||||
|
} else if self > 0.0 {
|
||||||
|
self // log(Inf) = Inf
|
||||||
|
} else {
|
||||||
|
NAN // log(-Inf) = NaN
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the logarithm of the number with respect to an arbitrary base.
|
/// Returns the logarithm of the number with respect to an arbitrary base.
|
||||||
@ -578,7 +567,27 @@ impl f64 {
|
|||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn log2(self) -> f64 {
|
pub fn log2(self) -> f64 {
|
||||||
log_wrapper!(self, log2f64)
|
if !cfg!(target_os = "sunos") {
|
||||||
|
unsafe { intrinsics::log2f64(self) }
|
||||||
|
} else {
|
||||||
|
// Illumos requires a wrapper around the log2 function because of
|
||||||
|
// its non-standard behavior
|
||||||
|
if self.is_finite() {
|
||||||
|
if self > 0.0 {
|
||||||
|
unsafe { intrinsics::log2f64(self) }
|
||||||
|
} else if self == 0.0 {
|
||||||
|
NEG_INFINITY // log2(0) = -Inf
|
||||||
|
} else {
|
||||||
|
NAN // log2(-n) = NaN
|
||||||
|
}
|
||||||
|
} else if self.is_nan() {
|
||||||
|
self // log2(NaN) = NaN
|
||||||
|
} else if self > 0.0 {
|
||||||
|
self // log2(Inf) = Inf
|
||||||
|
} else {
|
||||||
|
NAN // log2(-Inf) = NaN
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the base 10 logarithm of the number.
|
/// Returns the base 10 logarithm of the number.
|
||||||
@ -594,7 +603,27 @@ impl f64 {
|
|||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn log10(self) -> f64 {
|
pub fn log10(self) -> f64 {
|
||||||
log_wrapper!(self, log10f64)
|
if !cfg!(target_os = "sunos") {
|
||||||
|
unsafe { intrinsics::log10f64(self) }
|
||||||
|
} else {
|
||||||
|
// Illumos requires a wrapper around the log10 function because of
|
||||||
|
// its non-standard behavior.
|
||||||
|
if self.is_finite() {
|
||||||
|
if self > 0.0 {
|
||||||
|
unsafe { intrinsics::log10f64(self) }
|
||||||
|
} else if self == 0.0 {
|
||||||
|
NEG_INFINITY // log10(0) = -Inf
|
||||||
|
} else {
|
||||||
|
NAN // log10(-n) = NaN
|
||||||
|
}
|
||||||
|
} else if self.is_nan() {
|
||||||
|
self // log10(NaN) = NaN
|
||||||
|
} else if self > 0.0 {
|
||||||
|
self // log10(Inf) = Inf
|
||||||
|
} else {
|
||||||
|
NAN // log10(-Inf) = NaN
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts radians to degrees.
|
/// Converts radians to degrees.
|
||||||
|
@ -39,6 +39,12 @@ extern {}
|
|||||||
#[link(name = "pthread")]
|
#[link(name = "pthread")]
|
||||||
extern {}
|
extern {}
|
||||||
|
|
||||||
|
#[cfg(target_os = "sunos")]
|
||||||
|
#[link(name = "socket")]
|
||||||
|
#[link(name = "posix4")]
|
||||||
|
#[link(name = "pthread")]
|
||||||
|
extern {}
|
||||||
|
|
||||||
// For PNaCl targets, nacl_io is a Pepper wrapper for some IO functions
|
// For PNaCl targets, nacl_io is a Pepper wrapper for some IO functions
|
||||||
// missing (ie always error) in Newlib.
|
// missing (ie always error) in Newlib.
|
||||||
#[cfg(all(target_os = "nacl", not(test)))]
|
#[cfg(all(target_os = "nacl", not(test)))]
|
||||||
|
@ -269,12 +269,14 @@ pub fn current_exe() -> io::Result<PathBuf> {
|
|||||||
Err(io::Error::last_os_error())
|
Err(io::Error::last_os_error())
|
||||||
} else {
|
} else {
|
||||||
let filename = CStr::from_ptr(path).to_bytes();
|
let filename = CStr::from_ptr(path).to_bytes();
|
||||||
|
let path = PathBuf::from(<OsStr as OsStrExt>::from_bytes(filename));
|
||||||
|
|
||||||
|
// Prepend a current working directory to the path if
|
||||||
|
// it doesn't contain an absolute pathname.
|
||||||
if filename[0] == b'/' {
|
if filename[0] == b'/' {
|
||||||
Ok(PathBuf::from(<OsStr as OsStrExt>::from_bytes(filename)))
|
Ok(path)
|
||||||
} else {
|
} else {
|
||||||
// Prepend current working directory to the path if
|
getcwd().map(|cwd| cwd.join(path))
|
||||||
// it doesn't contain an absolute pathname.
|
|
||||||
return getcwd().map(|cwd| cwd.join(<OsStr as OsStrExt>::from_bytes(filename)))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user