]> gitweb.factorcode.org Git - factor.git/commitdiff
fixed up linux64 bootstrap (single threaded)
authorPhil Dawes <phil@phildawes.net>
Tue, 25 Aug 2009 05:35:54 +0000 (06:35 +0100)
committerPhil Dawes <phil@phildawes.net>
Wed, 16 Sep 2009 07:20:09 +0000 (08:20 +0100)
vm/factor.cpp
vm/mach_signal.cpp
vm/os-unix.cpp
vm/os-unix.hpp
vm/os-windows-nt.cpp
vm/vm.hpp

index 77ad60bd474893540f3b161dd853f5aba88238d3..a241ccf86b18b75600805469419d429b8d252c18 100755 (executable)
@@ -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);
 }
 
 }
index ca3b7aa1617a252cc2097df5071783be238d7597..c1d263527df7213fe73f7c15c220a66ab938eafb 100644 (file)
@@ -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
index 97e1e0c04d0465854638c26331e96cd16d8a37a5..4de5ede70467a2481f545c4013ed80c313c6acff 100644 (file)
@@ -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()
index b7e528a4211dae8107ae1fa7372f15d19f76ad03..60beb88233b781768ae341511f0559b383607ebd 100644 (file)
@@ -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);
index c36c2f3f7eb912496a6665d50bcd18fa2f4d704e..6085d65670d47455b6d3141ddfd0c8e65fc90e87 100755 (executable)
@@ -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()
 {
index b3e40640b70e255e0d93413eead1ebc58e44c6b8..384c98186ab72b62f0a58b318bd91a332dd4361e 100644 (file)
--- a/vm/vm.hpp
+++ b/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
 
 };