diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2022-11-28 18:57:52 +0100 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2022-11-28 18:57:52 +0100 |
| commit | d6d2b2e7563eebea88620dbc67f361523b47cc68 (patch) | |
| tree | 1e8ee0809c9167a4eda966fd4e433c4cfc03f798 /src/custommem.c | |
| parent | 4276573f6736f8c57f9a6ff58a1bbecb57800d23 (diff) | |
| download | box64-d6d2b2e7563eebea88620dbc67f361523b47cc68.tar.gz box64-d6d2b2e7563eebea88620dbc67f361523b47cc68.zip | |
Changed how mmap with MAP_32BITS flag is handled (help deadcells, maybe some others)
Diffstat (limited to 'src/custommem.c')
| -rw-r--r-- | src/custommem.c | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/src/custommem.c b/src/custommem.c index d8d2d768..3b31b326 100644 --- a/src/custommem.c +++ b/src/custommem.c @@ -1324,23 +1324,14 @@ uint32_t getProtection(uintptr_t addr) } #define LOWEST (void*)0x10000 -void* find32bitBlock(size_t size) -{ - return findBlockNearHint(LOWEST, size); -} -void* find47bitBlock(size_t size) -{ - void* ret = find47bitBlockNearHint((void*)0x100000000LL, size); - if(!ret) - ret = find32bitBlock(size); - return ret; -} -void* find47bitBlockNearHint(void* hint, size_t size) +#define MEDIUM (void*)0x20000000 + +void* find31bitBlockNearHint(void* hint, size_t size) { mapmem_t* m = mapmem; uintptr_t h = (uintptr_t)hint; if(hint<LOWEST) hint = LOWEST; - while(m && m->end<0x800000000000LL) { + while(m && m->end<0x80000000LL) { // granularity 0x10000 uintptr_t addr = (m->end+1+0xffff)&~0xffff; uintptr_t end = (m->next)?(m->next->begin-1):0xffffffffffffffffLL; @@ -1353,12 +1344,28 @@ void* find47bitBlockNearHint(void* hint, size_t size) } return NULL; } -void* findBlockNearHint(void* hint, size_t size) + +void* find32bitBlock(size_t size) +{ + void* ret = find31bitBlockNearHint(MEDIUM, size); + if(ret) + return ret; + ret = find31bitBlockNearHint(LOWEST, size); + return ret?ret:find47bitBlock(size); +} +void* find47bitBlock(size_t size) +{ + void* ret = find47bitBlockNearHint((void*)0x100000000LL, size); + if(!ret) + ret = find32bitBlock(size); + return ret; +} +void* find47bitBlockNearHint(void* hint, size_t size) { mapmem_t* m = mapmem; uintptr_t h = (uintptr_t)hint; if(hint<LOWEST) hint = LOWEST; - while(m && m->end<0x100000000LL) { + while(m && m->end<0x800000000000LL) { // granularity 0x10000 uintptr_t addr = (m->end+1+0xffff)&~0xffff; uintptr_t end = (m->next)?(m->next->begin-1):0xffffffffffffffffLL; @@ -1369,7 +1376,7 @@ void* findBlockNearHint(void* hint, size_t size) return (void*)addr; m = m->next; } - return hint; + return NULL; } int unlockCustommemMutex() |