about summary refs log tree commit diff
path: root/src/libstd/sys/common
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-06-03 04:09:31 -0700
committerbors <bors@rust-lang.org>2016-06-03 04:09:31 -0700
commit9552bcdd92dfd09049ce9dd299b4bfc513ac075d (patch)
tree30e4ca00974aaf0c10b6a8ac546cd5e63026fda0 /src/libstd/sys/common
parent95206f438f1573e95601f06b315a151de010e92f (diff)
parentfc4b35612550d833cefcd586cb13ebc0dc5a51e1 (diff)
downloadrust-9552bcdd92dfd09049ce9dd299b4bfc513ac075d.tar.gz
rust-9552bcdd92dfd09049ce9dd299b4bfc513ac075d.zip
Auto merge of #33861 - Amanieu:lock_elision_fix, r=alexcrichton
Make sure Mutex and RwLock can't be re-locked on the same thread

Fixes #33770

r? @alexcrichton
Diffstat (limited to 'src/libstd/sys/common')
-rw-r--r--src/libstd/sys/common/mutex.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libstd/sys/common/mutex.rs b/src/libstd/sys/common/mutex.rs
index 5a6dfe7fb1a..7a2183c522f 100644
--- a/src/libstd/sys/common/mutex.rs
+++ b/src/libstd/sys/common/mutex.rs
@@ -27,6 +27,12 @@ impl Mutex {
     /// first used with any of the functions below.
     pub const fn new() -> Mutex { Mutex(imp::Mutex::new()) }
 
+    /// Prepare the mutex for use.
+    ///
+    /// This should be called once the mutex is at a stable memory address.
+    #[inline]
+    pub unsafe fn init(&mut self) { self.0.init() }
+
     /// Locks the mutex blocking the current thread until it is available.
     ///
     /// Behavior is undefined if the mutex has been moved between this and any