anchor.diff:  ;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
   ;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
   
  -;; $Id: gdk.lisp,v 1.47 2007-11-14 12:52:32 espen Exp $
  +;; $Id: gdk.lisp,v 1.48 2008-01-02 15:26:46 espen Exp $
   
   
   (in-package "GDK")
  
positive.code: #+sb-thread
  (progn
    (defvar *global-lock* nil)
  
    (defun %global-lock-p ()
      (eq (car (sb-thread:mutex-value *global-lock*)) sb-thread:*current-thread*))
  
    (defun threads-enter ()
      (when *global-lock*
        (if (%global-lock-p)
  	  (incf (cdr (sb-thread:mutex-value *global-lock*)))
  	(sb-thread:get-mutex *global-lock* (cons sb-thread:*current-thread* 0)))))
      
    (defun threads-leave (&optional flush-p)
      (when *global-lock*
        (assert (%global-lock-p))
        (cond
         ((zerop (cdr (sb-thread:mutex-value *global-lock*)))
  	(when flush-p
  	  (flush))
  	(sb-thread:release-mutex *global-lock*))
         (t (decf (cdr (sb-thread:mutex-value *global-lock*)))))))
  
    (define-callback %enter-fn nil ()
      (threads-enter))
  
negative.code:   (define-callback %leave-fn nil ()
      (threads-leave))
    
    (defbinding %threads-set-lock-functions (nil) nil
      (%enter-fn callback)
      (%leave-fn callback))
  
  