0.9.4.2:
[sbcl.git] / src / runtime / interrupt.c
index d711858..79275ef 100644 (file)
@@ -157,17 +157,7 @@ void reset_signal_mask ()
     thread_sigmask(SIG_SETMASK,&new,0);
 }
 
-void block_deferrable_signals_and_inhibit_gc ()
-{
-    struct thread *thread=arch_os_get_current_thread();
-    sigset_t block;
-    sigemptyset(&block);
-    sigaddset_deferrable(&block);
-    thread_sigmask(SIG_BLOCK, &block, 0);
-    bind_variable(GC_INHIBIT,T,thread);
-}
-
-static void block_blockable_signals ()
+void block_blockable_signals ()
 {
     sigset_t block;
     sigemptyset(&block);
@@ -615,8 +605,7 @@ maybe_now_maybe_later(int signal, siginfo_t *info, void *void_context)
 #ifdef LISP_FEATURE_LINUX
     os_restore_fp_control(context);
 #endif
-    if(maybe_defer_handler(interrupt_handle_now,data,
-                           signal,info,context))
+    if(maybe_defer_handler(interrupt_handle_now,data,signal,info,context))
         return;
     interrupt_handle_now(signal, info, context);
 #ifdef LISP_FEATURE_DARWIN
@@ -630,13 +619,14 @@ low_level_interrupt_handle_now(int signal, siginfo_t *info, void *void_context)
 {
     os_context_t *context = (os_context_t*)void_context;
     struct thread *thread=arch_os_get_current_thread();
+    struct interrupt_data *data=thread->interrupt_data;
 
 #ifdef LISP_FEATURE_LINUX
     os_restore_fp_control(context);
 #endif
     check_blockables_blocked_or_lose();
     check_interrupts_enabled_or_lose(context);
-    (*thread->interrupt_data->interrupt_low_level_handlers[signal])
+    (*data->interrupt_low_level_handlers[signal])
         (signal, info, void_context);
 #ifdef LISP_FEATURE_DARWIN
     /* Work around G5 bug */
@@ -897,14 +887,18 @@ void interrupt_thread_handler(int num, siginfo_t *info, void *v_context)
      * thread interrupt execution is undefined. */
     struct thread *th=arch_os_get_current_thread();
     struct cons *c;
+    lispobj function;
     if (th->state != STATE_RUNNING)
-        lose("interrupt_thread_handler: thread %ld in wrong state: %d\n",
+        lose("interrupt_thread_handler: thread %lu in wrong state: %d\n",
              th->os_thread,fixnum_value(th->state));
     get_spinlock(&th->interrupt_fun_lock,(long)th);
     c=((struct cons *)native_pointer(th->interrupt_fun));
-    arrange_return_to_lisp_function(context,c->car);
+    function=c->car;
     th->interrupt_fun=c->cdr;
     release_spinlock(&th->interrupt_fun_lock);
+    if (function==NIL)
+        lose("interrupt_thread_handler: NIL function\n");
+    arrange_return_to_lisp_function(context,function);
 }
 
 #endif
@@ -969,8 +963,7 @@ interrupt_maybe_gc(int signal, siginfo_t *info, void *void_context)
 {
     os_context_t *context=(os_context_t *) void_context;
     struct thread *th=arch_os_get_current_thread();
-    struct interrupt_data *data=
-        th ? th->interrupt_data : global_interrupt_data;
+    struct interrupt_data *data=th->interrupt_data;
 
     if(!foreign_function_call_active && gc_trigger_hit(signal, info, context)){
         struct thread *thread=arch_os_get_current_thread();
@@ -1059,6 +1052,7 @@ undoably_install_low_level_interrupt_handler (int signal,
 {
     struct sigaction sa;
     struct thread *th=arch_os_get_current_thread();
+    /* It may be before the initial thread is started. */
     struct interrupt_data *data=
         th ? th->interrupt_data : global_interrupt_data;
 
@@ -1096,6 +1090,7 @@ install_handler(int signal, void handler(int, siginfo_t*, void*))
     sigset_t old, new;
     union interrupt_handler oldhandler;
     struct thread *th=arch_os_get_current_thread();
+    /* It may be before the initial thread is started. */
     struct interrupt_data *data=
         th ? th->interrupt_data : global_interrupt_data;