]> gitweb.factorcode.org Git - factor.git/commitdiff
removed some error vm-> functions
authorPhil Dawes <phil@phildawes.net>
Sun, 23 Aug 2009 20:39:17 +0000 (21:39 +0100)
committerPhil Dawes <phil@phildawes.net>
Wed, 16 Sep 2009 07:17:27 +0000 (08:17 +0100)
vm/errors.cpp
vm/errors.hpp
vm/mach_signal.cpp
vm/os-linux-arm.cpp
vm/os-linux.cpp
vm/os-unix.cpp
vm/os-windows-ce.cpp
vm/vm.hpp

index e1266cf60892f70dc881c34f83ad913a4a86142e..09b397dd0230b7a6aa2f3a1ab3dd10ee1d32a900 100755 (executable)
@@ -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);
index 69a90b70e28917988cabee9b8fc53a54ecfbe697..cc85cfd0a87e93795888e9478505a1c54c36bd96 100755 (executable)
@@ -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);
 
index df5d78d35ee99f70638188a1f3ca51b06d32749e..7b050f72dccb0ce2aabf39f2b60f6b03c00577ea 100644 (file)
@@ -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);
 }
 
 }
index 8e131b9011b8df4ef4573c7a7598931689a6c4c1..9a9ce7ada5ab728f20bb1087c15036368860f0e5 100644 (file)
@@ -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);
 }
 
 }
index 62deb70f01e5dd75d8f42c913b46f05525935557..c21f8142a1f5d5b5ed7cc22bd2287bb17774f23e 100644 (file)
@@ -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;
 }
 
index c96addb6f4bb29184dbe7ddc33be20adf14848a5..3cb72959962bfef2483b35a015942add1a4bc44c 100644 (file)
@@ -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);
        }
 }
 
index a3192b07f5fc9ebb3f0c276d40995c47db0201fd..6454535f430beb6c99c5e9219140dbe026cf59b0 100644 (file)
@@ -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)
index 1b0274e0b17d34d78127d680bf48169dad26ff79..50006d012adaaa7cf6de97e694063173b33dc3bf 100644 (file)
--- 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