os: implement waitable management.

This implements waitable management for Events (and
implements Events). It also refactors PM to use new
Event/Waitable semantics, and also adds STS_ASSERT
as a macro for asserting a boolean expression. The
rest of stratosphere has been refactored to use
STS_ASSERT whenever possible.
This commit is contained in:
Michael Scire 2019-09-27 18:04:58 -07:00 committed by SciresM
parent e07011be32
commit 609a302e16
108 changed files with 2752 additions and 1223 deletions

View file

@ -218,9 +218,7 @@ namespace sts::pm::resource {
g_resource_limits[ResourceLimitGroup_Applet][LimitableResource_Threads];
/* Ensure we don't over-commit threads. */
if (total_threads_available < total_threads_allocated) {
std::abort();
}
STS_ASSERT(total_threads_allocated <= total_threads_available);
/* Set number of extra threads. */
g_extra_application_threads_available = total_threads_available - total_threads_allocated;
@ -244,9 +242,7 @@ namespace sts::pm::resource {
const u64 reserved_non_system_size = (application_size + applet_size + ReservedMemorySize600);
/* Ensure there's enough memory for the system region. */
if (reserved_non_system_size >= total_memory) {
std::abort();
}
STS_ASSERT(reserved_non_system_size < total_memory);
g_memory_resource_limits[spl::MemoryArrangement_Dynamic][ResourceLimitGroup_System] = total_memory - reserved_non_system_size;
} else {
@ -344,9 +340,8 @@ namespace sts::pm::resource {
Result GetResourceLimitValues(u64 *out_cur, u64 *out_lim, ResourceLimitGroup group, LimitableResource resource) {
/* Do not allow out of bounds access. */
if (group >= ResourceLimitGroup_Count || resource >= LimitableResource_Count) {
std::abort();
}
STS_ASSERT(group < ResourceLimitGroup_Count);
STS_ASSERT(resource < LimitableResource_Count);
const Handle reslimit_hnd = GetResourceLimitHandle(group);
R_TRY(svcGetResourceLimitCurrentValue(out_cur, reslimit_hnd, resource));