about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorBastian Köcher <git@kchr.de>2017-12-23 00:47:25 +0100
committerBastian Köcher <git@kchr.de>2017-12-26 12:26:39 +0100
commitdbbba553828b1763951fc0eb02fa436ac61d9a95 (patch)
treead72957f2499676126569f300aab23e40fd38c22 /src/libstd
parentf972f529b2e17e7b6b8ed4a4b4a6ad29917acfce (diff)
downloadrust-dbbba553828b1763951fc0eb02fa436ac61d9a95.tar.gz
rust-dbbba553828b1763951fc0eb02fa436ac61d9a95.zip
Rework the exit failure and success declaration for wasm32
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/termination.rs18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/libstd/termination.rs b/src/libstd/termination.rs
index cfbeff0de15..61137ba4922 100644
--- a/src/libstd/termination.rs
+++ b/src/libstd/termination.rs
@@ -9,7 +9,17 @@
 // except according to those terms.
 
 use error::Error;
-use libc;
+#[cfg(target_arch = "wasm32")]
+mod exit {
+    pub const SUCCESS: i32 = 0;
+    pub const FAILURE: i32 = 1;
+}
+#[cfg(not(target_arch = "wasm32"))]
+mod exit {
+    use libc;
+    pub const SUCCESS: i32 = libc::EXIT_SUCCESS;
+    pub const FAILURE: i32 = libc::EXIT_FAILURE;
+}
 
 /// A trait for implementing arbitrary return types in the `main` function.
 ///
@@ -31,7 +41,7 @@ pub trait Termination {
 
 #[unstable(feature = "termination_trait", issue = "43301")]
 impl Termination for () {
-    fn report(self) -> i32 { libc::EXIT_SUCCESS }
+    fn report(self) -> i32 { exit::SUCCESS }
 }
 
 #[unstable(feature = "termination_trait", issue = "43301")]
@@ -41,7 +51,7 @@ impl<T: Termination, E: Error> Termination for Result<T, E> {
             Ok(val) => val.report(),
             Err(err) => {
                 print_error(err);
-                libc::EXIT_FAILURE
+                exit::FAILURE
             }
         }
     }
@@ -64,7 +74,7 @@ impl Termination for ! {
 #[unstable(feature = "termination_trait", issue = "43301")]
 impl Termination for bool {
     fn report(self) -> i32 {
-        if self { libc::EXIT_SUCCESS } else { libc::EXIT_FAILURE }
+        if self { exit::SUCCESS } else { exit::FAILURE }
     }
 }