forked from M-Labs/zynq-rs
libcortex_a9: fixed usage of deprecated APIs
This commit is contained in:
parent
4555afa624
commit
d62c77e6e0
@ -32,7 +32,7 @@ impl<T> Mutex<T> {
|
|||||||
/// Lock the Mutex, blocks when already locked
|
/// Lock the Mutex, blocks when already locked
|
||||||
pub fn lock(&self) -> MutexGuard<T> {
|
pub fn lock(&self) -> MutexGuard<T> {
|
||||||
let mut irq = unsafe { enter_critical() };
|
let mut irq = unsafe { enter_critical() };
|
||||||
while self.locked.compare_and_swap(UNLOCKED, LOCKED, Ordering::AcqRel) != UNLOCKED {
|
while self.locked.compare_exchange_weak(UNLOCKED, LOCKED, Ordering::AcqRel, Ordering::Relaxed).is_err() {
|
||||||
unsafe {
|
unsafe {
|
||||||
exit_critical(irq);
|
exit_critical(irq);
|
||||||
spin_lock_yield();
|
spin_lock_yield();
|
||||||
@ -44,7 +44,7 @@ impl<T> Mutex<T> {
|
|||||||
|
|
||||||
pub fn try_lock(&self) -> Option<MutexGuard<T>> {
|
pub fn try_lock(&self) -> Option<MutexGuard<T>> {
|
||||||
let irq = unsafe { enter_critical() };
|
let irq = unsafe { enter_critical() };
|
||||||
if self.locked.compare_and_swap(UNLOCKED, LOCKED, Ordering::AcqRel) != UNLOCKED {
|
if self.locked.compare_exchange_weak(UNLOCKED, LOCKED, Ordering::AcqRel, Ordering::Relaxed).is_err() {
|
||||||
unsafe { exit_critical(irq) };
|
unsafe { exit_critical(irq) };
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
|
@ -20,7 +20,7 @@ impl Semaphore {
|
|||||||
loop {
|
loop {
|
||||||
let value = self.value.load(Ordering::Relaxed);
|
let value = self.value.load(Ordering::Relaxed);
|
||||||
if value > 0 {
|
if value > 0 {
|
||||||
if self.value.compare_and_swap(value, value - 1, Ordering::SeqCst) == value {
|
if self.value.compare_exchange_weak(value, value - 1, Ordering::SeqCst, Ordering::Relaxed).is_ok() {
|
||||||
return Some(());
|
return Some(());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -58,7 +58,7 @@ impl Semaphore {
|
|||||||
loop {
|
loop {
|
||||||
let value = self.value.load(Ordering::Relaxed);
|
let value = self.value.load(Ordering::Relaxed);
|
||||||
if value < self.max {
|
if value < self.max {
|
||||||
if self.value.compare_and_swap(value, value + 1, Ordering::SeqCst) == value {
|
if self.value.compare_exchange_weak(value, value + 1, Ordering::SeqCst, Ordering::Relaxed).is_ok() {
|
||||||
notify_spin_lock();
|
notify_spin_lock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ use core::{
|
|||||||
ops::{Deref, DerefMut},
|
ops::{Deref, DerefMut},
|
||||||
mem::{align_of, size_of},
|
mem::{align_of, size_of},
|
||||||
};
|
};
|
||||||
use alloc::alloc::{dealloc, Layout, LayoutErr};
|
use alloc::alloc::{dealloc, Layout, LayoutError};
|
||||||
use crate::mmu::{L1_PAGE_SIZE, L1Table};
|
use crate::mmu::{L1_PAGE_SIZE, L1Table};
|
||||||
|
|
||||||
pub struct UncachedSlice<T: 'static> {
|
pub struct UncachedSlice<T: 'static> {
|
||||||
@ -12,7 +12,7 @@ pub struct UncachedSlice<T: 'static> {
|
|||||||
|
|
||||||
impl<T> UncachedSlice<T> {
|
impl<T> UncachedSlice<T> {
|
||||||
/// allocates in chunks of 1 MB
|
/// allocates in chunks of 1 MB
|
||||||
pub fn new<F: Fn() -> T>(len: usize, default: F) -> Result<Self, LayoutErr> {
|
pub fn new<F: Fn() -> T>(len: usize, default: F) -> Result<Self, LayoutError> {
|
||||||
// round to full pages
|
// round to full pages
|
||||||
let size = ((len * size_of::<T>() - 1) | (L1_PAGE_SIZE - 1)) + 1;
|
let size = ((len * size_of::<T>() - 1) | (L1_PAGE_SIZE - 1)) + 1;
|
||||||
let align = align_of::<T>()
|
let align = align_of::<T>()
|
||||||
|
Loading…
Reference in New Issue
Block a user