From 12d596d1e65654fd3c57f9fb99b332be19ba8004 Mon Sep 17 00:00:00 2001 From: slava Date: Sun, 15 Oct 2006 04:10:54 +0000 Subject: [PATCH] Windows SEH fix --- vm/factor.c | 4 ++-- vm/os-genunix.c | 9 +++++++-- vm/os-macosx.m | 9 +++++++-- vm/os-windows.c | 9 +++++++-- vm/run.c | 12 ++++++------ vm/run.h | 5 +++-- 6 files changed, 32 insertions(+), 16 deletions(-) diff --git a/vm/factor.c b/vm/factor.c index 1eaff44595..d2e7eaa561 100644 --- a/vm/factor.c +++ b/vm/factor.c @@ -92,9 +92,9 @@ int main(int argc, char** argv) userenv[ARGS_ENV] = tag_object(args); - platform_run(); + run_toplevel(); - critical_error("run() returned due to empty callstack",0); + critical_error("run_toplevel() returned due to empty callstack",0); return 0; } diff --git a/vm/os-genunix.c b/vm/os-genunix.c index ac0811c605..1703515d82 100644 --- a/vm/os-genunix.c +++ b/vm/os-genunix.c @@ -1,8 +1,13 @@ #include "factor.h" -void platform_run(void) +void run(void) { - run_toplevel(); + interpreter(); +} + +void run_toplevel(void) +{ + run(); } const char *default_image_path(void) diff --git a/vm/os-macosx.m b/vm/os-macosx.m index 1f3c1af95b..159e405db5 100644 --- a/vm/os-macosx.m +++ b/vm/os-macosx.m @@ -11,7 +11,7 @@ static CELL error; /* This code is convoluted because Cocoa places restrictions on longjmp and exception handling. In particular, a longjmp can never cross an NS_DURING, NS_HANDLER or NS_ENDHANDLER. */ -void platform_run() +void run() { error = F; @@ -28,7 +28,7 @@ NS_DURING general_error(ERROR_OBJECTIVE_C,e,F,true); } - run(); + interpreter_loop(); NS_VOIDRETURN; NS_HANDLER error = tag_object(make_alien(F,(CELL)localException)); @@ -36,6 +36,11 @@ NS_ENDHANDLER } } +void run_toplevel(void) +{ + interpreter(); +} + void early_init(void) { [[NSAutoreleasePool alloc] init]; diff --git a/vm/os-windows.c b/vm/os-windows.c index 263dc1ff1f..08faa1e126 100644 --- a/vm/os-windows.c +++ b/vm/os-windows.c @@ -242,7 +242,12 @@ static long exception_handler(PEXCEPTION_RECORD rec, void *frame, void *ctx, voi return -1; /* unreachable */ } -void platform_run(void) +void run(void) { - seh_call(run_toplevel, exception_handler); + interpreter(); +} + +void run_toplevel(void) +{ + seh_call(run, exception_handler); } diff --git a/vm/run.c b/vm/run.c index fde495312e..b3ce9e19e7 100644 --- a/vm/run.c +++ b/vm/run.c @@ -34,7 +34,7 @@ void call(CELL quot) set_callframe(quot); } -/* Called from platform_run() */ +/* Called from interpreter() */ void handle_error(void) { if(throwing) @@ -55,7 +55,7 @@ void handle_error(void) } } -void run(void) +void interpreter_loop(void) { CELL next; @@ -91,18 +91,18 @@ void run(void) } } -void run_toplevel(void) +void interpreter(void) { SETJMP(stack_chain->toplevel); handle_error(); - run(); + interpreter_loop(); } /* Called by compiled callbacks after nest_stacks() and boxing registers */ void run_callback(CELL quot) { call(quot); - platform_run(); + run(); } /* XT of deferred words */ @@ -280,7 +280,7 @@ void throw_error(CELL error, bool keep_stacks) thrown_ds = ds; thrown_rs = rs; - /* Return to run() method */ + /* Return to interpreter() function */ LONGJMP(stack_chain->toplevel,1); } diff --git a/vm/run.h b/vm/run.h index b9fdcc710f..4f3093fa6c 100644 --- a/vm/run.h +++ b/vm/run.h @@ -101,10 +101,11 @@ INLINE CELL type_of(CELL tagged) void call(CELL quot); void handle_error(); +void interpreter_loop(void); +void interpreter(void); +DLLEXPORT void run_callback(CELL quot); void run(void); void run_toplevel(void); -DLLEXPORT void run_callback(CELL quot); -void platform_run(void); void undefined(F_WORD *word); void docol(F_WORD *word); void dosym(F_WORD *word); -- 2.34.1