-#!+sb-thread
-(defun release-foreground ()
- (sb!sys:enable-interrupt :sigint :ignore)
- (release-mutex *session-lock*)
- t)
-#!-sb-thread
-(defun release-foreground () t)
+(sb!xc:defmacro with-recursive-lock ((mutex) &body body)
+ #!+sb-doc
+ "Acquires MUTEX for the dynamic scope of BODY. Within that scope
+further recursive lock attempts for the same mutex succeed. It is
+allowed to mix WITH-MUTEX and WITH-RECURSIVE-LOCK for the same mutex
+provided the default value is used for the mutex."
+ #!-sb-thread
+ (declare (ignore mutex))
+ #!+sb-thread
+ (with-unique-names (mutex1 inner-lock-p)
+ `(let* ((,mutex1 ,mutex)
+ (,inner-lock-p (eq (mutex-value ,mutex1) *current-thread*)))
+ (unwind-protect
+ (progn
+ (unless ,inner-lock-p
+ (get-mutex ,mutex1))
+ (locally
+ ,@body))
+ (unless ,inner-lock-p
+ (release-mutex ,mutex1)))))
+ #!-sb-thread
+ `(locally ,@body))