]> gitweb.factorcode.org Git - factor.git/commitdiff
removed vm ptrs from unix code (still in signal handlers tho)
authorPhil Dawes <phil@phildawes.net>
Tue, 25 Aug 2009 07:35:22 +0000 (08:35 +0100)
committerPhil Dawes <phil@phildawes.net>
Wed, 16 Sep 2009 07:20:10 +0000 (08:20 +0100)
vm/os-unix.cpp
vm/os-windows-nt.cpp
vm/vm.hpp

index 832b93b39238b6d684c5466688f632edadf6c7de..ed007398a3e4e5289f2089c2731f398d8861874c 100644 (file)
@@ -31,40 +31,40 @@ void sleep_micros(cell usec)
        usleep(usec);
 }
 
-void init_ffi()
+void factorvm::init_ffi()
 {
        /* NULL_DLL is "libfactor.dylib" for OS X and NULL for generic unix */
        null_dll = dlopen(NULL_DLL,RTLD_LAZY);
 }
 
-void ffi_dlopen(dll *dll)
+void factorvm::ffi_dlopen(dll *dll)
 {
-       dll->dll = dlopen(alien_offset(dll->path,vm), RTLD_LAZY);
+       dll->dll = dlopen(alien_offset(dll->path), RTLD_LAZY);
 }
 
-void *ffi_dlsym(dll *dll, symbol_char *symbol)
+void *factorvm::ffi_dlsym(dll *dll, symbol_char *symbol)
 {
        void *handle = (dll == NULL ? null_dll : dll->dll);
        return dlsym(handle,symbol);
 }
 
-void ffi_dlclose(dll *dll)
+void factorvm::ffi_dlclose(dll *dll)
 {
        if(dlclose(dll->dll))
-               vm->general_error(ERROR_FFI,F,F,NULL);
+               general_error(ERROR_FFI,F,F,NULL);
        dll->dll = NULL;
 }
 
 
-long factorvm::thread_id(){
-       return 0;  // TODO fix me
+cell factorvm::thread_id(){
+       return pthread_self();
 }
 
 
 inline void factorvm::vmprim_existsp()
 {
        struct stat sb;
-       char *path = (char *)(vm->untag_check<byte_array>(dpop()) + 1);
+       char *path = (char *)(untag_check<byte_array>(dpop()) + 1);
        box_boolean(stat(path,&sb) >= 0);
 }
 
@@ -73,7 +73,7 @@ PRIMITIVE(existsp)
        PRIMITIVE_GETVM()->vmprim_existsp();
 }
 
-segment *alloc_segment(cell size)
+segment *factorvm::alloc_segment(cell size)
 {
        int pagesize = getpagesize();
 
@@ -82,7 +82,7 @@ segment *alloc_segment(cell size)
                MAP_ANON | MAP_PRIVATE,-1,0);
 
        if(array == (char*)-1)
-               vm->out_of_memory();
+               out_of_memory();
 
        if(mprotect(array,pagesize,PROT_NONE) == -1)
                fatal_error("Cannot protect low guard page",(cell)array);
index 6085d65670d47455b6d3141ddfd0c8e65fc90e87..630782a9463d7dd111e60ee30443fb10779c1a3d 100755 (executable)
@@ -7,7 +7,7 @@ void *start_thread(void *(*start_routine)(void *),void *args){
     return CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)start_routine, args, 0, 0); 
 }
 
-long factorvm::thread_id(){
+cell factorvm::thread_id(){
        return GetCurrentThreadId();
 }
 
index 0a0393700c7e66e2668e6d9af94cc40851f2a743..9af73e4c7ec311186e47f2a10900dbaa5a8b94af 100644 (file)
--- a/vm/vm.hpp
+++ b/vm/vm.hpp
@@ -659,18 +659,18 @@ struct factorvm {
 
        // os-*
        inline void vmprim_existsp();
-       long thread_id();
-
-       // os-windows
-  #if defined(WINDOWS)
+       cell thread_id();
        void init_ffi();
        void ffi_dlopen(dll *dll);
        void *ffi_dlsym(dll *dll, symbol_char *symbol);
        void ffi_dlclose(dll *dll);
+       segment *alloc_segment(cell size);
+
+       // os-windows
+  #if defined(WINDOWS)
        void sleep_micros(u64 usec);
        long getpagesize();
        void dealloc_segment(segment *block);
-       segment *alloc_segment(cell size);
        const vm_char *vm_executable_path();
        const vm_char *default_image_path();
        void windows_image_path(vm_char *full_path, vm_char *temp_path, unsigned int length);