about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNikita Baksalyar <nikita.baksalyar@gmail.com>2016-01-26 17:15:10 +0300
committerNikita Baksalyar <nikita.baksalyar@gmail.com>2016-01-31 18:57:28 +0300
commitebab24059a2b85cf6167c589c40a265f815d9f45 (patch)
tree45743743244ea0ac23f8bbc9518265d7adce155a
parentf189d7a6937c063f9592136a39c836b17c008a93 (diff)
downloadrust-ebab24059a2b85cf6167c589c40a265f815d9f45.tar.gz
rust-ebab24059a2b85cf6167c589c40a265f815d9f45.zip
Apply several fixes for Illumos support
-rwxr-xr-xconfigure6
-rw-r--r--src/librustc_back/target/x86_64_sun_solaris.rs2
-rw-r--r--src/libstd/num/f64.rs99
-rw-r--r--src/libstd/rtdeps.rs6
-rw-r--r--src/libstd/sys/unix/os.rs10
5 files changed, 79 insertions, 44 deletions
diff --git a/configure b/configure
index 83f7e1736c2..27e0234a7de 100755
--- a/configure
+++ b/configure
@@ -1,12 +1,12 @@
 #!/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
     POSIX_SHELL="true"
     export POSIX_SHELL
-    exec /usr/bin/bash $0 "$@"
+    exec /usr/bin/env bash $0 "$@"
 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() {
     echo "configure: $*"
diff --git a/src/librustc_back/target/x86_64_sun_solaris.rs b/src/librustc_back/target/x86_64_sun_solaris.rs
index a18aa0277e1..233f9a20c1f 100644
--- a/src/librustc_back/target/x86_64_sun_solaris.rs
+++ b/src/librustc_back/target/x86_64_sun_solaris.rs
@@ -13,8 +13,6 @@ use target::Target;
 pub fn target() -> Target {
     let mut base = super::sunos_base::opts();
     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 {
         llvm_target: "x86_64-pc-solaris2.11".to_string(),
diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs
index 2afaef2fff1..f119b1d9f9a 100644
--- a/src/libstd/num/f64.rs
+++ b/src/libstd/num/f64.rs
@@ -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))]
 #[lang = "f64"]
 impl f64 {
@@ -543,7 +511,28 @@ impl f64 {
     #[stable(feature = "rust1", since = "1.0.0")]
     #[inline]
     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.
@@ -578,7 +567,27 @@ impl f64 {
     #[stable(feature = "rust1", since = "1.0.0")]
     #[inline]
     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.
@@ -594,7 +603,27 @@ impl f64 {
     #[stable(feature = "rust1", since = "1.0.0")]
     #[inline]
     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.
diff --git a/src/libstd/rtdeps.rs b/src/libstd/rtdeps.rs
index 9b1046f39a7..f5853cdaf3d 100644
--- a/src/libstd/rtdeps.rs
+++ b/src/libstd/rtdeps.rs
@@ -39,6 +39,12 @@ extern {}
 #[link(name = "pthread")]
 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
 // missing (ie always error) in Newlib.
 #[cfg(all(target_os = "nacl", not(test)))]
diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs
index e77cd65edde..e6883a11ada 100644
--- a/src/libstd/sys/unix/os.rs
+++ b/src/libstd/sys/unix/os.rs
@@ -269,12 +269,14 @@ pub fn current_exe() -> io::Result<PathBuf> {
             Err(io::Error::last_os_error())
         } else {
             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'/' {
-                Ok(PathBuf::from(<OsStr as OsStrExt>::from_bytes(filename)))
+                Ok(path)
             } else {
-                // Prepend current working directory to the path if
-                // it doesn't contain an absolute pathname.
-                return getcwd().map(|cwd| cwd.join(<OsStr as OsStrExt>::from_bytes(filename)))
+                getcwd().map(|cwd| cwd.join(path))
             }
         }
     }