From: Phil Dawes Date: Sun, 23 Aug 2009 20:39:17 +0000 (+0100) Subject: removed some error vm-> functions X-Git-Tag: 0.97~5502^2~2^2~48 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=20ef4200fb44f748e07bf3727ece63fec514144b removed some error vm-> functions --- diff --git a/vm/errors.cpp b/vm/errors.cpp index e1266cf608..09b397dd02 100755 --- a/vm/errors.cpp +++ b/vm/errors.cpp @@ -17,11 +17,6 @@ void factorvm::out_of_memory() exit(1); } -void out_of_memory() -{ - return vm->out_of_memory(); -} - void factorvm::fatal_error(const char* msg, cell tagged) { print_string("fatal_error: "); print_string(msg); @@ -29,11 +24,6 @@ void factorvm::fatal_error(const char* msg, cell tagged) 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) { 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(); } -void critical_error(const char* msg, cell tagged) -{ - return vm->critical_error(msg,tagged); -} - void factorvm::throw_error(cell error, stack_frame *callstack_top) { /* 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); } -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) { @@ -113,10 +94,6 @@ void factorvm::not_implemented_error() 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 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); } -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) { general_error(ERROR_FP_TRAP,tag_fixnum(fpu_status),F,signal_callstack_top); diff --git a/vm/errors.hpp b/vm/errors.hpp index 69a90b70e2..cc85cfd0a8 100755 --- a/vm/errors.hpp +++ b/vm/errors.hpp @@ -23,16 +23,7 @@ enum vm_error_type 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); - -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(unimplemented); diff --git a/vm/mach_signal.cpp b/vm/mach_signal.cpp index df5d78d35e..7b050f72dc 100644 --- a/vm/mach_signal.cpp +++ b/vm/mach_signal.cpp @@ -203,13 +203,13 @@ void mach_initialize () /* Allocate a port on which the thread shall listen for exceptions. */ if (mach_port_allocate (self, MACH_PORT_RIGHT_RECEIVE, &our_exception_port) != 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. */ if (mach_port_insert_right (self, our_exception_port, our_exception_port, MACH_MSG_TYPE_MAKE_SEND) != 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. */ 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, EXCEPTION_DEFAULT, MACHINE_THREAD_STATE) != KERN_SUCCESS) - fatal_error("task_set_exception_ports() failed",0); + vm->fatal_error("task_set_exception_ports() failed",0); } } diff --git a/vm/os-linux-arm.cpp b/vm/os-linux-arm.cpp index 8e131b9011..9a9ce7ada5 100644 --- a/vm/os-linux-arm.cpp +++ b/vm/os-linux-arm.cpp @@ -25,7 +25,7 @@ void flush_icache(cell start, cell len) : "r0","r1","r2"); if(result < 0) - critical_error("flush_icache() failed",result); + vm->critical_error("flush_icache() failed",result); } } diff --git a/vm/os-linux.cpp b/vm/os-linux.cpp index 62deb70f01..c21f8142a1 100644 --- a/vm/os-linux.cpp +++ b/vm/os-linux.cpp @@ -11,7 +11,7 @@ const char *vm_executable_path() int size = readlink("/proc/self/exe", path, PATH_MAX); if (size < 0) { - fatal_error("Cannot read /proc/self/exe",0); + vm->fatal_error("Cannot read /proc/self/exe",0); return NULL; } else @@ -42,19 +42,19 @@ VM_C_API int inotify_rm_watch(int fd, u32 wd) VM_C_API int inotify_init() { - not_implemented_error(); + vm->not_implemented_error(); return -1; } VM_C_API int inotify_add_watch(int fd, const char *name, u32 mask) { - not_implemented_error(); + vm->not_implemented_error(); return -1; } VM_C_API int inotify_rm_watch(int fd, u32 wd) { - not_implemented_error(); + vm->not_implemented_error(); return -1; } diff --git a/vm/os-unix.cpp b/vm/os-unix.cpp index c96addb6f4..3cb7295996 100644 --- a/vm/os-unix.cpp +++ b/vm/os-unix.cpp @@ -9,11 +9,11 @@ void start_thread(void *(*start_routine)(void *)) pthread_t thread; 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) - fatal_error("pthread_attr_setdetachstate() failed",0); + vm->fatal_error("pthread_attr_setdetachstate() failed",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); } @@ -51,7 +51,7 @@ void *ffi_dlsym(dll *dll, symbol_char *symbol) void ffi_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; } @@ -71,13 +71,13 @@ segment *alloc_segment(cell size) MAP_ANON | MAP_PRIVATE,-1,0); if(array == (char*)-1) - out_of_memory(); + vm->out_of_memory(); 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) - 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)); @@ -96,7 +96,7 @@ void dealloc_segment(segment *block) pagesize + block->size + pagesize); if(retval) - fatal_error("dealloc_segment failed",0); + vm->fatal_error("dealloc_segment failed",0); free(block); } @@ -111,7 +111,7 @@ static stack_frame *uap_stack_pointer(void *uap) { stack_frame *ptr = (stack_frame *)ucontext_stack_pointer(uap); if(!ptr) - critical_error("Invalid uap",(cell)uap); + vm->critical_error("Invalid uap",(cell)uap); return ptr; } else @@ -154,7 +154,7 @@ static void sigaction_safe(int signum, const struct sigaction *act, struct sigac while(ret == -1 && errno == EINTR); if(ret == -1) - fatal_error("sigaction failed", 0); + vm->fatal_error("sigaction failed", 0); } void unix_init_signals() @@ -216,7 +216,7 @@ extern "C" { void safe_close(int fd) { 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) @@ -235,7 +235,7 @@ bool check_write(int fd, void *data, ssize_t size) void safe_write(int fd, void *data, ssize_t 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) @@ -247,7 +247,7 @@ bool safe_read(int fd, void *data, ssize_t size) return safe_read(fd,data,size); else { - fatal_error("error reading fd",errno); + vm->fatal_error("error reading fd",errno); return false; } } @@ -266,7 +266,7 @@ void *stdin_loop(void *arg) break; 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(;;) { @@ -303,19 +303,19 @@ void open_console() int filedes[2]; if(pipe(filedes) < 0) - fatal_error("Error opening control pipe",errno); + vm->fatal_error("Error opening control pipe",errno); control_read = filedes[0]; control_write = filedes[1]; if(pipe(filedes) < 0) - fatal_error("Error opening size pipe",errno); + vm->fatal_error("Error opening size pipe",errno); size_read = filedes[0]; size_write = filedes[1]; if(pipe(filedes) < 0) - fatal_error("Error opening stdin pipe",errno); + vm->fatal_error("Error opening stdin pipe",errno); stdin_read = filedes[0]; stdin_write = filedes[1]; @@ -330,7 +330,7 @@ VM_C_API void wait_for_stdin() if(errno == EINTR) wait_for_stdin(); else - fatal_error("Error writing control fd",errno); + vm->fatal_error("Error writing control fd",errno); } } diff --git a/vm/os-windows-ce.cpp b/vm/os-windows-ce.cpp index a3192b07f5..6454535f43 100644 --- a/vm/os-windows-ce.cpp +++ b/vm/os-windows-ce.cpp @@ -26,13 +26,13 @@ void flush_icache(cell start, cell end) char *getenv(char *name) { - not_implemented_error(); + vm->not_implemented_error(); return 0; /* unreachable */ } PRIMITIVE(os_envs) { - not_implemented_error(); + vm->not_implemented_error(); } void c_to_factor_toplevel(cell quot) diff --git a/vm/vm.hpp b/vm/vm.hpp index 1b0274e0b1..50006d012a 100644 --- a/vm/vm.hpp +++ b/vm/vm.hpp @@ -68,14 +68,14 @@ struct factorvm { void memory_protection_error(cell addr, stack_frame *native_stack); void signal_error(int signal, stack_frame *native_stack); 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_unimplemented(); void memory_signal_handler_impl(); void misc_signal_handler_impl(); void fp_signal_handler_impl(); 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