]> gitweb.factorcode.org Git - factor.git/blob - vm/mvm-unix.cpp
vm: split up TLS code and add a dummy implementation for a dummy OS known as NetBSD
[factor.git] / vm / mvm-unix.cpp
1 #include "master.hpp"
2
3 namespace factor
4 {
5
6 pthread_key_t current_vm_tls_key = 0;
7
8 void init_mvm()
9 {
10         if(pthread_key_create(&current_vm_tls_key, NULL) != 0)
11                 fatal_error("pthread_key_create() failed",0);
12 }
13
14 void register_vm_with_thread(factor_vm *vm)
15 {
16         pthread_setspecific(current_vm_tls_key,vm);
17 }
18
19 factor_vm *current_vm()
20 {
21         factor_vm *vm = (factor_vm*)pthread_getspecific(current_vm_tls_key);
22         assert(vm != NULL);
23         return vm;
24 }
25
26 }