win32 main starts factorvm in new thread
parent
5c2a28173a
commit
aa005c948f
|
@ -170,8 +170,9 @@ void factorvm::pass_args_to_factor(int argc, vm_char **argv)
|
||||||
growable_array args(this);
|
growable_array args(this);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 1; i < argc; i++)
|
for(i = 1; i < argc; i++){
|
||||||
args.add(allot_alien(F,(cell)argv[i]));
|
args.add(allot_alien(F,(cell)argv[i]));
|
||||||
|
}
|
||||||
|
|
||||||
args.trim();
|
args.trim();
|
||||||
userenv[ARGS_ENV] = args.elements.value();
|
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)
|
void factorvm::start_standalone_factor(int argc, vm_char **argv)
|
||||||
{
|
{
|
||||||
//printf("thread id is %d\n",GetCurrentThreadId());fflush(stdout);
|
|
||||||
register_vm(GetCurrentThreadId(),this);
|
register_vm(GetCurrentThreadId(),this);
|
||||||
vm_parameters p;
|
vm_parameters p;
|
||||||
default_parameters(&p);
|
default_parameters(&p);
|
||||||
|
|
|
@ -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(int argc, vm_char **argv);
|
||||||
VM_C_API void *start_standalone_factor_in_new_thread(int argc, vm_char **argv);
|
VM_C_API void *start_standalone_factor_in_new_thread(int argc, vm_char **argv);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ s64 factorvm::current_micros()
|
||||||
|
|
||||||
FACTOR_STDCALL LONG exception_handler(PEXCEPTION_POINTERS pe)
|
FACTOR_STDCALL LONG exception_handler(PEXCEPTION_POINTERS pe)
|
||||||
{
|
{
|
||||||
//printf("exception handler %d\n",GetCurrentThreadId());fflush(stdout);
|
|
||||||
factorvm *myvm = lookup_vm(GetCurrentThreadId());
|
factorvm *myvm = lookup_vm(GetCurrentThreadId());
|
||||||
PEXCEPTION_RECORD e = (PEXCEPTION_RECORD)pe->ExceptionRecord;
|
PEXCEPTION_RECORD e = (PEXCEPTION_RECORD)pe->ExceptionRecord;
|
||||||
CONTEXT *c = (CONTEXT*)pe->ContextRecord;
|
CONTEXT *c = (CONTEXT*)pe->ContextRecord;
|
||||||
|
@ -64,12 +63,17 @@ FACTOR_STDCALL LONG exception_handler(PEXCEPTION_POINTERS pe)
|
||||||
return EXCEPTION_CONTINUE_EXECUTION;
|
return EXCEPTION_CONTINUE_EXECUTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool handler_added = 0;
|
||||||
|
|
||||||
void factorvm::c_to_factor_toplevel(cell quot)
|
void factorvm::c_to_factor_toplevel(cell quot)
|
||||||
{
|
{
|
||||||
if(!AddVectoredExceptionHandler(0, (PVECTORED_EXCEPTION_HANDLER)exception_handler))
|
if(!handler_added){
|
||||||
fatal_error("AddVectoredExceptionHandler failed", 0);
|
if(!AddVectoredExceptionHandler(0, (PVECTORED_EXCEPTION_HANDLER)exception_handler))
|
||||||
|
fatal_error("AddVectoredExceptionHandler failed", 0);
|
||||||
|
handler_added = 1;
|
||||||
|
}
|
||||||
c_to_factor(quot,this);
|
c_to_factor(quot,this);
|
||||||
RemoveVectoredExceptionHandler((void *)exception_handler);
|
RemoveVectoredExceptionHandler((void *)exception_handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void factorvm::open_console()
|
void factorvm::open_console()
|
||||||
|
|
Loading…
Reference in New Issue