moved the thread stuff around a bit
parent
f371bbbc2d
commit
1e93c766a1
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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())
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue