enable full execution privileges for the dynamic core cache (windows DEP);
raise generated data per block overflow buffer a bit Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2879
This commit is contained in:
parent
b6aff7b628
commit
24eba30d23
4 changed files with 30 additions and 2 deletions
|
@ -27,6 +27,11 @@
|
|||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined (_MSC_VER)
|
||||
#include <windows.h>
|
||||
#include <winbase.h>
|
||||
#endif
|
||||
|
||||
#if (C_HAVE_MPROTECT)
|
||||
#include <sys/mman.h>
|
||||
|
||||
|
@ -45,7 +50,7 @@
|
|||
#include "inout.h"
|
||||
#include "fpu.h"
|
||||
|
||||
#define CACHE_MAXSIZE (4096*2)
|
||||
#define CACHE_MAXSIZE (4096*3)
|
||||
#define CACHE_TOTAL (1024*1024*8)
|
||||
#define CACHE_PAGES (512)
|
||||
#define CACHE_BLOCKS (64*1024)
|
||||
|
|
|
@ -457,8 +457,15 @@ static void cache_init(bool enable) {
|
|||
}
|
||||
}
|
||||
if (cache_code_start_ptr==NULL) {
|
||||
#if defined (_MSC_VER)
|
||||
cache_code_start_ptr=(Bit8u*)VirtualAlloc(0,CACHE_TOTAL+CACHE_MAXSIZE+PAGESIZE_TEMP-1+PAGESIZE_TEMP,
|
||||
MEM_COMMIT,PAGE_EXECUTE_READWRITE);
|
||||
if (!cache_code_start_ptr)
|
||||
cache_code_start_ptr=(Bit8u*)malloc(CACHE_TOTAL+CACHE_MAXSIZE+PAGESIZE_TEMP-1+PAGESIZE_TEMP);
|
||||
#else
|
||||
cache_code_start_ptr=(Bit8u*)malloc(CACHE_TOTAL+CACHE_MAXSIZE+PAGESIZE_TEMP-1+PAGESIZE_TEMP);
|
||||
if(!cache_code_start_ptr) E_Exit("Allocating dynamic cache failed");
|
||||
#endif
|
||||
if(!cache_code_start_ptr) E_Exit("Allocating dynamic core cache memory failed");
|
||||
|
||||
cache_code=(Bit8u*)(((int)cache_code_start_ptr + PAGESIZE_TEMP-1) & ~(PAGESIZE_TEMP-1)); //MEM LEAK. store old pointer if you want to free it.
|
||||
|
||||
|
@ -510,6 +517,8 @@ static void cache_close(void) {
|
|||
cache_blocks = NULL;
|
||||
}
|
||||
if (cache_code_start_ptr != NULL) {
|
||||
### care: under windows VirtualFree() has to be used if
|
||||
### VirtualAlloc was used for memory allocation
|
||||
free(cache_code_start_ptr);
|
||||
cache_code_start_ptr = NULL;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,11 @@
|
|||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined (_MSC_VER)
|
||||
#include <windows.h>
|
||||
#include <winbase.h>
|
||||
#endif
|
||||
|
||||
#if (C_HAVE_MPROTECT)
|
||||
#include <sys/mman.h>
|
||||
|
||||
|
|
|
@ -562,7 +562,14 @@ static void cache_init(bool enable) {
|
|||
}
|
||||
if (cache_code_start_ptr==NULL) {
|
||||
// allocate the code cache memory
|
||||
#if defined (_MSC_VER)
|
||||
cache_code_start_ptr=(Bit8u*)VirtualAlloc(0,CACHE_TOTAL+CACHE_MAXSIZE+PAGESIZE_TEMP-1+PAGESIZE_TEMP,
|
||||
MEM_COMMIT,PAGE_EXECUTE_READWRITE);
|
||||
if (!cache_code_start_ptr)
|
||||
cache_code_start_ptr=(Bit8u*)malloc(CACHE_TOTAL+CACHE_MAXSIZE+PAGESIZE_TEMP-1+PAGESIZE_TEMP);
|
||||
#else
|
||||
cache_code_start_ptr=(Bit8u*)malloc(CACHE_TOTAL+CACHE_MAXSIZE+PAGESIZE_TEMP-1+PAGESIZE_TEMP);
|
||||
#endif
|
||||
if(!cache_code_start_ptr) E_Exit("Allocating dynamic cache failed");
|
||||
|
||||
// align the cache at a page boundary
|
||||
|
@ -624,6 +631,8 @@ static void cache_close(void) {
|
|||
cache_blocks = NULL;
|
||||
}
|
||||
if (cache_code_start_ptr != NULL) {
|
||||
### care: under windows VirtualFree() has to be used if
|
||||
### VirtualAlloc was used for memory allocation
|
||||
free(cache_code_start_ptr);
|
||||
cache_code_start_ptr = NULL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue