Mercurial > repos > blastem
changeset 1340:101b5ce682fe
Fix some inconsequential issues in code for executable memory allocation noticed while tracking down a different issue
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 04 May 2017 21:00:25 -0700 |
parents | 35e6a93b4586 |
children | f1607874dbee |
files | gen_x86.c mem.c |
diffstat | 2 files changed, 4 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/gen_x86.c Wed May 03 21:28:40 2017 -0700 +++ b/gen_x86.c Thu May 04 21:00:25 2017 -0700 @@ -207,7 +207,6 @@ //new chunk is not contiguous with the current one jmp_nocheck(code, next_code); code->cur = next_code; - code->last = next_code + size/sizeof(RESERVE_WORDS); } code->last = next_code + size/sizeof(code_word) - RESERVE_WORDS; }
--- a/mem.c Wed May 03 21:28:40 2017 -0700 +++ b/mem.c Thu May 04 21:00:25 2017 -0700 @@ -30,8 +30,10 @@ if (ret) { return ret; } - *size += PAGE_SIZE - (*size & (PAGE_SIZE - 1)); - ret = mmap(NULL, *size, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_32BIT, -1, 0); + if (*size & (PAGE_SIZE -1)) { + *size += PAGE_SIZE - (*size & (PAGE_SIZE - 1)); + } + ret = mmap(next, *size, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_32BIT, -1, 0); if (ret == MAP_FAILED) { perror("alloc_code"); return NULL;