ams: revamp assertion system
This commit is contained in:
@@ -31,7 +31,7 @@ namespace ams::os::impl {
|
||||
}
|
||||
|
||||
InterProcessEvent::InterProcessEvent(bool autoclear) : is_initialized(false) {
|
||||
R_ASSERT(this->Initialize(autoclear));
|
||||
R_ABORT_UNLESS(this->Initialize(autoclear));
|
||||
}
|
||||
|
||||
InterProcessEvent::~InterProcessEvent() {
|
||||
@@ -39,7 +39,7 @@ namespace ams::os::impl {
|
||||
}
|
||||
|
||||
Result InterProcessEvent::Initialize(bool autoclear) {
|
||||
AMS_ASSERT(!this->is_initialized);
|
||||
AMS_ABORT_UNLESS(!this->is_initialized);
|
||||
Handle rh, wh;
|
||||
R_TRY(CreateEventHandles(&rh, &wh));
|
||||
this->Initialize(rh, true, wh, true, autoclear);
|
||||
@@ -47,8 +47,8 @@ namespace ams::os::impl {
|
||||
}
|
||||
|
||||
void InterProcessEvent::Initialize(Handle read_handle, bool manage_read_handle, Handle write_handle, bool manage_write_handle, bool autoclear) {
|
||||
AMS_ASSERT(!this->is_initialized);
|
||||
AMS_ASSERT(read_handle != INVALID_HANDLE || write_handle != INVALID_HANDLE);
|
||||
AMS_ABORT_UNLESS(!this->is_initialized);
|
||||
AMS_ABORT_UNLESS(read_handle != INVALID_HANDLE || write_handle != INVALID_HANDLE);
|
||||
this->read_handle = read_handle;
|
||||
this->manage_read_handle = manage_read_handle;
|
||||
this->write_handle = write_handle;
|
||||
@@ -58,40 +58,40 @@ namespace ams::os::impl {
|
||||
}
|
||||
|
||||
Handle InterProcessEvent::DetachReadableHandle() {
|
||||
AMS_ASSERT(this->is_initialized);
|
||||
AMS_ABORT_UNLESS(this->is_initialized);
|
||||
const Handle handle = this->read_handle;
|
||||
AMS_ASSERT(handle != INVALID_HANDLE);
|
||||
AMS_ABORT_UNLESS(handle != INVALID_HANDLE);
|
||||
this->read_handle = INVALID_HANDLE;
|
||||
this->manage_read_handle = false;
|
||||
return handle;
|
||||
}
|
||||
|
||||
Handle InterProcessEvent::DetachWritableHandle() {
|
||||
AMS_ASSERT(this->is_initialized);
|
||||
AMS_ABORT_UNLESS(this->is_initialized);
|
||||
const Handle handle = this->write_handle;
|
||||
AMS_ASSERT(handle != INVALID_HANDLE);
|
||||
AMS_ABORT_UNLESS(handle != INVALID_HANDLE);
|
||||
this->write_handle = INVALID_HANDLE;
|
||||
this->manage_write_handle = false;
|
||||
return handle;
|
||||
}
|
||||
|
||||
Handle InterProcessEvent::GetReadableHandle() const {
|
||||
AMS_ASSERT(this->is_initialized);
|
||||
AMS_ABORT_UNLESS(this->is_initialized);
|
||||
return this->read_handle;
|
||||
}
|
||||
|
||||
Handle InterProcessEvent::GetWritableHandle() const {
|
||||
AMS_ASSERT(this->is_initialized);
|
||||
AMS_ABORT_UNLESS(this->is_initialized);
|
||||
return this->write_handle;
|
||||
}
|
||||
|
||||
void InterProcessEvent::Finalize() {
|
||||
if (this->is_initialized) {
|
||||
if (this->manage_read_handle && this->read_handle != INVALID_HANDLE) {
|
||||
R_ASSERT(svcCloseHandle(this->read_handle));
|
||||
R_ABORT_UNLESS(svcCloseHandle(this->read_handle));
|
||||
}
|
||||
if (this->manage_write_handle && this->write_handle != INVALID_HANDLE) {
|
||||
R_ASSERT(svcCloseHandle(this->write_handle));
|
||||
R_ABORT_UNLESS(svcCloseHandle(this->write_handle));
|
||||
}
|
||||
}
|
||||
this->read_handle = INVALID_HANDLE;
|
||||
@@ -102,7 +102,7 @@ namespace ams::os::impl {
|
||||
}
|
||||
|
||||
void InterProcessEvent::Signal() {
|
||||
R_ASSERT(svcSignalEvent(this->GetWritableHandle()));
|
||||
R_ABORT_UNLESS(svcSignalEvent(this->GetWritableHandle()));
|
||||
}
|
||||
|
||||
void InterProcessEvent::Reset() {
|
||||
@@ -110,7 +110,7 @@ namespace ams::os::impl {
|
||||
if (handle == INVALID_HANDLE) {
|
||||
handle = this->GetWritableHandle();
|
||||
}
|
||||
R_ASSERT(svcClearEvent(handle));
|
||||
R_ABORT_UNLESS(svcClearEvent(handle));
|
||||
}
|
||||
|
||||
void InterProcessEvent::Wait() {
|
||||
|
||||
@@ -25,8 +25,8 @@ namespace ams::os::impl {
|
||||
/* Nintendo does not check the result of these invocations, but we will for safety. */
|
||||
/* Nintendo uses entropy values 0, 1 to seed the public TinyMT random, and values */
|
||||
/* 2, 3 to seed os::detail::RngManager's private TinyMT random. */
|
||||
R_ASSERT(svcGetInfo(reinterpret_cast<u64 *>(&seed[0]), InfoType_RandomEntropy, INVALID_HANDLE, 0));
|
||||
R_ASSERT(svcGetInfo(reinterpret_cast<u64 *>(&seed[2]), InfoType_RandomEntropy, INVALID_HANDLE, 1));
|
||||
R_ABORT_UNLESS(svcGetInfo(reinterpret_cast<u64 *>(&seed[0]), InfoType_RandomEntropy, INVALID_HANDLE, 0));
|
||||
R_ABORT_UNLESS(svcGetInfo(reinterpret_cast<u64 *>(&seed[2]), InfoType_RandomEntropy, INVALID_HANDLE, 1));
|
||||
|
||||
mt->Initialize(seed, util::size(seed));
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace ams::os::impl {
|
||||
}
|
||||
|
||||
virtual Handle GetHandle() const override {
|
||||
AMS_ASSERT(this->event->is_initialized);
|
||||
AMS_ABORT_UNLESS(this->event->is_initialized);
|
||||
return this->event->GetReadableHandle();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace ams::os::impl {
|
||||
}
|
||||
|
||||
virtual Handle GetHandle() const override {
|
||||
AMS_ASSERT(this->event->is_initialized);
|
||||
AMS_ABORT_UNLESS(this->event->is_initialized);
|
||||
return this->event->handle.Get();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace ams::os::impl{
|
||||
index = WaitTimedOut;
|
||||
} else {
|
||||
index = this->WaitSynchronization(object_handles, count, min_timeout);
|
||||
AMS_ASSERT(index != WaitInvalid);
|
||||
AMS_ABORT_UNLESS(index != WaitInvalid);
|
||||
}
|
||||
|
||||
switch (index) {
|
||||
@@ -115,7 +115,7 @@ namespace ams::os::impl{
|
||||
|
||||
for (WaitableHolderBase &holder_base : this->waitable_list) {
|
||||
if (Handle handle = holder_base.GetHandle(); handle != INVALID_HANDLE) {
|
||||
AMS_ASSERT(count < MaximumHandleCount);
|
||||
AMS_ABORT_UNLESS(count < MaximumHandleCount);
|
||||
|
||||
out_handles[count] = handle;
|
||||
out_objects[count] = &holder_base;
|
||||
@@ -170,7 +170,7 @@ namespace ams::os::impl{
|
||||
|
||||
if (this->signaled_holder == nullptr) {
|
||||
this->signaled_holder = holder_base;
|
||||
R_ASSERT(svcCancelSynchronization(this->waiting_thread_handle));
|
||||
R_ABORT_UNLESS(svcCancelSynchronization(this->waiting_thread_handle));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user