From 6af5f467218e437a17bfc9b1a1dbd5b509240346 Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Wed, 27 Feb 2013 20:57:40 +0900 Subject: [PATCH] Fixing exception handlers for threadless builds. --- lib/init-7.scm | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/init-7.scm b/lib/init-7.scm index 759aee01..d744719a 100644 --- a/lib/init-7.scm +++ b/lib/init-7.scm @@ -890,13 +890,22 @@ (define (raise-continuable exn) (raise (list *continuable* exn))) -(define (%with-exception-handler handler thunk) - (let* ((old (thread-parameters)) - (new (cons (cons current-exception-handler handler) old))) - (dynamic-wind - (lambda () (thread-parameters-set! new)) - thunk - (lambda () (thread-parameters-set! old))))) +(cond-expand + (threads + (define (%with-exception-handler handler thunk) + (let* ((old (thread-parameters)) + (new (cons (cons current-exception-handler handler) old))) + (dynamic-wind + (lambda () (thread-parameters-set! new)) + thunk + (lambda () (thread-parameters-set! old)))))) + (else + (define (%with-exception-handler handler thunk) + (let ((old (current-exception-handler))) + (dynamic-wind + (lambda () (current-exception-handler handler)) + thunk + (lambda () (current-exception-handler old))))))) (define (with-exception-handler handler thunk) (letrec ((orig-handler (current-exception-handler))