moved some os-windows functions into the vm
parent
3fef06d21d
commit
1431ae806f
|
|
@ -12,43 +12,23 @@ void factorvm::init_ffi()
|
||||||
fatal_error("GetModuleHandle(\"" FACTOR_DLL_NAME "\") failed", 0);
|
fatal_error("GetModuleHandle(\"" FACTOR_DLL_NAME "\") failed", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_ffi()
|
|
||||||
{
|
|
||||||
return vm->init_ffi();
|
|
||||||
}
|
|
||||||
|
|
||||||
void factorvm::ffi_dlopen(dll *dll)
|
void factorvm::ffi_dlopen(dll *dll)
|
||||||
{
|
{
|
||||||
dll->dll = LoadLibraryEx((WCHAR *)alien_offset(dll->path), NULL, 0);
|
dll->dll = LoadLibraryEx((WCHAR *)alien_offset(dll->path), NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ffi_dlopen(dll *dll)
|
|
||||||
{
|
|
||||||
return vm->ffi_dlopen(dll);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *factorvm::ffi_dlsym(dll *dll, symbol_char *symbol)
|
void *factorvm::ffi_dlsym(dll *dll, symbol_char *symbol)
|
||||||
{
|
{
|
||||||
return (void *)GetProcAddress(dll ? (HMODULE)dll->dll : hFactorDll, symbol);
|
return (void *)GetProcAddress(dll ? (HMODULE)dll->dll : hFactorDll, symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *ffi_dlsym(dll *dll, symbol_char *symbol)
|
|
||||||
{
|
|
||||||
return vm->ffi_dlsym(dll,symbol);
|
|
||||||
}
|
|
||||||
|
|
||||||
void factorvm::ffi_dlclose(dll *dll)
|
void factorvm::ffi_dlclose(dll *dll)
|
||||||
{
|
{
|
||||||
FreeLibrary((HMODULE)dll->dll);
|
FreeLibrary((HMODULE)dll->dll);
|
||||||
dll->dll = NULL;
|
dll->dll = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ffi_dlclose(dll *dll)
|
bool factorvm::windows_stat(vm_char *path)
|
||||||
{
|
|
||||||
return vm->ffi_dlclose(dll);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool windows_stat(vm_char *path)
|
|
||||||
{
|
{
|
||||||
BY_HANDLE_FILE_INFORMATION bhfi;
|
BY_HANDLE_FILE_INFORMATION bhfi;
|
||||||
HANDLE h = CreateFileW(path,
|
HANDLE h = CreateFileW(path,
|
||||||
|
|
@ -76,14 +56,15 @@ bool windows_stat(vm_char *path)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void windows_image_path(vm_char *full_path, vm_char *temp_path, unsigned int length)
|
|
||||||
|
void factorvm::windows_image_path(vm_char *full_path, vm_char *temp_path, unsigned int length)
|
||||||
{
|
{
|
||||||
snwprintf(temp_path, length-1, L"%s.image", full_path);
|
snwprintf(temp_path, length-1, L"%s.image", full_path);
|
||||||
temp_path[sizeof(temp_path) - 1] = 0;
|
temp_path[sizeof(temp_path) - 1] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* You must free() this yourself. */
|
/* You must free() this yourself. */
|
||||||
const vm_char *default_image_path()
|
const vm_char *factorvm::default_image_path()
|
||||||
{
|
{
|
||||||
vm_char full_path[MAX_UNICODE_PATH];
|
vm_char full_path[MAX_UNICODE_PATH];
|
||||||
vm_char *ptr;
|
vm_char *ptr;
|
||||||
|
|
@ -110,11 +91,6 @@ const vm_char *factorvm::vm_executable_path()
|
||||||
return safe_strdup(full_path);
|
return safe_strdup(full_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
const vm_char *vm_executable_path()
|
|
||||||
{
|
|
||||||
return vm->vm_executable_path();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline void factorvm::vmprim_existsp()
|
inline void factorvm::vmprim_existsp()
|
||||||
{
|
{
|
||||||
|
|
@ -152,11 +128,6 @@ segment *factorvm::alloc_segment(cell size)
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
segment *alloc_segment(cell size)
|
|
||||||
{
|
|
||||||
return vm->alloc_segment(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void factorvm::dealloc_segment(segment *block)
|
void factorvm::dealloc_segment(segment *block)
|
||||||
{
|
{
|
||||||
SYSTEM_INFO si;
|
SYSTEM_INFO si;
|
||||||
|
|
@ -166,11 +137,6 @@ void factorvm::dealloc_segment(segment *block)
|
||||||
free(block);
|
free(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dealloc_segment(segment *block)
|
|
||||||
{
|
|
||||||
return vm->dealloc_segment(block);
|
|
||||||
}
|
|
||||||
|
|
||||||
long factorvm::getpagesize()
|
long factorvm::getpagesize()
|
||||||
{
|
{
|
||||||
static long g_pagesize = 0;
|
static long g_pagesize = 0;
|
||||||
|
|
@ -183,19 +149,9 @@ long factorvm::getpagesize()
|
||||||
return g_pagesize;
|
return g_pagesize;
|
||||||
}
|
}
|
||||||
|
|
||||||
long getpagesize()
|
|
||||||
{
|
|
||||||
return vm->getpagesize();
|
|
||||||
}
|
|
||||||
|
|
||||||
void factorvm::sleep_micros(u64 usec)
|
void factorvm::sleep_micros(u64 usec)
|
||||||
{
|
{
|
||||||
Sleep((DWORD)(usec / 1000));
|
Sleep((DWORD)(usec / 1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
void sleep_micros(u64 usec)
|
|
||||||
{
|
|
||||||
return vm->sleep_micros(usec);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,18 +41,9 @@ typedef wchar_t vm_char;
|
||||||
/* Difference between Jan 1 00:00:00 1601 and Jan 1 00:00:00 1970 */
|
/* Difference between Jan 1 00:00:00 1601 and Jan 1 00:00:00 1970 */
|
||||||
#define EPOCH_OFFSET 0x019db1ded53e8000LL
|
#define EPOCH_OFFSET 0x019db1ded53e8000LL
|
||||||
|
|
||||||
void init_ffi();
|
|
||||||
void ffi_dlopen(dll *dll);
|
|
||||||
void *ffi_dlsym(dll *dll, symbol_char *symbol);
|
|
||||||
void ffi_dlclose(dll *dll);
|
|
||||||
|
|
||||||
void sleep_micros(u64 msec);
|
|
||||||
|
|
||||||
inline static void init_signals() {}
|
inline static void init_signals() {}
|
||||||
inline static void early_init() {}
|
inline static void early_init() {}
|
||||||
const vm_char *vm_executable_path();
|
|
||||||
const vm_char *default_image_path();
|
|
||||||
long getpagesize ();
|
|
||||||
|
|
||||||
s64 current_micros();
|
s64 current_micros();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -660,6 +660,9 @@ struct factorvm {
|
||||||
segment *alloc_segment(cell size);
|
segment *alloc_segment(cell size);
|
||||||
const vm_char *vm_executable_path();
|
const vm_char *vm_executable_path();
|
||||||
inline void vmprim_existsp();
|
inline void vmprim_existsp();
|
||||||
|
const vm_char *default_image_path();
|
||||||
|
void windows_image_path(vm_char *full_path, vm_char *temp_path, unsigned int length);
|
||||||
|
bool windows_stat(vm_char *path);
|
||||||
// next method here:
|
// next method here:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue