0.pre8.4
[sbcl.git] / src / code / gc.lisp
index 086d683..2389750 100644 (file)
@@ -70,7 +70,7 @@
   (format t "Control stack usage is:   ~10:D bytes.~%" (control-stack-usage))
   (format t "Binding stack usage is:   ~10:D bytes.~%" (binding-stack-usage))
   (format t "Garbage collection is currently ~:[enabled~;DISABLED~].~%"
-         *gc-inhibit*))
+         (> *gc-inhibit* 0)))
 
 (defun room-intermediate-info ()
   (room-minimal-info)
@@ -223,7 +223,7 @@ and submit it as a patch."
 (declaim (type (or index null) *gc-trigger*))
 (defvar *gc-trigger* nil)
 
-;;; When non-NIL, inhibits garbage collection.
+;;; When >0, inhibits garbage collection.
 (defvar *gc-inhibit*) ; initialized in cold init
 
 ;;; This flag is used to prevent recursive entry into the garbage
@@ -300,6 +300,13 @@ function should notify the user that the system has finished GC'ing.")
 ;;; is not greater than *GC-TRIGGER*.
 ;;;
 ;;; For GENCGC all generations < GEN will be GC'ed.
+
+;;; XXX need (1) some kind of locking to ensure that only one thread
+;;; at a time is trying to GC, (2) to look at all these specials and
+;;; work out how much of this "do we really need to GC now?" stuff is
+;;; actually necessary: I think we actually end up GCing every time we
+;;; hit this code
+
 (defun sub-gc (&key force-p (gen 0))
   (/show0 "entering SUB-GC")
   (unless *already-maybe-gcing*
@@ -323,7 +330,7 @@ function should notify the user that the system has finished GC'ing.")
       (when (and *gc-trigger* (> pre-gc-dynamic-usage *gc-trigger*))
        (setf *need-to-collect-garbage* t))
       (when (or force-p
-               (and *need-to-collect-garbage* (not *gc-inhibit*)))
+               (and *need-to-collect-garbage* (zerop *gc-inhibit*)))
        ;; KLUDGE: Wow, we really mask interrupts all the time we're
        ;; collecting garbage? That seems like a long time.. -- WHN 19991129
        (without-interrupts
@@ -452,7 +459,7 @@ function should notify the user that the system has finished GC'ing.")
 (defun gc-on ()
   #!+sb-doc
   "Enable the garbage collector."
-  (setq *gc-inhibit* nil)
+  (setq *gc-inhibit* 0)
   (when *need-to-collect-garbage*
     (sub-gc))
   nil)
@@ -460,7 +467,7 @@ function should notify the user that the system has finished GC'ing.")
 (defun gc-off ()
   #!+sb-doc
   "Disable the garbage collector."
-  (setq *gc-inhibit* t)
+  (setq *gc-inhibit* 1)
   nil)
 \f
 ;;;; initialization stuff