зеркало из https://github.com/mozilla/pjs.git
Bug 530012 - [OS/2] build break in nsPresArena.cpp; r=wuno a=dbaron
--HG-- extra : rebase_source : a64adf531e9132c583419def72c712fc345774d7
This commit is contained in:
Родитель
0c479aa37e
Коммит
303ea8f873
|
@ -70,7 +70,7 @@
|
|||
|
||||
#ifdef _WIN32
|
||||
# include <windows.h>
|
||||
#else
|
||||
#elif !defined(__OS2__)
|
||||
# include <unistd.h>
|
||||
# include <sys/mman.h>
|
||||
# ifndef MAP_ANON
|
||||
|
@ -131,6 +131,38 @@ GetDesiredRegionSize()
|
|||
|
||||
#define RESERVE_FAILED 0
|
||||
|
||||
#elif defined(__OS2__)
|
||||
static void *
|
||||
ReserveRegion(PRUword region, PRUword size)
|
||||
{
|
||||
// OS/2 doesn't support allocation at an arbitrary address,
|
||||
// so return an address that is known to be invalid.
|
||||
return (void*)0xFFFD0000;
|
||||
}
|
||||
|
||||
static void
|
||||
ReleaseRegion(void *region, PRUword size)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static bool
|
||||
ProbeRegion(PRUword region, PRUword size)
|
||||
{
|
||||
// There's no reliable way to probe an address in the system
|
||||
// arena other than by touching it and seeing if a trap occurs.
|
||||
return false;
|
||||
}
|
||||
|
||||
static PRUword
|
||||
GetDesiredRegionSize()
|
||||
{
|
||||
// Page size is fixed at 4k.
|
||||
return 0x1000;
|
||||
}
|
||||
|
||||
#define RESERVE_FAILED 0
|
||||
|
||||
#else // Unix
|
||||
|
||||
static void *
|
||||
|
|
|
@ -134,6 +134,12 @@ typedef unsigned int uint32_t;
|
|||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#elif defined(__OS2__)
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <setjmp.h>
|
||||
#define INCL_DOS
|
||||
#include <os2.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -283,7 +289,76 @@ MakeRegionExecutable(void *)
|
|||
#undef MAP_FAILED
|
||||
#define MAP_FAILED 0
|
||||
|
||||
#else
|
||||
#elif defined(__OS2__)
|
||||
|
||||
// page size is always 4k
|
||||
#undef PAGESIZE
|
||||
#define PAGESIZE 0x1000
|
||||
static unsigned long rc = 0;
|
||||
|
||||
char * LastErrMsg()
|
||||
{
|
||||
char * errmsg = (char *)malloc(16);
|
||||
sprintf(errmsg, "rc= %ld", rc);
|
||||
rc = 0;
|
||||
return errmsg;
|
||||
}
|
||||
|
||||
static void *
|
||||
ReserveRegion(uintptr_t request, bool accessible)
|
||||
{
|
||||
// OS/2 doesn't support allocation at an arbitrary address,
|
||||
// so return an address that is known to be invalid.
|
||||
if (request) {
|
||||
return (void*)0xFFFD0000;
|
||||
}
|
||||
void * mem = 0;
|
||||
rc = DosAllocMem(&mem, PAGESIZE,
|
||||
(accessible ? PAG_COMMIT : 0) | PAG_READ | PAG_WRITE);
|
||||
return rc ? 0 : mem;
|
||||
}
|
||||
|
||||
static void
|
||||
ReleaseRegion(void *page)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static bool
|
||||
ProbeRegion(uintptr_t page)
|
||||
{
|
||||
// There's no reliable way to probe an address in the system
|
||||
// arena other than by touching it and seeing if a trap occurs.
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool
|
||||
MakeRegionExecutable(void *page)
|
||||
{
|
||||
rc = DosSetMem(page, PAGESIZE, PAG_READ | PAG_WRITE | PAG_EXECUTE);
|
||||
return rc ? true : false;
|
||||
}
|
||||
|
||||
typedef struct _XCPT {
|
||||
EXCEPTIONREGISTRATIONRECORD regrec;
|
||||
jmp_buf jmpbuf;
|
||||
} XCPT;
|
||||
|
||||
static unsigned long _System
|
||||
ExceptionHandler(PEXCEPTIONREPORTRECORD pReport,
|
||||
PEXCEPTIONREGISTRATIONRECORD pRegRec,
|
||||
PCONTEXTRECORD pContext, PVOID pVoid)
|
||||
{
|
||||
if (pReport->fHandlerFlags == 0) {
|
||||
longjmp(((XCPT*)pRegRec)->jmpbuf, pReport->ExceptionNum);
|
||||
}
|
||||
return XCPT_CONTINUE_SEARCH;
|
||||
}
|
||||
|
||||
#undef MAP_FAILED
|
||||
#define MAP_FAILED 0
|
||||
|
||||
#else // Unix
|
||||
|
||||
#define LastErrMsg() (strerror(errno))
|
||||
|
||||
|
@ -505,6 +580,41 @@ TestPage(const char *pagelabel, uintptr_t pageaddr, int should_succeed)
|
|||
failed = true;
|
||||
}
|
||||
}
|
||||
#elif defined(__OS2__)
|
||||
XCPT xcpt;
|
||||
volatile int code = setjmp(xcpt.jmpbuf);
|
||||
|
||||
if (!code) {
|
||||
xcpt.regrec.prev_structure = 0;
|
||||
xcpt.regrec.ExceptionHandler = ExceptionHandler;
|
||||
DosSetExceptionHandler(&xcpt.regrec);
|
||||
unsigned char scratch;
|
||||
switch (test) {
|
||||
case 0: scratch = *(volatile unsigned char *)opaddr; break;
|
||||
case 1: ((void (*)())opaddr)(); break;
|
||||
case 2: *(volatile unsigned char *)opaddr = 0; break;
|
||||
default: abort();
|
||||
}
|
||||
}
|
||||
|
||||
if (code) {
|
||||
if (should_succeed) {
|
||||
printf("TEST-UNEXPECTED-FAIL | %s %s | exception code %x\n",
|
||||
oplabel, pagelabel, code);
|
||||
failed = true;
|
||||
} else {
|
||||
printf("TEST-PASS | %s %s | exception code %x\n",
|
||||
oplabel, pagelabel, code);
|
||||
}
|
||||
} else {
|
||||
if (should_succeed) {
|
||||
printf("TEST-PASS | %s %s\n", oplabel, pagelabel);
|
||||
} else {
|
||||
printf("TEST-UNEXPECTED-FAIL | %s %s\n", oplabel, pagelabel);
|
||||
failed = true;
|
||||
}
|
||||
DosUnsetExceptionHandler(&xcpt.regrec);
|
||||
}
|
||||
#else
|
||||
pid_t pid = fork();
|
||||
if (pid == -1) {
|
||||
|
@ -565,7 +675,7 @@ main()
|
|||
{
|
||||
#ifdef _WIN32
|
||||
GetSystemInfo(&_sinfo);
|
||||
#else
|
||||
#elif !defined(__OS2__)
|
||||
_pagesize = sysconf(_SC_PAGESIZE);
|
||||
#endif
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче