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 smc-shmatdt.cpp -g -o ../smc-shmatdt
|
||||||
gcc prot-growsdown.cpp -g -o ../prot-growsdown
|
gcc prot-growsdown.cpp -g -o ../prot-growsdown
|
||||||
gcc memfd.cpp -g -o ../memfd
|
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
|
#ifndef PAGE_SIZE
|
||||||
#define PAGE_SIZE 4096
|
#define PAGE_SIZE 4096
|
||||||
#endif
|
#endif
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
|
||||||
// Based on discussion in https://github.com/FEX-Emu/FEX/issues/1708
|
// Based on discussion in https://github.com/FEX-Emu/FEX/issues/1708
|
||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
|
auto start_time = std::chrono::high_resolution_clock::now();
|
||||||
size_t total_len = 0;
|
size_t total_len = 0;
|
||||||
size_t alloc_len = 1ULL << 51;
|
size_t alloc_len = 1ULL << 51;
|
||||||
while (alloc_len >= PAGE_SIZE) {
|
while (alloc_len >= PAGE_SIZE) {
|
||||||
@ -23,8 +26,12 @@ int main() {
|
|||||||
|
|
||||||
// No more free VM gaps of this size.
|
// No more free VM gaps of this size.
|
||||||
if (result == MAP_FAILED) {
|
if (result == MAP_FAILED) {
|
||||||
assert(errno == ENOMEM);
|
if (errno != ENOMEM && errno != EPERM /* when len is too big ?*/) {
|
||||||
break;
|
printf("Error, errno: %d\n", errno);
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
total_len += alloc_len;
|
total_len += alloc_len;
|
||||||
}
|
}
|
||||||
@ -32,6 +39,9 @@ int main() {
|
|||||||
// Halve the size and continue filling in gaps.
|
// Halve the size and continue filling in gaps.
|
||||||
alloc_len >>= 1;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user