VMUserAddressSpace: Use std::min/max instead of min/max_c
This commit is contained in:
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <KernelExport.h>
|
#include <KernelExport.h>
|
||||||
|
|
||||||
#include <heap.h>
|
#include <heap.h>
|
||||||
@@ -175,7 +177,7 @@ VMUserAddressSpace::InsertArea(VMArea* _area, size_t size,
|
|||||||
// TODO: remove this again when vm86 mode is moved into the kernel
|
// TODO: remove this again when vm86 mode is moved into the kernel
|
||||||
// completely (currently needs a userland address space!)
|
// completely (currently needs a userland address space!)
|
||||||
if (addressRestrictions->address_specification != B_EXACT_ADDRESS)
|
if (addressRestrictions->address_specification != B_EXACT_ADDRESS)
|
||||||
searchBase = max_c(searchBase, USER_BASE_ANY);
|
searchBase = std::max(searchBase, (addr_t)USER_BASE_ANY);
|
||||||
|
|
||||||
status = _InsertAreaSlot(searchBase, size, searchEnd,
|
status = _InsertAreaSlot(searchBase, size, searchEnd,
|
||||||
addressRestrictions->address_specification,
|
addressRestrictions->address_specification,
|
||||||
@@ -404,9 +406,9 @@ VMUserAddressSpace::_RandomizeAddress(addr_t start, addr_t end,
|
|||||||
|
|
||||||
addr_t range = end - start + 1;
|
addr_t range = end - start + 1;
|
||||||
if (initial)
|
if (initial)
|
||||||
range = min_c(range, kMaxInitialRandomize);
|
range = std::min(range, kMaxInitialRandomize);
|
||||||
else
|
else
|
||||||
range = min_c(range, kMaxRandomize);
|
range = std::min(range, kMaxRandomize);
|
||||||
|
|
||||||
addr_t random = secure_get_random<addr_t>();
|
addr_t random = secure_get_random<addr_t>();
|
||||||
random %= range;
|
random %= range;
|
||||||
@@ -569,10 +571,11 @@ second_chance:
|
|||||||
if (last == NULL) {
|
if (last == NULL) {
|
||||||
// see if we can build it at the beginning of the virtual map
|
// see if we can build it at the beginning of the virtual map
|
||||||
addr_t alignedBase = ROUNDUP(start, alignment);
|
addr_t alignedBase = ROUNDUP(start, alignment);
|
||||||
addr_t nextBase = next == NULL ? end : min_c(next->Base() - 1, end);
|
addr_t nextBase = next == NULL
|
||||||
|
? end : std::min(next->Base() - 1, end);
|
||||||
if (is_valid_spot(start, alignedBase, size, nextBase)) {
|
if (is_valid_spot(start, alignedBase, size, nextBase)) {
|
||||||
|
|
||||||
addr_t rangeEnd = min_c(nextBase - size + 1, end);
|
addr_t rangeEnd = std::min(nextBase - size + 1, end);
|
||||||
if (is_randomized(addressSpec)) {
|
if (is_randomized(addressSpec)) {
|
||||||
alignedBase = _RandomizeAddress(alignedBase, rangeEnd,
|
alignedBase = _RandomizeAddress(alignedBase, rangeEnd,
|
||||||
alignment);
|
alignment);
|
||||||
@@ -591,11 +594,11 @@ second_chance:
|
|||||||
while (next != NULL && next->Base() + next->Size() - 1 <= end) {
|
while (next != NULL && next->Base() + next->Size() - 1 <= end) {
|
||||||
addr_t alignedBase = ROUNDUP(last->Base() + last->Size(),
|
addr_t alignedBase = ROUNDUP(last->Base() + last->Size(),
|
||||||
alignment);
|
alignment);
|
||||||
addr_t nextBase = min_c(end, next->Base() - 1);
|
addr_t nextBase = std::min(end, next->Base() - 1);
|
||||||
if (is_valid_spot(last->Base() + (last->Size() - 1),
|
if (is_valid_spot(last->Base() + (last->Size() - 1),
|
||||||
alignedBase, size, nextBase)) {
|
alignedBase, size, nextBase)) {
|
||||||
|
|
||||||
addr_t rangeEnd = min_c(nextBase - size + 1, end);
|
addr_t rangeEnd = std::min(nextBase - size + 1, end);
|
||||||
if (is_randomized(addressSpec)) {
|
if (is_randomized(addressSpec)) {
|
||||||
alignedBase = _RandomizeAddress(alignedBase,
|
alignedBase = _RandomizeAddress(alignedBase,
|
||||||
rangeEnd, alignment);
|
rangeEnd, alignment);
|
||||||
@@ -677,7 +680,7 @@ second_chance:
|
|||||||
&& alignedBase == next->Base()
|
&& alignedBase == next->Base()
|
||||||
&& next->Size() >= size) {
|
&& next->Size() >= size) {
|
||||||
|
|
||||||
addr_t rangeEnd = min_c(
|
addr_t rangeEnd = std::min(
|
||||||
next->Base() + next->Size() - size, end);
|
next->Base() + next->Size() - size, end);
|
||||||
if (is_randomized(addressSpec)) {
|
if (is_randomized(addressSpec)) {
|
||||||
alignedBase = _RandomizeAddress(next->Base(),
|
alignedBase = _RandomizeAddress(next->Base(),
|
||||||
@@ -696,7 +699,7 @@ second_chance:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (is_valid_spot(next->Base(), alignedBase, size,
|
if (is_valid_spot(next->Base(), alignedBase, size,
|
||||||
min_c(next->Base() + next->Size() - 1, end))) {
|
std::min(next->Base() + next->Size() - 1, end))) {
|
||||||
// The new area will be placed at the end of the
|
// The new area will be placed at the end of the
|
||||||
// reserved area, and the reserved area will be resized
|
// reserved area, and the reserved area will be resized
|
||||||
// to make space
|
// to make space
|
||||||
@@ -709,10 +712,10 @@ second_chance:
|
|||||||
startRange -= size + kMaxRandomize;
|
startRange -= size + kMaxRandomize;
|
||||||
startRange = ROUNDDOWN(startRange, alignment);
|
startRange = ROUNDDOWN(startRange, alignment);
|
||||||
|
|
||||||
startRange = max_c(startRange, alignedNextBase);
|
startRange = std::max(startRange, alignedNextBase);
|
||||||
|
|
||||||
addr_t rangeEnd
|
addr_t rangeEnd
|
||||||
= min_c(next->Base() + next->Size() - size,
|
= std::min(next->Base() + next->Size() - size,
|
||||||
end);
|
end);
|
||||||
alignedBase = _RandomizeAddress(startRange,
|
alignedBase = _RandomizeAddress(startRange,
|
||||||
rangeEnd, alignment);
|
rangeEnd, alignment);
|
||||||
|
|||||||
Reference in New Issue
Block a user