Use plat_mmap on the dynarecs as well

This commit is contained in:
RichardG867
2024-11-20 11:23:24 -03:00
parent d7a2db5025
commit 1e052e5dc0
3 changed files with 6 additions and 45 deletions

View File

@@ -7,6 +7,7 @@
# include <stdlib.h>
# define HAVE_STDARG_H
# include <86box/86box.h>
# include <86box/plat.h>
# include "cpu.h"
# include "x86.h"
# include "x86_flags.h"
@@ -25,14 +26,6 @@
# include "codegen_ops.h"
# include "codegen_ops_x86-64.h"
# if defined(__unix__) || defined(__APPLE__) || defined(__HAIKU__)
# include <sys/mman.h>
# include <unistd.h>
# endif
# if _WIN64
# include <windows.h>
# endif
int codegen_flat_ds;
int codegen_flat_ss;
int codegen_flags_changed = 0;
@@ -68,15 +61,7 @@ static int last_ssegs;
void
codegen_init(void)
{
# if _WIN64
codeblock = VirtualAlloc(NULL, BLOCK_SIZE * sizeof(codeblock_t), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
# elif defined(PROT_MPROTECT)
codeblock = mmap(NULL, BLOCK_SIZE * sizeof(codeblock_t), PROT_MPROTECT(PROT_READ | PROT_WRITE | PROT_EXEC), MAP_ANON | MAP_PRIVATE, -1, 0);
# elif defined(__unix__) || defined(__APPLE__) || defined(__HAIKU__)
codeblock = mmap(NULL, BLOCK_SIZE * sizeof(codeblock_t), PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE, -1, 0);
# else
codeblock = malloc(BLOCK_SIZE * sizeof(codeblock_t));
# endif
codeblock = plat_mmap(BLOCK_SIZE * sizeof(codeblock_t), 1);
codeblock_hash = malloc(HASH_SIZE * sizeof(codeblock_t *));
memset(codeblock, 0, BLOCK_SIZE * sizeof(codeblock_t));

View File

@@ -44,6 +44,7 @@
# include <stdlib.h>
# include <wchar.h>
# include <86box/86box.h>
# include <86box/plat.h>
# include "cpu.h"
# include <86box/mem.h>
# include "x86.h"
@@ -64,14 +65,6 @@
# include "codegen_ops.h"
# include "codegen_ops_x86.h"
# ifdef __unix__
# include <sys/mman.h>
# include <unistd.h>
# endif
# if defined _WIN32
# include <windows.h>
# endif
int codegen_flat_ds;
int codegen_flat_ss;
int mmx_ebx_ecx_loaded;
@@ -1194,15 +1187,7 @@ gen_MEM_CHECK_WRITE_L(void)
void
codegen_init(void)
{
# ifdef _WIN32
codeblock = VirtualAlloc(NULL, (BLOCK_SIZE + 1) * sizeof(codeblock_t), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
# elif defined(PROT_MPROTECT)
codeblock = mmap(NULL, (BLOCK_SIZE + 1) * sizeof(codeblock_t), PROT_MPROTECT(PROT_READ | PROT_WRITE | PROT_EXEC), MAP_ANON | MAP_PRIVATE, 0, 0);
# elif defined __unix__
codeblock = mmap(NULL, (BLOCK_SIZE + 1) * sizeof(codeblock_t), PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE, 0, 0);
# else
codeblock = malloc((BLOCK_SIZE + 1) * sizeof(codeblock_t));
# endif
codeblock = plat_mmap((BLOCK_SIZE + 1) * sizeof(codeblock_t), 1);
codeblock_hash = malloc(HASH_SIZE * sizeof(codeblock_t *));
memset(codeblock, 0, (BLOCK_SIZE + 1) * sizeof(codeblock_t));