Dynamic recompiler now works on Linux (32-bit only)
This commit is contained in:
parent
6caeca2c7c
commit
1fb4de4507
10 changed files with 3644 additions and 35 deletions
|
|
@ -16,6 +16,11 @@
|
|||
#include "codegen_ops.h"
|
||||
#include "codegen_ops_x86.h"
|
||||
|
||||
#ifdef __linux__
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
x86seg *op_ea_seg;
|
||||
int op_ssegs;
|
||||
uint32_t op_old_pc;
|
||||
|
|
@ -49,13 +54,28 @@ static int last_ssegs;
|
|||
void codegen_init()
|
||||
{
|
||||
int c;
|
||||
#ifdef __linux__
|
||||
void *start;
|
||||
size_t len;
|
||||
long pagesize = sysconf(_SC_PAGESIZE);
|
||||
long pagemask = ~(pagesize - 1);
|
||||
#endif
|
||||
|
||||
codeblock = malloc(BLOCK_SIZE * sizeof(codeblock_t));
|
||||
codeblock_hash = malloc(HASH_SIZE * sizeof(codeblock_t *));
|
||||
|
||||
memset(codeblock, 0, BLOCK_SIZE * sizeof(codeblock_t));
|
||||
memset(codeblock_hash, 0, HASH_SIZE * sizeof(codeblock_t *));
|
||||
|
||||
|
||||
#ifdef __linux__
|
||||
start = (void *)((long)codeblock & pagemask);
|
||||
len = ((BLOCK_SIZE * sizeof(codeblock_t)) + pagesize) & pagemask;
|
||||
if (mprotect(start, len, PROT_READ | PROT_WRITE | PROT_EXEC) != 0)
|
||||
{
|
||||
perror("mprotect");
|
||||
exit(-1);
|
||||
}
|
||||
#endif
|
||||
// pclog("Codegen is %p\n", (void *)pages[0xfab12 >> 12].block);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue