From nobody Thu Nov 6 14:40:06 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541426247535800.1442697843557; Mon, 5 Nov 2018 05:57:27 -0800 (PST) Received: from localhost ([::1]:35400 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJfNd-00024P-Tv for importer@patchew.org; Mon, 05 Nov 2018 08:57:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55097) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJfMA-0001Gv-DD for qemu-devel@nongnu.org; Mon, 05 Nov 2018 08:55:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gJfM9-0006l9-7E for qemu-devel@nongnu.org; Mon, 05 Nov 2018 08:55:54 -0500 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:52278) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gJfM8-0006eU-Sn for qemu-devel@nongnu.org; Mon, 05 Nov 2018 08:55:53 -0500 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1gJfLz-0006Hk-AM; Mon, 05 Nov 2018 13:55:43 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 5 Nov 2018 13:55:37 +0000 Message-Id: <20181105135538.28025-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181105135538.28025-1-peter.maydell@linaro.org> References: <20181105135538.28025-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PATCH for-3.1 1/2] include/qemu/thread.h: Document qemu_thread_atexit* API X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Paolo Bonzini , patches@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Add documentation for the qemu_thread_atexit_add() and qemu_thread_atexit_remove() functions. We include a (previously undocumented) constraint that notifiers may not be called if a thread is exiting because the entire process is exiting. This is fine for our current use because the callers use it only for cleaning up resources which go away on process exit (memory, Win32 fibers), and we will need the flexibility for the new posix implementation. Signed-off-by: Peter Maydell Reviewed-by: Eric Blake --- include/qemu/thread.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/qemu/thread.h b/include/qemu/thread.h index b2661b66720..55d83a907cd 100644 --- a/include/qemu/thread.h +++ b/include/qemu/thread.h @@ -162,7 +162,29 @@ void qemu_thread_exit(void *retval); void qemu_thread_naming(bool enable); =20 struct Notifier; +/** + * qemu_thread_atexit_add: + * @notifier: Notifier to add + * + * Add the specified notifier to a list which will be run via + * notifier_list_notify() when this thread exits (either by calling + * qemu_thread_exit() or by returning from its start_routine). + * The usual usage is that the caller passes a Notifier which is + * a per-thread variable; it can then use the callback to free + * other per-thread data. + * + * If the thread exits as part of the entire process exiting, + * it is unspecified whether notifiers are called or not. + */ void qemu_thread_atexit_add(struct Notifier *notifier); +/** + * qemu_thread_atexit_remove: + * @notifier: Notifier to remove + * + * Remove the specified notifier from the thread-exit notification + * list. It is not valid to try to remove a notifier which is not + * on the list. + */ void qemu_thread_atexit_remove(struct Notifier *notifier); =20 struct QemuSpin { --=20 2.19.1