mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-31 14:58:22 -04:00
strat: use m_ for member variables
This commit is contained in:
parent
ce28591ab2
commit
a595c232b9
425 changed files with 8531 additions and 8484 deletions
|
@ -20,27 +20,27 @@
|
|||
namespace ams::os::impl {
|
||||
|
||||
void InternalConditionVariableImpl::Signal() {
|
||||
ams::svc::SignalProcessWideKey(reinterpret_cast<uintptr_t>(std::addressof(this->value)), 1);
|
||||
ams::svc::SignalProcessWideKey(reinterpret_cast<uintptr_t>(std::addressof(m_value)), 1);
|
||||
}
|
||||
|
||||
void InternalConditionVariableImpl::Broadcast() {
|
||||
ams::svc::SignalProcessWideKey(reinterpret_cast<uintptr_t>(std::addressof(this->value)), -1);
|
||||
ams::svc::SignalProcessWideKey(reinterpret_cast<uintptr_t>(std::addressof(m_value)), -1);
|
||||
}
|
||||
|
||||
void InternalConditionVariableImpl::Wait(InternalCriticalSection *cs) {
|
||||
const auto cur_handle = GetCurrentThreadHandle();
|
||||
AMS_ASSERT((cs->Get()->thread_handle & ~ams::svc::HandleWaitMask) == cur_handle);
|
||||
AMS_ASSERT((cs->Get()->m_thread_handle & ~ams::svc::HandleWaitMask) == cur_handle);
|
||||
|
||||
R_ABORT_UNLESS(ams::svc::WaitProcessWideKeyAtomic(reinterpret_cast<uintptr_t>(std::addressof(cs->Get()->thread_handle)), reinterpret_cast<uintptr_t>(std::addressof(this->value)), cur_handle, -1));
|
||||
R_ABORT_UNLESS(ams::svc::WaitProcessWideKeyAtomic(reinterpret_cast<uintptr_t>(std::addressof(cs->Get()->m_thread_handle)), reinterpret_cast<uintptr_t>(std::addressof(m_value)), cur_handle, -1));
|
||||
}
|
||||
|
||||
ConditionVariableStatus InternalConditionVariableImpl::TimedWait(InternalCriticalSection *cs, const TimeoutHelper &timeout_helper) {
|
||||
const auto cur_handle = GetCurrentThreadHandle();
|
||||
AMS_ASSERT((cs->Get()->thread_handle & ~ams::svc::HandleWaitMask) == cur_handle);
|
||||
AMS_ASSERT((cs->Get()->m_thread_handle & ~ams::svc::HandleWaitMask) == cur_handle);
|
||||
|
||||
const TimeSpan left = timeout_helper.GetTimeLeftOnTarget();
|
||||
if (left > 0) {
|
||||
R_TRY_CATCH(ams::svc::WaitProcessWideKeyAtomic(reinterpret_cast<uintptr_t>(std::addressof(cs->Get()->thread_handle)), reinterpret_cast<uintptr_t>(std::addressof(this->value)), cur_handle, left.GetNanoSeconds())) {
|
||||
R_TRY_CATCH(ams::svc::WaitProcessWideKeyAtomic(reinterpret_cast<uintptr_t>(std::addressof(cs->Get()->m_thread_handle)), reinterpret_cast<uintptr_t>(std::addressof(m_value)), cur_handle, left.GetNanoSeconds())) {
|
||||
R_CATCH(svc::ResultTimedOut) {
|
||||
cs->Enter();
|
||||
return ConditionVariableStatus::TimedOut;
|
||||
|
|
|
@ -25,30 +25,30 @@ namespace ams::os::impl {
|
|||
AMS_ASSERT(svc::GetThreadLocalRegion()->disable_count == 0);
|
||||
|
||||
/* Use the libnx impl. */
|
||||
static_assert(std::is_same<decltype(this->thread_handle), ::Mutex>::value);
|
||||
return ::mutexLock(std::addressof(this->thread_handle));
|
||||
static_assert(std::is_same<decltype(m_thread_handle), ::Mutex>::value);
|
||||
return ::mutexLock(std::addressof(m_thread_handle));
|
||||
}
|
||||
|
||||
bool InternalCriticalSectionImpl::TryEnter() {
|
||||
AMS_ASSERT(svc::GetThreadLocalRegion()->disable_count == 0);
|
||||
|
||||
/* Use the libnx impl. */
|
||||
static_assert(std::is_same<decltype(this->thread_handle), ::Mutex>::value);
|
||||
return ::mutexTryLock(std::addressof(this->thread_handle));
|
||||
static_assert(std::is_same<decltype(m_thread_handle), ::Mutex>::value);
|
||||
return ::mutexTryLock(std::addressof(m_thread_handle));
|
||||
}
|
||||
|
||||
void InternalCriticalSectionImpl::Leave() {
|
||||
AMS_ASSERT(svc::GetThreadLocalRegion()->disable_count == 0);
|
||||
|
||||
/* Use the libnx impl. */
|
||||
static_assert(std::is_same<decltype(this->thread_handle), ::Mutex>::value);
|
||||
return ::mutexUnlock(std::addressof(this->thread_handle));
|
||||
static_assert(std::is_same<decltype(m_thread_handle), ::Mutex>::value);
|
||||
return ::mutexUnlock(std::addressof(m_thread_handle));
|
||||
}
|
||||
|
||||
bool InternalCriticalSectionImpl::IsLockedByCurrentThread() const {
|
||||
/* Use the libnx impl. */
|
||||
static_assert(std::is_same<decltype(this->thread_handle), ::Mutex>::value);
|
||||
return ::mutexIsLockedByCurrentThread(std::addressof(this->thread_handle));
|
||||
static_assert(std::is_same<decltype(m_thread_handle), ::Mutex>::value);
|
||||
return ::mutexIsLockedByCurrentThread(std::addressof(m_thread_handle));
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
|
@ -26,32 +26,32 @@ namespace ams::os::impl {
|
|||
|
||||
class InterruptEventImpl {
|
||||
private:
|
||||
InterruptEventTargetImpl impl;
|
||||
InterruptEventTargetImpl m_impl;
|
||||
public:
|
||||
explicit InterruptEventImpl(InterruptName name, EventClearMode clear_mode) : impl(name, clear_mode) { /* ... */ }
|
||||
explicit InterruptEventImpl(InterruptName name, EventClearMode clear_mode) : m_impl(name, clear_mode) { /* ... */ }
|
||||
|
||||
void Clear() {
|
||||
return this->impl.Clear();
|
||||
return m_impl.Clear();
|
||||
}
|
||||
|
||||
void Wait() {
|
||||
return this->impl.Wait();
|
||||
return m_impl.Wait();
|
||||
}
|
||||
|
||||
bool TryWait() {
|
||||
return this->impl.TryWait();
|
||||
return m_impl.TryWait();
|
||||
}
|
||||
|
||||
bool TimedWait(TimeSpan timeout) {
|
||||
return this->impl.TimedWait(timeout);
|
||||
return m_impl.TimedWait(timeout);
|
||||
}
|
||||
|
||||
TriBool IsSignaled() {
|
||||
return this->impl.IsSignaled();
|
||||
return m_impl.IsSignaled();
|
||||
}
|
||||
|
||||
NativeHandle GetHandle() const {
|
||||
return this->impl.GetHandle();
|
||||
return m_impl.GetHandle();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -20,32 +20,32 @@
|
|||
namespace ams::os::impl {
|
||||
|
||||
InterruptEventHorizonImpl::InterruptEventHorizonImpl(InterruptName name, EventClearMode clear_mode) {
|
||||
this->manual_clear = (clear_mode == EventClearMode_ManualClear);
|
||||
m_manual_clear = (clear_mode == EventClearMode_ManualClear);
|
||||
|
||||
auto interrupt_type = this->manual_clear ? svc::InterruptType_Level : svc::InterruptType_Edge;
|
||||
auto interrupt_type = m_manual_clear ? svc::InterruptType_Level : svc::InterruptType_Edge;
|
||||
svc::Handle handle;
|
||||
R_ABORT_UNLESS(svc::CreateInterruptEvent(std::addressof(handle), static_cast<s32>(name), interrupt_type));
|
||||
|
||||
this->handle = handle;
|
||||
m_handle = handle;
|
||||
}
|
||||
|
||||
InterruptEventHorizonImpl::~InterruptEventHorizonImpl() {
|
||||
R_ABORT_UNLESS(svc::CloseHandle(this->handle));
|
||||
R_ABORT_UNLESS(svc::CloseHandle(m_handle));
|
||||
}
|
||||
|
||||
void InterruptEventHorizonImpl::Clear() {
|
||||
R_ABORT_UNLESS(svc::ClearEvent(this->handle));
|
||||
R_ABORT_UNLESS(svc::ClearEvent(m_handle));
|
||||
}
|
||||
|
||||
void InterruptEventHorizonImpl::Wait() {
|
||||
while (true) {
|
||||
/* Continuously wait, until success. */
|
||||
s32 index;
|
||||
Result res = svc::WaitSynchronization(std::addressof(index), std::addressof(this->handle), 1, svc::WaitInfinite);
|
||||
Result res = svc::WaitSynchronization(std::addressof(index), std::addressof(m_handle), 1, svc::WaitInfinite);
|
||||
if (R_SUCCEEDED(res)) {
|
||||
/* Clear, if we must. */
|
||||
if (!this->manual_clear) {
|
||||
R_TRY_CATCH(svc::ResetSignal(this->handle)) {
|
||||
if (!m_manual_clear) {
|
||||
R_TRY_CATCH(svc::ResetSignal(m_handle)) {
|
||||
/* Some other thread might have caught this before we did. */
|
||||
R_CATCH(svc::ResultInvalidState) { continue; }
|
||||
} R_END_TRY_CATCH_WITH_ABORT_UNLESS;
|
||||
|
@ -60,15 +60,15 @@ namespace ams::os::impl {
|
|||
|
||||
bool InterruptEventHorizonImpl::TryWait() {
|
||||
/* If we're auto clear, just try to reset. */
|
||||
if (!this->manual_clear) {
|
||||
return R_SUCCEEDED(svc::ResetSignal(this->handle));
|
||||
if (!m_manual_clear) {
|
||||
return R_SUCCEEDED(svc::ResetSignal(m_handle));
|
||||
}
|
||||
|
||||
/* Not auto-clear. */
|
||||
while (true) {
|
||||
/* Continuously wait, until success or timeout. */
|
||||
s32 index;
|
||||
Result res = svc::WaitSynchronization(std::addressof(index), std::addressof(this->handle), 1, 0);
|
||||
Result res = svc::WaitSynchronization(std::addressof(index), std::addressof(m_handle), 1, 0);
|
||||
|
||||
/* If we succeeded, we're signaled. */
|
||||
if (R_SUCCEEDED(res)) {
|
||||
|
@ -90,11 +90,11 @@ namespace ams::os::impl {
|
|||
while (true) {
|
||||
/* Continuously wait, until success. */
|
||||
s32 index;
|
||||
Result res = svc::WaitSynchronization(std::addressof(index), std::addressof(this->handle), 1, timeout_helper.GetTimeLeftOnTarget().GetNanoSeconds());
|
||||
Result res = svc::WaitSynchronization(std::addressof(index), std::addressof(m_handle), 1, timeout_helper.GetTimeLeftOnTarget().GetNanoSeconds());
|
||||
if (R_SUCCEEDED(res)) {
|
||||
/* Clear, if we must. */
|
||||
if (!this->manual_clear) {
|
||||
R_TRY_CATCH(svc::ResetSignal(this->handle)) {
|
||||
if (!m_manual_clear) {
|
||||
R_TRY_CATCH(svc::ResetSignal(m_handle)) {
|
||||
/* Some other thread might have caught this before we did. */
|
||||
R_CATCH(svc::ResultInvalidState) { continue; }
|
||||
} R_END_TRY_CATCH_WITH_ABORT_UNLESS;
|
||||
|
|
|
@ -20,8 +20,8 @@ namespace ams::os::impl {
|
|||
|
||||
class InterruptEventHorizonImpl {
|
||||
private:
|
||||
svc::Handle handle;
|
||||
bool manual_clear;
|
||||
svc::Handle m_handle;
|
||||
bool m_manual_clear;
|
||||
public:
|
||||
explicit InterruptEventHorizonImpl(InterruptName name, EventClearMode mode);
|
||||
~InterruptEventHorizonImpl();
|
||||
|
@ -36,7 +36,7 @@ namespace ams::os::impl {
|
|||
}
|
||||
|
||||
NativeHandle GetHandle() const {
|
||||
return this->handle;
|
||||
return m_handle;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -23,10 +23,10 @@ namespace ams::os::impl {
|
|||
|
||||
class MultiWaitHolderBase {
|
||||
private:
|
||||
MultiWaitImpl *multi_wait = nullptr;
|
||||
MultiWaitImpl *m_multi_wait = nullptr;
|
||||
public:
|
||||
util::IntrusiveListNode multi_wait_node;
|
||||
util::IntrusiveListNode object_list_node;
|
||||
util::IntrusiveListNode m_multi_wait_node;
|
||||
util::IntrusiveListNode m_object_list_node;
|
||||
public:
|
||||
/* Gets whether the held object is currently signaled. */
|
||||
virtual TriBool IsSignaled() const = 0;
|
||||
|
@ -43,15 +43,15 @@ namespace ams::os::impl {
|
|||
|
||||
/* Interface with multi wait. */
|
||||
void SetMultiWait(MultiWaitImpl *m) {
|
||||
this->multi_wait = m;
|
||||
m_multi_wait = m;
|
||||
}
|
||||
|
||||
MultiWaitImpl *GetMultiWait() const {
|
||||
return this->multi_wait;
|
||||
return m_multi_wait;
|
||||
}
|
||||
|
||||
bool IsLinked() const {
|
||||
return this->multi_wait != nullptr;
|
||||
return m_multi_wait != nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -21,31 +21,31 @@ namespace ams::os::impl {
|
|||
|
||||
class MultiWaitHolderOfEvent : public MultiWaitHolderOfUserObject {
|
||||
private:
|
||||
EventType *event;
|
||||
EventType *m_event;
|
||||
private:
|
||||
TriBool IsSignaledImpl() const {
|
||||
return this->event->signaled ? TriBool::True : TriBool::False;
|
||||
return m_event->signaled ? TriBool::True : TriBool::False;
|
||||
}
|
||||
public:
|
||||
explicit MultiWaitHolderOfEvent(EventType *e) : event(e) { /* ... */ }
|
||||
explicit MultiWaitHolderOfEvent(EventType *e) : m_event(e) { /* ... */ }
|
||||
|
||||
/* IsSignaled, Link, Unlink implemented. */
|
||||
virtual TriBool IsSignaled() const override {
|
||||
std::scoped_lock lk(GetReference(this->event->cs_event));
|
||||
std::scoped_lock lk(GetReference(m_event->cs_event));
|
||||
return this->IsSignaledImpl();
|
||||
}
|
||||
|
||||
virtual TriBool LinkToObjectList() override {
|
||||
std::scoped_lock lk(GetReference(this->event->cs_event));
|
||||
std::scoped_lock lk(GetReference(m_event->cs_event));
|
||||
|
||||
GetReference(this->event->multi_wait_object_list_storage).LinkMultiWaitHolder(*this);
|
||||
GetReference(m_event->multi_wait_object_list_storage).LinkMultiWaitHolder(*this);
|
||||
return this->IsSignaledImpl();
|
||||
}
|
||||
|
||||
virtual void UnlinkFromObjectList() override {
|
||||
std::scoped_lock lk(GetReference(this->event->cs_event));
|
||||
std::scoped_lock lk(GetReference(m_event->cs_event));
|
||||
|
||||
GetReference(this->event->multi_wait_object_list_storage).UnlinkMultiWaitHolder(*this);
|
||||
GetReference(m_event->multi_wait_object_list_storage).UnlinkMultiWaitHolder(*this);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -20,9 +20,9 @@ namespace ams::os::impl {
|
|||
|
||||
class MultiWaitHolderOfHandle : public MultiWaitHolderOfKernelObject {
|
||||
private:
|
||||
NativeHandle handle;
|
||||
NativeHandle m_handle;
|
||||
public:
|
||||
explicit MultiWaitHolderOfHandle(NativeHandle h) : handle(h) { /* ... */ }
|
||||
explicit MultiWaitHolderOfHandle(NativeHandle h) : m_handle(h) { /* ... */ }
|
||||
|
||||
/* IsSignaled, GetHandle both implemented. */
|
||||
virtual TriBool IsSignaled() const override {
|
||||
|
@ -30,7 +30,7 @@ namespace ams::os::impl {
|
|||
}
|
||||
|
||||
virtual NativeHandle GetHandle() const override {
|
||||
return this->handle;
|
||||
return m_handle;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -21,9 +21,9 @@ namespace ams::os::impl {
|
|||
|
||||
class MultiWaitHolderOfInterProcessEvent : public MultiWaitHolderOfKernelObject {
|
||||
private:
|
||||
InterProcessEventType *event;
|
||||
InterProcessEventType *m_event;
|
||||
public:
|
||||
explicit MultiWaitHolderOfInterProcessEvent(InterProcessEventType *e) : event(e) { /* ... */ }
|
||||
explicit MultiWaitHolderOfInterProcessEvent(InterProcessEventType *e) : m_event(e) { /* ... */ }
|
||||
|
||||
/* IsSignaled, GetHandle both implemented. */
|
||||
virtual TriBool IsSignaled() const override {
|
||||
|
@ -31,7 +31,7 @@ namespace ams::os::impl {
|
|||
}
|
||||
|
||||
virtual NativeHandle GetHandle() const override {
|
||||
return this->event->readable_handle;
|
||||
return m_event->readable_handle;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
namespace ams::os::impl {
|
||||
|
||||
NativeHandle MultiWaitHolderOfInterruptEvent::GetHandle() const {
|
||||
return GetReference(event->impl).GetHandle();
|
||||
return GetReference(m_event->impl).GetHandle();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,9 +20,9 @@ namespace ams::os::impl {
|
|||
|
||||
class MultiWaitHolderOfInterruptEvent : public MultiWaitHolderOfKernelObject {
|
||||
private:
|
||||
InterruptEventType *event;
|
||||
InterruptEventType *m_event;
|
||||
public:
|
||||
explicit MultiWaitHolderOfInterruptEvent(InterruptEventType *e) : event(e) { /* ... */ }
|
||||
explicit MultiWaitHolderOfInterruptEvent(InterruptEventType *e) : m_event(e) { /* ... */ }
|
||||
|
||||
/* IsSignaled, GetHandle both implemented. */
|
||||
virtual TriBool IsSignaled() const override {
|
||||
|
|
|
@ -23,15 +23,15 @@ namespace ams::os::impl {
|
|||
class MultiWaitHolderOfMessageQueue : public MultiWaitHolderOfUserObject {
|
||||
static_assert(WaitType == MessageQueueWaitType::ForNotEmpty || WaitType == MessageQueueWaitType::ForNotFull);
|
||||
private:
|
||||
MessageQueueType *mq;
|
||||
MessageQueueType *m_mq;
|
||||
private:
|
||||
constexpr inline TriBool IsSignaledImpl() const {
|
||||
if constexpr (WaitType == MessageQueueWaitType::ForNotEmpty) {
|
||||
/* ForNotEmpty. */
|
||||
return this->mq->count > 0 ? TriBool::True : TriBool::False;
|
||||
return m_mq->count > 0 ? TriBool::True : TriBool::False;
|
||||
} else if constexpr (WaitType == MessageQueueWaitType::ForNotFull) {
|
||||
/* ForNotFull */
|
||||
return this->mq->count < this->mq->capacity ? TriBool::True : TriBool::False;
|
||||
return m_mq->count < m_mq->capacity ? TriBool::True : TriBool::False;
|
||||
} else {
|
||||
static_assert(WaitType != WaitType);
|
||||
}
|
||||
|
@ -39,31 +39,31 @@ namespace ams::os::impl {
|
|||
|
||||
constexpr inline MultiWaitObjectList &GetObjectList() const {
|
||||
if constexpr (WaitType == MessageQueueWaitType::ForNotEmpty) {
|
||||
return GetReference(this->mq->waitlist_not_empty);
|
||||
return GetReference(m_mq->waitlist_not_empty);
|
||||
} else if constexpr (WaitType == MessageQueueWaitType::ForNotFull) {
|
||||
return GetReference(this->mq->waitlist_not_full);
|
||||
return GetReference(m_mq->waitlist_not_full);
|
||||
} else {
|
||||
static_assert(WaitType != WaitType);
|
||||
}
|
||||
}
|
||||
public:
|
||||
explicit MultiWaitHolderOfMessageQueue(MessageQueueType *mq) : mq(mq) { /* ... */ }
|
||||
explicit MultiWaitHolderOfMessageQueue(MessageQueueType *mq) : m_mq(mq) { /* ... */ }
|
||||
|
||||
/* IsSignaled, Link, Unlink implemented. */
|
||||
virtual TriBool IsSignaled() const override {
|
||||
std::scoped_lock lk(GetReference(this->mq->cs_queue));
|
||||
std::scoped_lock lk(GetReference(m_mq->cs_queue));
|
||||
return this->IsSignaledImpl();
|
||||
}
|
||||
|
||||
virtual TriBool LinkToObjectList() override {
|
||||
std::scoped_lock lk(GetReference(this->mq->cs_queue));
|
||||
std::scoped_lock lk(GetReference(m_mq->cs_queue));
|
||||
|
||||
this->GetObjectList().LinkMultiWaitHolder(*this);
|
||||
return this->IsSignaledImpl();
|
||||
}
|
||||
|
||||
virtual void UnlinkFromObjectList() override {
|
||||
std::scoped_lock lk(GetReference(this->mq->cs_queue));
|
||||
std::scoped_lock lk(GetReference(m_mq->cs_queue));
|
||||
|
||||
this->GetObjectList().UnlinkMultiWaitHolder(*this);
|
||||
}
|
||||
|
|
|
@ -21,31 +21,31 @@ namespace ams::os::impl {
|
|||
|
||||
class MultiWaitHolderOfSemaphore : public MultiWaitHolderOfUserObject {
|
||||
private:
|
||||
SemaphoreType *semaphore;
|
||||
SemaphoreType *m_semaphore;
|
||||
private:
|
||||
TriBool IsSignaledImpl() const {
|
||||
return this->semaphore->count > 0 ? TriBool::True : TriBool::False;
|
||||
return m_semaphore->count > 0 ? TriBool::True : TriBool::False;
|
||||
}
|
||||
public:
|
||||
explicit MultiWaitHolderOfSemaphore(SemaphoreType *s) : semaphore(s) { /* ... */ }
|
||||
explicit MultiWaitHolderOfSemaphore(SemaphoreType *s) : m_semaphore(s) { /* ... */ }
|
||||
|
||||
/* IsSignaled, Link, Unlink implemented. */
|
||||
virtual TriBool IsSignaled() const override {
|
||||
std::scoped_lock lk(GetReference(this->semaphore->cs_sema));
|
||||
std::scoped_lock lk(GetReference(m_semaphore->cs_sema));
|
||||
return this->IsSignaledImpl();
|
||||
}
|
||||
|
||||
virtual TriBool LinkToObjectList() override {
|
||||
std::scoped_lock lk(GetReference(this->semaphore->cs_sema));
|
||||
std::scoped_lock lk(GetReference(m_semaphore->cs_sema));
|
||||
|
||||
GetReference(this->semaphore->waitlist).LinkMultiWaitHolder(*this);
|
||||
GetReference(m_semaphore->waitlist).LinkMultiWaitHolder(*this);
|
||||
return this->IsSignaledImpl();
|
||||
}
|
||||
|
||||
virtual void UnlinkFromObjectList() override {
|
||||
std::scoped_lock lk(GetReference(this->semaphore->cs_sema));
|
||||
std::scoped_lock lk(GetReference(m_semaphore->cs_sema));
|
||||
|
||||
GetReference(this->semaphore->waitlist).UnlinkMultiWaitHolder(*this);
|
||||
GetReference(m_semaphore->waitlist).UnlinkMultiWaitHolder(*this);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -20,31 +20,31 @@ namespace ams::os::impl {
|
|||
|
||||
class MultiWaitHolderOfThread : public MultiWaitHolderOfUserObject {
|
||||
private:
|
||||
ThreadType *thread;
|
||||
ThreadType *m_thread;
|
||||
private:
|
||||
TriBool IsSignaledImpl() const {
|
||||
return this->thread->state == ThreadType::State_Terminated ? TriBool::True : TriBool::False;
|
||||
return m_thread->state == ThreadType::State_Terminated ? TriBool::True : TriBool::False;
|
||||
}
|
||||
public:
|
||||
explicit MultiWaitHolderOfThread(ThreadType *t) : thread(t) { /* ... */ }
|
||||
explicit MultiWaitHolderOfThread(ThreadType *t) : m_thread(t) { /* ... */ }
|
||||
|
||||
/* IsSignaled, Link, Unlink implemented. */
|
||||
virtual TriBool IsSignaled() const override {
|
||||
std::scoped_lock lk(GetReference(this->thread->cs_thread));
|
||||
std::scoped_lock lk(GetReference(m_thread->cs_thread));
|
||||
return this->IsSignaledImpl();
|
||||
}
|
||||
|
||||
virtual TriBool LinkToObjectList() override {
|
||||
std::scoped_lock lk(GetReference(this->thread->cs_thread));
|
||||
std::scoped_lock lk(GetReference(m_thread->cs_thread));
|
||||
|
||||
GetReference(this->thread->waitlist).LinkMultiWaitHolder(*this);
|
||||
GetReference(m_thread->waitlist).LinkMultiWaitHolder(*this);
|
||||
return this->IsSignaledImpl();
|
||||
}
|
||||
|
||||
virtual void UnlinkFromObjectList() override {
|
||||
std::scoped_lock lk(GetReference(this->thread->cs_thread));
|
||||
std::scoped_lock lk(GetReference(m_thread->cs_thread));
|
||||
|
||||
GetReference(this->thread->waitlist).UnlinkMultiWaitHolder(*this);
|
||||
GetReference(m_thread->waitlist).UnlinkMultiWaitHolder(*this);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -23,44 +23,44 @@ namespace ams::os::impl {
|
|||
|
||||
class MultiWaitHolderOfTimerEvent : public MultiWaitHolderOfUserObject {
|
||||
private:
|
||||
TimerEventType *event;
|
||||
TimerEventType *m_event;
|
||||
private:
|
||||
TriBool IsSignaledImpl() const {
|
||||
TimeSpan cur_time = this->GetMultiWait()->GetCurrentTime();
|
||||
UpdateSignalStateAndRecalculateNextTimeToWakeupUnsafe(this->event, cur_time);
|
||||
return this->event->signaled ? TriBool::True : TriBool::False;
|
||||
UpdateSignalStateAndRecalculateNextTimeToWakeupUnsafe(m_event, cur_time);
|
||||
return m_event->signaled ? TriBool::True : TriBool::False;
|
||||
}
|
||||
public:
|
||||
explicit MultiWaitHolderOfTimerEvent(TimerEventType *e) : event(e) { /* ... */ }
|
||||
explicit MultiWaitHolderOfTimerEvent(TimerEventType *e) : m_event(e) { /* ... */ }
|
||||
|
||||
/* IsSignaled, Link, Unlink implemented. */
|
||||
virtual TriBool IsSignaled() const override {
|
||||
std::scoped_lock lk(GetReference(this->event->cs_timer_event));
|
||||
std::scoped_lock lk(GetReference(m_event->cs_timer_event));
|
||||
return this->IsSignaledImpl();
|
||||
}
|
||||
|
||||
virtual TriBool LinkToObjectList() override {
|
||||
std::scoped_lock lk(GetReference(this->event->cs_timer_event));
|
||||
std::scoped_lock lk(GetReference(m_event->cs_timer_event));
|
||||
|
||||
GetReference(this->event->multi_wait_object_list_storage).LinkMultiWaitHolder(*this);
|
||||
GetReference(m_event->multi_wait_object_list_storage).LinkMultiWaitHolder(*this);
|
||||
return this->IsSignaledImpl();
|
||||
}
|
||||
|
||||
virtual void UnlinkFromObjectList() override {
|
||||
std::scoped_lock lk(GetReference(this->event->cs_timer_event));
|
||||
std::scoped_lock lk(GetReference(m_event->cs_timer_event));
|
||||
|
||||
GetReference(this->event->multi_wait_object_list_storage).UnlinkMultiWaitHolder(*this);
|
||||
GetReference(m_event->multi_wait_object_list_storage).UnlinkMultiWaitHolder(*this);
|
||||
}
|
||||
|
||||
/* Gets the amount of time remaining until this wakes up. */
|
||||
virtual TimeSpan GetAbsoluteWakeupTime() const override {
|
||||
std::scoped_lock lk(GetReference(this->event->cs_timer_event));
|
||||
std::scoped_lock lk(GetReference(m_event->cs_timer_event));
|
||||
|
||||
if (this->event->timer_state == TimerEventType::TimerState_Stop) {
|
||||
if (m_event->timer_state == TimerEventType::TimerState_Stop) {
|
||||
return TimeSpan::FromNanoSeconds(std::numeric_limits<s64>::max());
|
||||
}
|
||||
|
||||
return GetReference(this->event->next_time_to_wakeup);
|
||||
return GetReference(m_event->next_time_to_wakeup);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -22,15 +22,15 @@ namespace ams::os::impl {
|
|||
|
||||
Result MultiWaitImpl::WaitAnyImpl(MultiWaitHolderBase **out, bool infinite, TimeSpan timeout, bool reply, NativeHandle reply_target) {
|
||||
/* Prepare for processing. */
|
||||
this->signaled_holder = nullptr;
|
||||
this->target_impl.SetCurrentThreadHandleForCancelWait();
|
||||
m_signaled_holder = nullptr;
|
||||
m_target_impl.SetCurrentThreadHandleForCancelWait();
|
||||
MultiWaitHolderBase *holder = this->LinkHoldersToObjectList();
|
||||
|
||||
/* Check if we've been signaled. */
|
||||
{
|
||||
std::scoped_lock lk(this->cs_wait);
|
||||
if (this->signaled_holder != nullptr) {
|
||||
holder = this->signaled_holder;
|
||||
std::scoped_lock lk(m_cs_wait);
|
||||
if (m_signaled_holder != nullptr) {
|
||||
holder = m_signaled_holder;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ namespace ams::os::impl {
|
|||
if (holder != nullptr) {
|
||||
if (reply && reply_target != os::InvalidNativeHandle) {
|
||||
s32 index;
|
||||
wait_result = this->target_impl.TimedReplyAndReceive(std::addressof(index), nullptr, 0, 0, reply_target, TimeSpan::FromNanoSeconds(0));
|
||||
wait_result = m_target_impl.TimedReplyAndReceive(std::addressof(index), nullptr, 0, 0, reply_target, TimeSpan::FromNanoSeconds(0));
|
||||
if (R_FAILED(wait_result)) {
|
||||
holder = nullptr;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ namespace ams::os::impl {
|
|||
/* Unlink holders from the current object list. */
|
||||
this->UnlinkHoldersFromObjectList();
|
||||
|
||||
this->target_impl.ClearCurrentThreadHandleForCancelWait();
|
||||
m_target_impl.ClearCurrentThreadHandleForCancelWait();
|
||||
|
||||
/* Set output holder. */
|
||||
*out = holder;
|
||||
|
@ -67,7 +67,7 @@ namespace ams::os::impl {
|
|||
const TimeSpan end_time = infinite ? TimeSpan::FromNanoSeconds(std::numeric_limits<s64>::max()) : GetCurrentTick().ToTimeSpan() + timeout;
|
||||
|
||||
while (true) {
|
||||
this->current_time = GetCurrentTick().ToTimeSpan();
|
||||
m_current_time = GetCurrentTick().ToTimeSpan();
|
||||
|
||||
TimeSpan min_timeout = 0;
|
||||
MultiWaitHolderBase *min_timeout_object = this->RecalculateNextTimeout(std::addressof(min_timeout), end_time);
|
||||
|
@ -76,17 +76,17 @@ namespace ams::os::impl {
|
|||
Result wait_result = ResultSuccess();
|
||||
if (reply) {
|
||||
if (infinite && min_timeout_object == nullptr) {
|
||||
wait_result = this->target_impl.ReplyAndReceive(std::addressof(index), object_handles, MaximumHandleCount, count, reply_target);
|
||||
wait_result = m_target_impl.ReplyAndReceive(std::addressof(index), object_handles, MaximumHandleCount, count, reply_target);
|
||||
} else {
|
||||
wait_result = this->target_impl.TimedReplyAndReceive(std::addressof(index), object_handles, MaximumHandleCount, count, reply_target, min_timeout);
|
||||
wait_result = m_target_impl.TimedReplyAndReceive(std::addressof(index), object_handles, MaximumHandleCount, count, reply_target, min_timeout);
|
||||
}
|
||||
} else if (infinite && min_timeout_object == nullptr) {
|
||||
wait_result = this->target_impl.WaitAny(std::addressof(index), object_handles, MaximumHandleCount, count);
|
||||
wait_result = m_target_impl.WaitAny(std::addressof(index), object_handles, MaximumHandleCount, count);
|
||||
} else {
|
||||
if (count == 0 && min_timeout == 0) {
|
||||
index = WaitTimedOut;
|
||||
} else {
|
||||
wait_result = this->target_impl.TimedWaitAny(std::addressof(index), object_handles, MaximumHandleCount, count, min_timeout);
|
||||
wait_result = m_target_impl.TimedWaitAny(std::addressof(index), object_handles, MaximumHandleCount, count, min_timeout);
|
||||
AMS_ABORT_UNLESS(index != WaitInvalid);
|
||||
}
|
||||
}
|
||||
|
@ -99,11 +99,11 @@ namespace ams::os::impl {
|
|||
switch (index) {
|
||||
case WaitTimedOut:
|
||||
if (min_timeout_object) {
|
||||
this->current_time = GetCurrentTick().ToTimeSpan();
|
||||
m_current_time = GetCurrentTick().ToTimeSpan();
|
||||
if (min_timeout_object->IsSignaled() == TriBool::True) {
|
||||
std::scoped_lock lk(this->cs_wait);
|
||||
this->signaled_holder = min_timeout_object;
|
||||
*out = min_timeout_object;
|
||||
std::scoped_lock lk(m_cs_wait);
|
||||
m_signaled_holder = min_timeout_object;
|
||||
*out = min_timeout_object;
|
||||
return wait_result;
|
||||
}
|
||||
} else {
|
||||
|
@ -113,9 +113,9 @@ namespace ams::os::impl {
|
|||
break;
|
||||
case WaitCancelled:
|
||||
{
|
||||
std::scoped_lock lk(this->cs_wait);
|
||||
if (this->signaled_holder) {
|
||||
*out = this->signaled_holder;
|
||||
std::scoped_lock lk(m_cs_wait);
|
||||
if (m_signaled_holder) {
|
||||
*out = m_signaled_holder;
|
||||
return wait_result;
|
||||
}
|
||||
}
|
||||
|
@ -124,9 +124,9 @@ namespace ams::os::impl {
|
|||
{
|
||||
AMS_ASSERT(0 <= index && index < static_cast<s32>(MaximumHandleCount));
|
||||
|
||||
std::scoped_lock lk(this->cs_wait);
|
||||
this->signaled_holder = objects[index];
|
||||
*out = objects[index];
|
||||
std::scoped_lock lk(m_cs_wait);
|
||||
m_signaled_holder = objects[index];
|
||||
*out = objects[index];
|
||||
return wait_result;
|
||||
}
|
||||
break;
|
||||
|
@ -139,7 +139,7 @@ namespace ams::os::impl {
|
|||
s32 MultiWaitImpl::BuildHandleArray(NativeHandle out_handles[], MultiWaitHolderBase *out_objects[], s32 num) {
|
||||
s32 count = 0;
|
||||
|
||||
for (MultiWaitHolderBase &holder_base : this->multi_wait_list) {
|
||||
for (MultiWaitHolderBase &holder_base : m_multi_wait_list) {
|
||||
if (auto handle = holder_base.GetHandle(); handle != os::InvalidNativeHandle) {
|
||||
AMS_ABORT_UNLESS(count < num);
|
||||
|
||||
|
@ -155,7 +155,7 @@ namespace ams::os::impl {
|
|||
MultiWaitHolderBase *MultiWaitImpl::LinkHoldersToObjectList() {
|
||||
MultiWaitHolderBase *signaled_holder = nullptr;
|
||||
|
||||
for (MultiWaitHolderBase &holder_base : this->multi_wait_list) {
|
||||
for (MultiWaitHolderBase &holder_base : m_multi_wait_list) {
|
||||
TriBool is_signaled = holder_base.LinkToObjectList();
|
||||
|
||||
if (signaled_holder == nullptr && is_signaled == TriBool::True) {
|
||||
|
@ -167,7 +167,7 @@ namespace ams::os::impl {
|
|||
}
|
||||
|
||||
void MultiWaitImpl::UnlinkHoldersFromObjectList() {
|
||||
for (MultiWaitHolderBase &holder_base : this->multi_wait_list) {
|
||||
for (MultiWaitHolderBase &holder_base : m_multi_wait_list) {
|
||||
holder_base.UnlinkFromObjectList();
|
||||
}
|
||||
}
|
||||
|
@ -176,27 +176,27 @@ namespace ams::os::impl {
|
|||
MultiWaitHolderBase *min_timeout_holder = nullptr;
|
||||
TimeSpan min_time = end_time;
|
||||
|
||||
for (MultiWaitHolderBase &holder_base : this->multi_wait_list) {
|
||||
for (MultiWaitHolderBase &holder_base : m_multi_wait_list) {
|
||||
if (const TimeSpan cur_time = holder_base.GetAbsoluteWakeupTime(); cur_time < min_time) {
|
||||
min_timeout_holder = std::addressof(holder_base);
|
||||
min_time = cur_time;
|
||||
}
|
||||
}
|
||||
|
||||
if (min_time < this->current_time) {
|
||||
if (min_time < m_current_time) {
|
||||
*out_min_timeout = 0;
|
||||
} else {
|
||||
*out_min_timeout = min_time - this->current_time;
|
||||
*out_min_timeout = min_time - m_current_time;
|
||||
}
|
||||
return min_timeout_holder;
|
||||
}
|
||||
|
||||
void MultiWaitImpl::SignalAndWakeupThread(MultiWaitHolderBase *holder_base) {
|
||||
std::scoped_lock lk(this->cs_wait);
|
||||
std::scoped_lock lk(m_cs_wait);
|
||||
|
||||
if (this->signaled_holder == nullptr) {
|
||||
this->signaled_holder = holder_base;
|
||||
this->target_impl.CancelWait();
|
||||
if (m_signaled_holder == nullptr) {
|
||||
m_signaled_holder = holder_base;
|
||||
m_target_impl.CancelWait();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,13 +30,13 @@ namespace ams::os::impl {
|
|||
static constexpr s32 WaitInvalid = -3;
|
||||
static constexpr s32 WaitCancelled = -2;
|
||||
static constexpr s32 WaitTimedOut = -1;
|
||||
using MultiWaitList = util::IntrusiveListMemberTraits<&MultiWaitHolderBase::multi_wait_node>::ListType;
|
||||
using MultiWaitList = util::IntrusiveListMemberTraits<&MultiWaitHolderBase::m_multi_wait_node>::ListType;
|
||||
private:
|
||||
MultiWaitList multi_wait_list;
|
||||
MultiWaitHolderBase *signaled_holder;
|
||||
TimeSpan current_time;
|
||||
InternalCriticalSection cs_wait;
|
||||
MultiWaitTargetImpl target_impl;
|
||||
MultiWaitList m_multi_wait_list;
|
||||
MultiWaitHolderBase *m_signaled_holder;
|
||||
TimeSpan m_current_time;
|
||||
InternalCriticalSection m_cs_wait;
|
||||
MultiWaitTargetImpl m_target_impl;
|
||||
private:
|
||||
Result WaitAnyImpl(MultiWaitHolderBase **out, bool infinite, TimeSpan timeout, bool reply, NativeHandle reply_target);
|
||||
Result WaitAnyHandleImpl(MultiWaitHolderBase **out, bool infinite, TimeSpan timeout, bool reply, NativeHandle reply_target);
|
||||
|
@ -76,35 +76,35 @@ namespace ams::os::impl {
|
|||
|
||||
/* List management. */
|
||||
bool IsEmpty() const {
|
||||
return this->multi_wait_list.empty();
|
||||
return m_multi_wait_list.empty();
|
||||
}
|
||||
|
||||
void LinkMultiWaitHolder(MultiWaitHolderBase &holder_base) {
|
||||
this->multi_wait_list.push_back(holder_base);
|
||||
m_multi_wait_list.push_back(holder_base);
|
||||
}
|
||||
|
||||
void UnlinkMultiWaitHolder(MultiWaitHolderBase &holder_base) {
|
||||
this->multi_wait_list.erase(this->multi_wait_list.iterator_to(holder_base));
|
||||
m_multi_wait_list.erase(m_multi_wait_list.iterator_to(holder_base));
|
||||
}
|
||||
|
||||
void UnlinkAll() {
|
||||
while (!this->IsEmpty()) {
|
||||
this->multi_wait_list.front().SetMultiWait(nullptr);
|
||||
this->multi_wait_list.pop_front();
|
||||
m_multi_wait_list.front().SetMultiWait(nullptr);
|
||||
m_multi_wait_list.pop_front();
|
||||
}
|
||||
}
|
||||
|
||||
void MoveAllFrom(MultiWaitImpl &other) {
|
||||
/* Set ourselves as multi wait for all of the other's holders. */
|
||||
for (auto &w : other.multi_wait_list) {
|
||||
for (auto &w : other.m_multi_wait_list) {
|
||||
w.SetMultiWait(this);
|
||||
}
|
||||
this->multi_wait_list.splice(this->multi_wait_list.end(), other.multi_wait_list);
|
||||
m_multi_wait_list.splice(m_multi_wait_list.end(), other.m_multi_wait_list);
|
||||
}
|
||||
|
||||
/* Other. */
|
||||
TimeSpan GetCurrentTime() const {
|
||||
return this->current_time;
|
||||
return m_current_time;
|
||||
}
|
||||
|
||||
void SignalAndWakeupThread(MultiWaitHolderBase *holder_base);
|
||||
|
|
|
@ -21,32 +21,32 @@ namespace ams::os::impl {
|
|||
|
||||
class MultiWaitObjectList {
|
||||
public:
|
||||
using ListType = util::IntrusiveListMemberTraits<&MultiWaitHolderBase::object_list_node>::ListType;
|
||||
using ListType = util::IntrusiveListMemberTraits<&MultiWaitHolderBase::m_object_list_node>::ListType;
|
||||
private:
|
||||
ListType object_list;
|
||||
ListType m_object_list;
|
||||
public:
|
||||
void SignalAllThreads() {
|
||||
for (MultiWaitHolderBase &holder_base : this->object_list) {
|
||||
for (MultiWaitHolderBase &holder_base : m_object_list) {
|
||||
holder_base.GetMultiWait()->SignalAndWakeupThread(std::addressof(holder_base));
|
||||
}
|
||||
}
|
||||
|
||||
void BroadcastAllThreads() {
|
||||
for (MultiWaitHolderBase &holder_base : this->object_list) {
|
||||
for (MultiWaitHolderBase &holder_base : m_object_list) {
|
||||
holder_base.GetMultiWait()->SignalAndWakeupThread(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
bool IsEmpty() const {
|
||||
return this->object_list.empty();
|
||||
return m_object_list.empty();
|
||||
}
|
||||
|
||||
void LinkMultiWaitHolder(MultiWaitHolderBase &holder_base) {
|
||||
this->object_list.push_back(holder_base);
|
||||
m_object_list.push_back(holder_base);
|
||||
}
|
||||
|
||||
void UnlinkMultiWaitHolder(MultiWaitHolderBase &holder_base) {
|
||||
this->object_list.erase(this->object_list.iterator_to(holder_base));
|
||||
m_object_list.erase(m_object_list.iterator_to(holder_base));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace ams::os::impl {
|
|||
}
|
||||
|
||||
void MultiWaitHorizonImpl::CancelWait() {
|
||||
R_ABORT_UNLESS(svc::CancelSynchronization(this->handle));
|
||||
R_ABORT_UNLESS(svc::CancelSynchronization(m_handle));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,11 +23,13 @@ namespace ams::os::impl {
|
|||
public:
|
||||
static constexpr size_t MaximumHandleCount = static_cast<size_t>(ams::svc::ArgumentHandleCountMax);
|
||||
private:
|
||||
NativeHandle handle;
|
||||
NativeHandle m_handle;
|
||||
private:
|
||||
Result WaitSynchronizationN(s32 *out_index, s32 num, NativeHandle arr[], s32 array_size, s64 ns);
|
||||
Result ReplyAndReceiveN(s32 *out_index, s32 num, NativeHandle arr[], s32 array_size, s64 ns, NativeHandle reply_target);
|
||||
public:
|
||||
constexpr MultiWaitHorizonImpl() : m_handle(os::InvalidNativeHandle) { /* ... */ }
|
||||
|
||||
void CancelWait();
|
||||
|
||||
Result WaitAny(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num) {
|
||||
|
@ -55,11 +57,11 @@ namespace ams::os::impl {
|
|||
}
|
||||
|
||||
void SetCurrentThreadHandleForCancelWait() {
|
||||
this->handle = GetCurrentThreadHandle();
|
||||
m_handle = GetCurrentThreadHandle();
|
||||
}
|
||||
|
||||
void ClearCurrentThreadHandleForCancelWait() {
|
||||
this->handle = os::InvalidNativeHandle;
|
||||
m_handle = os::InvalidNativeHandle;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -24,20 +24,20 @@ namespace ams::os::impl {
|
|||
|
||||
class OsResourceManager {
|
||||
private:
|
||||
RngManager rng_manager{};
|
||||
AslrSpaceManager aslr_space_manager{};
|
||||
RngManager m_rng_manager{};
|
||||
AslrSpaceManager m_aslr_space_manager{};
|
||||
/* TODO */
|
||||
ThreadManager thread_manager{};
|
||||
ThreadManager m_thread_manager{};
|
||||
/* TODO */
|
||||
TickManager tick_manager{};
|
||||
TickManager m_tick_manager{};
|
||||
/* TODO */
|
||||
public:
|
||||
OsResourceManager() = default;
|
||||
|
||||
constexpr ALWAYS_INLINE RngManager &GetRngManager() { return this->rng_manager; }
|
||||
constexpr ALWAYS_INLINE AslrSpaceManager &GetAslrSpaceManager() { return this->aslr_space_manager; }
|
||||
constexpr ALWAYS_INLINE ThreadManager &GetThreadManager() { return this->thread_manager; }
|
||||
constexpr ALWAYS_INLINE TickManager &GetTickManager() { return this->tick_manager; }
|
||||
constexpr ALWAYS_INLINE RngManager &GetRngManager() { return m_rng_manager; }
|
||||
constexpr ALWAYS_INLINE AslrSpaceManager &GetAslrSpaceManager() { return m_aslr_space_manager; }
|
||||
constexpr ALWAYS_INLINE ThreadManager &GetThreadManager() { return m_thread_manager; }
|
||||
constexpr ALWAYS_INLINE TickManager &GetTickManager() { return m_tick_manager; }
|
||||
};
|
||||
|
||||
class ResourceManagerHolder {
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
namespace ams::os::impl {
|
||||
|
||||
u64 RngManager::GenerateRandomU64() {
|
||||
std::scoped_lock lk(this->lock);
|
||||
std::scoped_lock lk(m_lock);
|
||||
|
||||
if (AMS_UNLIKELY(!this->initialized)) {
|
||||
if (AMS_UNLIKELY(!m_initialized)) {
|
||||
this->Initialize();
|
||||
}
|
||||
|
||||
return this->mt.GenerateRandomU64();
|
||||
return m_mt.GenerateRandomU64();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,13 +20,13 @@ namespace ams::os::impl {
|
|||
|
||||
class RngManager {
|
||||
private:
|
||||
util::TinyMT mt;
|
||||
os::SdkMutex lock;
|
||||
bool initialized;
|
||||
util::TinyMT m_mt;
|
||||
os::SdkMutex m_lock;
|
||||
bool m_initialized;
|
||||
private:
|
||||
void Initialize();
|
||||
public:
|
||||
constexpr RngManager() : mt(), lock(), initialized() { /* ... */ }
|
||||
constexpr RngManager() : m_mt(), m_lock(), m_initialized() { /* ... */ }
|
||||
public:
|
||||
u64 GenerateRandomU64();
|
||||
};
|
||||
|
|
|
@ -29,10 +29,10 @@ namespace ams::os::impl {
|
|||
R_ABORT_UNLESS(svc::GetInfo(reinterpret_cast<u64 *>(seed + 0), svc::InfoType_RandomEntropy, svc::InvalidHandle, 2));
|
||||
R_ABORT_UNLESS(svc::GetInfo(reinterpret_cast<u64 *>(seed + 2), svc::InfoType_RandomEntropy, svc::InvalidHandle, 3));
|
||||
|
||||
this->mt.Initialize(seed, util::size(seed));
|
||||
m_mt.Initialize(seed, util::size(seed));
|
||||
|
||||
/* Note that we've initialized. */
|
||||
this->initialized = true;
|
||||
m_initialized = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,15 +23,15 @@ namespace ams::os::impl {
|
|||
using LockCount = os::ReaderWriterLockType::LockCount;
|
||||
private:
|
||||
static ALWAYS_INLINE u32 GetThreadHandle(const LockCount &lc) {
|
||||
return GetReference(lc.cs_storage).Get()->thread_handle;
|
||||
return GetReference(lc.cs_storage).Get()->m_thread_handle;
|
||||
}
|
||||
|
||||
static ALWAYS_INLINE uintptr_t GetThreadHandleAddress(LockCount &lc) {
|
||||
return reinterpret_cast<uintptr_t>(std::addressof(GetReference(lc.cs_storage).Get()->thread_handle));
|
||||
return reinterpret_cast<uintptr_t>(std::addressof(GetReference(lc.cs_storage).Get()->m_thread_handle));
|
||||
}
|
||||
|
||||
static ALWAYS_INLINE void SetThreadHandle(LockCount &lc, u32 handle) {
|
||||
GetReference(lc.cs_storage).Get()->thread_handle = handle;
|
||||
GetReference(lc.cs_storage).Get()->m_thread_handle = handle;
|
||||
}
|
||||
|
||||
static void AcquireReadLockWriteLocked(os::ReaderWriterLockType *rw_lock);
|
||||
|
|
|
@ -73,12 +73,12 @@ namespace ams::os::impl {
|
|||
manager.CleanupThread();
|
||||
}
|
||||
|
||||
ThreadManager::ThreadManager() : impl(std::addressof(main_thread)), total_thread_stack_size(0), num_created_threads(0) {
|
||||
this->main_thread.state = ThreadType::State_Started;
|
||||
ThreadManager::ThreadManager() : m_impl(std::addressof(m_main_thread)), m_total_thread_stack_size(0), m_num_created_threads(0) {
|
||||
m_main_thread.state = ThreadType::State_Started;
|
||||
|
||||
this->SetCurrentThread(std::addressof(this->main_thread));
|
||||
this->SetCurrentThread(std::addressof(m_main_thread));
|
||||
|
||||
this->PlaceThreadObjectUnderThreadManagerSafe(std::addressof(this->main_thread));
|
||||
this->PlaceThreadObjectUnderThreadManagerSafe(std::addressof(m_main_thread));
|
||||
}
|
||||
|
||||
void ThreadManager::CleanupThread() {
|
||||
|
@ -98,7 +98,7 @@ namespace ams::os::impl {
|
|||
SetupThreadObjectUnsafe(thread, nullptr, function, argument, stack, stack_size, priority);
|
||||
|
||||
auto guard = SCOPE_GUARD { thread->state = ThreadType::State_NotInitialized; };
|
||||
R_TRY(this->impl.CreateThread(thread, ideal_core));
|
||||
R_TRY(m_impl.CreateThread(thread, ideal_core));
|
||||
guard.Cancel();
|
||||
|
||||
this->PlaceThreadObjectUnderThreadManagerSafe(thread);
|
||||
|
@ -107,7 +107,7 @@ namespace ams::os::impl {
|
|||
}
|
||||
|
||||
Result ThreadManager::CreateThread(ThreadType *thread, ThreadFunction function, void *argument, void *stack, size_t stack_size, s32 priority) {
|
||||
return this->CreateThread(thread, function, argument, stack, stack_size, priority, this->impl.GetDefaultCoreNumber());
|
||||
return this->CreateThread(thread, function, argument, stack, stack_size, priority, m_impl.GetDefaultCoreNumber());
|
||||
}
|
||||
|
||||
void ThreadManager::DestroyThread(ThreadType *thread) {
|
||||
|
@ -116,12 +116,12 @@ namespace ams::os::impl {
|
|||
|
||||
if (thread->state == ThreadType::State_Initialized) {
|
||||
thread->state = ThreadType::State_DestroyedBeforeStarted;
|
||||
this->impl.StartThread(thread);
|
||||
m_impl.StartThread(thread);
|
||||
GetReference(thread->cv_thread).Signal();
|
||||
}
|
||||
}
|
||||
|
||||
this->impl.WaitForThreadExit(thread);
|
||||
m_impl.WaitForThreadExit(thread);
|
||||
|
||||
AMS_ASSERT(thread->state == ThreadType::State_Initialized);
|
||||
|
||||
|
@ -130,7 +130,7 @@ namespace ams::os::impl {
|
|||
|
||||
/* NOTE: Here Nintendo would cleanup the alias stack. */
|
||||
|
||||
this->impl.DestroyThreadUnsafe(thread);
|
||||
m_impl.DestroyThreadUnsafe(thread);
|
||||
|
||||
thread->state = ThreadType::State_NotInitialized;
|
||||
|
||||
|
@ -140,7 +140,7 @@ namespace ams::os::impl {
|
|||
thread->magic = 0xCCCC;
|
||||
|
||||
{
|
||||
std::scoped_lock tlk(this->cs);
|
||||
std::scoped_lock tlk(m_cs);
|
||||
this->EraseFromAllThreadsListUnsafe(thread);
|
||||
}
|
||||
}
|
||||
|
@ -151,14 +151,14 @@ namespace ams::os::impl {
|
|||
|
||||
AMS_ASSERT(thread->state == ThreadType::State_Initialized);
|
||||
|
||||
this->impl.StartThread(thread);
|
||||
m_impl.StartThread(thread);
|
||||
thread->state = ThreadType::State_Started;
|
||||
|
||||
GetReference(thread->cv_thread).Signal();
|
||||
}
|
||||
|
||||
void ThreadManager::WaitThread(ThreadType *thread) {
|
||||
this->impl.WaitForThreadExit(thread);
|
||||
m_impl.WaitForThreadExit(thread);
|
||||
|
||||
{
|
||||
std::scoped_lock lk(GetReference(thread->cs_thread));
|
||||
|
@ -168,7 +168,7 @@ namespace ams::os::impl {
|
|||
}
|
||||
|
||||
bool ThreadManager::TryWaitThread(ThreadType *thread) {
|
||||
const bool result = this->impl.TryWaitForThreadExit(thread);
|
||||
const bool result = m_impl.TryWaitForThreadExit(thread);
|
||||
|
||||
if (result) {
|
||||
std::scoped_lock lk(GetReference(thread->cs_thread));
|
||||
|
@ -187,7 +187,7 @@ namespace ams::os::impl {
|
|||
thread->suspend_count = prev_suspend_count + 1;
|
||||
|
||||
if (prev_suspend_count == 0) {
|
||||
this->impl.SuspendThreadUnsafe(thread);
|
||||
m_impl.SuspendThreadUnsafe(thread);
|
||||
}
|
||||
return prev_suspend_count;
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ namespace ams::os::impl {
|
|||
if (prev_suspend_count > 0) {
|
||||
thread->suspend_count = prev_suspend_count - 1;
|
||||
if (prev_suspend_count == 1) {
|
||||
this->impl.ResumeThreadUnsafe(thread);
|
||||
m_impl.ResumeThreadUnsafe(thread);
|
||||
}
|
||||
}
|
||||
return prev_suspend_count;
|
||||
|
@ -208,7 +208,7 @@ namespace ams::os::impl {
|
|||
void ThreadManager::CancelThreadSynchronization(ThreadType *thread) {
|
||||
std::scoped_lock lk(GetReference(thread->cs_thread));
|
||||
|
||||
this->impl.CancelThreadSynchronizationUnsafe(thread);
|
||||
m_impl.CancelThreadSynchronizationUnsafe(thread);
|
||||
}
|
||||
|
||||
/* TODO void ThreadManager::GetThreadContext(ThreadContextInfo *out_context, const ThreadType *thread); */
|
||||
|
@ -221,7 +221,7 @@ namespace ams::os::impl {
|
|||
}
|
||||
|
||||
void ThreadManager::SetInitialThreadNameUnsafe(ThreadType *thread) {
|
||||
if (thread == std::addressof(this->main_thread)) {
|
||||
if (thread == std::addressof(m_main_thread)) {
|
||||
static_assert(sizeof(thread->name_buffer) >= sizeof(MainThreadName));
|
||||
static_assert(MainThreadName[sizeof(MainThreadName) - 1] == '\x00');
|
||||
std::memcpy(thread->name_buffer, MainThreadName, sizeof(MainThreadName));
|
||||
|
|
|
@ -53,17 +53,17 @@ namespace ams::os::impl {
|
|||
|
||||
using AllThreadsList = ThreadListTraits::ListType;
|
||||
private:
|
||||
ThreadManagerImpl impl;
|
||||
ThreadType main_thread;
|
||||
InternalCriticalSection cs;
|
||||
AllThreadsList all_threads_list;
|
||||
size_t total_thread_stack_size;
|
||||
s32 num_created_threads;
|
||||
ThreadManagerImpl m_impl;
|
||||
ThreadType m_main_thread;
|
||||
InternalCriticalSection m_cs;
|
||||
AllThreadsList m_all_threads_list;
|
||||
size_t m_total_thread_stack_size;
|
||||
s32 m_num_created_threads;
|
||||
public:
|
||||
ThreadManager();
|
||||
|
||||
void CleanupThread();
|
||||
s32 GetThreadCountForDebug() const { return this->num_created_threads; }
|
||||
s32 GetThreadCountForDebug() const { return m_num_created_threads; }
|
||||
|
||||
Result CreateThread(ThreadType *thread, ThreadFunction function, void *argument, void *stack, size_t stack_size, s32 priority, s32 ideal_core);
|
||||
Result CreateThread(ThreadType *thread, ThreadFunction function, void *argument, void *stack, size_t stack_size, s32 priority);
|
||||
|
@ -73,11 +73,11 @@ namespace ams::os::impl {
|
|||
void WaitThread(ThreadType *thread);
|
||||
bool TryWaitThread(ThreadType *thread);
|
||||
|
||||
void YieldThread() { return this->impl.YieldThread(); }
|
||||
void YieldThread() { return m_impl.YieldThread(); }
|
||||
|
||||
bool ChangePriority(ThreadType *thread, s32 priority) { return this->impl.ChangePriority(thread, priority); }
|
||||
s32 GetCurrentPriority(const ThreadType *thread) const { return this->impl.GetCurrentPriority(thread); }
|
||||
ThreadType *GetCurrentThread() const { return this->impl.GetCurrentThread(); }
|
||||
bool ChangePriority(ThreadType *thread, s32 priority) { return m_impl.ChangePriority(thread, priority); }
|
||||
s32 GetCurrentPriority(const ThreadType *thread) const { return m_impl.GetCurrentPriority(thread); }
|
||||
ThreadType *GetCurrentThread() const { return m_impl.GetCurrentThread(); }
|
||||
|
||||
s32 SuspendThread(ThreadType *thread);
|
||||
s32 ResumeThread(ThreadType *thread);
|
||||
|
@ -88,39 +88,39 @@ namespace ams::os::impl {
|
|||
|
||||
void SetInitialThreadNameUnsafe(ThreadType *thread);
|
||||
|
||||
void NotifyThreadNameChanged(const ThreadType *thread) const { return this->impl.NotifyThreadNameChangedImpl(thread); }
|
||||
void SetCurrentThread(ThreadType *thread) const { return this->impl.SetCurrentThread(thread); }
|
||||
s32 GetCurrentCoreNumber() const { return this->impl.GetCurrentCoreNumber(); }
|
||||
void SetThreadCoreMask(ThreadType *thread, s32 ideal_core, u64 affinity_mask) const { return this->impl.SetThreadCoreMask(thread, ideal_core, affinity_mask); }
|
||||
void GetThreadCoreMask(s32 *out_ideal_core, u64 *out_affinity_mask, const ThreadType *thread) const { return this->impl.GetThreadCoreMask(out_ideal_core, out_affinity_mask, thread); }
|
||||
u64 GetThreadAvailableCoreMask() const { return this->impl.GetThreadAvailableCoreMask(); }
|
||||
void NotifyThreadNameChanged(const ThreadType *thread) const { return m_impl.NotifyThreadNameChangedImpl(thread); }
|
||||
void SetCurrentThread(ThreadType *thread) const { return m_impl.SetCurrentThread(thread); }
|
||||
s32 GetCurrentCoreNumber() const { return m_impl.GetCurrentCoreNumber(); }
|
||||
void SetThreadCoreMask(ThreadType *thread, s32 ideal_core, u64 affinity_mask) const { return m_impl.SetThreadCoreMask(thread, ideal_core, affinity_mask); }
|
||||
void GetThreadCoreMask(s32 *out_ideal_core, u64 *out_affinity_mask, const ThreadType *thread) const { return m_impl.GetThreadCoreMask(out_ideal_core, out_affinity_mask, thread); }
|
||||
u64 GetThreadAvailableCoreMask() const { return m_impl.GetThreadAvailableCoreMask(); }
|
||||
|
||||
void PushBackToAllThreadsListUnsafe(ThreadType *thread) {
|
||||
this->all_threads_list.push_back(*thread);
|
||||
++this->num_created_threads;
|
||||
this->total_thread_stack_size += thread->stack_size;
|
||||
m_all_threads_list.push_back(*thread);
|
||||
++m_num_created_threads;
|
||||
m_total_thread_stack_size += thread->stack_size;
|
||||
}
|
||||
|
||||
void EraseFromAllThreadsListUnsafe(ThreadType *thread) {
|
||||
this->all_threads_list.erase(this->all_threads_list.iterator_to(*thread));
|
||||
--this->num_created_threads;
|
||||
this->total_thread_stack_size -= thread->stack_size;
|
||||
m_all_threads_list.erase(m_all_threads_list.iterator_to(*thread));
|
||||
--m_num_created_threads;
|
||||
m_total_thread_stack_size -= thread->stack_size;
|
||||
}
|
||||
|
||||
void PushBackToAllThreadsListSafe(ThreadType *thread) {
|
||||
std::scoped_lock lk(this->cs);
|
||||
std::scoped_lock lk(m_cs);
|
||||
this->PushBackToAllThreadsListUnsafe(thread);
|
||||
}
|
||||
|
||||
void EraseFromAllThreadsListSafe(ThreadType *thread) {
|
||||
std::scoped_lock lk(this->cs);
|
||||
std::scoped_lock lk(m_cs);
|
||||
this->EraseFromAllThreadsListUnsafe(thread);
|
||||
}
|
||||
|
||||
void PlaceThreadObjectUnderThreadManagerSafe(ThreadType *thread) {
|
||||
SetInitialThreadNameUnsafe(thread);
|
||||
{
|
||||
std::scoped_lock lk(this->cs);
|
||||
std::scoped_lock lk(m_cs);
|
||||
this->PushBackToAllThreadsListUnsafe(thread);
|
||||
}
|
||||
}
|
||||
|
@ -134,15 +134,15 @@ namespace ams::os::impl {
|
|||
}
|
||||
|
||||
const ThreadType *GetMainThread() const {
|
||||
return std::addressof(this->main_thread);
|
||||
return std::addressof(m_main_thread);
|
||||
}
|
||||
|
||||
size_t GetTotalThreadStackSize() const {
|
||||
return this->total_thread_stack_size;
|
||||
return m_total_thread_stack_size;
|
||||
}
|
||||
|
||||
ThreadId GetThreadId(const ThreadType *thread) {
|
||||
return this->impl.GetThreadId(thread);
|
||||
return m_impl.GetThreadId(thread);
|
||||
}
|
||||
public:
|
||||
static void InvokeThread(ThreadType *thread);
|
||||
|
|
|
@ -29,28 +29,28 @@ namespace ams::os::impl {
|
|||
|
||||
class TickManager {
|
||||
private:
|
||||
TickManagerImpl impl;
|
||||
TickManagerImpl m_impl;
|
||||
public:
|
||||
constexpr TickManager() : impl() { /* ... */ }
|
||||
constexpr TickManager() : m_impl() { /* ... */ }
|
||||
|
||||
ALWAYS_INLINE Tick GetTick() const {
|
||||
return this->impl.GetTick();
|
||||
return m_impl.GetTick();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE Tick GetSystemTickOrdered() const {
|
||||
return this->impl.GetSystemTickOrdered();
|
||||
return m_impl.GetSystemTickOrdered();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE s64 GetTickFrequency() const {
|
||||
return this->impl.GetTickFrequency();
|
||||
return m_impl.GetTickFrequency();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE s64 GetMaxTick() const {
|
||||
return this->impl.GetMaxTick();
|
||||
return m_impl.GetMaxTick();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE s64 GetMaxTimeSpanNs() const {
|
||||
return this->impl.GetMaxTimeSpanNs();
|
||||
return m_impl.GetMaxTimeSpanNs();
|
||||
}
|
||||
|
||||
TimeSpan ConvertToTimeSpan(Tick tick) const;
|
||||
|
|
|
@ -20,18 +20,18 @@ namespace ams::os::impl {
|
|||
|
||||
TargetTimeSpan TimeoutHelper::GetTimeLeftOnTarget() const {
|
||||
/* If the absolute tick is zero, we're expired. */
|
||||
if (this->absolute_end_tick.GetInt64Value() == 0) {
|
||||
if (m_absolute_end_tick.GetInt64Value() == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Check if we've expired. */
|
||||
const Tick cur_tick = impl::GetTickManager().GetTick();
|
||||
if (cur_tick >= this->absolute_end_tick) {
|
||||
if (cur_tick >= m_absolute_end_tick) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Return the converted difference as a timespan. */
|
||||
return TimeoutHelperImpl::ConvertToImplTime(this->absolute_end_tick - cur_tick);
|
||||
return TimeoutHelperImpl::ConvertToImplTime(m_absolute_end_tick - cur_tick);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,12 +27,12 @@ namespace ams::os::impl {
|
|||
|
||||
class TimeoutHelper {
|
||||
private:
|
||||
Tick absolute_end_tick;
|
||||
Tick m_absolute_end_tick;
|
||||
public:
|
||||
explicit TimeoutHelper(TimeSpan timeout) {
|
||||
if (timeout == 0) {
|
||||
/* If timeout is zero, don't do relative tick calculations. */
|
||||
this->absolute_end_tick = Tick(0);
|
||||
m_absolute_end_tick = Tick(0);
|
||||
} else {
|
||||
const auto &tick_manager = impl::GetTickManager();
|
||||
|
||||
|
@ -40,7 +40,7 @@ namespace ams::os::impl {
|
|||
const u64 timeout_tick = tick_manager.ConvertToTick(timeout).GetInt64Value();
|
||||
const u64 end_tick = cur_tick + timeout_tick + 1;
|
||||
|
||||
this->absolute_end_tick = Tick(std::min<u64>(std::numeric_limits<s64>::max(), end_tick));
|
||||
m_absolute_end_tick = Tick(std::min<u64>(std::numeric_limits<s64>::max(), end_tick));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,13 +49,13 @@ namespace ams::os::impl {
|
|||
}
|
||||
|
||||
bool TimedOut() const {
|
||||
if (this->absolute_end_tick.GetInt64Value() == 0) {
|
||||
if (m_absolute_end_tick.GetInt64Value() == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const Tick cur_tick = impl::GetTickManager().GetTick();
|
||||
|
||||
return cur_tick >= this->absolute_end_tick;
|
||||
return cur_tick >= m_absolute_end_tick;
|
||||
}
|
||||
|
||||
TargetTimeSpan GetTimeLeftOnTarget() const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue