mirror of
https://github.com/FEX-Emu/fex-assorted-tests-bins.git
synced 2024-11-23 06:20:05 +00:00
Update reserve-address-space
This commit is contained in:
parent
667a30cbef
commit
8ce1c4b930
Binary file not shown.
@ -15,4 +15,4 @@ gcc signals-nested-2.cpp -g -o ../signals-nested-2 -lpthread
|
||||
gcc smc-shmatdt.cpp -g -o ../smc-shmatdt
|
||||
gcc prot-growsdown.cpp -g -o ../prot-growsdown
|
||||
gcc memfd.cpp -g -o ../memfd
|
||||
gcc reserve-address-space.cpp -g -o ../reserve-address-space
|
||||
g++ reserve-address-space.cpp -g -o ../reserve-address-space
|
||||
|
@ -9,10 +9,13 @@
|
||||
#ifndef PAGE_SIZE
|
||||
#define PAGE_SIZE 4096
|
||||
#endif
|
||||
#include <chrono>
|
||||
|
||||
|
||||
// Based on discussion in https://github.com/FEX-Emu/FEX/issues/1708
|
||||
int main() {
|
||||
|
||||
auto start_time = std::chrono::high_resolution_clock::now();
|
||||
size_t total_len = 0;
|
||||
size_t alloc_len = 1ULL << 51;
|
||||
while (alloc_len >= PAGE_SIZE) {
|
||||
@ -23,15 +26,22 @@ int main() {
|
||||
|
||||
// No more free VM gaps of this size.
|
||||
if (result == MAP_FAILED) {
|
||||
assert(errno == ENOMEM);
|
||||
if (errno != ENOMEM && errno != EPERM /* when len is too big ?*/) {
|
||||
printf("Error, errno: %d\n", errno);
|
||||
return -1;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
total_len += alloc_len;
|
||||
}
|
||||
|
||||
// Halve the size and continue filling in gaps.
|
||||
alloc_len >>= 1;
|
||||
}
|
||||
printf("done, allocated %ld\n", total_len);
|
||||
|
||||
std::chrono::duration<double, std::milli> duration = std::chrono::high_resolution_clock::now() - start_time;
|
||||
|
||||
printf("done, allocated %ld in %.3f ms\n", total_len, duration.count());
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user