Received: from [140.186.70.92] (port=50096 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OIOJC-0003uJ-4w for qemu-devel@nongnu.org; Sat, 29 May 2010 11:50:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OIGcV-00056G-ID for qemu-devel@nongnu.org; Sat, 29 May 2010 03:38:18 -0400 Received: from iksaif.net ([88.191.73.63]:48655) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OIGcV-00055j-CE for qemu-devel@nongnu.org; Sat, 29 May 2010 03:38:11 -0400 From: Corentin Chary Date: Sat, 29 May 2010 09:38:05 +0200 Message-Id: <1275118686-15649-3-git-send-email-corentincj@iksaif.net> In-Reply-To: <1275118686-15649-1-git-send-email-corentincj@iksaif.net> References: <1275118686-15649-1-git-send-email-corentincj@iksaif.net> Subject: [Qemu-devel] [PATCH 2/3] qemu-thread: add cleanup_push() and cleanup_pop() List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Corentin Chary , Anthony Liguori , Gautham R Shenoy , Alexander Graf , Adam Litke >From pthread man: These functions manipulate the calling thread's stack of thread-cancellation clean-up handlers. A clean-up handler is a function that is automatically executed when a thread is canceled [...] it might, for example, unlock a mutex so that it becomes available to other threads in the process. These two functions are implemented using macros because there is no other way to do that (pthread man, again): On Linux, the pthread_cleanup_push() and pthread_cleanup_pop() functions are implemented as macros that expand to text containing '{' and '}', respectively. This means that variables declared within the scope of paired calls to these functions will only be visible within that scope. Signed-off-by: Corentin Chary --- qemu-thread.h | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/qemu-thread.h b/qemu-thread.h index 19bb30c..e5006bb 100644 --- a/qemu-thread.h +++ b/qemu-thread.h @@ -41,4 +41,8 @@ void qemu_thread_self(QemuThread *thread); int qemu_thread_equal(QemuThread *thread1, QemuThread *thread2); void qemu_thread_exit(void *retval); +#define qemu_thread_cleanup_pop(execute) pthread_cleanup_pop(execute) +#define qemu_thread_cleanup_push(routine, arg) \ + pthread_cleanup_push(routine, arg) + #endif -- 1.7.1