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)
|
||||
{
|
||||
register_vm(GetCurrentThreadId(),this);
|
||||
register_vm(thread_id(),this);
|
||||
vm_parameters p;
|
||||
default_parameters(&p);
|
||||
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
|
||||
args->argc = argc; args->argv = argv;
|
||||
void *handle = start_thread(start_standalone_factor_thread,args);
|
||||
return handle;
|
||||
return start_thread(start_standalone_factor_thread,args);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -215,7 +215,7 @@ void mach_initialize ()
|
|||
mask = EXC_MASK_BAD_ACCESS | EXC_MASK_ARITHMETIC;
|
||||
|
||||
/* 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.
|
||||
Note that we replace the exception port for the entire task, not only
|
||||
|
|
|
@ -3,18 +3,18 @@
|
|||
namespace factor
|
||||
{
|
||||
|
||||
void start_thread(void *(*start_routine)(void *))
|
||||
void *start_thread(void *(*start_routine)(void *),void *args)
|
||||
{
|
||||
pthread_attr_t attr;
|
||||
pthread_t thread;
|
||||
|
||||
if (pthread_attr_init (&attr) != 0)
|
||||
vm->fatal_error("pthread_attr_init() failed",0);
|
||||
if (pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED) != 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);
|
||||
pthread_attr_destroy (&attr);
|
||||
return (void*)thread;
|
||||
}
|
||||
|
||||
static void *null_dll;
|
||||
|
@ -55,13 +55,24 @@ void ffi_dlclose(dll *dll)
|
|||
dll->dll = NULL;
|
||||
}
|
||||
|
||||
PRIMITIVE(existsp)
|
||||
|
||||
long factorvm::thread_id(){
|
||||
return 0; // TODO fix me
|
||||
}
|
||||
|
||||
|
||||
inline void factorvm::vmprim_existsp()
|
||||
{
|
||||
struct stat sb;
|
||||
char *path = (char *)(vm->untag_check<byte_array>(dpop()) + 1);
|
||||
box_boolean(stat(path,&sb) >= 0);
|
||||
}
|
||||
|
||||
PRIMITIVE(existsp)
|
||||
{
|
||||
PRIMITIVE_GETVM()->vmprim_existsp();
|
||||
}
|
||||
|
||||
segment *alloc_segment(cell size)
|
||||
{
|
||||
int pagesize = getpagesize();
|
||||
|
@ -320,7 +331,7 @@ void open_console()
|
|||
stdin_read = filedes[0];
|
||||
stdin_write = filedes[1];
|
||||
|
||||
start_thread(stdin_loop);
|
||||
start_thread(stdin_loop,NULL);
|
||||
}
|
||||
|
||||
VM_C_API void wait_for_stdin()
|
||||
|
|
|
@ -42,7 +42,7 @@ typedef char symbol_char;
|
|||
|
||||
#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 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);
|
||||
}
|
||||
|
||||
long factorvm::thread_id(){
|
||||
return GetCurrentThreadId();
|
||||
}
|
||||
|
||||
|
||||
s64 factorvm::current_micros()
|
||||
{
|
||||
|
|
12
vm/vm.hpp
12
vm/vm.hpp
|
@ -669,6 +669,12 @@ struct factorvm {
|
|||
void print_fixnum(fixnum x);
|
||||
cell read_cell_hex();
|
||||
|
||||
|
||||
|
||||
|
||||
// os-*
|
||||
inline void vmprim_existsp();
|
||||
long thread_id();
|
||||
|
||||
// os-windows
|
||||
#if defined(WINDOWS)
|
||||
|
@ -681,17 +687,17 @@ struct factorvm {
|
|||
void dealloc_segment(segment *block);
|
||||
segment *alloc_segment(cell size);
|
||||
const vm_char *vm_executable_path();
|
||||
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);
|
||||
|
||||
|
||||
#if defined(WINNT)
|
||||
s64 current_micros();
|
||||
void c_to_factor_toplevel(cell quot);
|
||||
void open_console();
|
||||
// next method here:
|
||||
// next method here:
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue