From 293b07bbb6267835af07aac6481df7697757d843 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Wed, 9 Mar 2022 12:23:01 +0100 Subject: Fixed non-dynarec builds --- src/custommem.c | 78 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 40 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/custommem.c b/src/custommem.c index da38fb4d..c328fdf1 100644 --- a/src/custommem.c +++ b/src/custommem.c @@ -831,44 +831,7 @@ void unprotectDB(uintptr_t addr, size_t size) } pthread_mutex_unlock(&mutex_prot); } -void addMapMem(uintptr_t begin, uintptr_t end) -{ - // granularity is 0x10000, like on x86_64 - begin &=~0xffff; - end = (end&~0xffff)+0xffff; // full granulirity - // sanitize values - if(end==0xffff) return; - if(!begin) begin = 0x1000; - // find attach point (cannot be the 1st one by construction) - mapmem_t* m = mapmem; - while(m->next && m->next->beginnext; - } - // attach at the end of m - if(m->end>end) { - return; // included... nothing to do - } - if(m->end+1>=begin) { - m->end = end; // enlarge block - return; - } - mapmem_t* newm = (mapmem_t*)calloc(1, sizeof(mapmem_t)); - newm->prev = m; - newm->next = m->next; - newm->begin = begin; - newm->end = end; - m->next = newm; - while(newm->next && newm->next->beginend) { - // fuse with next - if(newm->next->end>newm->end) - newm->end = newm->next->end; - mapmem_t* tmp = newm->next; - newm->next = tmp->next; - tmp->prev = newm; - free(tmp); - } - // all done! -} + void removeMapMem(uintptr_t begin, uintptr_t end) { // granularity is 0x10000, like on x86_64 @@ -952,6 +915,45 @@ int isprotectedDB(uintptr_t addr, size_t size) #endif +void addMapMem(uintptr_t begin, uintptr_t end) +{ + // granularity is 0x10000, like on x86_64 + begin &=~0xffff; + end = (end&~0xffff)+0xffff; // full granulirity + // sanitize values + if(end==0xffff) return; + if(!begin) begin = 0x1000; + // find attach point (cannot be the 1st one by construction) + mapmem_t* m = mapmem; + while(m->next && m->next->beginnext; + } + // attach at the end of m + if(m->end>end) { + return; // included... nothing to do + } + if(m->end+1>=begin) { + m->end = end; // enlarge block + return; + } + mapmem_t* newm = (mapmem_t*)calloc(1, sizeof(mapmem_t)); + newm->prev = m; + newm->next = m->next; + newm->begin = begin; + newm->end = end; + m->next = newm; + while(newm->next && newm->next->beginend) { + // fuse with next + if(newm->next->end>newm->end) + newm->end = newm->next->end; + mapmem_t* tmp = newm->next; + newm->next = tmp->next; + tmp->prev = newm; + free(tmp); + } + // all done! +} + void updateProtection(uintptr_t addr, size_t size, uint32_t prot) { dynarec_log(LOG_DEBUG, "updateProtection %p:%p 0x%x\n", (void*)addr, (void*)(addr+size-1), prot); -- cgit 1.4.1