stratosphere: use SdkMutex/SdkRecursiveMutex over Mutex
This commit is contained in:
@@ -30,13 +30,13 @@ namespace ams::lmem::impl {
|
||||
public:
|
||||
explicit ScopedHeapLock(HeapHandle h) : handle(h) {
|
||||
if (this->handle->option & CreateOption_ThreadSafe) {
|
||||
os::LockMutex(std::addressof(this->handle->mutex));
|
||||
os::LockSdkMutex(std::addressof(this->handle->mutex));
|
||||
}
|
||||
}
|
||||
|
||||
~ScopedHeapLock() {
|
||||
if (this->handle->option & CreateOption_ThreadSafe) {
|
||||
os::UnlockMutex(std::addressof(this->handle->mutex));
|
||||
os::UnlockSdkMutex(std::addressof(this->handle->mutex));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -427,6 +427,7 @@ namespace ams::lmem::impl {
|
||||
const s32 abs_alignment = std::abs(alignment);
|
||||
AMS_ASSERT((abs_alignment & (abs_alignment - 1)) == 0);
|
||||
AMS_ASSERT(MinimumAlignment <= static_cast<size_t>(abs_alignment));
|
||||
AMS_UNUSED(abs_alignment);
|
||||
|
||||
/* Fix size to be correctly aligned. */
|
||||
if (size == 0) {
|
||||
|
||||
@@ -21,15 +21,12 @@ namespace ams::lmem {
|
||||
HeapHandle CreateExpHeap(void *address, size_t size, u32 option) {
|
||||
HeapHandle handle = impl::CreateExpHeap(address, size, option);
|
||||
if (option & CreateOption_ThreadSafe) {
|
||||
os::InitializeMutex(std::addressof(handle->mutex), false, 0);
|
||||
os::InitializeSdkMutex(std::addressof(handle->mutex));
|
||||
}
|
||||
return handle;
|
||||
}
|
||||
|
||||
void DestroyExpHeap(HeapHandle handle) {
|
||||
if (handle->option & CreateOption_ThreadSafe) {
|
||||
os::FinalizeMutex(std::addressof(handle->mutex));
|
||||
}
|
||||
impl::DestroyExpHeap(handle);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace ams::lmem {
|
||||
HeapHandle CreateUnitHeap(void *address, size_t size, size_t unit_size, u32 option) {
|
||||
HeapHandle handle = impl::CreateUnitHeap(address, size, unit_size, DefaultAlignment, static_cast<u16>(option), InfoPlacement_Head, nullptr);
|
||||
if (option & CreateOption_ThreadSafe) {
|
||||
os::InitializeMutex(std::addressof(handle->mutex), false, 0);
|
||||
os::InitializeSdkMutex(std::addressof(handle->mutex));
|
||||
}
|
||||
return handle;
|
||||
}
|
||||
@@ -29,7 +29,7 @@ namespace ams::lmem {
|
||||
HeapHandle CreateUnitHeap(void *address, size_t size, size_t unit_size, u32 option, s32 alignment, InfoPlacement info_placement) {
|
||||
HeapHandle handle = impl::CreateUnitHeap(address, size, unit_size, alignment, static_cast<u16>(option), info_placement, nullptr);
|
||||
if (option & CreateOption_ThreadSafe) {
|
||||
os::InitializeMutex(std::addressof(handle->mutex), false, 0);
|
||||
os::InitializeSdkMutex(std::addressof(handle->mutex));
|
||||
}
|
||||
return handle;
|
||||
}
|
||||
@@ -37,15 +37,12 @@ namespace ams::lmem {
|
||||
HeapHandle CreateUnitHeap(void *address, size_t size, size_t unit_size, u32 option, s32 alignment, HeapCommonHead *heap_head) {
|
||||
HeapHandle handle = impl::CreateUnitHeap(address, size, unit_size, alignment, static_cast<u16>(option), InfoPlacement_Head, heap_head);
|
||||
if (option & CreateOption_ThreadSafe) {
|
||||
os::InitializeMutex(std::addressof(handle->mutex), false, 0);
|
||||
os::InitializeSdkMutex(std::addressof(handle->mutex));
|
||||
}
|
||||
return handle;
|
||||
}
|
||||
|
||||
void DestroyUnitHeap(HeapHandle handle) {
|
||||
if (handle->option & CreateOption_ThreadSafe) {
|
||||
os::FinalizeMutex(std::addressof(handle->mutex));
|
||||
}
|
||||
impl::DestroyUnitHeap(handle);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user