vm: clean up windows ctrl-handler

db4
Joe Groff 2011-10-26 21:40:14 -07:00
parent c70a1004f8
commit 8e66c7abee
2 changed files with 2 additions and 11 deletions

View File

@ -23,10 +23,8 @@ void factor_vm::init_c_io()
void factor_vm::io_error() void factor_vm::io_error()
{ {
#ifndef WINCE
if(errno == EINTR) if(errno == EINTR)
return; return;
#endif
general_error(ERROR_IO,tag_fixnum(errno),false_object); general_error(ERROR_IO,tag_fixnum(errno),false_object);
} }
@ -50,7 +48,7 @@ int factor_vm::safe_fgetc(FILE *stream)
int c; int c;
for(;;) for(;;)
{ {
c = fgetc(stream); c = getc(stream);
if(c == EOF) if(c == EOF)
{ {
if(feof(stream)) if(feof(stream))
@ -89,7 +87,7 @@ void factor_vm::safe_fputc(int c, FILE *stream)
{ {
for(;;) for(;;)
{ {
if(fputc(c,stream) == EOF) if(putc(c,stream) == EOF)
io_error(); io_error();
else else
break; break;

View File

@ -287,15 +287,8 @@ static BOOL WINAPI ctrl_handler(DWORD dwCtrlType)
VM we can get. This will not be a good idea when we actually support native VM we can get. This will not be a good idea when we actually support native
threads. */ threads. */
assert(thread_vms.size() == 1); assert(thread_vms.size() == 1);
THREADHANDLE vm_thread = thread_vms.begin()->first;
factor_vm *vm = thread_vms.begin()->second; factor_vm *vm = thread_vms.begin()->second;
assert(SuspendThread(vm_thread) == 0);
std::cout << "handling ctrl-c" << std::endl;
vm->enqueue_safepoint_fep(); vm->enqueue_safepoint_fep();
MemoryBarrier();
assert(ResumeThread(vm_thread) == 1);
return TRUE; return TRUE;
} }
default: default: