QNX6 support

This commit is contained in:
pagefault
2001-07-03 20:02:20 +00:00
parent 910128f81f
commit 74293c9b25

View File

@@ -23,6 +23,12 @@
#include <limits.h> #include <limits.h>
#include <unistd.h> #include <unistd.h>
#ifdef __QNXNTO__
/* QNX6 has getpagesize() commented out in unistd.h,
however it's a static value that we can just define */
#define getpagesize() 4096
#endif
extern void GuiAsmStart(); extern void GuiAsmStart();
extern void GuiAsmEnd(); extern void GuiAsmEnd();
extern void SfxProcAsmStart(); extern void SfxProcAsmStart();
@@ -139,16 +145,18 @@ void MakeCodeWriteable (unsigned long startaddr, unsigned long length)
unsigned int addr; unsigned int addr;
int psize = getpagesize(); int psize = getpagesize();
//fprintf(stderr, "Unprotecting 0x%x to 0x%x\n", startaddr, startaddr+length); //fprintf(stderr, "Unprotecting 0x%x to 0x%x\n", startaddr, startaddr+length);
addr = (startaddr & ~(psize -1)) - psize; addr = (startaddr & ~(psize -1)) - psize;
r = mprotect ((char *) addr, length + startaddr - addr + psize, 7); /* Using 7 is a very stupid thing to do, but I'll leave it in commented form for the non-posix compliant zealots to ph34r... */
//r = mprotect ((char *) addr, length + startaddr - addr + psize, 7);
r = mprotect ((char *) addr, length + startaddr - addr + psize, PROT_READ | PROT_WRITE | PROT_EXEC);
if (r < 0) if (r < 0)
fprintf (stderr, "Error! Memory *NOT* unprotected. startaddr = 0x%08lx\n", startaddr); fprintf (stderr, "Error! Memory *NOT* unprotected. startaddr = 0x%08lx\n", startaddr);
} }
void UnProtectMemory(void) void UnProtectMemory(void)
{ {
MakeCodeWriteable((long) SfxProcAsmStart, (long) SfxProcAsmEnd - (long) SfxProcAsmStart); MakeCodeWriteable((long) SfxProcAsmStart, (long) SfxProcAsmEnd - (long) SfxProcAsmStart);