All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xin Wang <x.wang@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: matthew.d.roper@intel.com, zbigniew.kempczynski@intel.com,
	kamil.konieczny@linux.intel.com, ravi.kumar.vodapalli@intel.com,
	Xin Wang <x.wang@intel.com>
Subject: [PATCH v12 1/4] lib/igt_core: add igt_destructor helper macro
Date: Sat, 17 Jan 2026 23:48:17 +0000	[thread overview]
Message-ID: <20260117234821.929209-2-x.wang@intel.com> (raw)
In-Reply-To: <20260117234821.929209-1-x.wang@intel.com>

Add igt_destructor alongside igt_constructor to make it easy to run
library teardown code when the binary unloads/exits.

Signed-off-by: Xin Wang <x.wang@intel.com>
---
 lib/igt_core.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/lib/igt_core.h b/lib/igt_core.h
index 6845f853c..ebeac140e 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -516,6 +516,18 @@ void igt_simple_init_parse_opts(int *argc, char **argv,
 	__attribute__((constructor)) \
 	static void igt_unique(__igt_constructor_l)(void)
 
+/**
+ * igt_destructor:
+ *
+ * Convenience macro to run the provided code block when igt is exiting,
+ * after all tests have been run. This should be used for parts of the igt
+ * library that require de-initialization of objects with global context.
+ * This code block will be executed exactly once.
+ */
+#define igt_destructor \
+	__attribute__((destructor)) \
+	static void igt_unique(__igt_destructor_l)(void)
+
 __noreturn __attribute__((format(printf, 1, 2)))
 void igt_skip(const char *f, ...);
 __noreturn __attribute__((format(printf, 5, 6)))
-- 
2.43.0


  reply	other threads:[~2026-01-17 23:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-17 23:48 [PATCH v12 0/4] lib/intel_device_info: get the xe .graphics_rel from GMD_ID Xin Wang
2026-01-17 23:48 ` Xin Wang [this message]
2026-01-17 23:48 ` [PATCH v12 2/4] lib/intel_device_info: make device info cache thread-safe Xin Wang
2026-01-17 23:48 ` [PATCH v12 3/4] lib/intel_device_info: allow xe_query to override graphics version Xin Wang
2026-01-17 23:48 ` [PATCH v12 4/4] lib/intel_device_info: remove the graphcs_rel from xe2+ devices Xin Wang
2026-01-18  0:40 ` ✓ Xe.CI.BAT: success for lib/intel_device_info: get the xe .graphics_rel from GMD_ID Patchwork
2026-01-18  0:52 ` ✓ i915.CI.BAT: " Patchwork
2026-01-18  1:47 ` ✗ Xe.CI.Full: failure " Patchwork
2026-01-18  2:56 ` ✓ i915.CI.Full: success " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260117234821.929209-2-x.wang@intel.com \
    --to=x.wang@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=matthew.d.roper@intel.com \
    --cc=ravi.kumar.vodapalli@intel.com \
    --cc=zbigniew.kempczynski@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.