From 2b37e5d486945196e63a16e0f0c1ca6c1d5b0d4e Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Fri, 1 Oct 2021 11:42:34 -0700 Subject: [PATCH] os: adopt nintendo ReaderWriter naming over ReadWrite --- .../fssrv_filesystem_interface_adapter.hpp | 6 +- .../fssrv_storage_interface_adapter.hpp | 4 +- ...ernal_critical_section_impl.os.horizon.hpp | 4 +- .../os/impl/os_internal_rw_busy_mutex.hpp | 10 +- ...internal_rw_busy_mutex_impl.os.horizon.hpp | 4 +- .../stratosphere/os/os_rw_busy_mutex.hpp | 16 +-- .../stratosphere/os/os_rw_busy_mutex_api.hpp | 12 +- .../os/os_rw_busy_mutex_types.hpp | 8 +- .../include/stratosphere/os/os_rw_lock.hpp | 20 +-- .../stratosphere/os/os_rw_lock_api.hpp | 24 ++-- .../stratosphere/os/os_rw_lock_common.hpp | 4 +- .../stratosphere/os/os_rw_lock_types.hpp | 4 +- .../diag/impl/diag_observer_manager.hpp | 2 +- .../fssrv_filesystem_interface_adapter.cpp | 8 +- .../fssrv/fssrv_storage_interface_adapter.cpp | 4 +- ...internal_rw_busy_mutex_impl.os.horizon.hpp | 8 +- .../source/os/impl/os_rw_lock_impl.hpp | 116 +++++++++--------- .../os_rw_lock_target_impl.os.horizon.cpp | 18 +-- .../os_rw_lock_target_impl.os.horizon.hpp | 24 ++-- .../source/os/os_rw_busy_mutex.cpp | 12 +- .../libstratosphere/source/os/os_rw_lock.cpp | 58 ++++----- 21 files changed, 183 insertions(+), 183 deletions(-) diff --git a/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_filesystem_interface_adapter.hpp b/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_filesystem_interface_adapter.hpp index a84556fa0..5275e9310 100644 --- a/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_filesystem_interface_adapter.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_filesystem_interface_adapter.hpp @@ -81,7 +81,7 @@ namespace ams::fssrv::impl { private: std::shared_ptr base_fs; util::unique_lock mount_count_semaphore; - os::ReadWriteLock invalidation_lock; + os::ReaderWriterLock invalidation_lock; bool open_count_limited; bool deep_retry_enabled = false; public: @@ -92,8 +92,8 @@ namespace ams::fssrv::impl { public: bool IsDeepRetryEnabled() const; bool IsAccessFailureDetectionObserved() const; - util::optional> AcquireCacheInvalidationReadLock(); - os::ReadWriteLock &GetReadWriteLockForCacheInvalidation(); + util::optional> AcquireCacheInvalidationReadLock(); + os::ReaderWriterLock &GetReaderWriterLockForCacheInvalidation(); public: /* Command API. */ Result CreateFile(const fssrv::sf::Path &path, s64 size, s32 option); diff --git a/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_storage_interface_adapter.hpp b/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_storage_interface_adapter.hpp index b2cb7966c..df1a8cd5b 100644 --- a/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_storage_interface_adapter.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_storage_interface_adapter.hpp @@ -33,7 +33,7 @@ namespace ams::fssrv::impl { /* TODO: Nintendo uses fssystem::AsynchronousAccessStorage here. */ std::shared_ptr base_storage; util::unique_lock open_count_semaphore; - os::ReadWriteLock invalidation_lock; + os::ReaderWriterLock invalidation_lock; /* TODO: DataStorageContext. */ bool deep_retry_enabled = false; public: @@ -44,7 +44,7 @@ namespace ams::fssrv::impl { ~StorageInterfaceAdapter(); private: - util::optional> AcquireCacheInvalidationReadLock(); + util::optional> AcquireCacheInvalidationReadLock(); public: /* Command API. */ Result Read(s64 offset, const ams::sf::OutNonSecureBuffer &buffer, s64 size); diff --git a/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_critical_section_impl.os.horizon.hpp b/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_critical_section_impl.os.horizon.hpp index 76ea12f2e..693ded98e 100644 --- a/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_critical_section_impl.os.horizon.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_critical_section_impl.os.horizon.hpp @@ -20,7 +20,7 @@ namespace ams::os::impl { #if defined(ATMOSPHERE_OS_HORIZON) - class ReadWriteLockHorizonImpl; + class ReaderWriterLockHorizonImpl; #endif class InternalConditionVariableImpl; @@ -28,7 +28,7 @@ namespace ams::os::impl { class InternalCriticalSectionImpl { private: #if defined(ATMOSPHERE_OS_HORIZON) - friend class ReadWriteLockHorizonImpl; + friend class ReaderWriterLockHorizonImpl; #endif friend class InternalConditionVariableImpl; diff --git a/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_rw_busy_mutex.hpp b/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_rw_busy_mutex.hpp index a8aa7d0b7..9715fe3f7 100644 --- a/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_rw_busy_mutex.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_rw_busy_mutex.hpp @@ -20,16 +20,16 @@ #if defined(ATMOSPHERE_OS_HORIZON) #include #else - #error "Unknown OS for ams::os::impl::InternalReadWriteBusyMutexImpl" + #error "Unknown OS for ams::os::impl::InternalReaderWriterBusyMutexImpl" #endif namespace ams::os::impl { - class InternalReadWriteBusyMutex { + class InternalReaderWriterBusyMutex { private: - InternalReadWriteBusyMutexImpl m_impl; + InternalReaderWriterBusyMutexImpl m_impl; public: - constexpr InternalReadWriteBusyMutex() : m_impl() { /* ... */ } + constexpr InternalReaderWriterBusyMutex() : m_impl() { /* ... */ } ALWAYS_INLINE void AcquireReadLock() { return m_impl.AcquireReadLock(); } ALWAYS_INLINE void ReleaseReadLock() { return m_impl.ReleaseReadLock(); } @@ -38,6 +38,6 @@ namespace ams::os::impl { ALWAYS_INLINE void ReleaseWriteLock() { return m_impl.ReleaseWriteLock(); } }; - using InternalReadWriteBusyMutexStorage = util::TypedStorage; + using InternalReaderWriterBusyMutexStorage = util::TypedStorage; } diff --git a/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_rw_busy_mutex_impl.os.horizon.hpp b/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_rw_busy_mutex_impl.os.horizon.hpp index da58679ab..afe149168 100644 --- a/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_rw_busy_mutex_impl.os.horizon.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_rw_busy_mutex_impl.os.horizon.hpp @@ -19,11 +19,11 @@ namespace ams::os::impl { - class InternalReadWriteBusyMutexImpl { + class InternalReaderWriterBusyMutexImpl { private: u32 m_value; public: - constexpr InternalReadWriteBusyMutexImpl() : m_value(0) { /* ... */ } + constexpr InternalReaderWriterBusyMutexImpl() : m_value(0) { /* ... */ } constexpr void Initialize() { m_value = 0; } diff --git a/libraries/libstratosphere/include/stratosphere/os/os_rw_busy_mutex.hpp b/libraries/libstratosphere/include/stratosphere/os/os_rw_busy_mutex.hpp index b6acef848..681e2fc76 100644 --- a/libraries/libstratosphere/include/stratosphere/os/os_rw_busy_mutex.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/os_rw_busy_mutex.hpp @@ -20,13 +20,13 @@ namespace ams::os { - class ReadWriteBusyMutex { - NON_COPYABLE(ReadWriteBusyMutex); - NON_MOVEABLE(ReadWriteBusyMutex); + class ReaderWriterBusyMutex { + NON_COPYABLE(ReaderWriterBusyMutex); + NON_MOVEABLE(ReaderWriterBusyMutex); private: - ReadWriteBusyMutexType m_rw_mutex; + ReaderWriterBusyMutexType m_rw_mutex; public: - constexpr explicit ReadWriteBusyMutex() : m_rw_mutex{{0}} { /* ... */ } + constexpr explicit ReaderWriterBusyMutex() : m_rw_mutex{{0}} { /* ... */ } void AcquireReadLock() { return os::AcquireReadLockBusyMutex(std::addressof(m_rw_mutex)); @@ -60,15 +60,15 @@ namespace ams::os { return this->ReleaseWriteLock(); } - operator ReadWriteBusyMutexType &() { + operator ReaderWriterBusyMutexType &() { return m_rw_mutex; } - operator const ReadWriteBusyMutexType &() const { + operator const ReaderWriterBusyMutexType &() const { return m_rw_mutex; } - ReadWriteBusyMutexType *GetBase() { + ReaderWriterBusyMutexType *GetBase() { return std::addressof(m_rw_mutex); } }; diff --git a/libraries/libstratosphere/include/stratosphere/os/os_rw_busy_mutex_api.hpp b/libraries/libstratosphere/include/stratosphere/os/os_rw_busy_mutex_api.hpp index df4b62e6f..4c2ec3896 100644 --- a/libraries/libstratosphere/include/stratosphere/os/os_rw_busy_mutex_api.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/os_rw_busy_mutex_api.hpp @@ -19,14 +19,14 @@ namespace ams::os { - struct ReadWriteBusyMutexType; + struct ReaderWriterBusyMutexType; - void InitalizeReadWriteLockBusyMutex(ReadWriteBusyMutexType *rw_mutex); + void InitalizeReaderWriterLockBusyMutex(ReaderWriterBusyMutexType *rw_mutex); - void AcquireReadLockBusyMutex(ReadWriteBusyMutexType *rw_mutex); - void ReleaseReadLockBusyMutex(ReadWriteBusyMutexType *rw_mutex); + void AcquireReadLockBusyMutex(ReaderWriterBusyMutexType *rw_mutex); + void ReleaseReadLockBusyMutex(ReaderWriterBusyMutexType *rw_mutex); - void AcquireWriteLockBusyMutex(ReadWriteBusyMutexType *rw_mutex); - void ReleaseWriteLockBusyMutex(ReadWriteBusyMutexType *rw_mutex); + void AcquireWriteLockBusyMutex(ReaderWriterBusyMutexType *rw_mutex); + void ReleaseWriteLockBusyMutex(ReaderWriterBusyMutexType *rw_mutex); } diff --git a/libraries/libstratosphere/include/stratosphere/os/os_rw_busy_mutex_types.hpp b/libraries/libstratosphere/include/stratosphere/os/os_rw_busy_mutex_types.hpp index f0f95179f..c90d920c6 100644 --- a/libraries/libstratosphere/include/stratosphere/os/os_rw_busy_mutex_types.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/os_rw_busy_mutex_types.hpp @@ -20,12 +20,12 @@ namespace ams::os { - struct ReadWriteBusyMutexType { + struct ReaderWriterBusyMutexType { union { - s32 _arr[sizeof(impl::InternalReadWriteBusyMutexStorage) / sizeof(s32)]; - impl::InternalReadWriteBusyMutexStorage _storage; + s32 _arr[sizeof(impl::InternalReaderWriterBusyMutexStorage) / sizeof(s32)]; + impl::InternalReaderWriterBusyMutexStorage _storage; }; }; - static_assert(std::is_trivial::value); + static_assert(std::is_trivial::value); } diff --git a/libraries/libstratosphere/include/stratosphere/os/os_rw_lock.hpp b/libraries/libstratosphere/include/stratosphere/os/os_rw_lock.hpp index c0272c52b..11823bd16 100644 --- a/libraries/libstratosphere/include/stratosphere/os/os_rw_lock.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/os_rw_lock.hpp @@ -21,15 +21,15 @@ namespace ams::os { - class ReadWriteLock { - NON_COPYABLE(ReadWriteLock); - NON_MOVEABLE(ReadWriteLock); + class ReaderWriterLock { + NON_COPYABLE(ReaderWriterLock); + NON_MOVEABLE(ReaderWriterLock); private: - ReadWriteLockType rw_lock; + ReaderWriterLockType rw_lock; public: - constexpr explicit ReadWriteLock() : rw_lock{{}, 0, ::ams::os::ReadWriteLockType::State_Initialized, nullptr, 0, {}, {}} { /* ... */ } + constexpr explicit ReaderWriterLock() : rw_lock{{}, 0, ::ams::os::ReaderWriterLockType::State_Initialized, nullptr, 0, {}, {}} { /* ... */ } - ~ReadWriteLock() { os::FinalizeReadWriteLock(std::addressof(this->rw_lock)); } + ~ReaderWriterLock() { os::FinalizeReaderWriterLock(std::addressof(this->rw_lock)); } void AcquireReadLock() { return os::AcquireReadLock(std::addressof(this->rw_lock)); @@ -64,7 +64,7 @@ namespace ams::os { } bool IsLockOwner() const { - return os::IsReadWriteLockOwnerThread(std::addressof(this->rw_lock)); + return os::IsReaderWriterLockOwnerThread(std::addressof(this->rw_lock)); } void lock_shared() { @@ -91,15 +91,15 @@ namespace ams::os { return this->ReleaseWriteLock(); } - operator ReadWriteLockType &() { + operator ReaderWriterLockType &() { return this->rw_lock; } - operator const ReadWriteLockType &() const { + operator const ReaderWriterLockType &() const { return this->rw_lock; } - ReadWriteLockType *GetBase() { + ReaderWriterLockType *GetBase() { return std::addressof(this->rw_lock); } }; diff --git a/libraries/libstratosphere/include/stratosphere/os/os_rw_lock_api.hpp b/libraries/libstratosphere/include/stratosphere/os/os_rw_lock_api.hpp index 3129d43fe..4f788d0a5 100644 --- a/libraries/libstratosphere/include/stratosphere/os/os_rw_lock_api.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/os_rw_lock_api.hpp @@ -20,21 +20,21 @@ namespace ams::os { - struct ReadWriteLockType; + struct ReaderWriterLockType; - void InitalizeReadWriteLock(ReadWriteLockType *rw_lock); - void FinalizeReadWriteLock(ReadWriteLockType *rw_lock); + void InitalizeReaderWriterLock(ReaderWriterLockType *rw_lock); + void FinalizeReaderWriterLock(ReaderWriterLockType *rw_lock); - void AcquireReadLock(ReadWriteLockType *rw_lock); - bool TryAcquireReadLock(ReadWriteLockType *rw_lock); - void ReleaseReadLock(ReadWriteLockType *rw_lock); + void AcquireReadLock(ReaderWriterLockType *rw_lock); + bool TryAcquireReadLock(ReaderWriterLockType *rw_lock); + void ReleaseReadLock(ReaderWriterLockType *rw_lock); - void AcquireWriteLock(ReadWriteLockType *rw_lock); - bool TryAcquireWriteLock(ReadWriteLockType *rw_lock); - void ReleaseWriteLock(ReadWriteLockType *rw_lock); + void AcquireWriteLock(ReaderWriterLockType *rw_lock); + bool TryAcquireWriteLock(ReaderWriterLockType *rw_lock); + void ReleaseWriteLock(ReaderWriterLockType *rw_lock); - bool IsReadLockHeld(const ReadWriteLockType *rw_lock); - bool IsWriteLockHeldByCurrentThread(const ReadWriteLockType *rw_lock); - bool IsReadWriteLockOwnerThread(const ReadWriteLockType *rw_lock); + bool IsReadLockHeld(const ReaderWriterLockType *rw_lock); + bool IsWriteLockHeldByCurrentThread(const ReaderWriterLockType *rw_lock); + bool IsReaderWriterLockOwnerThread(const ReaderWriterLockType *rw_lock); } diff --git a/libraries/libstratosphere/include/stratosphere/os/os_rw_lock_common.hpp b/libraries/libstratosphere/include/stratosphere/os/os_rw_lock_common.hpp index 748fa237e..305f4e958 100644 --- a/libraries/libstratosphere/include/stratosphere/os/os_rw_lock_common.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/os_rw_lock_common.hpp @@ -18,7 +18,7 @@ namespace ams::os { - constexpr inline s32 ReadWriteLockCountMax = (1 << (BITSIZEOF(u16) - 1)) - 1; - constexpr inline s32 ReadWriteLockWaiterCountMax = (1 << BITSIZEOF(u8)) - 1; + constexpr inline s32 ReaderWriterLockCountMax = (1 << (BITSIZEOF(u16) - 1)) - 1; + constexpr inline s32 ReaderWriterLockWaiterCountMax = (1 << BITSIZEOF(u8)) - 1; } \ No newline at end of file diff --git a/libraries/libstratosphere/include/stratosphere/os/os_rw_lock_types.hpp b/libraries/libstratosphere/include/stratosphere/os/os_rw_lock_types.hpp index 166d9de8d..93b1c7511 100644 --- a/libraries/libstratosphere/include/stratosphere/os/os_rw_lock_types.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/os_rw_lock_types.hpp @@ -23,7 +23,7 @@ namespace ams::os { struct ThreadType; - struct ReadWriteLockType { + struct ReaderWriterLockType { enum State { State_NotInitialized = 0, State_Initialized = 1, @@ -65,6 +65,6 @@ namespace ams::os { impl::InternalConditionVariableStorage _storage; } cv_write_lock; }; - static_assert(std::is_trivial::value); + static_assert(std::is_trivial::value); } diff --git a/libraries/libstratosphere/source/diag/impl/diag_observer_manager.hpp b/libraries/libstratosphere/source/diag/impl/diag_observer_manager.hpp index 02119b1fa..1d9bc5abf 100644 --- a/libraries/libstratosphere/source/diag/impl/diag_observer_manager.hpp +++ b/libraries/libstratosphere/source/diag/impl/diag_observer_manager.hpp @@ -25,7 +25,7 @@ namespace ams::diag::impl { private: Holder *m_observer_list_head; Holder **m_observer_list_tail; - os::ReadWriteLock m_lock; + os::ReaderWriterLock m_lock; public: constexpr ObserverManager() : m_observer_list_head(nullptr), m_observer_list_tail(std::addressof(m_observer_list_head)), m_lock() { /* ... */ diff --git a/libraries/libstratosphere/source/fssrv/fssrv_filesystem_interface_adapter.cpp b/libraries/libstratosphere/source/fssrv/fssrv_filesystem_interface_adapter.cpp index dcad08f53..df94ddebd 100644 --- a/libraries/libstratosphere/source/fssrv/fssrv_filesystem_interface_adapter.cpp +++ b/libraries/libstratosphere/source/fssrv/fssrv_filesystem_interface_adapter.cpp @@ -31,7 +31,7 @@ namespace ams::fssrv::impl { void FileInterfaceAdapter::InvalidateCache() { AMS_ABORT_UNLESS(this->parent_filesystem->IsDeepRetryEnabled()); - std::scoped_lock scoped_write_lock(this->parent_filesystem->GetReadWriteLockForCacheInvalidation()); + std::scoped_lock scoped_write_lock(this->parent_filesystem->GetReaderWriterLockForCacheInvalidation()); this->base_file->OperateRange(nullptr, 0, fs::OperationId::Invalidate, 0, std::numeric_limits::max(), nullptr, 0); } @@ -154,15 +154,15 @@ namespace ams::fssrv::impl { AMS_ABORT_UNLESS(false); } - util::optional> FileSystemInterfaceAdapter::AcquireCacheInvalidationReadLock() { - util::optional> lock; + util::optional> FileSystemInterfaceAdapter::AcquireCacheInvalidationReadLock() { + util::optional> lock; if (this->deep_retry_enabled) { lock.emplace(this->invalidation_lock); } return lock; } - os::ReadWriteLock &FileSystemInterfaceAdapter::GetReadWriteLockForCacheInvalidation() { + os::ReaderWriterLock &FileSystemInterfaceAdapter::GetReaderWriterLockForCacheInvalidation() { return this->invalidation_lock; } diff --git a/libraries/libstratosphere/source/fssrv/fssrv_storage_interface_adapter.cpp b/libraries/libstratosphere/source/fssrv/fssrv_storage_interface_adapter.cpp index 60c366ee3..cffb51e0c 100644 --- a/libraries/libstratosphere/source/fssrv/fssrv_storage_interface_adapter.cpp +++ b/libraries/libstratosphere/source/fssrv/fssrv_storage_interface_adapter.cpp @@ -34,8 +34,8 @@ namespace ams::fssrv::impl { /* ... */ } - util::optional> StorageInterfaceAdapter::AcquireCacheInvalidationReadLock() { - util::optional> lock; + util::optional> StorageInterfaceAdapter::AcquireCacheInvalidationReadLock() { + util::optional> lock; if (this->deep_retry_enabled) { lock.emplace(this->invalidation_lock); } diff --git a/libraries/libstratosphere/source/os/impl/os_internal_rw_busy_mutex_impl.os.horizon.hpp b/libraries/libstratosphere/source/os/impl/os_internal_rw_busy_mutex_impl.os.horizon.hpp index ffb46a340..becef2ea9 100644 --- a/libraries/libstratosphere/source/os/impl/os_internal_rw_busy_mutex_impl.os.horizon.hpp +++ b/libraries/libstratosphere/source/os/impl/os_internal_rw_busy_mutex_impl.os.horizon.hpp @@ -101,7 +101,7 @@ namespace ams::os::impl { } - void InternalReadWriteBusyMutexImpl::AcquireReadLock() { + void InternalReaderWriterBusyMutexImpl::AcquireReadLock() { /* Get the thread local region. */ auto * const tlr = svc::GetThreadLocalRegion(); @@ -152,7 +152,7 @@ namespace ams::os::impl { } } - void InternalReadWriteBusyMutexImpl::ReleaseReadLock() { + void InternalReaderWriterBusyMutexImpl::ReleaseReadLock() { /* Release the read lock. */ { /* Get pointer to our value. */ @@ -183,7 +183,7 @@ namespace ams::os::impl { } } - void InternalReadWriteBusyMutexImpl::AcquireWriteLock() { + void InternalReaderWriterBusyMutexImpl::AcquireWriteLock() { /* Get the thread local region. */ auto * const tlr = svc::GetThreadLocalRegion(); @@ -247,7 +247,7 @@ namespace ams::os::impl { } } - void InternalReadWriteBusyMutexImpl::ReleaseWriteLock() { + void InternalReaderWriterBusyMutexImpl::ReleaseWriteLock() { /* Check pre-conditions. */ AMS_ABORT_UNLESS(IsWriteLocked(m_value)); diff --git a/libraries/libstratosphere/source/os/impl/os_rw_lock_impl.hpp b/libraries/libstratosphere/source/os/impl/os_rw_lock_impl.hpp index 9c728871b..14131e82e 100644 --- a/libraries/libstratosphere/source/os/impl/os_rw_lock_impl.hpp +++ b/libraries/libstratosphere/source/os/impl/os_rw_lock_impl.hpp @@ -19,40 +19,40 @@ #if defined(ATMOSPHERE_OS_HORIZON) #include "os_rw_lock_target_impl.os.horizon.hpp" #else - #error "Unknown OS for os::ReadWriteLockTargetImpl" + #error "Unknown OS for os::ReaderWriterLockTargetImpl" #endif namespace ams::os::impl { - static_assert(alignof(ReadWriteLockType) == sizeof(u64) || alignof(ReadWriteLockType) == sizeof(u32)); - constexpr inline bool IsReadWriteLockGuaranteedAlignment = alignof(ReadWriteLockType) == sizeof(u64); + static_assert(alignof(ReaderWriterLockType) == sizeof(u64) || alignof(ReaderWriterLockType) == sizeof(u32)); + constexpr inline bool IsReaderWriterLockGuaranteedAlignment = alignof(ReaderWriterLockType) == sizeof(u64); - struct ReadWriteLockCounter { + struct ReaderWriterLockCounter { using ReadLockCount = util::BitPack32::Field< 0, BITSIZEOF(u16) - 1, u32>; using WriteLocked = util::BitPack32::Field< ReadLockCount::Next, 1, u32>; using ReadLockWaiterCount = util::BitPack32::Field< WriteLocked::Next, BITSIZEOF(u8), u32>; using WriteLockWaiterCount = util::BitPack32::Field; }; - static_assert(ReadWriteLockCounter::WriteLockWaiterCount::Next == BITSIZEOF(u32)); + static_assert(ReaderWriterLockCounter::WriteLockWaiterCount::Next == BITSIZEOF(u32)); - ALWAYS_INLINE void ClearReadLockCount(ReadWriteLockType::LockCount &lc) { - lc.counter.Set(0); + ALWAYS_INLINE void ClearReadLockCount(ReaderWriterLockType::LockCount &lc) { + lc.counter.Set(0); } - ALWAYS_INLINE void ClearWriteLocked(ReadWriteLockType::LockCount &lc) { - lc.counter.Set(0); + ALWAYS_INLINE void ClearWriteLocked(ReaderWriterLockType::LockCount &lc) { + lc.counter.Set(0); } - ALWAYS_INLINE void ClearReadLockWaiterCount(ReadWriteLockType::LockCount &lc) { - lc.counter.Set(0); + ALWAYS_INLINE void ClearReadLockWaiterCount(ReaderWriterLockType::LockCount &lc) { + lc.counter.Set(0); } - ALWAYS_INLINE void ClearWriteLockWaiterCount(ReadWriteLockType::LockCount &lc) { - lc.counter.Set(0); + ALWAYS_INLINE void ClearWriteLockWaiterCount(ReaderWriterLockType::LockCount &lc) { + lc.counter.Set(0); } - ALWAYS_INLINE void ClearWriteLockCount(ReadWriteLockType *rw_lock) { - if constexpr (IsReadWriteLockGuaranteedAlignment) { + ALWAYS_INLINE void ClearWriteLockCount(ReaderWriterLockType *rw_lock) { + if constexpr (IsReaderWriterLockGuaranteedAlignment) { rw_lock->lock_count.aligned.write_lock_count = 0; } else { if (reinterpret_cast(std::addressof(rw_lock->lock_count)) & sizeof(u32)) { @@ -63,8 +63,8 @@ namespace ams::os::impl { } } - ALWAYS_INLINE ReadWriteLockType::LockCount &GetLockCount(ReadWriteLockType *rw_lock) { - if constexpr (IsReadWriteLockGuaranteedAlignment) { + ALWAYS_INLINE ReaderWriterLockType::LockCount &GetLockCount(ReaderWriterLockType *rw_lock) { + if constexpr (IsReaderWriterLockGuaranteedAlignment) { return rw_lock->lock_count.aligned.c; } else { if (reinterpret_cast(std::addressof(rw_lock->lock_count)) & sizeof(u32)) { @@ -75,8 +75,8 @@ namespace ams::os::impl { } } - ALWAYS_INLINE const ReadWriteLockType::LockCount &GetLockCount(const ReadWriteLockType *rw_lock) { - if constexpr (IsReadWriteLockGuaranteedAlignment) { + ALWAYS_INLINE const ReaderWriterLockType::LockCount &GetLockCount(const ReaderWriterLockType *rw_lock) { + if constexpr (IsReaderWriterLockGuaranteedAlignment) { return rw_lock->lock_count.aligned.c; } else { if (reinterpret_cast(std::addressof(rw_lock->lock_count)) & sizeof(u32)) { @@ -87,24 +87,24 @@ namespace ams::os::impl { } } - ALWAYS_INLINE u32 GetReadLockCount(const ReadWriteLockType::LockCount &lc) { - return lc.counter.Get(); + ALWAYS_INLINE u32 GetReadLockCount(const ReaderWriterLockType::LockCount &lc) { + return lc.counter.Get(); } - ALWAYS_INLINE u32 GetWriteLocked(const ReadWriteLockType::LockCount &lc) { - return lc.counter.Get(); + ALWAYS_INLINE u32 GetWriteLocked(const ReaderWriterLockType::LockCount &lc) { + return lc.counter.Get(); } - ALWAYS_INLINE u32 GetReadLockWaiterCount(const ReadWriteLockType::LockCount &lc) { - return lc.counter.Get(); + ALWAYS_INLINE u32 GetReadLockWaiterCount(const ReaderWriterLockType::LockCount &lc) { + return lc.counter.Get(); } - ALWAYS_INLINE u32 GetWriteLockWaiterCount(const ReadWriteLockType::LockCount &lc) { - return lc.counter.Get(); + ALWAYS_INLINE u32 GetWriteLockWaiterCount(const ReaderWriterLockType::LockCount &lc) { + return lc.counter.Get(); } - ALWAYS_INLINE u32 &GetWriteLockCount(ReadWriteLockType &rw_lock) { - if constexpr (IsReadWriteLockGuaranteedAlignment) { + ALWAYS_INLINE u32 &GetWriteLockCount(ReaderWriterLockType &rw_lock) { + if constexpr (IsReaderWriterLockGuaranteedAlignment) { return rw_lock.lock_count.aligned.write_lock_count; } else { if (reinterpret_cast(std::addressof(rw_lock.lock_count)) & sizeof(u32)) { @@ -115,8 +115,8 @@ namespace ams::os::impl { } } - ALWAYS_INLINE const u32 &GetWriteLockCount(const ReadWriteLockType &rw_lock) { - if constexpr (IsReadWriteLockGuaranteedAlignment) { + ALWAYS_INLINE const u32 &GetWriteLockCount(const ReaderWriterLockType &rw_lock) { + if constexpr (IsReaderWriterLockGuaranteedAlignment) { return rw_lock.lock_count.aligned.write_lock_count; } else { if (reinterpret_cast(std::addressof(rw_lock.lock_count)) & sizeof(u32)) { @@ -127,59 +127,59 @@ namespace ams::os::impl { } } - ALWAYS_INLINE void IncReadLockCount(ReadWriteLockType::LockCount &lc) { - const u32 read_lock_count = lc.counter.Get(); - AMS_ASSERT(read_lock_count < ReadWriteLockCountMax); - lc.counter.Set(read_lock_count + 1); + ALWAYS_INLINE void IncReadLockCount(ReaderWriterLockType::LockCount &lc) { + const u32 read_lock_count = lc.counter.Get(); + AMS_ASSERT(read_lock_count < ReaderWriterLockCountMax); + lc.counter.Set(read_lock_count + 1); } - ALWAYS_INLINE void DecReadLockCount(ReadWriteLockType::LockCount &lc) { - const u32 read_lock_count = lc.counter.Get(); + ALWAYS_INLINE void DecReadLockCount(ReaderWriterLockType::LockCount &lc) { + const u32 read_lock_count = lc.counter.Get(); AMS_ASSERT(read_lock_count > 0); - lc.counter.Set(read_lock_count - 1); + lc.counter.Set(read_lock_count - 1); } - ALWAYS_INLINE void IncReadLockWaiterCount(ReadWriteLockType::LockCount &lc) { - const u32 read_lock_waiter_count = lc.counter.Get(); - AMS_ASSERT(read_lock_waiter_count < ReadWriteLockWaiterCountMax); - lc.counter.Set(read_lock_waiter_count + 1); + ALWAYS_INLINE void IncReadLockWaiterCount(ReaderWriterLockType::LockCount &lc) { + const u32 read_lock_waiter_count = lc.counter.Get(); + AMS_ASSERT(read_lock_waiter_count < ReaderWriterLockWaiterCountMax); + lc.counter.Set(read_lock_waiter_count + 1); } - ALWAYS_INLINE void DecReadLockWaiterCount(ReadWriteLockType::LockCount &lc) { - const u32 read_lock_waiter_count = lc.counter.Get(); + ALWAYS_INLINE void DecReadLockWaiterCount(ReaderWriterLockType::LockCount &lc) { + const u32 read_lock_waiter_count = lc.counter.Get(); AMS_ASSERT(read_lock_waiter_count > 0); - lc.counter.Set(read_lock_waiter_count - 1); + lc.counter.Set(read_lock_waiter_count - 1); } - ALWAYS_INLINE void IncWriteLockWaiterCount(ReadWriteLockType::LockCount &lc) { - const u32 write_lock_waiter_count = lc.counter.Get(); - AMS_ASSERT(write_lock_waiter_count < ReadWriteLockWaiterCountMax); - lc.counter.Set(write_lock_waiter_count + 1); + ALWAYS_INLINE void IncWriteLockWaiterCount(ReaderWriterLockType::LockCount &lc) { + const u32 write_lock_waiter_count = lc.counter.Get(); + AMS_ASSERT(write_lock_waiter_count < ReaderWriterLockWaiterCountMax); + lc.counter.Set(write_lock_waiter_count + 1); } - ALWAYS_INLINE void DecWriteLockWaiterCount(ReadWriteLockType::LockCount &lc) { - const u32 write_lock_waiter_count = lc.counter.Get(); + ALWAYS_INLINE void DecWriteLockWaiterCount(ReaderWriterLockType::LockCount &lc) { + const u32 write_lock_waiter_count = lc.counter.Get(); AMS_ASSERT(write_lock_waiter_count > 0); - lc.counter.Set(write_lock_waiter_count - 1); + lc.counter.Set(write_lock_waiter_count - 1); } - ALWAYS_INLINE void IncWriteLockCount(ReadWriteLockType &rw_lock) { + ALWAYS_INLINE void IncWriteLockCount(ReaderWriterLockType &rw_lock) { u32 &write_lock_count = GetWriteLockCount(rw_lock); - AMS_ASSERT(write_lock_count < ReadWriteLockCountMax); + AMS_ASSERT(write_lock_count < ReaderWriterLockCountMax); ++write_lock_count; } - ALWAYS_INLINE void DecWriteLockCount(ReadWriteLockType &rw_lock) { + ALWAYS_INLINE void DecWriteLockCount(ReaderWriterLockType &rw_lock) { u32 &write_lock_count = GetWriteLockCount(rw_lock); AMS_ASSERT(write_lock_count > 0); --write_lock_count; } - ALWAYS_INLINE void SetWriteLocked(ReadWriteLockType::LockCount &lc) { - lc.counter.Set(1); + ALWAYS_INLINE void SetWriteLocked(ReaderWriterLockType::LockCount &lc) { + lc.counter.Set(1); } - using ReadWriteLockImpl = ReadWriteLockTargetImpl; + using ReaderWriterLockImpl = ReaderWriterLockTargetImpl; } diff --git a/libraries/libstratosphere/source/os/impl/os_rw_lock_target_impl.os.horizon.cpp b/libraries/libstratosphere/source/os/impl/os_rw_lock_target_impl.os.horizon.cpp index 5e81dc349..3b391901e 100644 --- a/libraries/libstratosphere/source/os/impl/os_rw_lock_target_impl.os.horizon.cpp +++ b/libraries/libstratosphere/source/os/impl/os_rw_lock_target_impl.os.horizon.cpp @@ -23,7 +23,7 @@ namespace ams::os::impl { (__atomic_compare_exchange(reinterpret_cast(&dst_ref), reinterpret_cast(&expected_ref), reinterpret_cast(&desired_ref), true, success, fail)) - void ReadWriteLockHorizonImpl::AcquireReadLockWriteLocked(os::ReadWriteLockType *rw_lock) { + void ReaderWriterLockHorizonImpl::AcquireReadLockWriteLocked(os::ReaderWriterLockType *rw_lock) { AMS_ASSERT(GetWriteLocked(GetLockCount(rw_lock)) == 1); AMS_ASSERT((GetThreadHandle(GetLockCount(rw_lock)) | svc::HandleWaitMask) == (impl::GetCurrentThreadHandle() | svc::HandleWaitMask)); alignas(alignof(u64)) LockCount expected = GetLockCount(rw_lock); @@ -34,7 +34,7 @@ namespace ams::os::impl { } while (!ATOMIC_COMPARE_EXCHANGE_LOCK_COUNT(GetLockCount(rw_lock), expected, lock_count, __ATOMIC_RELAXED, __ATOMIC_RELAXED)); } - void ReadWriteLockHorizonImpl::ReleaseReadLockWriteLocked(os::ReadWriteLockType *rw_lock) { + void ReaderWriterLockHorizonImpl::ReleaseReadLockWriteLocked(os::ReaderWriterLockType *rw_lock) { AMS_ASSERT(GetWriteLocked(GetLockCount(rw_lock)) == 1); AMS_ASSERT((GetThreadHandle(GetLockCount(rw_lock)) | svc::HandleWaitMask) == (impl::GetCurrentThreadHandle() | svc::HandleWaitMask)); alignas(alignof(u64)) LockCount expected = GetLockCount(rw_lock); @@ -46,7 +46,7 @@ namespace ams::os::impl { return ReleaseWriteLockImpl(rw_lock); } - void ReadWriteLockHorizonImpl::ReleaseWriteLockImpl(os::ReadWriteLockType *rw_lock) { + void ReaderWriterLockHorizonImpl::ReleaseWriteLockImpl(os::ReaderWriterLockType *rw_lock) { alignas(alignof(u64)) LockCount expected = GetLockCount(rw_lock); alignas(alignof(u64)) LockCount lock_count = expected; AMS_ASSERT(GetWriteLocked(lock_count) == 1); @@ -70,7 +70,7 @@ namespace ams::os::impl { } } - void ReadWriteLockHorizonImpl::AcquireReadLock(os::ReadWriteLockType *rw_lock) { + void ReaderWriterLockHorizonImpl::AcquireReadLock(os::ReaderWriterLockType *rw_lock) { AMS_ASSERT(::ams::svc::GetThreadLocalRegion()->disable_count == 0); auto *cur_thread = impl::GetCurrentThread(); @@ -143,7 +143,7 @@ namespace ams::os::impl { } } - bool ReadWriteLockHorizonImpl::TryAcquireReadLock(os::ReadWriteLockType *rw_lock) { + bool ReaderWriterLockHorizonImpl::TryAcquireReadLock(os::ReaderWriterLockType *rw_lock) { AMS_ASSERT(::ams::svc::GetThreadLocalRegion()->disable_count == 0); auto *cur_thread = impl::GetCurrentThread(); @@ -168,7 +168,7 @@ namespace ams::os::impl { } } - void ReadWriteLockHorizonImpl::ReleaseReadLock(os::ReadWriteLockType *rw_lock) { + void ReaderWriterLockHorizonImpl::ReleaseReadLock(os::ReaderWriterLockType *rw_lock) { AMS_ASSERT(::ams::svc::GetThreadLocalRegion()->disable_count == 0); AMS_ASSERT(GetReadLockCount(GetLockCount(rw_lock)) > 0); @@ -226,7 +226,7 @@ namespace ams::os::impl { } } - void ReadWriteLockHorizonImpl::AcquireWriteLock(os::ReadWriteLockType *rw_lock) { + void ReaderWriterLockHorizonImpl::AcquireWriteLock(os::ReaderWriterLockType *rw_lock) { AMS_ASSERT(::ams::svc::GetThreadLocalRegion()->disable_count == 0); auto *cur_thread = impl::GetCurrentThread(); @@ -301,7 +301,7 @@ namespace ams::os::impl { } } - bool ReadWriteLockHorizonImpl::TryAcquireWriteLock(os::ReadWriteLockType *rw_lock) { + bool ReaderWriterLockHorizonImpl::TryAcquireWriteLock(os::ReaderWriterLockType *rw_lock) { AMS_ASSERT(::ams::svc::GetThreadLocalRegion()->disable_count == 0); auto *cur_thread = impl::GetCurrentThread(); @@ -334,7 +334,7 @@ namespace ams::os::impl { } } - void ReadWriteLockHorizonImpl::ReleaseWriteLock(os::ReadWriteLockType *rw_lock) { + void ReaderWriterLockHorizonImpl::ReleaseWriteLock(os::ReaderWriterLockType *rw_lock) { AMS_ASSERT(::ams::svc::GetThreadLocalRegion()->disable_count == 0); AMS_ASSERT(GetWriteLockCount(*rw_lock) > 0); diff --git a/libraries/libstratosphere/source/os/impl/os_rw_lock_target_impl.os.horizon.hpp b/libraries/libstratosphere/source/os/impl/os_rw_lock_target_impl.os.horizon.hpp index 457cf7c2b..57c640bd0 100644 --- a/libraries/libstratosphere/source/os/impl/os_rw_lock_target_impl.os.horizon.hpp +++ b/libraries/libstratosphere/source/os/impl/os_rw_lock_target_impl.os.horizon.hpp @@ -18,9 +18,9 @@ namespace ams::os::impl { - class ReadWriteLockHorizonImpl { + class ReaderWriterLockHorizonImpl { private: - using LockCount = os::ReadWriteLockType::LockCount; + using LockCount = os::ReaderWriterLockType::LockCount; private: static ALWAYS_INLINE u32 GetThreadHandle(const LockCount &lc) { return GetReference(lc.cs_storage).Get()->thread_handle; @@ -34,19 +34,19 @@ namespace ams::os::impl { GetReference(lc.cs_storage).Get()->thread_handle = handle; } - static void AcquireReadLockWriteLocked(os::ReadWriteLockType *rw_lock); - static void ReleaseReadLockWriteLocked(os::ReadWriteLockType *rw_lock); - static void ReleaseWriteLockImpl(os::ReadWriteLockType *rw_lock); + static void AcquireReadLockWriteLocked(os::ReaderWriterLockType *rw_lock); + static void ReleaseReadLockWriteLocked(os::ReaderWriterLockType *rw_lock); + static void ReleaseWriteLockImpl(os::ReaderWriterLockType *rw_lock); public: - static void AcquireReadLock(os::ReadWriteLockType *rw_lock); - static bool TryAcquireReadLock(os::ReadWriteLockType *rw_lock); - static void ReleaseReadLock(os::ReadWriteLockType *rw_lock); + static void AcquireReadLock(os::ReaderWriterLockType *rw_lock); + static bool TryAcquireReadLock(os::ReaderWriterLockType *rw_lock); + static void ReleaseReadLock(os::ReaderWriterLockType *rw_lock); - static void AcquireWriteLock(os::ReadWriteLockType *rw_lock); - static bool TryAcquireWriteLock(os::ReadWriteLockType *rw_lock); - static void ReleaseWriteLock(os::ReadWriteLockType *rw_lock); + static void AcquireWriteLock(os::ReaderWriterLockType *rw_lock); + static bool TryAcquireWriteLock(os::ReaderWriterLockType *rw_lock); + static void ReleaseWriteLock(os::ReaderWriterLockType *rw_lock); }; - using ReadWriteLockTargetImpl = ReadWriteLockHorizonImpl; + using ReaderWriterLockTargetImpl = ReaderWriterLockHorizonImpl; } diff --git a/libraries/libstratosphere/source/os/os_rw_busy_mutex.cpp b/libraries/libstratosphere/source/os/os_rw_busy_mutex.cpp index aa2a94b72..3768aca13 100644 --- a/libraries/libstratosphere/source/os/os_rw_busy_mutex.cpp +++ b/libraries/libstratosphere/source/os/os_rw_busy_mutex.cpp @@ -19,32 +19,32 @@ #if defined(ATMOSPHERE_OS_HORIZON) #include "impl/os_internal_rw_busy_mutex_impl.os.horizon.hpp" #else - #error "Unknown OS for ams::os::impl::InternalReadWriteBusyMutexImpl" + #error "Unknown OS for ams::os::impl::InternalReaderWriterBusyMutexImpl" #endif namespace ams::os { - void InitalizeReadWriteLockBusyMutex(ReadWriteBusyMutexType *rw_mutex) { + void InitalizeReaderWriterLockBusyMutex(ReaderWriterBusyMutexType *rw_mutex) { /* Create object. */ util::ConstructAt(rw_mutex->_storage); } - void AcquireReadLockBusyMutex(ReadWriteBusyMutexType *rw_mutex) { + void AcquireReadLockBusyMutex(ReaderWriterBusyMutexType *rw_mutex) { /* Acquire read lock. */ util::GetReference(rw_mutex->_storage).AcquireReadLock(); } - void ReleaseReadLockBusyMutex(ReadWriteBusyMutexType *rw_mutex) { + void ReleaseReadLockBusyMutex(ReaderWriterBusyMutexType *rw_mutex) { /* Release read lock. */ util::GetReference(rw_mutex->_storage).ReleaseReadLock(); } - void AcquireWriteLockBusyMutex(ReadWriteBusyMutexType *rw_mutex) { + void AcquireWriteLockBusyMutex(ReaderWriterBusyMutexType *rw_mutex) { /* Acquire write lock. */ util::GetReference(rw_mutex->_storage).AcquireWriteLock(); } - void ReleaseWriteLockBusyMutex(ReadWriteBusyMutexType *rw_mutex) { + void ReleaseWriteLockBusyMutex(ReaderWriterBusyMutexType *rw_mutex) { /* Release write lock. */ util::GetReference(rw_mutex->_storage).ReleaseWriteLock(); } diff --git a/libraries/libstratosphere/source/os/os_rw_lock.cpp b/libraries/libstratosphere/source/os/os_rw_lock.cpp index ca6782e1b..0d63ed340 100644 --- a/libraries/libstratosphere/source/os/os_rw_lock.cpp +++ b/libraries/libstratosphere/source/os/os_rw_lock.cpp @@ -19,7 +19,7 @@ namespace ams::os { - void InitalizeReadWriteLock(ReadWriteLockType *rw_lock) { + void InitalizeReaderWriterLock(ReaderWriterLockType *rw_lock) { /* Create objects. */ util::ConstructAt(impl::GetLockCount(rw_lock).cs_storage); util::ConstructAt(rw_lock->cv_read_lock._storage); @@ -34,18 +34,18 @@ namespace ams::os { rw_lock->owner_thread = nullptr; /* Mark initialized. */ - rw_lock->state = ReadWriteLockType::State_Initialized; + rw_lock->state = ReaderWriterLockType::State_Initialized; } - void FinalizeReadWriteLock(ReadWriteLockType *rw_lock) { - AMS_ASSERT(rw_lock->state == ReadWriteLockType::State_Initialized); + void FinalizeReaderWriterLock(ReaderWriterLockType *rw_lock) { + AMS_ASSERT(rw_lock->state == ReaderWriterLockType::State_Initialized); /* Don't allow finalizing a locked lock. */ AMS_ASSERT(impl::GetReadLockCount(impl::GetLockCount(rw_lock)) == 0); AMS_ASSERT(impl::GetWriteLocked(impl::GetLockCount(rw_lock)) == 0); /* Mark not initialized. */ - rw_lock->state = ReadWriteLockType::State_NotInitialized; + rw_lock->state = ReaderWriterLockType::State_NotInitialized; /* Destroy objects. */ util::DestroyAt(rw_lock->cv_write_lock._storage); @@ -53,49 +53,49 @@ namespace ams::os { util::DestroyAt(impl::GetLockCount(rw_lock).cs_storage); } - void AcquireReadLock(ReadWriteLockType *rw_lock) { - AMS_ASSERT(rw_lock->state == ReadWriteLockType::State_Initialized); - return impl::ReadWriteLockImpl::AcquireReadLock(rw_lock); + void AcquireReadLock(ReaderWriterLockType *rw_lock) { + AMS_ASSERT(rw_lock->state == ReaderWriterLockType::State_Initialized); + return impl::ReaderWriterLockImpl::AcquireReadLock(rw_lock); } - bool TryAcquireReadLock(ReadWriteLockType *rw_lock) { - AMS_ASSERT(rw_lock->state == ReadWriteLockType::State_Initialized); - return impl::ReadWriteLockImpl::TryAcquireReadLock(rw_lock); + bool TryAcquireReadLock(ReaderWriterLockType *rw_lock) { + AMS_ASSERT(rw_lock->state == ReaderWriterLockType::State_Initialized); + return impl::ReaderWriterLockImpl::TryAcquireReadLock(rw_lock); } - void ReleaseReadLock(ReadWriteLockType *rw_lock) { - AMS_ASSERT(rw_lock->state == ReadWriteLockType::State_Initialized); - return impl::ReadWriteLockImpl::ReleaseReadLock(rw_lock); + void ReleaseReadLock(ReaderWriterLockType *rw_lock) { + AMS_ASSERT(rw_lock->state == ReaderWriterLockType::State_Initialized); + return impl::ReaderWriterLockImpl::ReleaseReadLock(rw_lock); } - void AcquireWriteLock(ReadWriteLockType *rw_lock) { - AMS_ASSERT(rw_lock->state == ReadWriteLockType::State_Initialized); - return impl::ReadWriteLockImpl::AcquireWriteLock(rw_lock); + void AcquireWriteLock(ReaderWriterLockType *rw_lock) { + AMS_ASSERT(rw_lock->state == ReaderWriterLockType::State_Initialized); + return impl::ReaderWriterLockImpl::AcquireWriteLock(rw_lock); } - bool TryAcquireWriteLock(ReadWriteLockType *rw_lock) { - AMS_ASSERT(rw_lock->state == ReadWriteLockType::State_Initialized); - return impl::ReadWriteLockImpl::TryAcquireWriteLock(rw_lock); + bool TryAcquireWriteLock(ReaderWriterLockType *rw_lock) { + AMS_ASSERT(rw_lock->state == ReaderWriterLockType::State_Initialized); + return impl::ReaderWriterLockImpl::TryAcquireWriteLock(rw_lock); } - void ReleaseWriteLock(ReadWriteLockType *rw_lock) { - AMS_ASSERT(rw_lock->state == ReadWriteLockType::State_Initialized); + void ReleaseWriteLock(ReaderWriterLockType *rw_lock) { + AMS_ASSERT(rw_lock->state == ReaderWriterLockType::State_Initialized); AMS_ABORT_UNLESS(rw_lock->owner_thread == impl::GetCurrentThread()); - return impl::ReadWriteLockImpl::ReleaseWriteLock(rw_lock); + return impl::ReaderWriterLockImpl::ReleaseWriteLock(rw_lock); } - bool IsReadLockHeld(const ReadWriteLockType *rw_lock) { - AMS_ASSERT(rw_lock->state == ReadWriteLockType::State_Initialized); + bool IsReadLockHeld(const ReaderWriterLockType *rw_lock) { + AMS_ASSERT(rw_lock->state == ReaderWriterLockType::State_Initialized); return impl::GetReadLockCount(impl::GetLockCount(rw_lock)) != 0; } - bool IsWriteLockHeldByCurrentThread(const ReadWriteLockType *rw_lock) { - AMS_ASSERT(rw_lock->state == ReadWriteLockType::State_Initialized); + bool IsWriteLockHeldByCurrentThread(const ReaderWriterLockType *rw_lock) { + AMS_ASSERT(rw_lock->state == ReaderWriterLockType::State_Initialized); return rw_lock->owner_thread == impl::GetCurrentThread() && impl::GetWriteLockCount(*rw_lock) != 0; } - bool IsReadWriteLockOwnerThread(const ReadWriteLockType *rw_lock) { - AMS_ASSERT(rw_lock->state == ReadWriteLockType::State_Initialized); + bool IsReaderWriterLockOwnerThread(const ReaderWriterLockType *rw_lock) { + AMS_ASSERT(rw_lock->state == ReaderWriterLockType::State_Initialized); return rw_lock->owner_thread == impl::GetCurrentThread(); }