Merge remote-tracking branch 'origin/master' into feature/machine_and_kb

This commit is contained in:
OBattler
2021-10-16 22:18:13 +02:00
4 changed files with 20 additions and 38 deletions

View File

@@ -21,7 +21,7 @@
#include "codegen_ops.h"
#include "codegen_ops_x86-64.h"
#if defined(__linux__) || defined(__APPLE__)
#if defined(__unix__) || defined(__APPLE__)
#include <sys/mman.h>
#include <unistd.h>
#endif
@@ -63,16 +63,11 @@ static int last_ssegs;
void codegen_init()
{
int c;
#if defined(__linux__) || defined(__APPLE__)
void *start;
size_t len;
long pagesize = sysconf(_SC_PAGESIZE);
long pagemask = ~(pagesize - 1);
#endif
#if _WIN64
codeblock = VirtualAlloc(NULL, BLOCK_SIZE * sizeof(codeblock_t), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
#elif defined(__unix__) || defined(__APPLE__)
codeblock = mmap(NULL, BLOCK_SIZE * sizeof(codeblock_t), PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE, 0, 0);
#else
codeblock = malloc(BLOCK_SIZE * sizeof(codeblock_t));
#endif
@@ -83,16 +78,6 @@ void codegen_init()
for (c = 0; c < BLOCK_SIZE; c++)
codeblock[c].valid = 0;
#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)
{
perror("mprotect");
exit(-1);
}
#endif
}
void codegen_reset()

View File

@@ -61,7 +61,7 @@
#include "codegen_ops.h"
#include "codegen_ops_x86.h"
#ifdef __linux__
#ifdef __unix__
#include <sys/mman.h>
#include <unistd.h>
#endif
@@ -1173,15 +1173,10 @@ static uint32_t gen_MEM_CHECK_WRITE_L()
void codegen_init()
{
#ifdef __linux__
void *start;
size_t len;
long pagesize = sysconf(_SC_PAGESIZE);
long pagemask = ~(pagesize - 1);
#endif
#ifdef _WIN32
codeblock = VirtualAlloc(NULL, (BLOCK_SIZE+1) * sizeof(codeblock_t), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
#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
@@ -1190,16 +1185,6 @@ void codegen_init()
memset(codeblock, 0, (BLOCK_SIZE+1) * sizeof(codeblock_t));
memset(codeblock_hash, 0, HASH_SIZE * sizeof(codeblock_t *));
#ifdef __linux__
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)
{
perror("mprotect");
exit(-1);
}
#endif
block_current = BLOCK_SIZE;
block_pos = 0;
mem_abrt_rout = (uint32_t)&codeblock[block_current].data[block_pos];

View File

@@ -249,6 +249,12 @@ wchar_t* plat_get_string(int i)
return L"Make sure libpcap is installed and that you are on a libpcap-compatible network connection.";
case IDS_2114:
return L"Unable to initialize Ghostscript";
case IDS_2063:
return L"Machine \"%hs\" is not available due to missing ROMs in the roms/machines directory. Switching to an available machine.";
case IDS_2064:
return L"Video card \"%hs\" is not available due to missing ROMs in the roms/video directory. Switching to an available video card.";
case IDS_2128:
return L"Hardware not available";
}
return L"";
}

View File

@@ -1304,13 +1304,19 @@ ui_init(int nCmdShow)
wincl.lpfnWndProc = MainWindowProcedure;
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof(WNDCLASSEX);
wincl.hIcon = LoadIcon(hinstance, (LPCTSTR)10);
wincl.hIconSm = LoadIcon(hinstance, (LPCTSTR)10);
wincl.hIcon = NULL;
wincl.hIconSm = NULL;
wincl.hCursor = NULL;
wincl.lpszMenuName = NULL;
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;
wincl.hbrBackground = CreateSolidBrush(RGB(0,0,0));
/* Load proper icons */
wchar_t path[MAX_PATH + 1] = {0};
GetModuleFileNameW(hinstance, path, MAX_PATH);
ExtractIconExW(path, 0, &wincl.hIcon, &wincl.hIconSm, 1);
if (! RegisterClassEx(&wincl))
return(2);
wincl.lpszClassName = SUB_CLASS_NAME;