mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-27 21:24:11 -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,20 @@ namespace ams::kern::svc {
|
|||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result GetResourceLimitPeakValue(int64_t *out_peak_value, ams::svc::Handle resource_limit_handle, ams::svc::LimitableResource which) {
|
||||
/* Validate the resource. */
|
||||
R_UNLESS(IsValidLimitableResource(which), svc::ResultInvalidEnumValue());
|
||||
|
||||
/* Get the resource limit. */
|
||||
KScopedAutoObject resource_limit = GetCurrentProcess().GetHandleTable().GetObject<KResourceLimit>(resource_limit_handle);
|
||||
R_UNLESS(resource_limit.IsNotNull(), svc::ResultInvalidHandle());
|
||||
|
||||
/* Get the peak value. */
|
||||
*out_peak_value = resource_limit->GetCurrentValue(which);
|
||||
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result CreateResourceLimit(ams::svc::Handle *out_handle) {
|
||||
/* Create a new resource limit. */
|
||||
KResourceLimit *resource_limit = KResourceLimit::Create();
|
||||
|
@ -99,6 +113,10 @@ namespace ams::kern::svc {
|
|||
return GetResourceLimitCurrentValue(out_current_value, resource_limit_handle, which);
|
||||
}
|
||||
|
||||
Result GetResourceLimitPeakValue64(int64_t *out_peak_value, ams::svc::Handle resource_limit_handle, ams::svc::LimitableResource which) {
|
||||
return GetResourceLimitPeakValue(out_peak_value, resource_limit_handle, which);
|
||||
}
|
||||
|
||||
Result CreateResourceLimit64(ams::svc::Handle *out_handle) {
|
||||
return CreateResourceLimit(out_handle);
|
||||
}
|
||||
|
@ -117,6 +135,10 @@ namespace ams::kern::svc {
|
|||
return GetResourceLimitCurrentValue(out_current_value, resource_limit_handle, which);
|
||||
}
|
||||
|
||||
Result GetResourceLimitPeakValue64From32(int64_t *out_peak_value, ams::svc::Handle resource_limit_handle, ams::svc::LimitableResource which) {
|
||||
return GetResourceLimitPeakValue(out_peak_value, resource_limit_handle, which);
|
||||
}
|
||||
|
||||
Result CreateResourceLimit64From32(ams::svc::Handle *out_handle) {
|
||||
return CreateResourceLimit(out_handle);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue