1.0.6.9: micro-optimize portions of the reader
[sbcl.git] / src / code / signal.lisp
index 9d2290a..cc21007 100644 (file)
 (defvar *interrupts-enabled* t)
 (defvar *interrupt-pending* nil)
 
+;;; KLUDGE: This tells INTERRUPT-THREAD that it is being invoked as an
+;;; interruption, so that if the thread being interrupted is the
+;;; current thread it knows to enable interrupts. INVOKE-INTERRUPTION
+;;; binds it to T, and WITHOUT-INTERRUPTS binds it to NIL, so that if
+;;; interrupts are disable between INTERRUPT-THREAD and this we don't
+;;; accidentally re-enable them.
+(defvar *in-interruption* nil)
+
 (sb!xc:defmacro without-interrupts (&body body)
   #!+sb-doc
   "Execute BODY with all deferrable interrupts deferred. Deferrable interrupts
@@ -49,23 +57,24 @@ userspace threads, in SBCL WITHOUT-INTERRUPTS does not inhibit scheduling of
 other threads."
   (let ((name (gensym "WITHOUT-INTERRUPTS-BODY-")))
     `(flet ((,name () ,@body))
-      (if *interrupts-enabled*
-          (unwind-protect
-               (let ((*interrupts-enabled* nil))
-                 (,name))
-            ;; If we were interrupted in the protected section, then
-            ;; the interrupts are still blocked and it remains so
-            ;; until the pending interrupt is handled.
-            ;;
-            ;; If we were not interrupted in the protected section,
-            ;; but here, then even if the interrupt handler enters
-            ;; another WITHOUT-INTERRUPTS, the pending interrupt will
-            ;; be handled immediately upon exit from said
-            ;; WITHOUT-INTERRUPTS, so it is as if nothing has
-            ;; happened.
-            (when *interrupt-pending*
-              (receive-pending-interrupt)))
-          (,name)))))
+       (if *interrupts-enabled*
+           (unwind-protect
+                (let ((*interrupts-enabled* nil)
+                      (*in-interruption* nil))
+                  (,name))
+             ;; If we were interrupted in the protected section, then
+             ;; the interrupts are still blocked and it remains so
+             ;; until the pending interrupt is handled.
+             ;;
+             ;; If we were not interrupted in the protected section,
+             ;; but here, then even if the interrupt handler enters
+             ;; another WITHOUT-INTERRUPTS, the pending interrupt will
+             ;; be handled immediately upon exit from said
+             ;; WITHOUT-INTERRUPTS, so it is as if nothing has
+             ;; happened.
+             (when *interrupt-pending*
+               (receive-pending-interrupt)))
+           (,name)))))
 
 (sb!xc:defmacro with-interrupts (&body body)
   #!+sb-doc