VM code cleanups

slava 2006-09-24 19:28:44 +00:00
parent ae5768fee3
commit 4b0d95d9e6
1 changed files with 23 additions and 19 deletions

View File

@ -199,11 +199,29 @@ void dealloc_bounded_block(BOUNDED_BLOCK *block)
free(block); free(block);
} }
long getpagesize (void)
{
static long g_pagesize = 0;
if (! g_pagesize)
{
SYSTEM_INFO system_info;
GetSystemInfo (&system_info);
g_pagesize = system_info.dwPageSize;
}
return g_pagesize;
}
const char *default_image_path(void)
{
return "factor.image";
}
/* SEH support. Proceed with caution. */ /* SEH support. Proceed with caution. */
typedef long exception_handler_t( typedef long exception_handler_t(
void *rec, void *frame, void *context, void *dispatch); PEXCEPTION_RECORD rec, void *frame, void *context, void *dispatch);
typedef struct exception_record { typedef struct exception_record
{
struct exception_record *next_handler; struct exception_record *next_handler;
void *handler_func; void *handler_func;
} exception_record_t; } exception_record_t;
@ -218,27 +236,13 @@ void seh_call(void (*func)(), exception_handler_t *handler)
asm("mov %0, %%fs:0" : "=r" (record.next_handler)); asm("mov %0, %%fs:0" : "=r" (record.next_handler));
} }
long getpagesize (void) { static long exception_handler(PEXCEPTION_RECORD rec, void *frame, void *ctx, void *dispatch)
static long g_pagesize = 0;
if (! g_pagesize) {
SYSTEM_INFO system_info;
GetSystemInfo (&system_info);
g_pagesize = system_info.dwPageSize;
}
return g_pagesize;
}
static void exception_handler(PEXCEPTION_RECORD rec, void *frame, void *ctx, void *dispatch)
{ {
memory_protection_error((void*)rec->ExceptionInformation[1], SIGSEGV); memory_protection_error((void*)rec->ExceptionInformation[1], SIGSEGV);
return -1; /* unreachable */
} }
void platform_run(void) void platform_run(void)
{ {
seh_call(run_toplevel, (exception_handler_t*) exception_handler); seh_call(run_toplevel, exception_handler);
}
const char *default_image_path(void)
{
return "factor.image";
} }