about summary refs log tree commit diff
path: root/src/libstd/sys/wasm
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2019-12-22 17:42:04 -0500
committerMark Rousskov <mark.simulacrum@gmail.com>2019-12-22 17:42:47 -0500
commita06baa56b95674fc626b3c3fd680d6a65357fe60 (patch)
treecd9d867c2ca3cff5c1d6b3bd73377c44649fb075 /src/libstd/sys/wasm
parent8eb7c58dbb7b32701af113bc58722d0d1fefb1eb (diff)
downloadrust-a06baa56b95674fc626b3c3fd680d6a65357fe60.tar.gz
rust-a06baa56b95674fc626b3c3fd680d6a65357fe60.zip
Format the world
Diffstat (limited to 'src/libstd/sys/wasm')
-rw-r--r--src/libstd/sys/wasm/alloc.rs2
-rw-r--r--src/libstd/sys/wasm/condvar.rs13
-rw-r--r--src/libstd/sys/wasm/condvar_atomics.rs2
-rw-r--r--src/libstd/sys/wasm/fast_thread_local.rs2
-rw-r--r--src/libstd/sys/wasm/mod.rs14
-rw-r--r--src/libstd/sys/wasm/mutex.rs11
-rw-r--r--src/libstd/sys/wasm/mutex_atomics.rs7
-rw-r--r--src/libstd/sys/wasm/rwlock.rs7
-rw-r--r--src/libstd/sys/wasm/rwlock_atomics.rs23
9 files changed, 30 insertions, 51 deletions
diff --git a/src/libstd/sys/wasm/alloc.rs b/src/libstd/sys/wasm/alloc.rs
index 05e55334ac0..32b8b5bdaea 100644
--- a/src/libstd/sys/wasm/alloc.rs
+++ b/src/libstd/sys/wasm/alloc.rs
@@ -58,7 +58,7 @@ mod lock {
     pub fn lock() -> DropLock {
         loop {
             if LOCKED.swap(1, SeqCst) == 0 {
-                return DropLock
+                return DropLock;
             }
             // Ok so here's where things get a little depressing. At this point
             // in time we need to synchronously acquire a lock, but we're
diff --git a/src/libstd/sys/wasm/condvar.rs b/src/libstd/sys/wasm/condvar.rs
index 9c7cc3c63b1..9fd781c7282 100644
--- a/src/libstd/sys/wasm/condvar.rs
+++ b/src/libstd/sys/wasm/condvar.rs
@@ -1,23 +1,21 @@
 use crate::sys::mutex::Mutex;
 use crate::time::Duration;
 
-pub struct Condvar { }
+pub struct Condvar {}
 
 impl Condvar {
     pub const fn new() -> Condvar {
-        Condvar { }
+        Condvar {}
     }
 
     #[inline]
     pub unsafe fn init(&mut self) {}
 
     #[inline]
-    pub unsafe fn notify_one(&self) {
-    }
+    pub unsafe fn notify_one(&self) {}
 
     #[inline]
-    pub unsafe fn notify_all(&self) {
-    }
+    pub unsafe fn notify_all(&self) {}
 
     pub unsafe fn wait(&self, _mutex: &Mutex) {
         panic!("can't block with web assembly")
@@ -28,6 +26,5 @@ impl Condvar {
     }
 
     #[inline]
-    pub unsafe fn destroy(&self) {
-    }
+    pub unsafe fn destroy(&self) {}
 }
diff --git a/src/libstd/sys/wasm/condvar_atomics.rs b/src/libstd/sys/wasm/condvar_atomics.rs
index f452bbd3487..a4021c0ee83 100644
--- a/src/libstd/sys/wasm/condvar_atomics.rs
+++ b/src/libstd/sys/wasm/condvar_atomics.rs
@@ -78,7 +78,7 @@ impl Condvar {
         // `false` as we weren't actually notified.
         let ret = wasm32::i32_atomic_wait(self.ptr(), ticket, nanos as i64) != 2;
         mutex.lock();
-        return ret
+        return ret;
     }
 
     #[inline]
diff --git a/src/libstd/sys/wasm/fast_thread_local.rs b/src/libstd/sys/wasm/fast_thread_local.rs
index 9bdc26ae7d6..85d66098302 100644
--- a/src/libstd/sys/wasm/fast_thread_local.rs
+++ b/src/libstd/sys/wasm/fast_thread_local.rs
@@ -1,6 +1,6 @@
 #![unstable(feature = "thread_local_internals", issue = "none")]
 
-pub unsafe fn register_dtor(_t: *mut u8, _dtor: unsafe extern fn(*mut u8)) {
+pub unsafe fn register_dtor(_t: *mut u8, _dtor: unsafe extern "C" fn(*mut u8)) {
     // FIXME: right now there is no concept of "thread exit", but this is likely
     // going to show up at some point in the form of an exported symbol that the
     // wasm runtime is going to be expected to call. For now we basically just
diff --git a/src/libstd/sys/wasm/mod.rs b/src/libstd/sys/wasm/mod.rs
index de0bb38dc31..c115f756450 100644
--- a/src/libstd/sys/wasm/mod.rs
+++ b/src/libstd/sys/wasm/mod.rs
@@ -20,6 +20,7 @@ pub mod alloc;
 pub mod args;
 pub mod cmath;
 pub mod env;
+pub mod fast_thread_local;
 pub mod fs;
 pub mod io;
 pub mod memchr;
@@ -29,11 +30,10 @@ pub mod path;
 pub mod pipe;
 pub mod process;
 pub mod stack_overflow;
-pub mod thread;
-pub mod time;
 pub mod stdio;
+pub mod thread;
 pub mod thread_local;
-pub mod fast_thread_local;
+pub mod time;
 
 pub use crate::sys_common::os_str_bytes as os_str;
 
@@ -53,16 +53,14 @@ cfg_if::cfg_if! {
 }
 
 #[cfg(not(test))]
-pub fn init() {
-}
+pub fn init() {}
 
 pub fn unsupported<T>() -> crate::io::Result<T> {
     Err(unsupported_err())
 }
 
 pub fn unsupported_err() -> crate::io::Error {
-    crate::io::Error::new(crate::io::ErrorKind::Other,
-                   "operation not supported on wasm yet")
+    crate::io::Error::new(crate::io::ErrorKind::Other, "operation not supported on wasm yet")
 }
 
 pub fn decode_error_kind(_code: i32) -> crate::io::ErrorKind {
@@ -80,7 +78,7 @@ pub unsafe fn strlen(mut s: *const c_char) -> usize {
         n += 1;
         s = s.offset(1);
     }
-    return n
+    return n;
 }
 
 pub unsafe fn abort_internal() -> ! {
diff --git a/src/libstd/sys/wasm/mutex.rs b/src/libstd/sys/wasm/mutex.rs
index 9d713e9b439..07238d08730 100644
--- a/src/libstd/sys/wasm/mutex.rs
+++ b/src/libstd/sys/wasm/mutex.rs
@@ -13,8 +13,7 @@ impl Mutex {
     }
 
     #[inline]
-    pub unsafe fn init(&mut self) {
-    }
+    pub unsafe fn init(&mut self) {}
 
     #[inline]
     pub unsafe fn lock(&self) {
@@ -40,18 +39,16 @@ impl Mutex {
     }
 
     #[inline]
-    pub unsafe fn destroy(&self) {
-    }
+    pub unsafe fn destroy(&self) {}
 }
 
 // All empty stubs because wasm has no threads yet, so lock acquisition always
 // succeeds.
-pub struct ReentrantMutex {
-}
+pub struct ReentrantMutex {}
 
 impl ReentrantMutex {
     pub unsafe fn uninitialized() -> ReentrantMutex {
-        ReentrantMutex { }
+        ReentrantMutex {}
     }
 
     pub unsafe fn init(&mut self) {}
diff --git a/src/libstd/sys/wasm/mutex_atomics.rs b/src/libstd/sys/wasm/mutex_atomics.rs
index cddd584dd22..90c628a19c2 100644
--- a/src/libstd/sys/wasm/mutex_atomics.rs
+++ b/src/libstd/sys/wasm/mutex_atomics.rs
@@ -1,7 +1,7 @@
 use crate::arch::wasm32;
 use crate::cell::UnsafeCell;
 use crate::mem;
-use crate::sync::atomic::{AtomicUsize, AtomicU32, Ordering::SeqCst};
+use crate::sync::atomic::{AtomicU32, AtomicUsize, Ordering::SeqCst};
 use crate::sys::thread;
 
 pub struct Mutex {
@@ -81,10 +81,7 @@ unsafe impl Sync for ReentrantMutex {}
 
 impl ReentrantMutex {
     pub unsafe fn uninitialized() -> ReentrantMutex {
-        ReentrantMutex {
-            owner: AtomicU32::new(0),
-            recursions: UnsafeCell::new(0),
-        }
+        ReentrantMutex { owner: AtomicU32::new(0), recursions: UnsafeCell::new(0) }
     }
 
     pub unsafe fn init(&mut self) {
diff --git a/src/libstd/sys/wasm/rwlock.rs b/src/libstd/sys/wasm/rwlock.rs
index a2b07c7fa1f..a59944482e9 100644
--- a/src/libstd/sys/wasm/rwlock.rs
+++ b/src/libstd/sys/wasm/rwlock.rs
@@ -9,9 +9,7 @@ unsafe impl Sync for RWLock {} // no threads on wasm
 
 impl RWLock {
     pub const fn new() -> RWLock {
-        RWLock {
-            mode: UnsafeCell::new(0),
-        }
+        RWLock { mode: UnsafeCell::new(0) }
     }
 
     #[inline]
@@ -67,6 +65,5 @@ impl RWLock {
     }
 
     #[inline]
-    pub unsafe fn destroy(&self) {
-    }
+    pub unsafe fn destroy(&self) {}
 }
diff --git a/src/libstd/sys/wasm/rwlock_atomics.rs b/src/libstd/sys/wasm/rwlock_atomics.rs
index c705568cec9..06442e925f4 100644
--- a/src/libstd/sys/wasm/rwlock_atomics.rs
+++ b/src/libstd/sys/wasm/rwlock_atomics.rs
@@ -1,6 +1,6 @@
 use crate::cell::UnsafeCell;
-use crate::sys::mutex::Mutex;
 use crate::sys::condvar::Condvar;
+use crate::sys::mutex::Mutex;
 
 pub struct RWLock {
     lock: Mutex,
@@ -27,11 +27,7 @@ unsafe impl Sync for RWLock {}
 
 impl RWLock {
     pub const fn new() -> RWLock {
-        RWLock {
-            lock: Mutex::new(),
-            cond: Condvar::new(),
-            state: UnsafeCell::new(State::Unlocked),
-        }
+        RWLock { lock: Mutex::new(), cond: Condvar::new(), state: UnsafeCell::new(State::Unlocked) }
     }
 
     #[inline]
@@ -48,7 +44,7 @@ impl RWLock {
         self.lock.lock();
         let ok = (*self.state.get()).inc_readers();
         self.lock.unlock();
-        return ok
+        return ok;
     }
 
     #[inline]
@@ -65,7 +61,7 @@ impl RWLock {
         self.lock.lock();
         let ok = (*self.state.get()).inc_writers();
         self.lock.unlock();
-        return ok
+        return ok;
     }
 
     #[inline]
@@ -106,7 +102,7 @@ impl State {
                 *cnt += 1;
                 true
             }
-            State::Writing => false
+            State::Writing => false,
         }
     }
 
@@ -116,8 +112,7 @@ impl State {
                 *self = State::Writing;
                 true
             }
-            State::Reading(_) |
-            State::Writing => false
+            State::Reading(_) | State::Writing => false,
         }
     }
 
@@ -127,8 +122,7 @@ impl State {
                 *cnt -= 1;
                 *cnt == 0
             }
-            State::Unlocked |
-            State::Writing => invalid(),
+            State::Unlocked | State::Writing => invalid(),
         };
         if zero {
             *self = State::Unlocked;
@@ -139,8 +133,7 @@ impl State {
     fn dec_writers(&mut self) {
         match *self {
             State::Writing => {}
-            State::Unlocked |
-            State::Reading(_) => invalid(),
+            State::Unlocked | State::Reading(_) => invalid(),
         }
         *self = State::Unlocked;
     }