aboutsummaryrefslogtreecommitdiff
path: root/ctr-std/src/sys/unix/mutex.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ctr-std/src/sys/unix/mutex.rs')
-rw-r--r--ctr-std/src/sys/unix/mutex.rs30
1 files changed, 19 insertions, 11 deletions
diff --git a/ctr-std/src/sys/unix/mutex.rs b/ctr-std/src/sys/unix/mutex.rs
index 0cfd392..51e6b47 100644
--- a/ctr-std/src/sys/unix/mutex.rs
+++ b/ctr-std/src/sys/unix/mutex.rs
@@ -1,4 +1,4 @@
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@@ -11,7 +11,9 @@
use cell::UnsafeCell;
use mem;
-pub struct Mutex { inner: UnsafeCell<::libctru::LightLock> }
+pub struct Mutex {
+ inner: UnsafeCell<::libctru::LightLock>,
+}
#[inline]
pub unsafe fn raw(m: &Mutex) -> *mut ::libctru::LightLock {
@@ -21,23 +23,26 @@ pub unsafe fn raw(m: &Mutex) -> *mut ::libctru::LightLock {
unsafe impl Send for Mutex {}
unsafe impl Sync for Mutex {}
-#[allow(dead_code)] // sys isn't exported yet
impl Mutex {
pub const fn new() -> Mutex {
Mutex { inner: UnsafeCell::new(0) }
}
+
#[inline]
pub unsafe fn init(&mut self) {
::libctru::LightLock_Init(self.inner.get());
}
+
#[inline]
pub unsafe fn lock(&self) {
::libctru::LightLock_Lock(self.inner.get());
}
+
#[inline]
pub unsafe fn unlock(&self) {
::libctru::LightLock_Unlock(self.inner.get());
}
+
#[inline]
pub unsafe fn try_lock(&self) -> bool {
match ::libctru::LightLock_TryLock(self.inner.get()) {
@@ -45,8 +50,10 @@ impl Mutex {
_ => false,
}
}
+
#[inline]
- pub unsafe fn destroy(&self) {}
+ pub unsafe fn destroy(&self) {
+ }
}
pub struct ReentrantMutex { inner: UnsafeCell<::libctru::RecursiveLock> }
@@ -58,18 +65,15 @@ impl ReentrantMutex {
pub unsafe fn uninitialized() -> ReentrantMutex {
ReentrantMutex { inner: mem::uninitialized() }
}
- #[inline]
+
pub unsafe fn init(&mut self) {
::libctru::RecursiveLock_Init(self.inner.get());
}
- #[inline]
+
pub unsafe fn lock(&self) {
::libctru::RecursiveLock_Lock(self.inner.get());
}
- #[inline]
- pub unsafe fn unlock(&self) {
- ::libctru::RecursiveLock_Unlock(self.inner.get());
- }
+
#[inline]
pub unsafe fn try_lock(&self) -> bool {
match ::libctru::RecursiveLock_TryLock(self.inner.get()) {
@@ -77,6 +81,10 @@ impl ReentrantMutex {
_ => false,
}
}
- #[inline]
+
+ pub unsafe fn unlock(&self) {
+ ::libctru::RecursiveLock_Unlock(self.inner.get());
+ }
+
pub unsafe fn destroy(&self) {}
}