]> gitweb.factorcode.org Git - factor.git/commitdiff
VM: a bunch of methods on factor_vm that can be converted into free
authorBjörn Lindqvist <bjourne@gmail.com>
Mon, 3 Aug 2015 21:06:02 +0000 (23:06 +0200)
committerBjörn Lindqvist <bjourne@gmail.com>
Tue, 4 Aug 2015 14:02:09 +0000 (16:02 +0200)
functions

I think that makes it easier to see whats going on than having
everything added to factor_vm

vm/factor.hpp
vm/os-unix.cpp
vm/os-windows.cpp
vm/run.cpp
vm/vm.hpp

index 8f2ff6295d9c7a7614c24ac7f66784d1983766a8..5c60258a01aaa8e4dbe5dd0d773d72387280e7ba 100644 (file)
@@ -4,4 +4,13 @@ VM_C_API void init_globals();
 factor_vm* new_factor_vm();
 VM_C_API void start_standalone_factor(int argc, vm_char** argv);
 
+// os-*
+void open_console();
+void close_console();
+void lock_console();
+void unlock_console();
+
+void ignore_ctrl_c();
+void handle_ctrl_c();
+
 }
index 04f38dba3a5ba5f3f3f6213423f99f22fe8221ee..206f1827bf9b3ff4dad5018d64ec3a10182f49e8 100644 (file)
@@ -455,7 +455,7 @@ void* stdin_loop(void* arg) {
   return NULL;
 }
 
-void factor_vm::open_console() {
+void open_console() {
   FACTOR_ASSERT(!stdin_thread_initialized_p);
   safe_pipe(&control_read, &control_write);
   safe_pipe(&size_read, &size_write);
@@ -468,14 +468,14 @@ void factor_vm::open_console() {
 /* This method is used to kill the stdin_loop before exiting from factor.
    A Nvidia driver bug on Linux is the reason this has to be done, see:
      http://www.nvnews.net/vbulletin/showthread.php?t=164619 */
-void factor_vm::close_console() {
+void close_console() {
   if (stdin_thread_initialized_p) {
     pthread_cancel(stdin_thread);
     pthread_join(stdin_thread, 0);
   }
 }
 
-void factor_vm::lock_console() {
+void lock_console() {
   FACTOR_ASSERT(stdin_thread_initialized_p);
   /* Lock the stdin_mutex and send the stdin_loop thread a signal to interrupt
      any read() it has in progress. When the stdin loop iterates again, it will
@@ -484,19 +484,19 @@ void factor_vm::lock_console() {
   pthread_kill(stdin_thread, SIGUSR2);
 }
 
-void factor_vm::unlock_console() {
+void unlock_console() {
   FACTOR_ASSERT(stdin_thread_initialized_p);
   pthread_mutex_unlock(&stdin_mutex);
 }
 
-void factor_vm::ignore_ctrl_c() {
+void ignore_ctrl_c() {
   sig_t ret;
   do {
     ret = signal(SIGINT, SIG_DFL);
   } while (ret == SIG_ERR && errno == EINTR);
 }
 
-void factor_vm::handle_ctrl_c() {
+void handle_ctrl_c() {
   struct sigaction fep_sigaction;
   init_sigaction_with_handler(&fep_sigaction, fep_signal_handler);
   sigaction_safe(SIGINT, &fep_sigaction, NULL);
@@ -508,7 +508,7 @@ void abort() {
     ret = signal(SIGABRT, SIG_DFL);
   } while (ret == SIG_ERR && errno == EINTR);
 
-  factor_vm::close_console();
+  close_console();
   ::abort();
 }
 
index 9ac677213247e3a1610650bf13bc5913f89b9de0..214b48ca29d4e59e72b1568fadb2571059733180 100644 (file)
@@ -295,21 +295,21 @@ static BOOL WINAPI ctrl_handler(DWORD dwCtrlType) {
   }
 }
 
-void factor_vm::open_console() { handle_ctrl_c(); }
+void open_console() { handle_ctrl_c(); }
 
-void factor_vm::ignore_ctrl_c() {
+void ignore_ctrl_c() {
   SetConsoleCtrlHandler(factor::ctrl_handler, FALSE);
 }
 
-void factor_vm::handle_ctrl_c() {
+void handle_ctrl_c() {
   SetConsoleCtrlHandler(factor::ctrl_handler, TRUE);
 }
 
-void factor_vm::lock_console() {}
+void lock_console() {}
 
-void factor_vm::unlock_console() {}
+void unlock_console() {}
 
-void factor_vm::close_console() {}
+void close_console() {}
 
 void factor_vm::sampler_thread_loop() {
   LARGE_INTEGER counter, new_counter, units_per_second;
index 22dd77f5a80da1f2ab37470d91bd418b715020ad..7d9ead8a72c073b8a8df61cb57b443c01df37794 100644 (file)
@@ -5,7 +5,7 @@ namespace factor {
 void factor_vm::primitive_exit() { exit((int)to_fixnum(ctx->pop())); }
 
 void exit(int status) {
-  factor_vm::close_console();
+  close_console();
   ::exit(status);
 }
 
index 06fafa0cfc96125f0a1862d83a873cc2d1752edd..c37638a7fccca2245776104c057bb8c9ad0427c0 100644 (file)
--- a/vm/vm.hpp
+++ b/vm/vm.hpp
@@ -737,12 +737,6 @@ struct factor_vm {
   void init_signals();
   void start_sampling_profiler_timer();
   void end_sampling_profiler_timer();
-  static void open_console();
-  static void close_console();
-  static void lock_console();
-  static void unlock_console();
-  static void ignore_ctrl_c();
-  static void handle_ctrl_c();
 
 // os-windows
 #if defined(WINDOWS)