]> gitweb.factorcode.org Git - factor.git/commitdiff
moved the thread stuff around a bit
authorPhil Dawes <phil@phildawes.net>
Tue, 25 Aug 2009 07:55:18 +0000 (08:55 +0100)
committerPhil Dawes <phil@phildawes.net>
Wed, 16 Sep 2009 07:20:49 +0000 (08:20 +0100)
vm/factor.cpp
vm/factor.hpp
vm/os-unix.cpp
vm/os-unix.hpp
vm/os-windows-nt.cpp
vm/os-windows-nt.hpp
vm/vm.hpp

index a241ccf86b18b75600805469419d429b8d252c18..57bceb9cb7042f79961b121a23c0c5092da1277c 100755 (executable)
@@ -7,12 +7,12 @@ factorvm *vm;
 
 unordered_map<long,factorvm*> thread_vms;
 
-factorvm *lookup_vm(long threadid)
+factorvm *lookup_vm(unsigned long threadid)
 {
        return thread_vms[threadid];
 }
 
-void register_vm(long threadid, factorvm *vm)
+void register_vm(unsigned long threadid, factorvm *vm)
 {
        thread_vms[threadid] = vm;
 }
@@ -243,7 +243,7 @@ VM_C_API void start_standalone_factor(int argc, vm_char **argv)
        return newvm->start_standalone_factor(argc,argv);
 }
 
-VM_C_API void *start_standalone_factor_in_new_thread(int argc, vm_char **argv)
+VM_C_API THREADHANDLE start_standalone_factor_in_new_thread(int argc, vm_char **argv)
 {
        startargs *args = new startargs;   // leaks startargs structure
        args->argc = argc; args->argv = argv;
index b824758c8a41ea126e92a3c855f1dfddfbbcdd45..46662072b57f1d308274604f862a68c86ac3a866 100644 (file)
@@ -2,5 +2,5 @@ namespace factor
 {
 
 VM_C_API void start_standalone_factor(int argc, vm_char **argv);
-VM_C_API void *start_standalone_factor_in_new_thread(int argc, vm_char **argv);
+VM_C_API THREADHANDLE start_standalone_factor_in_new_thread(int argc, vm_char **argv);
 }
index ed007398a3e4e5289f2089c2731f398d8861874c..7f4b070c60e3f2866c05aa558b358523d90913eb 100644 (file)
@@ -3,7 +3,7 @@
 namespace factor
 {
 
-void *start_thread(void *(*start_routine)(void *),void *args)
+THREADHANDLE start_thread(void *(*start_routine)(void *),void *args)
 {
        pthread_attr_t attr;
        pthread_t thread;
@@ -14,9 +14,14 @@ void *start_thread(void *(*start_routine)(void *),void *args)
        if (pthread_create (&thread, &attr, start_routine, args) != 0)
                fatal_error("pthread_create() failed",0);
        pthread_attr_destroy (&attr);
-       return (void*)thread;
+       return thread;
 }
 
+unsigned long thread_id(){
+       return pthread_self();
+}
+
+
 static void *null_dll;
 
 s64 current_micros()
@@ -56,9 +61,6 @@ void factorvm::ffi_dlclose(dll *dll)
 }
 
 
-cell factorvm::thread_id(){
-       return pthread_self();
-}
 
 
 inline void factorvm::vmprim_existsp()
index 60beb88233b781768ae341511f0559b383607ebd..b37d2beeeae19d734cdd19f7acf0cbbe145dbcb2 100644 (file)
@@ -42,12 +42,10 @@ typedef char symbol_char;
 
 #define print_native_string(string) print_string(string)
 
-void *start_thread(void *(*start_routine)(void *),void *args);
+typedef pthread_t THREADHANDLE;
 
-void init_ffi();
-void ffi_dlopen(dll *dll);
-void *ffi_dlsym(dll *dll, symbol_char *symbol);
-void ffi_dlclose(dll *dll);
+THREADHANDLE start_thread(void *(*start_routine)(void *),void *args);
+unsigned long thread_id();
 
 void unix_init_signals();
 void signal_handler(int signal, siginfo_t* siginfo, void* uap);
index 630782a9463d7dd111e60ee30443fb10779c1a3d..fbaadaaba7e2799d3080753cad85aff2739f56de 100755 (executable)
@@ -3,16 +3,16 @@
 namespace factor
 {
 
-void *start_thread(void *(*start_routine)(void *),void *args){
-    return CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)start_routine, args, 0, 0); 
+THREADHANDLE start_thread(void *(*start_routine)(void *),void *args){
+    return (void*) CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)start_routine, args, 0, 0); 
 }
 
-cell factorvm::thread_id(){
+unsigned long thread_id(){
        return GetCurrentThreadId();
 }
 
 
-s64 factorvm::current_micros()
+s64 current_micros()
 {
        FILETIME t;
        GetSystemTimeAsFileTime(&t);
index e5c5adadf111f24660caee548b48aa6d1db8454f..68de8ff49e06908ac70bbc53451694434c587209 100755 (executable)
@@ -26,7 +26,10 @@ FACTOR_STDCALL LONG exception_handler(PEXCEPTION_POINTERS pe);
 #define STATUS_FLOAT_MULTIPLE_FAULTS 0xC00002B4
 #define STATUS_FLOAT_MULTIPLE_TRAPS  0xC00002B5
 
-void *start_thread(void *(*start_routine)(void *),void *args);
+typedef HANDLE THREADHANDLE;
+
+THREADHANDLE start_thread(void *(*start_routine)(void *),void *args);
+unsigned long thread_id();
 
 #define SIGNAL_VM_PTR lookup_vm(GetCurrentThreadId())
 
index 9af73e4c7ec311186e47f2a10900dbaa5a8b94af..76cf8c4e53819a8f5475599c75f169008b5fd445 100644 (file)
--- a/vm/vm.hpp
+++ b/vm/vm.hpp
@@ -659,7 +659,6 @@ struct factorvm {
 
        // os-*
        inline void vmprim_existsp();
-       cell thread_id();
        void init_ffi();
        void ffi_dlopen(dll *dll);
        void *ffi_dlsym(dll *dll, symbol_char *symbol);
@@ -677,7 +676,6 @@ struct factorvm {
        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:    
@@ -689,6 +687,6 @@ struct factorvm {
 
 extern factorvm *vm;
 
-extern factorvm *lookup_vm(long threadid);
-extern void register_vm(long threadid,factorvm *vm);
+extern factorvm *lookup_vm(unsigned long threadid);
+extern void register_vm(unsigned long threadid,factorvm *vm);
 }