8000 Rollup of 11 pull requests by Centril · Pull Request #62923 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

Rollup of 11 pull requests #62923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 36 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
962bf69
Take substs into account in `conservative_is_privately_uninhabited`
varkor Jun 30, 2019
5397dfc
Remove obsolete “should not have to exist” reasons
SimonSapin Jul 8, 2019
01d93bf
Split the SliceConcat trait into Concat and Join
SimonSapin Jul 8, 2019
283f676
Take separator by value in `[T]::join`
SimonSapin Jul 8, 2019
b62a77b
Add joining slices of slices with a slice separator, not just a singl…
SimonSapin Jul 8, 2019
d0635ee
Update src/liballoc/slice.rs
SimonSapin Jul 9, 2019
bbc9366
Update src/liballoc/slice.rs
SimonSapin Jul 9, 2019
5f7768a
Update src/liballoc/str.rs
SimonSapin Jul 9, 2019
bb9bf0c
Add riscv32i-unknown-none-elf target
Disasm Jul 18, 2019
21b502b
warn that raw pointers must be aligned when used, and that writes cau…
RalfJung Jul 20, 2019
2e6b13a
references must be aligned; also move up the warning that fn ptrs mus…
RalfJung Jul 20, 2019
f502bf7
sync with nomicon: raw ptr must be non-dangling and aligned every tim…
RalfJung Jul 21, 2019
4081222
apply feedback
RalfJung Jul 21, 2019
a7b9246
weasle, weasle
RalfJung Jul 22, 2019
9196781
account for non-drop-glue types
RalfJung Jul 22, 2019
4b33968
add support for hexagon-unknown-linux-musl
androm3da Aug 10, 2018
e1e0df8
Remove uses of mem::uninitialized in std::sys::cloudabi
nathanwhit Jul 22, 2019
82dd54b
Modify CloudABI ReentrantMutex to use MaybeUninit
nathanwhit Jul 22, 2019
dd5045e
Apply suggestions from code review
RalfJung Jul 23, 2019
65cf10d
word things more like we usually do
RalfJung Jul 23, 2019
6140371
cleanup: Remove `extern crate serialize as rustc_serialize`s
petrochenkov Jul 23, 2019
0ac6afa
Cleanup std::sys::cloudabi
nathanwhit Jul 23, 2019
b70f217
Use raw pointers in std::sys::cloudabi when passing MaybeUninit values
nathanwhit Jul 23, 2019
2083a12
Normalize use of backticks in compiler messages for libsyntax/*
Jul 23, 2019
ca8420c
Normalize use of backticks in compiler messages for doc
Jul 23, 2019
66815c6
normalize use of backticks for compiler messages in remaining modules
Jul 23, 2019
6afb4e8
Rollup merge of #62261 - varkor:conservative_is_privately_uninhabited…
Centril Jul 24, 2019
e4c3883
Rollup merge of #62528 - SimonSapin:concat, r=alexcrichton
Centril Jul 24, 2019
9258ed6
Rollup merge of #62738 - nathanwhit:fix_mem_uninit_cloudabi, r=RalfJung
Centril Jul 24, 2019
3835b13
Rollup merge of #62784 - Disasm:riscv32i, r=estebank
Centril Jul 24, 2019
6d3efb0
Rollup merge of #62814 - androm3da:hexagon_19jul_2019, r=alexcrichton
Centril Jul 24, 2019
b71e579
Rollup merge of #62822 - RalfJung:pointers, r=Centril
Centril Jul 24, 2019
960a4fc
Rollup merge of #62890 - fakenine:normalize_use_of_backticks_compiler…
Centril Jul 24, 2019
2462bd8
Rollup merge of #62901 - petrochenkov:serde, r=Centril
Centril Jul 24, 2019
9dcef0f
Rollup merge of #62905 - fakenine:normalize_use_of_backticks_compiler…
Centril Jul 24, 2019
69bc410
Rollup merge of #62908 - fakenine:normalize_use_of_backticks_compiler…
Centril Jul 24, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Modify CloudABI ReentrantMutex to use MaybeUninit
Remove uses of mem::uninitialized, which is now deprecated
  • Loading branch information
nathanwhit committed Jul 23, 2019
commit 82dd54baf3fda351abd56ee4bda9f8464da2df67
32 changes: 18 additions & 14 deletions src/libstd/sys/cloudabi/mutex.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::cell::UnsafeCell;
use crate::mem;
use crate::mem::MaybeUninit;
use crate::sync::atomic::{AtomicU32, Ordering};
use crate::sys::cloudabi::abi;
use crate::sys::rwlock::{self, RWLock};
Expand Down Expand Up @@ -47,25 +48,28 @@ impl Mutex {
}

pub struct ReentrantMutex {
lock: UnsafeCell<AtomicU32>,
recursion: UnsafeCell<u32>,
lock: UnsafeCell<MaybeUninit<AtomicU32>>,
recursion: UnsafeCell<MaybeUninit<u32>>,
}

impl ReentrantMutex {
pub unsafe fn uninitialized() -> ReentrantMutex {
mem::uninitialized()
ReentrantMutex {
lock: UnsafeCell::new(MaybeUninit::uninit()),
recursion: UnsafeCell::new(MaybeUninit::uninit())
}
}

pub unsafe fn init(&mut self) {
self.lock = UnsafeCell::new(AtomicU32::new(abi::LOCK_UNLOCKED.0));
self.recursion = UnsafeCell::new(0);
self.lock = UnsafeCell::new(MaybeUninit::new(AtomicU32::new(abi::LOCK_UNLOCKED.0)));
self.recursion = UnsafeCell::new(MaybeUninit::new(0));
}

pub unsafe fn try_lock(&self) -> bool {
// Attempt to acquire the lock.
let lock = self.lock.get();
let recursion = self.recursion.get();
if let Err(old) = (*lock).compare_exchange(
if let Err(old) = (*(*lock).as_mut_ptr()).compare_exchange(
abi::LOCK_UNLOCKED.0,
__pthread_thread_id.0 | abi::LOCK_WRLOCKED.0,
Ordering::Acquire,
Expand All @@ -74,14 +78,14 @@ impl ReentrantMutex {
// If we fail to acquire the lock, it may be the case
// that we've already acquired it and may need to recurse.
if old & !abi::LOCK_KERNEL_MANAGED.0 == __pthread_thread_id.0 | abi::LOCK_WRLOCKED.0 {
*recursion += 1;
*(*recursion).as_mut_ptr() += 1;
true
} else {
false
}
} else {
// Success.
assert_eq!(*recursion, 0, "Mutex has invalid recursion count");
assert_eq!(*(*recursion).as_mut_ptr(), 0, "Mutex has invalid recursion count");
true
}
}
Expand Down Expand Up @@ -112,14 +116,14 @@ impl ReentrantMutex {
let lock = self.lock.get();
let recursion = self.recursion.get();
assert_eq!(
(*lock).load(Ordering::Relaxed) & !abi::LOCK_KERNEL_MANAGED.0,
(*(*lock).as_mut_ptr()).load(Ordering::Relaxed) & !abi::LOCK_KERNEL_MANAGED.0,
__pthread_thread_id.0 | abi::LOCK_WRLOCKED.0,
"This mutex is locked by a different thread"
);

if *recursion > 0 {
*recursion -= 1;
} else if !(*lock)
if *(*recursion).as_mut_ptr() > 0 {
*(*recursion).as_mut_ptr() -= 1;
} else if !(*(*lock).as_mut_ptr())
.compare_exchange(
__pthread_thread_id.0 | abi::LOCK_WRLOCKED.0,
abi::LOCK_UNLOCKED.0,
Expand All @@ -139,10 +143,10 @@ impl ReentrantMutex {
let lock = self.lock.get();
let recursion = self.recursion.get();
assert_eq!(
(*lock).load(Ordering::Relaxed),
(*(*lock).as_mut_ptr()).load(Ordering::Relaxed),
abi::LOCK_UNLOCKED.0,
"Attempted to destroy locked mutex"
);
assert_eq!(*recursion, 0, "Recursion counter invalid");
assert_eq!(*(*recursion).as_mut_ptr(), 0, "Recursion counter invalid");
}
}
0