mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-19 09:25:08 -04:00
kern: SvcGetResourceLimitPeakValue
This commit is contained in:
parent
cc11d452e5
commit
f469dfbeb3
5 changed files with 48 additions and 2 deletions
|
@ -32,6 +32,7 @@ namespace ams::kern {
|
|||
this->limit_values[i] = 0;
|
||||
this->current_values[i] = 0;
|
||||
this->current_hints[i] = 0;
|
||||
this->peak_values[i] = 0;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
@ -70,6 +71,21 @@ namespace ams::kern {
|
|||
return value;
|
||||
}
|
||||
|
||||
s64 KResourceLimit::GetPeakValue(ams::svc::LimitableResource which) const {
|
||||
MESOSPHERE_ASSERT_THIS();
|
||||
|
||||
s64 value;
|
||||
{
|
||||
KScopedLightLock lk(this->lock);
|
||||
value = this->peak_values[which];
|
||||
MESOSPHERE_ASSERT(value >= 0);
|
||||
MESOSPHERE_ASSERT(this->current_values[which] <= this->limit_values[which]);
|
||||
MESOSPHERE_ASSERT(this->current_hints[which] <= this->current_values[which]);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
s64 KResourceLimit::GetFreeValue(ams::svc::LimitableResource which) const {
|
||||
MESOSPHERE_ASSERT_THIS();
|
||||
|
||||
|
@ -124,6 +140,7 @@ namespace ams::kern {
|
|||
if (this->current_values[which] + value <= this->limit_values[which]) {
|
||||
this->current_values[which] += value;
|
||||
this->current_hints[which] += value;
|
||||
this->peak_values[which] = std::max(this->peak_values[which], this->current_values[which]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue