0.pre8.28
[sbcl.git] / src / code / thread.lisp
1 (in-package :sb!thread)
2
3 (sb!xc:defmacro with-recursive-lock ((mutex) &body body)
4   #!+sb-thread
5   (let ((cfp (gensym "CFP")))
6     `(let ((,cfp (ash (sb!sys:sap-int (sb!vm::current-fp) ) -2)))
7       (unless (and (mutex-value ,mutex)
8                    (SB!DI::control-stack-pointer-valid-p
9                     (sb!sys:int-sap (ash (mutex-value ,mutex) 2))))
10         (get-mutex ,mutex ,cfp))
11       (unwind-protect
12            (progn ,@body)
13         (when (eql (mutex-value ,mutex) ,cfp) (release-mutex ,mutex)))))
14   #!-sb-thread
15   `(progn ,@body))
16
17 #!+sb-thread
18 (defun get-foreground ()
19   (when (not (eql (mutex-value *session-lock*) (current-thread-id)))
20     (get-mutex *session-lock*))
21   (sb!sys:enable-interrupt :sigint #'sb!unix::sigint-handler)
22   t)
23 #!-sb-thread
24 (defun get-foreground () t)
25
26 #!+sb-thread
27 (defun release-foreground ()
28   (sb!sys:enable-interrupt :sigint :ignore)
29   (release-mutex *session-lock*)
30   t)
31 #!-sb-thread
32 (defun release-foreground () t)