diff --git a/src/codegen_x86-64.c b/src/codegen_x86-64.c index 0c21a3a..b832a60 100644 --- a/src/codegen_x86-64.c +++ b/src/codegen_x86-64.c @@ -15,7 +15,7 @@ #include "codegen_ops.h" #include "codegen_ops_x86-64.h" -#ifdef __linux__ +#if defined(__linux__) || defined(__APPLE__) #include #include #endif @@ -63,7 +63,7 @@ void codegen_init() { int c; -#ifdef __linux__ +#if defined(__linux__) || defined(__APPLE__) void *start; size_t len; long pagesize = sysconf(_SC_PAGESIZE); @@ -83,7 +83,7 @@ void codegen_init() for (c = 0; c < BLOCK_SIZE; c++) codeblock[c].pc = BLOCK_PC_INVALID; -#ifdef __linux__ +#if defined(__linux__) || defined(__APPLE__) start = (void *)((long)codeblock & pagemask); len = ((BLOCK_SIZE * sizeof(codeblock_t)) + pagesize) & pagemask; if (mprotect(start, len, PROT_READ | PROT_WRITE | PROT_EXEC) != 0) diff --git a/src/codegen_x86.c b/src/codegen_x86.c index 688a363..b230074 100644 --- a/src/codegen_x86.c +++ b/src/codegen_x86.c @@ -15,7 +15,7 @@ #include "codegen_ops.h" #include "codegen_ops_x86.h" -#ifdef __linux__ +#if defined(__linux__) || defined(__APPLE__) #include #include #endif @@ -1124,7 +1124,7 @@ static uint32_t gen_MEM_CHECK_WRITE_L() void codegen_init() { int c; -#ifdef __linux__ +#if defined(__linux__) || defined(__APPLE__) void *start; size_t len; long pagesize = sysconf(_SC_PAGESIZE); @@ -1144,7 +1144,7 @@ void codegen_init() for (c = 0; c < BLOCK_SIZE; c++) codeblock[c].pc = BLOCK_PC_INVALID; -#ifdef __linux__ +#if defined(__linux__) || defined(__APPLE__) start = (void *)((long)codeblock & pagemask); len = (((BLOCK_SIZE+1) * sizeof(codeblock_t)) + pagesize) & pagemask; if (mprotect(start, len, PROT_READ | PROT_WRITE | PROT_EXEC) != 0) diff --git a/src/vid_voodoo_codegen_x86-64.h b/src/vid_voodoo_codegen_x86-64.h index 587e595..fda8b3f 100644 --- a/src/vid_voodoo_codegen_x86-64.h +++ b/src/vid_voodoo_codegen_x86-64.h @@ -5,7 +5,7 @@ fbzColorPath */ -#ifdef __linux__ +#if defined(__linux__) || defined(__APPLE__) #include #include #endif @@ -3352,7 +3352,7 @@ voodoo_recomp++; static void voodoo_codegen_init(voodoo_t *voodoo) { int c; -#ifdef __linux__ +#if defined(__linux__) || defined(__APPLE__) void *start; size_t len; long pagesize = sysconf(_SC_PAGESIZE); @@ -3365,7 +3365,7 @@ static void voodoo_codegen_init(voodoo_t *voodoo) voodoo->codegen_data = malloc(sizeof(voodoo_x86_data_t) * BLOCK_NUM * 2); #endif -#ifdef __linux__ +#if defined(__linux__) || defined(__APPLE__) start = (void *)((long)voodoo->codegen_data & pagemask); len = ((sizeof(voodoo_x86_data_t) * BLOCK_NUM * 2) + pagesize) & pagemask; if (mprotect(start, len, PROT_READ | PROT_WRITE | PROT_EXEC) != 0) diff --git a/src/vid_voodoo_codegen_x86.h b/src/vid_voodoo_codegen_x86.h index 417d86b..be4aad2 100644 --- a/src/vid_voodoo_codegen_x86.h +++ b/src/vid_voodoo_codegen_x86.h @@ -5,7 +5,7 @@ fbzColorPath */ -#ifdef __linux__ +#if defined(__linux__) || defined(__APPLE__) #include #include #endif @@ -3282,7 +3282,7 @@ voodoo_recomp++; static void voodoo_codegen_init(voodoo_t *voodoo) { int c; -#ifdef __linux__ +#if defined(__linux__) || defined(__APPLE__) void *start; size_t len; long pagesize = sysconf(_SC_PAGESIZE); @@ -3295,7 +3295,7 @@ static void voodoo_codegen_init(voodoo_t *voodoo) voodoo->codegen_data = malloc(sizeof(voodoo_x86_data_t) * BLOCK_NUM*2); #endif -#ifdef __linux__ +#if defined(__linux__) || defined(__APPLE__) start = (void *)((long)voodoo->codegen_data & pagemask); len = ((sizeof(voodoo_x86_data_t) * BLOCK_NUM*2) + pagesize) & pagemask; if (mprotect(start, len, PROT_READ | PROT_WRITE | PROT_EXEC) != 0)