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);
}
PRIMITIVE_GETVM()->vmprim_existsp();
}
-segment *alloc_segment(cell size)
+segment *factorvm::alloc_segment(cell size)
{
int pagesize = getpagesize();
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);
// 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);