fixed up linux64 bootstrap (single threaded)
parent
aa005c948f
commit
6ddd3c654e
|
@ -213,7 +213,7 @@ void factorvm::factor_sleep(long us)
|
||||||
|
|
||||||
void factorvm::start_standalone_factor(int argc, vm_char **argv)
|
void factorvm::start_standalone_factor(int argc, vm_char **argv)
|
||||||
{
|
{
|
||||||
register_vm(GetCurrentThreadId(),this);
|
register_vm(thread_id(),this);
|
||||||
vm_parameters p;
|
vm_parameters p;
|
||||||
default_parameters(&p);
|
default_parameters(&p);
|
||||||
init_parameters_from_args(&p,argc,argv);
|
init_parameters_from_args(&p,argc,argv);
|
||||||
|
@ -247,8 +247,7 @@ VM_C_API void *start_standalone_factor_in_new_thread(int argc, vm_char **argv)
|
||||||
{
|
{
|
||||||
startargs *args = new startargs; // leaks startargs structure
|
startargs *args = new startargs; // leaks startargs structure
|
||||||
args->argc = argc; args->argv = argv;
|
args->argc = argc; args->argv = argv;
|
||||||
void *handle = start_thread(start_standalone_factor_thread,args);
|
return start_thread(start_standalone_factor_thread,args);
|
||||||
return handle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,7 +215,7 @@ void mach_initialize ()
|
||||||
mask = EXC_MASK_BAD_ACCESS | EXC_MASK_ARITHMETIC;
|
mask = EXC_MASK_BAD_ACCESS | EXC_MASK_ARITHMETIC;
|
||||||
|
|
||||||
/* Create the thread listening on the exception port. */
|
/* Create the thread listening on the exception port. */
|
||||||
start_thread(mach_exception_thread);
|
start_thread(mach_exception_thread,NULL);
|
||||||
|
|
||||||
/* Replace the exception port info for these exceptions with our own.
|
/* Replace the exception port info for these exceptions with our own.
|
||||||
Note that we replace the exception port for the entire task, not only
|
Note that we replace the exception port for the entire task, not only
|
||||||
|
|
|
@ -3,18 +3,18 @@
|
||||||
namespace factor
|
namespace factor
|
||||||
{
|
{
|
||||||
|
|
||||||
void start_thread(void *(*start_routine)(void *))
|
void *start_thread(void *(*start_routine)(void *),void *args)
|
||||||
{
|
{
|
||||||
pthread_attr_t attr;
|
pthread_attr_t attr;
|
||||||
pthread_t thread;
|
pthread_t thread;
|
||||||
|
|
||||||
if (pthread_attr_init (&attr) != 0)
|
if (pthread_attr_init (&attr) != 0)
|
||||||
vm->fatal_error("pthread_attr_init() failed",0);
|
vm->fatal_error("pthread_attr_init() failed",0);
|
||||||
if (pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED) != 0)
|
if (pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED) != 0)
|
||||||
vm->fatal_error("pthread_attr_setdetachstate() failed",0);
|
vm->fatal_error("pthread_attr_setdetachstate() failed",0);
|
||||||
if (pthread_create (&thread, &attr, start_routine, NULL) != 0)
|
if (pthread_create (&thread, &attr, start_routine, args) != 0)
|
||||||
vm->fatal_error("pthread_create() failed",0);
|
vm->fatal_error("pthread_create() failed",0);
|
||||||
pthread_attr_destroy (&attr);
|
pthread_attr_destroy (&attr);
|
||||||
|
return (void*)thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *null_dll;
|
static void *null_dll;
|
||||||
|
@ -55,13 +55,24 @@ void ffi_dlclose(dll *dll)
|
||||||
dll->dll = NULL;
|
dll->dll = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRIMITIVE(existsp)
|
|
||||||
|
long factorvm::thread_id(){
|
||||||
|
return 0; // TODO fix me
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void factorvm::vmprim_existsp()
|
||||||
{
|
{
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
char *path = (char *)(vm->untag_check<byte_array>(dpop()) + 1);
|
char *path = (char *)(vm->untag_check<byte_array>(dpop()) + 1);
|
||||||
box_boolean(stat(path,&sb) >= 0);
|
box_boolean(stat(path,&sb) >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PRIMITIVE(existsp)
|
||||||
|
{
|
||||||
|
PRIMITIVE_GETVM()->vmprim_existsp();
|
||||||
|
}
|
||||||
|
|
||||||
segment *alloc_segment(cell size)
|
segment *alloc_segment(cell size)
|
||||||
{
|
{
|
||||||
int pagesize = getpagesize();
|
int pagesize = getpagesize();
|
||||||
|
@ -320,7 +331,7 @@ void open_console()
|
||||||
stdin_read = filedes[0];
|
stdin_read = filedes[0];
|
||||||
stdin_write = filedes[1];
|
stdin_write = filedes[1];
|
||||||
|
|
||||||
start_thread(stdin_loop);
|
start_thread(stdin_loop,NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
VM_C_API void wait_for_stdin()
|
VM_C_API void wait_for_stdin()
|
||||||
|
|
|
@ -42,7 +42,7 @@ typedef char symbol_char;
|
||||||
|
|
||||||
#define print_native_string(string) print_string(string)
|
#define print_native_string(string) print_string(string)
|
||||||
|
|
||||||
void start_thread(void *(*start_routine)(void *));
|
void *start_thread(void *(*start_routine)(void *),void *args);
|
||||||
|
|
||||||
void init_ffi();
|
void init_ffi();
|
||||||
void ffi_dlopen(dll *dll);
|
void ffi_dlopen(dll *dll);
|
||||||
|
|
|
@ -7,6 +7,10 @@ void *start_thread(void *(*start_routine)(void *),void *args){
|
||||||
return CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)start_routine, args, 0, 0);
|
return CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)start_routine, args, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long factorvm::thread_id(){
|
||||||
|
return GetCurrentThreadId();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
s64 factorvm::current_micros()
|
s64 factorvm::current_micros()
|
||||||
{
|
{
|
||||||
|
|
|
@ -670,6 +670,12 @@ struct factorvm {
|
||||||
cell read_cell_hex();
|
cell read_cell_hex();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// os-*
|
||||||
|
inline void vmprim_existsp();
|
||||||
|
long thread_id();
|
||||||
|
|
||||||
// os-windows
|
// os-windows
|
||||||
#if defined(WINDOWS)
|
#if defined(WINDOWS)
|
||||||
void init_ffi();
|
void init_ffi();
|
||||||
|
@ -681,7 +687,6 @@ struct factorvm {
|
||||||
void dealloc_segment(segment *block);
|
void dealloc_segment(segment *block);
|
||||||
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();
|
|
||||||
const vm_char *default_image_path();
|
const vm_char *default_image_path();
|
||||||
void windows_image_path(vm_char *full_path, vm_char *temp_path, unsigned int length);
|
void windows_image_path(vm_char *full_path, vm_char *temp_path, unsigned int length);
|
||||||
bool windows_stat(vm_char *path);
|
bool windows_stat(vm_char *path);
|
||||||
|
@ -692,6 +697,7 @@ struct factorvm {
|
||||||
void open_console();
|
void open_console();
|
||||||
// next method here:
|
// next method here:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue