removed vm ptrs from unix code (still in signal handlers tho)

db4
Phil Dawes 2009-08-25 08:35:22 +01:00
parent 784b8d16ae
commit 1456fb3c97
3 changed files with 17 additions and 17 deletions

View 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);

View File

@ -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();
}

View File

@ -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);