win32 main starts factorvm in new thread

db4
Phil Dawes 2009-08-24 21:10:18 +01:00
parent 5c2a28173a
commit aa005c948f
3 changed files with 10 additions and 7 deletions

View File

@ -170,8 +170,9 @@ void factorvm::pass_args_to_factor(int argc, vm_char **argv)
growable_array args(this);
int i;
for(i = 1; i < argc; i++)
for(i = 1; i < argc; i++){
args.add(allot_alien(F,(cell)argv[i]));
}
args.trim();
userenv[ARGS_ENV] = args.elements.value();
@ -212,7 +213,6 @@ void factorvm::factor_sleep(long us)
void factorvm::start_standalone_factor(int argc, vm_char **argv)
{
//printf("thread id is %d\n",GetCurrentThreadId());fflush(stdout);
register_vm(GetCurrentThreadId(),this);
vm_parameters p;
default_parameters(&p);

View File

@ -3,5 +3,4 @@ namespace factor
VM_C_API void start_standalone_factor(int argc, vm_char **argv);
VM_C_API void *start_standalone_factor_in_new_thread(int argc, vm_char **argv);
}

View File

@ -18,7 +18,6 @@ s64 factorvm::current_micros()
FACTOR_STDCALL LONG exception_handler(PEXCEPTION_POINTERS pe)
{
//printf("exception handler %d\n",GetCurrentThreadId());fflush(stdout);
factorvm *myvm = lookup_vm(GetCurrentThreadId());
PEXCEPTION_RECORD e = (PEXCEPTION_RECORD)pe->ExceptionRecord;
CONTEXT *c = (CONTEXT*)pe->ContextRecord;
@ -64,12 +63,17 @@ FACTOR_STDCALL LONG exception_handler(PEXCEPTION_POINTERS pe)
return EXCEPTION_CONTINUE_EXECUTION;
}
bool handler_added = 0;
void factorvm::c_to_factor_toplevel(cell quot)
{
if(!AddVectoredExceptionHandler(0, (PVECTORED_EXCEPTION_HANDLER)exception_handler))
fatal_error("AddVectoredExceptionHandler failed", 0);
if(!handler_added){
if(!AddVectoredExceptionHandler(0, (PVECTORED_EXCEPTION_HANDLER)exception_handler))
fatal_error("AddVectoredExceptionHandler failed", 0);
handler_added = 1;
}
c_to_factor(quot,this);
RemoveVectoredExceptionHandler((void *)exception_handler);
RemoveVectoredExceptionHandler((void *)exception_handler);
}
void factorvm::open_console()