mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 07:11:39 +00:00
Fix a handful of crash bugs I caused with the 32-bit ASM version of the classic renderer. DONT_BUILD.
git-svn-id: https://svn.eduke32.com/eduke32@4719 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
3c8034609f
commit
9c001e6e2e
6 changed files with 76 additions and 2483 deletions
|
@ -26,7 +26,7 @@ EXTRN _reciptable : near
|
|||
EXTRN _fpuasm : dword
|
||||
EXTRN _globalx3 : dword
|
||||
EXTRN _globaly3 : dword
|
||||
EXTRN _ylookup : near
|
||||
EXTRN _ylookup : dword
|
||||
|
||||
EXTRN _vplce : near
|
||||
EXTRN _vince : near
|
||||
|
@ -834,7 +834,8 @@ CDECLPARAM edi,1,5
|
|||
|
||||
push ebp
|
||||
|
||||
mov eax, dword ptr _ylookup[ecx*4]
|
||||
mov eax, _ylookup
|
||||
mov eax, [eax+ecx*4]
|
||||
add eax, edi
|
||||
mov dword ptr [machvline4end+2], eax
|
||||
sub edi, eax
|
||||
|
@ -987,7 +988,8 @@ CDECLPARAM edi,1,5
|
|||
|
||||
push ebp
|
||||
|
||||
mov eax, dword ptr _ylookup[ecx*4]
|
||||
mov eax, _ylookup
|
||||
mov eax, [eax+ecx*4]
|
||||
add eax, edi
|
||||
mov dword ptr [promachvline4end1+2], eax
|
||||
inc eax
|
||||
|
|
|
@ -964,7 +964,8 @@ CDECLPARAM ecx,0,5
|
|||
CDECLPARAM edi,1,5
|
||||
push ebp
|
||||
|
||||
mov eax, dword [ylookup+ecx*4]
|
||||
mov eax, dword ylookup
|
||||
mov eax, [eax+ecx*4]
|
||||
add eax, edi
|
||||
mov dword [machvline4end+2], eax
|
||||
sub edi, eax
|
||||
|
@ -1114,7 +1115,8 @@ CDECLPARAM ecx,0,5
|
|||
CDECLPARAM edi,1,5
|
||||
push ebp
|
||||
|
||||
mov eax, dword [ylookup+ecx*4]
|
||||
mov eax, dword ylookup
|
||||
mov eax, [eax+ecx*4]
|
||||
add eax, edi
|
||||
mov dword [promachvline4end1+2], eax
|
||||
inc eax
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -131,11 +131,65 @@ void readjoybstatus(int32_t *b)
|
|||
*b = joyb;
|
||||
}
|
||||
|
||||
#if defined _WIN32
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
#elif defined __linux || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ || defined __APPLE__
|
||||
# include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
#if !defined(NOASM) && !defined(GEKKO) && !defined(__ANDROID__)
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
extern intptr_t dep_begin, dep_end;
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int32_t nx_unprotect(intptr_t beg, intptr_t end)
|
||||
{
|
||||
#if !defined(NOASM) && !defined(GEKKO) && !defined(__ANDROID__)
|
||||
# if defined _WIN32
|
||||
DWORD oldprot;
|
||||
|
||||
if (!VirtualProtect((LPVOID) beg, (SIZE_T)end - (SIZE_T)beg, PAGE_EXECUTE_READWRITE, &oldprot))
|
||||
{
|
||||
initprintf("VirtualProtect() error! Crashing in 3... 2... 1...\n");
|
||||
return 1;
|
||||
}
|
||||
# elif defined __linux || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ || defined __APPLE__
|
||||
int32_t pagesize;
|
||||
size_t dep_begin_page;
|
||||
pagesize = sysconf(_SC_PAGE_SIZE);
|
||||
if (pagesize == -1)
|
||||
{
|
||||
initprintf("Error getting system page size\n");
|
||||
return 1;
|
||||
}
|
||||
dep_begin_page = ((size_t)beg) & ~(pagesize-1);
|
||||
if (mprotect((void *) dep_begin_page, (size_t)end - dep_begin_page, PROT_READ|PROT_WRITE) < 0)
|
||||
{
|
||||
initprintf("Error making code writeable (errno=%d)\n", errno);
|
||||
return 1;
|
||||
}
|
||||
# else
|
||||
# error "Don't know how to unprotect the self-modifying assembly on this platform!"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// Calculate ylookup[] and call setvlinebpl()
|
||||
void calc_ylookup(int32_t bpl, int32_t lastyidx)
|
||||
{
|
||||
int32_t i, j=0;
|
||||
|
||||
lastyidx++;
|
||||
|
||||
Bassert(lastyidx <= MAXYDIM);
|
||||
|
||||
if (lastyidx > ylookupsiz)
|
||||
|
@ -144,6 +198,9 @@ void calc_ylookup(int32_t bpl, int32_t lastyidx)
|
|||
Baligned_free(ylookup);
|
||||
|
||||
ylookup = (intptr_t *)Xaligned_alloc(16, lastyidx * sizeof(intptr_t));
|
||||
#if !defined(NOASM) && !defined(GEKKO) && !defined(__ANDROID__)
|
||||
nx_unprotect((intptr_t)ylookup, (intptr_t)ylookup + (lastyidx * sizeof(intptr_t)));
|
||||
#endif
|
||||
ylookupsiz = lastyidx;
|
||||
}
|
||||
|
||||
|
@ -165,6 +222,14 @@ void calc_ylookup(int32_t bpl, int32_t lastyidx)
|
|||
setvlinebpl(bpl);
|
||||
}
|
||||
|
||||
|
||||
void makeasmwriteable(void)
|
||||
{
|
||||
#if !defined(NOASM) && !defined(GEKKO) && !defined(__ANDROID__)
|
||||
nx_unprotect((intptr_t)&dep_begin, (intptr_t)&dep_end);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
void fullscreen_tint_gl(uint8_t r, uint8_t g, uint8_t b, uint8_t f)
|
||||
{
|
||||
|
@ -484,56 +549,6 @@ int32_t baselayer_init(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#if defined _WIN32
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
#elif defined __linux || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ || defined __APPLE__
|
||||
# include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
#if !defined(NOASM) && !defined(GEKKO) && !defined(__ANDROID__)
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
extern int32_t dep_begin, dep_end;
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void makeasmwriteable(void)
|
||||
{
|
||||
#if !defined(NOASM) && !defined(GEKKO) && !defined(__ANDROID__)
|
||||
// extern int32_t dep_begin, dep_end;
|
||||
# if defined _WIN32
|
||||
DWORD oldprot;
|
||||
if (!VirtualProtect((LPVOID)&dep_begin, (SIZE_T)&dep_end - (SIZE_T)&dep_begin, PAGE_EXECUTE_READWRITE, &oldprot))
|
||||
{
|
||||
initprintf("Error making code writeable\n");
|
||||
return;
|
||||
}
|
||||
# elif defined __linux || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ || defined __APPLE__
|
||||
int32_t pagesize;
|
||||
size_t dep_begin_page;
|
||||
pagesize = sysconf(_SC_PAGE_SIZE);
|
||||
if (pagesize == -1)
|
||||
{
|
||||
initprintf("Error getting system page size\n");
|
||||
return;
|
||||
}
|
||||
dep_begin_page = ((size_t)&dep_begin) & ~(pagesize-1);
|
||||
if (mprotect((void *)dep_begin_page, (size_t)&dep_end - dep_begin_page, PROT_READ|PROT_WRITE) < 0)
|
||||
{
|
||||
initprintf("Error making code writeable (errno=%d)\n", errno);
|
||||
return;
|
||||
}
|
||||
# else
|
||||
# error "Don't know how to unprotect the self-modifying assembly on this platform!"
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void maybe_redirect_outputs(void)
|
||||
{
|
||||
#if !(defined __APPLE__ && defined __BIG_ENDIAN__)
|
||||
|
|
|
@ -11407,7 +11407,6 @@ static void initsmost(void)
|
|||
{ (void **)&swall, xdim * sizeof(int32_t) },
|
||||
{ (void **)&lwall, (xdim + 4) * sizeof(int32_t) },
|
||||
{ (void **)&radarang2, xdim * sizeof(int16_t) },
|
||||
{ (void **)&ylookup, (ydim + 1) * sizeof(intptr_t) },
|
||||
{ (void **)&dotp1, ydim * sizeof(intptr_t) },
|
||||
{ (void **)&dotp2, ydim * sizeof(intptr_t) },
|
||||
{ (void **)&lastx, ydim * sizeof(int32_t) },
|
||||
|
@ -11423,7 +11422,6 @@ static void initsmost(void)
|
|||
|
||||
ysavecnt = YSAVES;
|
||||
nodesperline = tabledivide32_noinline(YSAVES, ydim);
|
||||
ylookupsiz = ydim + 1;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -788,7 +788,8 @@ int32_t initinput(void)
|
|||
//
|
||||
void uninitinput(void)
|
||||
{
|
||||
switchlayout(defaultlayoutname);
|
||||
if (defaultlayoutname[0])
|
||||
switchlayout(defaultlayoutname);
|
||||
|
||||
uninitmouse();
|
||||
UninitDirectInput();
|
||||
|
|
Loading…
Reference in a new issue