/vm/mvm-windows.cpp

http://github.com/abeaumont/factor · C++ · 25 lines · 19 code · 6 blank · 0 comment · 3 complexity · 1dcc1251c97c4c9994459e621c65baf2 MD5 · raw file

  1. #include "master.hpp"
  2. namespace factor
  3. {
  4. DWORD current_vm_tls_key;
  5. void init_mvm()
  6. {
  7. if((current_vm_tls_key = TlsAlloc()) == TLS_OUT_OF_INDEXES)
  8. fatal_error("TlsAlloc() failed",0);
  9. }
  10. void register_vm_with_thread(factor_vm *vm)
  11. {
  12. if(!TlsSetValue(current_vm_tls_key, vm))
  13. fatal_error("TlsSetValue() failed",0);
  14. }
  15. factor_vm *current_vm_p()
  16. {
  17. return (factor_vm *)TlsGetValue(current_vm_tls_key);
  18. }
  19. }