summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Benkard <code@mail.matthias.benkard.de>2008-03-04 16:59:42 +0100
committerMatthias Benkard <code@mail.matthias.benkard.de>2008-03-04 16:59:42 +0100
commitcb2858af09521a572ba8d222f1d1b21324ab6f44 (patch)
treef421a09b9b65189b1d314567c72d9e00c9b56b68
parent3bb7048d77f9e3888d4cf8d2cfa742b6956d3f7c (diff)
Acquire the exception lock when returning from a callback.
darcs-hash:f644e3e364ebb7bd2c81aa2c7f83a4887ac644d8
-rw-r--r--Lisp/libobjcl.lisp4
-rw-r--r--Lisp/method-definition.lisp10
-rw-r--r--Lisp/tests.lisp2
-rw-r--r--Objective-C/libobjcl.m4
4 files changed, 13 insertions, 7 deletions
diff --git a/Lisp/libobjcl.lisp b/Lisp/libobjcl.lisp
index d8e8b07..d038c62 100644
--- a/Lisp/libobjcl.lisp
+++ b/Lisp/libobjcl.lisp
@@ -145,10 +145,10 @@
(return-typespec :string)
(arg-typespecs (:array :string)))
-(defcfun ("objcl_acquire_lock" %objcl-release-lock) :pointer
+(defcfun ("objcl_acquire_lock" %objcl-acquire-lock) :pointer
(lock :pointer))
-(defcfun ("objcl_release_lock" %objcl-acquire-lock) :pointer
+(defcfun ("objcl_release_lock" %objcl-release-lock) :pointer
(lock :pointer))
(defcfun ("objcl_create_class" %objcl-create-class) :pointer
diff --git a/Lisp/method-definition.lisp b/Lisp/method-definition.lisp
index 0b41898..6df7feb 100644
--- a/Lisp/method-definition.lisp
+++ b/Lisp/method-definition.lisp
@@ -126,10 +126,12 @@
(print '(,(generic-function-name gf)
,@arguments))
(format t "~&~A" (list ,@arg-symbols)))
- (,(generic-function-name gf)
- ;; Leave the second argument (the
- ;; selector) out.
- ,@(list* (car arguments) (cddr arguments)))))))
+ (unwind-protect
+ (,(generic-function-name gf)
+ ;; Leave the second argument (the
+ ;; selector) out.
+ ,@(list* (car arguments) (cddr arguments)))
+ (%objcl-acquire-lock *objcl-current-exception-lock*))))))
(let ((callback (get-callback callback-name)))
(with-foreign-object (arg-typestring-buffer :string
(- (length arg-typestrings) 2))
diff --git a/Lisp/tests.lisp b/Lisp/tests.lisp
index 42ba3fe..c2ba1d6 100644
--- a/Lisp/tests.lisp
+++ b/Lisp/tests.lisp
@@ -435,7 +435,7 @@
(b ns::ns-number)
&rest rest)
(declare (ignore z rest))
- (+ y 150))))
+ (+ y 20))))
;; Sanity checks.
(is (typep class 'objective-c-class))
diff --git a/Objective-C/libobjcl.m b/Objective-C/libobjcl.m
index b3fe789..d32a37c 100644
--- a/Objective-C/libobjcl.m
+++ b/Objective-C/libobjcl.m
@@ -775,6 +775,8 @@ objcl_create_imp (IMP callback,
void
objcl_acquire_lock (id lock)
{
+ TRACE (@"acquire-lock");
+ TRACE (@" %@", lock);
[lock lock];
TRACE (@"Lock %@ acquired.", lock);
}
@@ -783,6 +785,8 @@ objcl_acquire_lock (id lock)
void
objcl_release_lock (id lock)
{
+ TRACE (@"release-lock");
+ TRACE (@" %@", lock);
[lock unlock];
TRACE (@"Lock %@ released.", lock);
}