Fix cut-to-width in the presence of bad constants in dead code.
[sbcl.git] / src / runtime / safepoint.c
index 3faabe5..10ac7c0 100644 (file)
@@ -576,7 +576,7 @@ check_pending_gc(os_context_t *ctx)
             block_deferrable_signals(NULL,&sigset);
             if(SymbolTlValue(GC_PENDING,self)==T)
                 gc_happened = funcall0(StaticSymbolFunction(SUB_GC));
-            unbind_variable(IN_SAFEPOINT,self);
+            unbind(self);
             thread_sigmask(SIG_SETMASK,&sigset,NULL);
             if (gc_happened == T) {
                 /* POST_GC wants to enable interrupts */
@@ -966,6 +966,26 @@ handle_safepoint_violation(os_context_t *ctx, os_vm_address_t fault_address)
 }
 #endif /* LISP_FEATURE_WIN32 */
 
+#if defined(LISP_FEATURE_SB_SAFEPOINT_STRICTLY) && !defined(LISP_FEATURE_WIN32)
+void
+signal_handler_callback(lispobj run_handler, int signo, void *info, void *ctx)
+{
+    init_thread_data scribble;
+    void *args[2];
+    args[0] = info;
+    args[1] = ctx;
+
+    attach_os_thread(&scribble);
+
+    odxprint(misc, "callback from signal handler thread for: %d\n", signo);
+    funcall3(StaticSymbolFunction(SIGNAL_HANDLER_CALLBACK),
+             run_handler, make_fixnum(signo), alloc_sap(args));
+
+    detach_os_thread(&scribble);
+    return;
+}
+#endif
+
 void
 callback_wrapper_trampoline(
 #if !(defined(LISP_FEATURE_X86) || defined(LISP_FEATURE_X86_64))
@@ -979,9 +999,22 @@ callback_wrapper_trampoline(
 #endif
     lispobj arg0, lispobj arg1, lispobj arg2)
 {
+#if defined(LISP_FEATURE_WIN32)
+    pthread_np_notice_thread();
+#endif
     struct thread* th = arch_os_get_current_thread();
-    if (!th)
-        lose("callback invoked in non-lisp thread.  Sorry, that is not supported yet.");
+    if (!th) {                  /* callback invoked in non-lisp thread */
+        init_thread_data scribble;
+        attach_os_thread(&scribble);
+        funcall3(StaticSymbolFunction(ENTER_FOREIGN_CALLBACK), arg0,arg1,arg2);
+        detach_os_thread(&scribble);
+        return;
+    }
+
+#ifdef LISP_FEATURE_WIN32
+    /* arg2 is the pointer to a return value, which sits on the stack */
+    th->carried_base_pointer = (os_context_register_t) *(((void**)arg2)-1);
+#endif
 
     WITH_GC_AT_SAFEPOINTS_ONLY()
         funcall3(SymbolValue(ENTER_ALIEN_CALLBACK, 0), arg0, arg1, arg2);