removed some error vm-> functions
parent
bbdcabae9c
commit
38eb7a23f1
|
@ -17,11 +17,6 @@ void factorvm::out_of_memory()
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void out_of_memory()
|
|
||||||
{
|
|
||||||
return vm->out_of_memory();
|
|
||||||
}
|
|
||||||
|
|
||||||
void factorvm::fatal_error(const char* msg, cell tagged)
|
void factorvm::fatal_error(const char* msg, cell tagged)
|
||||||
{
|
{
|
||||||
print_string("fatal_error: "); print_string(msg);
|
print_string("fatal_error: "); print_string(msg);
|
||||||
|
@ -29,11 +24,6 @@ void factorvm::fatal_error(const char* msg, cell tagged)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fatal_error(const char* msg, cell tagged)
|
|
||||||
{
|
|
||||||
return vm->fatal_error(msg,tagged);
|
|
||||||
}
|
|
||||||
|
|
||||||
void factorvm::critical_error(const char* msg, cell tagged)
|
void factorvm::critical_error(const char* msg, cell tagged)
|
||||||
{
|
{
|
||||||
print_string("You have triggered a bug in Factor. Please report.\n");
|
print_string("You have triggered a bug in Factor. Please report.\n");
|
||||||
|
@ -42,11 +32,6 @@ void factorvm::critical_error(const char* msg, cell tagged)
|
||||||
factorbug();
|
factorbug();
|
||||||
}
|
}
|
||||||
|
|
||||||
void critical_error(const char* msg, cell tagged)
|
|
||||||
{
|
|
||||||
return vm->critical_error(msg,tagged);
|
|
||||||
}
|
|
||||||
|
|
||||||
void factorvm::throw_error(cell error, stack_frame *callstack_top)
|
void factorvm::throw_error(cell error, stack_frame *callstack_top)
|
||||||
{
|
{
|
||||||
/* If the error handler is set, we rewind any C stack frames and
|
/* If the error handler is set, we rewind any C stack frames and
|
||||||
|
@ -98,10 +83,6 @@ void factorvm::general_error(vm_error_type error, cell arg1, cell arg2, stack_fr
|
||||||
tag_fixnum(error),arg1,arg2),callstack_top);
|
tag_fixnum(error),arg1,arg2),callstack_top);
|
||||||
}
|
}
|
||||||
|
|
||||||
void general_error(vm_error_type error, cell arg1, cell arg2, stack_frame *callstack_top)
|
|
||||||
{
|
|
||||||
return vm->general_error(error,arg1,arg2,callstack_top);
|
|
||||||
}
|
|
||||||
|
|
||||||
void factorvm::type_error(cell type, cell tagged)
|
void factorvm::type_error(cell type, cell tagged)
|
||||||
{
|
{
|
||||||
|
@ -113,10 +94,6 @@ void factorvm::not_implemented_error()
|
||||||
general_error(ERROR_NOT_IMPLEMENTED,F,F,NULL);
|
general_error(ERROR_NOT_IMPLEMENTED,F,F,NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void not_implemented_error()
|
|
||||||
{
|
|
||||||
return vm->not_implemented_error();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Test if 'fault' is in the guard page at the top or bottom (depending on
|
/* Test if 'fault' is in the guard page at the top or bottom (depending on
|
||||||
offset being 0 or -1) of area+area_size */
|
offset being 0 or -1) of area+area_size */
|
||||||
|
@ -155,11 +132,6 @@ void factorvm::divide_by_zero_error()
|
||||||
general_error(ERROR_DIVIDE_BY_ZERO,F,F,NULL);
|
general_error(ERROR_DIVIDE_BY_ZERO,F,F,NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void divide_by_zero_error()
|
|
||||||
{
|
|
||||||
return vm->divide_by_zero_error();
|
|
||||||
}
|
|
||||||
|
|
||||||
void factorvm::fp_trap_error(unsigned int fpu_status, stack_frame *signal_callstack_top)
|
void factorvm::fp_trap_error(unsigned int fpu_status, stack_frame *signal_callstack_top)
|
||||||
{
|
{
|
||||||
general_error(ERROR_FP_TRAP,tag_fixnum(fpu_status),F,signal_callstack_top);
|
general_error(ERROR_FP_TRAP,tag_fixnum(fpu_status),F,signal_callstack_top);
|
||||||
|
|
|
@ -23,16 +23,7 @@ enum vm_error_type
|
||||||
ERROR_FP_TRAP,
|
ERROR_FP_TRAP,
|
||||||
};
|
};
|
||||||
|
|
||||||
void out_of_memory();
|
|
||||||
void fatal_error(const char* msg, cell tagged);
|
|
||||||
void critical_error(const char* msg, cell tagged);
|
|
||||||
|
|
||||||
PRIMITIVE(die);
|
PRIMITIVE(die);
|
||||||
|
|
||||||
void general_error(vm_error_type error, cell arg1, cell arg2, stack_frame *native_stack);
|
|
||||||
void not_implemented_error();
|
|
||||||
void fp_trap_error(unsigned int fpu_status, stack_frame *signal_callstack_top);
|
|
||||||
|
|
||||||
PRIMITIVE(call_clear);
|
PRIMITIVE(call_clear);
|
||||||
PRIMITIVE(unimplemented);
|
PRIMITIVE(unimplemented);
|
||||||
|
|
||||||
|
|
|
@ -203,13 +203,13 @@ void mach_initialize ()
|
||||||
/* Allocate a port on which the thread shall listen for exceptions. */
|
/* Allocate a port on which the thread shall listen for exceptions. */
|
||||||
if (mach_port_allocate (self, MACH_PORT_RIGHT_RECEIVE, &our_exception_port)
|
if (mach_port_allocate (self, MACH_PORT_RIGHT_RECEIVE, &our_exception_port)
|
||||||
!= KERN_SUCCESS)
|
!= KERN_SUCCESS)
|
||||||
fatal_error("mach_port_allocate() failed",0);
|
vm->fatal_error("mach_port_allocate() failed",0);
|
||||||
|
|
||||||
/* See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/mach_port_insert_right.html. */
|
/* See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/mach_port_insert_right.html. */
|
||||||
if (mach_port_insert_right (self, our_exception_port, our_exception_port,
|
if (mach_port_insert_right (self, our_exception_port, our_exception_port,
|
||||||
MACH_MSG_TYPE_MAKE_SEND)
|
MACH_MSG_TYPE_MAKE_SEND)
|
||||||
!= KERN_SUCCESS)
|
!= KERN_SUCCESS)
|
||||||
fatal_error("mach_port_insert_right() failed",0);
|
vm->fatal_error("mach_port_insert_right() failed",0);
|
||||||
|
|
||||||
/* The exceptions we want to catch. */
|
/* The exceptions we want to catch. */
|
||||||
mask = EXC_MASK_BAD_ACCESS | EXC_MASK_ARITHMETIC;
|
mask = EXC_MASK_BAD_ACCESS | EXC_MASK_ARITHMETIC;
|
||||||
|
@ -226,7 +226,7 @@ void mach_initialize ()
|
||||||
if (task_set_exception_ports (self, mask, our_exception_port,
|
if (task_set_exception_ports (self, mask, our_exception_port,
|
||||||
EXCEPTION_DEFAULT, MACHINE_THREAD_STATE)
|
EXCEPTION_DEFAULT, MACHINE_THREAD_STATE)
|
||||||
!= KERN_SUCCESS)
|
!= KERN_SUCCESS)
|
||||||
fatal_error("task_set_exception_ports() failed",0);
|
vm->fatal_error("task_set_exception_ports() failed",0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ void flush_icache(cell start, cell len)
|
||||||
: "r0","r1","r2");
|
: "r0","r1","r2");
|
||||||
|
|
||||||
if(result < 0)
|
if(result < 0)
|
||||||
critical_error("flush_icache() failed",result);
|
vm->critical_error("flush_icache() failed",result);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ const char *vm_executable_path()
|
||||||
int size = readlink("/proc/self/exe", path, PATH_MAX);
|
int size = readlink("/proc/self/exe", path, PATH_MAX);
|
||||||
if (size < 0)
|
if (size < 0)
|
||||||
{
|
{
|
||||||
fatal_error("Cannot read /proc/self/exe",0);
|
vm->fatal_error("Cannot read /proc/self/exe",0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -42,19 +42,19 @@ VM_C_API int inotify_rm_watch(int fd, u32 wd)
|
||||||
|
|
||||||
VM_C_API int inotify_init()
|
VM_C_API int inotify_init()
|
||||||
{
|
{
|
||||||
not_implemented_error();
|
vm->not_implemented_error();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
VM_C_API int inotify_add_watch(int fd, const char *name, u32 mask)
|
VM_C_API int inotify_add_watch(int fd, const char *name, u32 mask)
|
||||||
{
|
{
|
||||||
not_implemented_error();
|
vm->not_implemented_error();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
VM_C_API int inotify_rm_watch(int fd, u32 wd)
|
VM_C_API int inotify_rm_watch(int fd, u32 wd)
|
||||||
{
|
{
|
||||||
not_implemented_error();
|
vm->not_implemented_error();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,11 @@ void start_thread(void *(*start_routine)(void *))
|
||||||
pthread_t thread;
|
pthread_t thread;
|
||||||
|
|
||||||
if (pthread_attr_init (&attr) != 0)
|
if (pthread_attr_init (&attr) != 0)
|
||||||
fatal_error("pthread_attr_init() failed",0);
|
vm->fatal_error("pthread_attr_init() failed",0);
|
||||||
if (pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED) != 0)
|
if (pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED) != 0)
|
||||||
fatal_error("pthread_attr_setdetachstate() failed",0);
|
vm->fatal_error("pthread_attr_setdetachstate() failed",0);
|
||||||
if (pthread_create (&thread, &attr, start_routine, NULL) != 0)
|
if (pthread_create (&thread, &attr, start_routine, NULL) != 0)
|
||||||
fatal_error("pthread_create() failed",0);
|
vm->fatal_error("pthread_create() failed",0);
|
||||||
pthread_attr_destroy (&attr);
|
pthread_attr_destroy (&attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ void *ffi_dlsym(dll *dll, symbol_char *symbol)
|
||||||
void ffi_dlclose(dll *dll)
|
void ffi_dlclose(dll *dll)
|
||||||
{
|
{
|
||||||
if(dlclose(dll->dll))
|
if(dlclose(dll->dll))
|
||||||
general_error(ERROR_FFI,F,F,NULL);
|
vm->general_error(ERROR_FFI,F,F,NULL);
|
||||||
dll->dll = NULL;
|
dll->dll = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,13 +71,13 @@ segment *alloc_segment(cell size)
|
||||||
MAP_ANON | MAP_PRIVATE,-1,0);
|
MAP_ANON | MAP_PRIVATE,-1,0);
|
||||||
|
|
||||||
if(array == (char*)-1)
|
if(array == (char*)-1)
|
||||||
out_of_memory();
|
vm->out_of_memory();
|
||||||
|
|
||||||
if(mprotect(array,pagesize,PROT_NONE) == -1)
|
if(mprotect(array,pagesize,PROT_NONE) == -1)
|
||||||
fatal_error("Cannot protect low guard page",(cell)array);
|
vm->fatal_error("Cannot protect low guard page",(cell)array);
|
||||||
|
|
||||||
if(mprotect(array + pagesize + size,pagesize,PROT_NONE) == -1)
|
if(mprotect(array + pagesize + size,pagesize,PROT_NONE) == -1)
|
||||||
fatal_error("Cannot protect high guard page",(cell)array);
|
vm->fatal_error("Cannot protect high guard page",(cell)array);
|
||||||
|
|
||||||
segment *retval = (segment *)vm->safe_malloc(sizeof(segment));
|
segment *retval = (segment *)vm->safe_malloc(sizeof(segment));
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ void dealloc_segment(segment *block)
|
||||||
pagesize + block->size + pagesize);
|
pagesize + block->size + pagesize);
|
||||||
|
|
||||||
if(retval)
|
if(retval)
|
||||||
fatal_error("dealloc_segment failed",0);
|
vm->fatal_error("dealloc_segment failed",0);
|
||||||
|
|
||||||
free(block);
|
free(block);
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ static stack_frame *uap_stack_pointer(void *uap)
|
||||||
{
|
{
|
||||||
stack_frame *ptr = (stack_frame *)ucontext_stack_pointer(uap);
|
stack_frame *ptr = (stack_frame *)ucontext_stack_pointer(uap);
|
||||||
if(!ptr)
|
if(!ptr)
|
||||||
critical_error("Invalid uap",(cell)uap);
|
vm->critical_error("Invalid uap",(cell)uap);
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -154,7 +154,7 @@ static void sigaction_safe(int signum, const struct sigaction *act, struct sigac
|
||||||
while(ret == -1 && errno == EINTR);
|
while(ret == -1 && errno == EINTR);
|
||||||
|
|
||||||
if(ret == -1)
|
if(ret == -1)
|
||||||
fatal_error("sigaction failed", 0);
|
vm->fatal_error("sigaction failed", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void unix_init_signals()
|
void unix_init_signals()
|
||||||
|
@ -216,7 +216,7 @@ extern "C" {
|
||||||
void safe_close(int fd)
|
void safe_close(int fd)
|
||||||
{
|
{
|
||||||
if(close(fd) < 0)
|
if(close(fd) < 0)
|
||||||
fatal_error("error closing fd",errno);
|
vm->fatal_error("error closing fd",errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool check_write(int fd, void *data, ssize_t size)
|
bool check_write(int fd, void *data, ssize_t size)
|
||||||
|
@ -235,7 +235,7 @@ bool check_write(int fd, void *data, ssize_t size)
|
||||||
void safe_write(int fd, void *data, ssize_t size)
|
void safe_write(int fd, void *data, ssize_t size)
|
||||||
{
|
{
|
||||||
if(!check_write(fd,data,size))
|
if(!check_write(fd,data,size))
|
||||||
fatal_error("error writing fd",errno);
|
vm->fatal_error("error writing fd",errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool safe_read(int fd, void *data, ssize_t size)
|
bool safe_read(int fd, void *data, ssize_t size)
|
||||||
|
@ -247,7 +247,7 @@ bool safe_read(int fd, void *data, ssize_t size)
|
||||||
return safe_read(fd,data,size);
|
return safe_read(fd,data,size);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fatal_error("error reading fd",errno);
|
vm->fatal_error("error reading fd",errno);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -266,7 +266,7 @@ void *stdin_loop(void *arg)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if(buf[0] != 'X')
|
if(buf[0] != 'X')
|
||||||
fatal_error("stdin_loop: bad data on control fd",buf[0]);
|
vm->fatal_error("stdin_loop: bad data on control fd",buf[0]);
|
||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
|
@ -303,19 +303,19 @@ void open_console()
|
||||||
int filedes[2];
|
int filedes[2];
|
||||||
|
|
||||||
if(pipe(filedes) < 0)
|
if(pipe(filedes) < 0)
|
||||||
fatal_error("Error opening control pipe",errno);
|
vm->fatal_error("Error opening control pipe",errno);
|
||||||
|
|
||||||
control_read = filedes[0];
|
control_read = filedes[0];
|
||||||
control_write = filedes[1];
|
control_write = filedes[1];
|
||||||
|
|
||||||
if(pipe(filedes) < 0)
|
if(pipe(filedes) < 0)
|
||||||
fatal_error("Error opening size pipe",errno);
|
vm->fatal_error("Error opening size pipe",errno);
|
||||||
|
|
||||||
size_read = filedes[0];
|
size_read = filedes[0];
|
||||||
size_write = filedes[1];
|
size_write = filedes[1];
|
||||||
|
|
||||||
if(pipe(filedes) < 0)
|
if(pipe(filedes) < 0)
|
||||||
fatal_error("Error opening stdin pipe",errno);
|
vm->fatal_error("Error opening stdin pipe",errno);
|
||||||
|
|
||||||
stdin_read = filedes[0];
|
stdin_read = filedes[0];
|
||||||
stdin_write = filedes[1];
|
stdin_write = filedes[1];
|
||||||
|
@ -330,7 +330,7 @@ VM_C_API void wait_for_stdin()
|
||||||
if(errno == EINTR)
|
if(errno == EINTR)
|
||||||
wait_for_stdin();
|
wait_for_stdin();
|
||||||
else
|
else
|
||||||
fatal_error("Error writing control fd",errno);
|
vm->fatal_error("Error writing control fd",errno);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,13 +26,13 @@ void flush_icache(cell start, cell end)
|
||||||
|
|
||||||
char *getenv(char *name)
|
char *getenv(char *name)
|
||||||
{
|
{
|
||||||
not_implemented_error();
|
vm->not_implemented_error();
|
||||||
return 0; /* unreachable */
|
return 0; /* unreachable */
|
||||||
}
|
}
|
||||||
|
|
||||||
PRIMITIVE(os_envs)
|
PRIMITIVE(os_envs)
|
||||||
{
|
{
|
||||||
not_implemented_error();
|
vm->not_implemented_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
void c_to_factor_toplevel(cell quot)
|
void c_to_factor_toplevel(cell quot)
|
||||||
|
|
|
@ -68,14 +68,14 @@ struct factorvm {
|
||||||
void memory_protection_error(cell addr, stack_frame *native_stack);
|
void memory_protection_error(cell addr, stack_frame *native_stack);
|
||||||
void signal_error(int signal, stack_frame *native_stack);
|
void signal_error(int signal, stack_frame *native_stack);
|
||||||
void divide_by_zero_error();
|
void divide_by_zero_error();
|
||||||
void fp_trap_error(stack_frame *signal_callstack_top);
|
void fp_trap_error(unsigned int fpu_status, stack_frame *signal_callstack_top);
|
||||||
inline void vmprim_call_clear();
|
inline void vmprim_call_clear();
|
||||||
inline void vmprim_unimplemented();
|
inline void vmprim_unimplemented();
|
||||||
void memory_signal_handler_impl();
|
void memory_signal_handler_impl();
|
||||||
void misc_signal_handler_impl();
|
void misc_signal_handler_impl();
|
||||||
void fp_signal_handler_impl();
|
void fp_signal_handler_impl();
|
||||||
void type_error(cell type, cell tagged);
|
void type_error(cell type, cell tagged);
|
||||||
void general_error(vm_error_type error, cell arg1, cell arg2, stack_frame *callstack_top);
|
void general_error(vm_error_type error, cell arg1, cell arg2, stack_frame *native_stack);
|
||||||
|
|
||||||
//callstack
|
//callstack
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue